Skip to content

Commit 1d4008f

Browse files
IlanTruanovskyzibaiwan
authored andcommitted
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 8cfe0db commit 1d4008f

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
@@ -394,6 +394,8 @@ TEST(package, pack) {
394394
static bool files_same(const char *f1, const char *f2) {
395395
std::ifstream file1(f1, std::ifstream::ate | std::ifstream::binary);
396396
std::ifstream file2(f2, std::ifstream::ate | std::ifstream::binary);
397+
file1.exceptions(std::ifstream::failbit | std::ifstream::badbit);
398+
file2.exceptions(std::ifstream::failbit | std::ifstream::badbit);
397399
const std::ifstream::pos_type fileSize = file1.tellg();
398400

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

0 commit comments

Comments
 (0)