diff --git a/modules/base/src/test_utils/compare_files.cc b/modules/base/src/test_utils/compare_files.cc index 265914ca1036d08e45c9b957656da7b184206e6c..098bf41b504c0b2bc1caa8f6eef504b839bd24d1 100644 --- a/modules/base/src/test_utils/compare_files.cc +++ b/modules/base/src/test_utils/compare_files.cc @@ -22,7 +22,7 @@ #include "compare_files.hh" namespace ost { -bool compare_files(const String& test, const String& gold_standard) +bool compare_files(const String& test, const String& gold_standard, const std::unordered_set<int>& ignore_line) { std::ifstream test_stream(test.c_str()); if (!test_stream) { @@ -36,6 +36,7 @@ bool compare_files(const String& test, const String& gold_standard) return false; } String test_line, gold_line; + int line_num = 1; while (true) { bool test_read = static_cast<bool>(std::getline(test_stream, test_line)); bool gold_read = static_cast<bool>(std::getline(gold_stream, gold_line)); @@ -54,10 +55,15 @@ bool compare_files(const String& test, const String& gold_standard) return false; } if (gold_line!=test_line) { + if (ignore_line.find(line_num) != ignore_line.end()) { + continue; + } std::cerr << "line mismatch:" << std::endl << "test: " << test_line - << std::endl << "gold: " << gold_line << std::endl; + << std::endl << "gold: " << gold_line << std::endl + << "line: " << line_num << std::endl; return false; } + ++line_num; } return true; } diff --git a/modules/base/src/test_utils/compare_files.hh b/modules/base/src/test_utils/compare_files.hh index 57ab1f6c21e02d5c9b4c9df91663c84425c4f7e9..f8dad2d095fc6c3194ae12d9f74dd44c0d3da762 100644 --- a/modules/base/src/test_utils/compare_files.hh +++ b/modules/base/src/test_utils/compare_files.hh @@ -22,11 +22,13 @@ #include <ost/base.hh> #include <ost/module_config.hh> +#include <unordered_set> namespace ost { -bool DLLEXPORT_OST_BASE compare_files(const String& test, - const String& gold_standard); +bool DLLEXPORT_OST_BASE compare_files(const String& test, + const String& gold_standard, + const std::unordered_set<int>& ignore_line = {}); } diff --git a/modules/io/tests/test_io_sdf.cc b/modules/io/tests/test_io_sdf.cc index 68009e9c990d1cf11962eaffdcaea489934d7a7e..8217c05c104e0019c980c4b7fb612585d40c880e 100644 --- a/modules/io/tests/test_io_sdf.cc +++ b/modules/io/tests/test_io_sdf.cc @@ -149,7 +149,8 @@ BOOST_AUTO_TEST_CASE(write_sdf) SaveEntity(eh, "testfiles/sdf/compound-out.sdf"); } BOOST_CHECK(compare_files("testfiles/sdf/compound-out.sdf", - "testfiles/sdf/compound.sdf")); + "testfiles/sdf/compound.sdf", + {2, 159, 316, 473})); } BOOST_AUTO_TEST_CASE(write_sdf_view) @@ -164,7 +165,8 @@ BOOST_AUTO_TEST_CASE(write_sdf_view) SaveEntity(ev, "testfiles/sdf/compound-view-out.sdf"); } BOOST_CHECK(compare_files("testfiles/sdf/compound-view-out.sdf", - "testfiles/sdf/compound-view.sdf")); + "testfiles/sdf/compound-view.sdf", + {2, 111, 220, 329})); } BOOST_AUTO_TEST_CASE(nonexisting_file)