mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add tests for assert()
This commit is contained in:
parent
f8461e9e31
commit
8429c03f2a
@ -9077,6 +9077,25 @@ BOOST_AUTO_TEST_CASE(invalid_instruction)
|
|||||||
BOOST_CHECK(callContractFunction("f()") == encodeArgs());
|
BOOST_CHECK(callContractFunction("f()") == encodeArgs());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(assert)
|
||||||
|
{
|
||||||
|
char const* sourceCode = R"(
|
||||||
|
contract C {
|
||||||
|
function f() {
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
function g(bool val) returns (bool) {
|
||||||
|
assert(val == true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
compileAndRun(sourceCode, 0, "C");
|
||||||
|
BOOST_CHECK(callContractFunction("f()") == encodeArgs());
|
||||||
|
BOOST_CHECK(callContractFunction("g(bool)", false) == encodeArgs());
|
||||||
|
BOOST_CHECK(callContractFunction("g(bool)", true) == encodeArgs(true));
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user