diff options
author | chriseth <c@ethdev.com> | 2016-09-06 17:07:56 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2016-09-06 17:07:56 +0800 |
commit | 43c28c1ede33a80b6c259988dde6059f493a41a9 (patch) | |
tree | 6b61903eba3c84452eefbbcb4f4462ddc911a4c1 | |
parent | ada31fa9b72434a24471116d0c7281d7499039b9 (diff) | |
download | dexon-solidity-43c28c1ede33a80b6c259988dde6059f493a41a9.tar.gz dexon-solidity-43c28c1ede33a80b6c259988dde6059f493a41a9.tar.zst dexon-solidity-43c28c1ede33a80b6c259988dde6059f493a41a9.zip |
Test case for non-utf8 characters in string literal.
-rw-r--r-- | test/libsolidity/ASTJSON.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/libsolidity/ASTJSON.cpp b/test/libsolidity/ASTJSON.cpp index ec60b668..c37f3542 100644 --- a/test/libsolidity/ASTJSON.cpp +++ b/test/libsolidity/ASTJSON.cpp @@ -195,6 +195,22 @@ BOOST_AUTO_TEST_CASE(placeholder_statement) BOOST_CHECK_EQUAL(placeholder["src"], "26:1:1"); } +BOOST_AUTO_TEST_CASE(non_utf8) +{ + CompilerStack c; + c.addSource("a", "contract C { function f() { var x = hex\"ff\"; } }"); + c.parse(); + map<string, unsigned> sourceIndices; + sourceIndices["a"] = 1; + Json::Value astJson = ASTJsonConverter(c.ast("a"), sourceIndices).json(); + Json::Value literal = astJson["children"][0]["children"][0]["children"][2]["children"][0]["children"][1]; + BOOST_CHECK_EQUAL(literal["name"], "Literal"); + BOOST_CHECK_EQUAL(literal["attributes"]["hexvalue"], "ff"); + BOOST_CHECK_EQUAL(literal["attributes"]["token"], Json::nullValue); + BOOST_CHECK_EQUAL(literal["attributes"]["value"], Json::nullValue); + BOOST_CHECK(literal["attributes"]["type"].asString().find("invalid") != string::npos); +} + BOOST_AUTO_TEST_SUITE_END() } |