aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/SolidityEndToEndTest.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-08-04 00:09:39 +0800
committerchriseth <c@ethdev.com>2015-08-04 00:10:08 +0800
commit765f30368837e3e930d6a221d870a277278e5c3f (patch)
tree68aafa25915f65ba836f9bb2b99a358941098d5d /libsolidity/SolidityEndToEndTest.cpp
parentb9055681071df381a7d74599ebd21cc2d1bfa512 (diff)
downloaddexon-solidity-765f30368837e3e930d6a221d870a277278e5c3f.tar
dexon-solidity-765f30368837e3e930d6a221d870a277278e5c3f.tar.gz
dexon-solidity-765f30368837e3e930d6a221d870a277278e5c3f.tar.bz2
dexon-solidity-765f30368837e3e930d6a221d870a277278e5c3f.tar.lz
dexon-solidity-765f30368837e3e930d6a221d870a277278e5c3f.tar.xz
dexon-solidity-765f30368837e3e930d6a221d870a277278e5c3f.tar.zst
dexon-solidity-765f30368837e3e930d6a221d870a277278e5c3f.zip
strings as mapping keys.
Diffstat (limited to 'libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r--libsolidity/SolidityEndToEndTest.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/libsolidity/SolidityEndToEndTest.cpp b/libsolidity/SolidityEndToEndTest.cpp
index d4454514..fc1d2eab 100644
--- a/libsolidity/SolidityEndToEndTest.cpp
+++ b/libsolidity/SolidityEndToEndTest.cpp
@@ -5099,6 +5099,39 @@ BOOST_AUTO_TEST_CASE(memory_structs_with_mappings)
BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(0)));
}
+BOOST_AUTO_TEST_CASE(string_as_mapping_key)
+{
+ char const* sourceCode = R"(
+ contract Test {
+ mapping(string => uint) data;
+ function set(string _s, uint _v) { data[_s] = _v; }
+ function get(string _s) returns (uint) { return data[_s]; }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "Test");
+ vector<string> strings{
+ "Hello, World!",
+ "Hello, World!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1111",
+ "",
+ "1"
+ };
+ for (unsigned i = 0; i < strings.size(); i++)
+ BOOST_CHECK(callContractFunction(
+ "set(string,uint256)",
+ u256(0x40),
+ u256(7 + i),
+ u256(strings[i].size()),
+ strings[i]
+ ) == encodeArgs());
+ for (unsigned i = 0; i < strings.size(); i++)
+ BOOST_CHECK(callContractFunction(
+ "get(string)",
+ u256(0x20),
+ u256(strings[i].size()),
+ strings[i]
+ ) == encodeArgs(u256(7 + i)));
+}
+
BOOST_AUTO_TEST_SUITE_END()
}