diff options
Diffstat (limited to 'test/libsolidity')
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 5 | ||||
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 15 |
2 files changed, 18 insertions, 2 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index c56845aa..2ba6ab85 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -1248,6 +1248,7 @@ BOOST_AUTO_TEST_CASE(convert_fixed_bytes_to_fixed_bytes_same_size) compileAndRun(sourceCode); BOOST_CHECK(callContractFunction("bytesToBytes(bytes4)", "abcd") == encodeArgs("abcd")); } + // fixed bytes to uint conversion tests BOOST_AUTO_TEST_CASE(convert_fixed_bytes_to_uint_same_size) { @@ -1300,6 +1301,7 @@ BOOST_AUTO_TEST_CASE(convert_fixed_bytes_to_uint_greater_size) BOOST_CHECK(callContractFunction("bytesToUint(bytes4)", string("abcd")) == encodeArgs(u256("0x61626364"))); } + // uint fixed bytes conversion tests BOOST_AUTO_TEST_CASE(convert_uint_to_fixed_bytes_same_size) { @@ -4188,7 +4190,8 @@ BOOST_AUTO_TEST_CASE(evm_exceptions_in_constructor_out_of_baund) uint[3] arr; function A() { - test = arr[5]; + uint index = 5; + test = arr[index]; ++test; } } diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 5d174367..2a720494 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -2250,10 +2250,23 @@ BOOST_AUTO_TEST_CASE(creating_contract_within_the_contract) function f() { var x = new Test(); } } )"; - BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); } +BOOST_AUTO_TEST_CASE(array_out_of_bound_access) +{ + char const* text = R"( + contract c { + uint[2] dataArray; + function set5th() returns (bool) { + dataArray[5] = 2; + return true; + } + } + )"; + BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError); +} + BOOST_AUTO_TEST_SUITE_END() } |