mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Converted the hexPrefix test to a separate boost test case.
This commit is contained in:
parent
84fd6bd28f
commit
cd132eae5e
@ -24,47 +24,29 @@
|
|||||||
#include "JsonSpiritHeaders.h"
|
#include "JsonSpiritHeaders.h"
|
||||||
#include "TrieCommon.h"
|
#include "TrieCommon.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace eth;
|
using namespace eth;
|
||||||
namespace js = json_spirit;
|
namespace js = json_spirit;
|
||||||
|
|
||||||
namespace eth
|
BOOST_AUTO_TEST_CASE(hexPrefix_test)
|
||||||
{
|
|
||||||
|
|
||||||
template <> class UnitTest<3>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int operator()()
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int hexPrefixTest()
|
|
||||||
{
|
{
|
||||||
cnote << "Testing Hex-Prefix-Encode...";
|
cnote << "Testing Hex-Prefix-Encode...";
|
||||||
return UnitTest<3>()();
|
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::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) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
main.cpp
1
main.cpp
@ -45,7 +45,6 @@ BOOST_AUTO_TEST_CASE(basic_tests)
|
|||||||
std::cout << sha3(s.out()) << std::endl;*/
|
std::cout << sha3(s.out()) << std::endl;*/
|
||||||
|
|
||||||
int r = 0;
|
int r = 0;
|
||||||
r += hexPrefixTest();
|
|
||||||
r += trieTest();
|
r += trieTest();
|
||||||
r += vmTest();
|
r += vmTest();
|
||||||
r += cryptoTest(); // TODO: Put in tests repo.
|
r += cryptoTest(); // TODO: Put in tests repo.
|
||||||
|
Loading…
Reference in New Issue
Block a user