From 588e4232eb55d501aea5c7bff513843815b0fd52 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 24 Nov 2015 14:54:18 +0100 Subject: Test for allocation bug. --- test/libsolidity/SolidityEndToEndTest.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'test/libsolidity') 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() } -- cgit