aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2016-11-25 22:59:35 +0800
committerGitHub <noreply@github.com>2016-11-25 22:59:35 +0800
commit721b6a969685e99078e296d88135ef84f6c001eb (patch)
treea3760ca2c2ff8dfd278de16cb09ccad1f7b2a3e5 /test/libsolidity
parentd52f191fec432e7503fadb0f24c562951638627b (diff)
parentda566b956e15d1b3b44fd1f3a9dccaee2b7f8b41 (diff)
downloaddexon-solidity-721b6a969685e99078e296d88135ef84f6c001eb.tar.gz
dexon-solidity-721b6a969685e99078e296d88135ef84f6c001eb.tar.zst
dexon-solidity-721b6a969685e99078e296d88135ef84f6c001eb.zip
Merge pull request #1439 from ethereum/utf
Disallow conversion of string literal into strings when the literal is not a valid UTF-8
Diffstat (limited to 'test/libsolidity')
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 6dc7ac8c..7a132068 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -2038,6 +2038,26 @@ BOOST_AUTO_TEST_CASE(string)
BOOST_CHECK_NO_THROW(parseAndAnalyse(sourceCode));
}
+BOOST_AUTO_TEST_CASE(invalid_utf8_implicit)
+{
+ char const* sourceCode = R"(
+ contract C {
+ string s = "\xa0\x00";
+ }
+ )";
+ CHECK_ERROR(sourceCode, TypeError, "invalid UTF-8");
+}
+
+BOOST_AUTO_TEST_CASE(invalid_utf8_explicit)
+{
+ char const* sourceCode = R"(
+ contract C {
+ string s = string("\xa0\x00");
+ }
+ )";
+ CHECK_ERROR(sourceCode, TypeError, "Explicit type conversion not allowed");
+}
+
BOOST_AUTO_TEST_CASE(string_index)
{
char const* sourceCode = R"(