mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
some more tests
This commit is contained in:
parent
32ae2ea75c
commit
a33564fbcc
@ -969,14 +969,41 @@ BOOST_AUTO_TEST_CASE(simple_accessor)
|
|||||||
BOOST_AUTO_TEST_CASE(array_accessor)
|
BOOST_AUTO_TEST_CASE(array_accessor)
|
||||||
{
|
{
|
||||||
char const* sourceCode = R"(
|
char const* sourceCode = R"(
|
||||||
contract test {
|
contract test {
|
||||||
uint[8] datas;
|
uint[8] data;
|
||||||
function test() {
|
uint[] dynamicData;
|
||||||
datas[2] = 8;
|
function test() {
|
||||||
}
|
data[2] = 8;
|
||||||
})";
|
dynamicData.length = 3;
|
||||||
|
dynamicData[2] = 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
compileAndRun(sourceCode);
|
compileAndRun(sourceCode);
|
||||||
BOOST_CHECK(callContractFunction("data(2)") == encodeArgs(8));
|
BOOST_CHECK(callContractFunction("data(uint256)", 2) == encodeArgs(8));
|
||||||
|
BOOST_CHECK(callContractFunction("data(uint256)", 8) == encodeArgs());
|
||||||
|
BOOST_CHECK(callContractFunction("dynamicData(uint256)", 2) == encodeArgs(8));
|
||||||
|
BOOST_CHECK(callContractFunction("dynamicData(uint256)", 8) == encodeArgs());
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(accessors_mapping_for_array)
|
||||||
|
{
|
||||||
|
char const* sourceCode = R"(
|
||||||
|
contract test {
|
||||||
|
mapping(uint => uint[8]) data;
|
||||||
|
mapping(uint => uint[]) dynamicData;
|
||||||
|
function test() {
|
||||||
|
data[2][2] = 8;
|
||||||
|
dynamicData[2].length = 3;
|
||||||
|
dynamicData[2][2] = 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
compileAndRun(sourceCode);
|
||||||
|
BOOST_CHECK(callContractFunction("data(uint256,uint256)", 2, 2) == encodeArgs(8));
|
||||||
|
BOOST_CHECK(callContractFunction("data(uint256, 256)", 2, 8) == encodeArgs());
|
||||||
|
BOOST_CHECK(callContractFunction("dynamicData(uint256,uint256)", 2, 2) == encodeArgs(8));
|
||||||
|
BOOST_CHECK(callContractFunction("dynamicData(uint256,uint256)", 2, 8) == encodeArgs());
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(multiple_elementary_accessors)
|
BOOST_AUTO_TEST_CASE(multiple_elementary_accessors)
|
||||||
|
Loading…
Reference in New Issue
Block a user