Test for allocation bug.

This commit is contained in:
chriseth 2015-11-24 14:54:18 +01:00
parent 2554d6104a
commit 588e4232eb

View File

@ -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()
}