Skip to content

Commit 9012ffe

Browse files
Add exceptions to files_same
This commit adds exceptions to the `files_same` function in the pkg_editor unit tests. Previously, the tests would pass even if one of the files passed into `files_same` did not exist. By adding exceptions, we correctly error out if one of the files did not exist.
1 parent f988ae0 commit 9012ffe

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/pkg_editor/test/pkg_editor_test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,8 @@ TEST(package, pack) {
382382
static bool files_same(const char *f1, const char *f2) {
383383
std::ifstream file1(f1, std::ifstream::ate | std::ifstream::binary);
384384
std::ifstream file2(f2, std::ifstream::ate | std::ifstream::binary);
385+
file1.exceptions(std::ifstream::failbit | std::ifstream::badbit);
386+
file2.exceptions(std::ifstream::failbit | std::ifstream::badbit);
385387
const std::ifstream::pos_type fileSize = file1.tellg();
386388

387389
if (fileSize != file2.tellg()) {

0 commit comments

Comments
 (0)