diff options
author | chriseth <c@ethdev.com> | 2017-03-10 00:03:53 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2017-03-14 21:21:33 +0800 |
commit | 47cd8964b8617e5c7e93232719224c8334a4c764 (patch) | |
tree | ea29137b7c499b0ddbef1e62bb8a4d401c694224 /test/libsolidity/SolidityEndToEndTest.cpp | |
parent | 9aab3b8639afa6e30e866e052a412b6f39c6ef6c (diff) | |
download | dexon-solidity-47cd8964b8617e5c7e93232719224c8334a4c764.tar.gz dexon-solidity-47cd8964b8617e5c7e93232719224c8334a4c764.tar.zst dexon-solidity-47cd8964b8617e5c7e93232719224c8334a4c764.zip |
Require and Assert.
Diffstat (limited to 'test/libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index baed3f1e..2a286cea 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -9133,24 +9133,30 @@ BOOST_AUTO_TEST_CASE(invalid_instruction) 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_CASE(assert_require) +{ + char const* sourceCode = R"( + contract C { + function f() { + assert(false); + } + function g(bool val) returns (bool) { + assert(val == true); + return true; + } + function h(bool val) returns (bool) { + require(val); + 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_CHECK(callContractFunction("h(bool)", false) == encodeArgs()); + BOOST_CHECK(callContractFunction("h(bool)", true) == encodeArgs(true)); +} BOOST_AUTO_TEST_CASE(revert) { |