aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/SolidityEndToEndTest.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-08-04 17:06:57 +0800
committerchriseth <c@ethdev.com>2015-08-04 17:06:57 +0800
commit45e6d94078816984dfdf9a35293502dd3d482fec (patch)
treed06031a3cb6eff43275a30c2efa96c17ac225fee /libsolidity/SolidityEndToEndTest.cpp
parent765f30368837e3e930d6a221d870a277278e5c3f (diff)
downloaddexon-solidity-45e6d94078816984dfdf9a35293502dd3d482fec.tar.gz
dexon-solidity-45e6d94078816984dfdf9a35293502dd3d482fec.tar.zst
dexon-solidity-45e6d94078816984dfdf9a35293502dd3d482fec.zip
Allow explicit conversions bytes <-> string.
Diffstat (limited to 'libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r--libsolidity/SolidityEndToEndTest.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/libsolidity/SolidityEndToEndTest.cpp b/libsolidity/SolidityEndToEndTest.cpp
index fc1d2eab..a10b4767 100644
--- a/libsolidity/SolidityEndToEndTest.cpp
+++ b/libsolidity/SolidityEndToEndTest.cpp
@@ -5099,6 +5099,31 @@ BOOST_AUTO_TEST_CASE(memory_structs_with_mappings)
BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(0)));
}
+BOOST_AUTO_TEST_CASE(string_bytes_conversion)
+{
+ char const* sourceCode = R"(
+ contract Test {
+ string s;
+ bytes b;
+ function f(string _s, uint n) returns (byte) {
+ b = bytes(_s);
+ s = string(b);
+ return bytes(s)[n];
+ }
+ function l() returns (uint) { return bytes(s).length; }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "Test");
+ BOOST_CHECK(callContractFunction(
+ "f(string,uint256)",
+ u256(0x40),
+ u256(2),
+ u256(6),
+ string("abcdef")
+ ) == encodeArgs("c"));
+ BOOST_CHECK(callContractFunction("l()") == encodeArgs(u256(6)));
+}
+
BOOST_AUTO_TEST_CASE(string_as_mapping_key)
{
char const* sourceCode = R"(