diff options
Diffstat (limited to 'src/test/alert_tests.cpp')
-rw-r--r-- | src/test/alert_tests.cpp | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/src/test/alert_tests.cpp b/src/test/alert_tests.cpp index f7a11376d3..cb941943f7 100644 --- a/src/test/alert_tests.cpp +++ b/src/test/alert_tests.cpp @@ -9,6 +9,7 @@ #include "alert.h" #include "serialize.h" #include "util.h" +#include "data/alertTests.raw.h" #if 0 // @@ -71,27 +72,13 @@ struct ReadAlerts { ReadAlerts() { - std::string filename("alertTests"); - namespace fs = boost::filesystem; - fs::path testFile = fs::current_path() / "test" / "data" / filename; -#ifdef TEST_DATA_DIR - if (!fs::exists(testFile)) - { - testFile = fs::path(BOOST_PP_STRINGIZE(TEST_DATA_DIR)) / filename; - } -#endif - FILE* fp = fopen(testFile.string().c_str(), "rb"); - if (!fp) return; - - - CAutoFile filein = CAutoFile(fp, SER_DISK, CLIENT_VERSION); - if (!filein) return; - + std::vector<unsigned char> vch(alert_tests::alertTests, alert_tests::alertTests + sizeof(alert_tests::alertTests)); + CDataStream stream(vch, SER_DISK, CLIENT_VERSION); try { - while (!feof(filein)) + while (stream.good()) { CAlert alert; - filein >> alert; + stream >> alert; alerts.push_back(alert); } } @@ -125,6 +112,9 @@ BOOST_AUTO_TEST_CASE(AlertApplies) { BOOST_CHECK(alert.CheckSignature()); } + + BOOST_CHECK(alerts.size() >= 3); + // Matches: BOOST_CHECK(alerts[0].AppliesTo(1, "")); BOOST_CHECK(alerts[0].AppliesTo(70001, "")); |