mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #972 from chriseth/sol_structAccessors
Accessors for structs.
This commit is contained in:
commit
86729f9eee
@ -959,6 +959,24 @@ BOOST_AUTO_TEST_CASE(complex_accessors)
|
|||||||
BOOST_CHECK(callContractFunction("to_multiple_map(uint256,uint256)", 42, 23) == encodeArgs(31));
|
BOOST_CHECK(callContractFunction("to_multiple_map(uint256,uint256)", 42, 23) == encodeArgs(31));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(struct_accessor)
|
||||||
|
{
|
||||||
|
char const* sourceCode = R"(
|
||||||
|
contract test {
|
||||||
|
struct Data { uint a; uint8 b; mapping(uint => uint) c; bool d; }
|
||||||
|
mapping(uint => Data) public data;
|
||||||
|
function test() {
|
||||||
|
data[7].a = 1;
|
||||||
|
data[7].b = 2;
|
||||||
|
data[7].c[0] = 3;
|
||||||
|
data[7].d = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
compileAndRun(sourceCode);
|
||||||
|
BOOST_CHECK(callContractFunction("data(uint256)", 7) == encodeArgs(1, 2, true));
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(balance)
|
BOOST_AUTO_TEST_CASE(balance)
|
||||||
{
|
{
|
||||||
char const* sourceCode = "contract test {\n"
|
char const* sourceCode = "contract test {\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user