Skip to content
Snippets Groups Projects
Unverified Commit ce83e7f0 authored by Xavier Robin's avatar Xavier Robin
Browse files

test: ignore lines that are no longer constant

parent c3a3a7f9
No related branches found
No related tags found
No related merge requests found
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include "compare_files.hh" #include "compare_files.hh"
namespace ost { 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()); std::ifstream test_stream(test.c_str());
if (!test_stream) { if (!test_stream) {
...@@ -36,6 +36,7 @@ bool compare_files(const String& test, const String& gold_standard) ...@@ -36,6 +36,7 @@ bool compare_files(const String& test, const String& gold_standard)
return false; return false;
} }
String test_line, gold_line; String test_line, gold_line;
int line_num = 1;
while (true) { while (true) {
bool test_read = static_cast<bool>(std::getline(test_stream, test_line)); bool test_read = static_cast<bool>(std::getline(test_stream, test_line));
bool gold_read = static_cast<bool>(std::getline(gold_stream, gold_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) ...@@ -54,10 +55,15 @@ bool compare_files(const String& test, const String& gold_standard)
return false; return false;
} }
if (gold_line!=test_line) { 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::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; return false;
} }
++line_num;
} }
return true; return true;
} }
......
...@@ -22,11 +22,13 @@ ...@@ -22,11 +22,13 @@
#include <ost/base.hh> #include <ost/base.hh>
#include <ost/module_config.hh> #include <ost/module_config.hh>
#include <unordered_set>
namespace ost { namespace ost {
bool DLLEXPORT_OST_BASE compare_files(const String& test, bool DLLEXPORT_OST_BASE compare_files(const String& test,
const String& gold_standard); const String& gold_standard,
const std::unordered_set<int>& ignore_line = {});
} }
......
...@@ -149,7 +149,8 @@ BOOST_AUTO_TEST_CASE(write_sdf) ...@@ -149,7 +149,8 @@ BOOST_AUTO_TEST_CASE(write_sdf)
SaveEntity(eh, "testfiles/sdf/compound-out.sdf"); SaveEntity(eh, "testfiles/sdf/compound-out.sdf");
} }
BOOST_CHECK(compare_files("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) BOOST_AUTO_TEST_CASE(write_sdf_view)
...@@ -164,7 +165,8 @@ 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"); SaveEntity(ev, "testfiles/sdf/compound-view-out.sdf");
} }
BOOST_CHECK(compare_files("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) BOOST_AUTO_TEST_CASE(nonexisting_file)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment