diff options
Diffstat (limited to 'test/libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 20fef48d..93b42c51 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -5849,6 +5849,37 @@ BOOST_AUTO_TEST_CASE(addmod_mulmod) compileAndRun(sourceCode); BOOST_CHECK(callContractFunction("test()") == encodeArgs(u256(0))); } + +BOOST_AUTO_TEST_CASE(string_allocation_bug) +{ + char const* sourceCode = R"( + contract Sample + { + struct s { uint16 x; uint16 y; string a; string b;} + s[2] public p; + function Sample() { + s memory m; + m.x = 0xbbbb; + m.y = 0xcccc; + m.a = "hello"; + m.b = "world"; + p[0] = m; + } + } + )"; + compileAndRun(sourceCode); + BOOST_CHECK(callContractFunction("p(uint256)") == encodeArgs( + u256(0xbbbb), + u256(0xcccc), + u256(0x80), + u256(0xc0), + u256(5), + string("hello"), + u256(5), + string("world") + )); +} + BOOST_AUTO_TEST_SUITE_END() } |