diff options
author | Carl Allendorph <callendorph@gmail.com> | 2014-04-20 00:31:37 +0800 |
---|---|---|
committer | Carl Allendorph <callendorph@gmail.com> | 2014-04-20 00:31:37 +0800 |
commit | cd132eae5e12f98410a62b06dd7abfd0eee9722d (patch) | |
tree | f222ff90880193bfdefd47ed7b93472c477c15b8 /hexPrefix.cpp | |
parent | 84fd6bd28ff4b4f0c19f8d7c75b384f0e5728aea (diff) | |
download | dexon-solidity-cd132eae5e12f98410a62b06dd7abfd0eee9722d.tar dexon-solidity-cd132eae5e12f98410a62b06dd7abfd0eee9722d.tar.gz dexon-solidity-cd132eae5e12f98410a62b06dd7abfd0eee9722d.tar.bz2 dexon-solidity-cd132eae5e12f98410a62b06dd7abfd0eee9722d.tar.lz dexon-solidity-cd132eae5e12f98410a62b06dd7abfd0eee9722d.tar.xz dexon-solidity-cd132eae5e12f98410a62b06dd7abfd0eee9722d.tar.zst dexon-solidity-cd132eae5e12f98410a62b06dd7abfd0eee9722d.zip |
Converted the hexPrefix test to a separate boost test case.
Diffstat (limited to 'hexPrefix.cpp')
-rw-r--r-- | hexPrefix.cpp | 52 |
1 files changed, 17 insertions, 35 deletions
diff --git a/hexPrefix.cpp b/hexPrefix.cpp index 0db8e75e..a3de61d2 100644 --- a/hexPrefix.cpp +++ b/hexPrefix.cpp @@ -24,47 +24,29 @@ #include "JsonSpiritHeaders.h" #include "TrieCommon.h" #include "Log.h" +#include <boost/test/unit_test.hpp> + using namespace std; using namespace eth; namespace js = json_spirit; -namespace eth -{ - -template <> class UnitTest<3> +BOOST_AUTO_TEST_CASE(hexPrefix_test) { -public: - int operator()() + cnote << "Testing Hex-Prefix-Encode..."; + js::mValue v; + string s = asString(contents("../../tests/hexencodetest.json")); + BOOST_REQUIRE_MESSAGE(s.length() > 0, "Content from 'hexencodetest.json' is empty. Have you cloned the 'tests' repo branch develop?"); + js::read_string(s, v); + for (auto& i: v.get_obj()) { - js::mValue v; - string s = asString(contents("../../tests/hexencodetest.json")); - js::read_string(s, v); - bool passed = true; - for (auto& i: v.get_obj()) - { - js::mObject& o = i.second.get_obj(); - cnote << i.first; - bytes v; - for (auto& i: o["seq"].get_array()) - v.push_back((byte)i.get_int()); - auto e = hexPrefixEncode(v, o["term"].get_bool()); - if (!o["out"].is_null() && o["out"].get_str() != toHex(e)) - { - cwarn << "Test failed."; - cwarn << "Test says:" << o["out"].get_str(); - cwarn << "Impl says:" << toHex(e); - passed = false; - } - } - return passed ? 0 : 1; + js::mObject& o = i.second.get_obj(); + cnote << i.first; + bytes v; + for (auto& i: o["seq"].get_array()) + v.push_back((byte)i.get_int()); + auto e = hexPrefixEncode(v, o["term"].get_bool()); + BOOST_REQUIRE( ! o["out"].is_null() ); + BOOST_CHECK( o["out"].get_str() == toHex(e) ); } - -}; - } -int hexPrefixTest() -{ - cnote << "Testing Hex-Prefix-Encode..."; - return UnitTest<3>()(); -} |