Update tests to use JSON

This commit is contained in:
Alex Beregszaszi 2016-11-15 17:20:24 +00:00
parent 9719cf38e6
commit 9205662de9
2 changed files with 5 additions and 9 deletions

View File

@ -40,9 +40,7 @@ public:
void checkInterface(std::string const& _code, std::string const& _expectedInterfaceString) void checkInterface(std::string const& _code, std::string const& _expectedInterfaceString)
{ {
ETH_TEST_REQUIRE_NO_THROW(m_compilerStack.parse("pragma solidity >=0.0;\n" + _code), "Parsing contract failed"); ETH_TEST_REQUIRE_NO_THROW(m_compilerStack.parse("pragma solidity >=0.0;\n" + _code), "Parsing contract failed");
std::string generatedInterfaceString = m_compilerStack.metadata("", DocumentationType::ABIInterface); Json::Value generatedInterface = m_compilerStack.metadata("", DocumentationType::ABIInterface);
Json::Value generatedInterface;
m_reader.parse(generatedInterfaceString, generatedInterface);
Json::Value expectedInterface; Json::Value expectedInterface;
m_reader.parse(_expectedInterfaceString, expectedInterface); m_reader.parse(_expectedInterfaceString, expectedInterface);
BOOST_CHECK_MESSAGE( BOOST_CHECK_MESSAGE(

View File

@ -45,21 +45,19 @@ public:
bool _userDocumentation bool _userDocumentation
) )
{ {
std::string generatedDocumentationString; Json::Value generatedDocumentation;
ETH_TEST_REQUIRE_NO_THROW(m_compilerStack.parse("pragma solidity >=0.0;\n" + _code), "Parsing failed"); ETH_TEST_REQUIRE_NO_THROW(m_compilerStack.parse("pragma solidity >=0.0;\n" + _code), "Parsing failed");
if (_userDocumentation) if (_userDocumentation)
generatedDocumentationString = m_compilerStack.metadata("", DocumentationType::NatspecUser); generatedDocumentation = m_compilerStack.metadata("", DocumentationType::NatspecUser);
else else
generatedDocumentationString = m_compilerStack.metadata("", DocumentationType::NatspecDev); generatedDocumentation = m_compilerStack.metadata("", DocumentationType::NatspecDev);
Json::Value generatedDocumentation;
m_reader.parse(generatedDocumentationString, generatedDocumentation);
Json::Value expectedDocumentation; Json::Value expectedDocumentation;
m_reader.parse(_expectedDocumentationString, expectedDocumentation); m_reader.parse(_expectedDocumentationString, expectedDocumentation);
BOOST_CHECK_MESSAGE( BOOST_CHECK_MESSAGE(
expectedDocumentation == generatedDocumentation, expectedDocumentation == generatedDocumentation,
"Expected " << _expectedDocumentationString << "Expected " << _expectedDocumentationString <<
"\n but got:\n" << generatedDocumentationString "\n but got:\n" << Json::StyledWriter().write(generatedDocumentation)
); );
} }