mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Test for internal types.
This commit is contained in:
parent
a33d173ad9
commit
d2332769d3
@ -5354,6 +5354,35 @@ BOOST_AUTO_TEST_CASE(fixed_arrays_as_return_type)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(internal_types_in_library)
|
||||||
|
{
|
||||||
|
char const* sourceCode = R"(
|
||||||
|
library Lib {
|
||||||
|
function find(uint16[] storage _haystack, uint16 _needle) constant returns (uint)
|
||||||
|
{
|
||||||
|
for (uint i = 0; i < _haystack.length; ++i)
|
||||||
|
if (_haystack[i] == _needle)
|
||||||
|
return i;
|
||||||
|
return uint(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
contract Test {
|
||||||
|
mapping(string => uint16[]) data;
|
||||||
|
function f() returns (uint a, uint b)
|
||||||
|
{
|
||||||
|
data["abc"].length = 20;
|
||||||
|
data["abc"][4] = 9;
|
||||||
|
data["abc"][17] = 3;
|
||||||
|
a = Lib.find(data["abc"], 9);
|
||||||
|
b = Lib.find(data["abc"], 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
compileAndRun(sourceCode, 0, "Lib");
|
||||||
|
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, Address>{{"Lib", m_contractAddress}});
|
||||||
|
BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(4), u256(17)));
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(short_strings)
|
BOOST_AUTO_TEST_CASE(short_strings)
|
||||||
{
|
{
|
||||||
// This test verifies that the byte array encoding that combines length and data works
|
// This test verifies that the byte array encoding that combines length and data works
|
||||||
|
Loading…
Reference in New Issue
Block a user