From 43c28c1ede33a80b6c259988dde6059f493a41a9 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 6 Sep 2016 11:07:56 +0200 Subject: Test case for non-utf8 characters in string literal. --- test/libsolidity/ASTJSON.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test/libsolidity/ASTJSON.cpp') 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 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() } -- cgit