aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SolidityScanner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/libsolidity/SolidityScanner.cpp')
-rw-r--r--test/libsolidity/SolidityScanner.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityScanner.cpp b/test/libsolidity/SolidityScanner.cpp
index 10f30b8e..4443b9f6 100644
--- a/test/libsolidity/SolidityScanner.cpp
+++ b/test/libsolidity/SolidityScanner.cpp
@@ -291,6 +291,46 @@ BOOST_AUTO_TEST_CASE(empty_comment)
}
+BOOST_AUTO_TEST_CASE(valid_unicode_string_escape)
+{
+ Scanner scanner(CharStream("{ \"\\u00DAnicode\""));
+ BOOST_CHECK_EQUAL(scanner.currentToken(), Token::LBrace);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::StringLiteral);
+ BOOST_CHECK_EQUAL(scanner.currentLiteral(), std::string("\xC3\x9Anicode", 8));
+}
+
+BOOST_AUTO_TEST_CASE(valid_unicode_string_escape_7f)
+{
+ Scanner scanner(CharStream("{ \"\\u007Fnicode\""));
+ BOOST_CHECK_EQUAL(scanner.currentToken(), Token::LBrace);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::StringLiteral);
+ BOOST_CHECK_EQUAL(scanner.currentLiteral(), std::string("\x7Fnicode", 7));
+}
+
+BOOST_AUTO_TEST_CASE(valid_unicode_string_escape_7ff)
+{
+ Scanner scanner(CharStream("{ \"\\u07FFnicode\""));
+ BOOST_CHECK_EQUAL(scanner.currentToken(), Token::LBrace);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::StringLiteral);
+ BOOST_CHECK_EQUAL(scanner.currentLiteral(), std::string("\xDF\xBFnicode", 8));
+}
+
+BOOST_AUTO_TEST_CASE(valid_unicode_string_escape_ffff)
+{
+ Scanner scanner(CharStream("{ \"\\uFFFFnicode\""));
+ BOOST_CHECK_EQUAL(scanner.currentToken(), Token::LBrace);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::StringLiteral);
+ BOOST_CHECK_EQUAL(scanner.currentLiteral(), std::string("\xEF\xBF\xBFnicode", 9));
+}
+
+BOOST_AUTO_TEST_CASE(invalid_short_unicode_string_escape)
+{
+ Scanner scanner(CharStream("{ \"\\uFFnicode\""));
+ BOOST_CHECK_EQUAL(scanner.currentToken(), Token::LBrace);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::Illegal);
+}
+
+
BOOST_AUTO_TEST_SUITE_END()
}