aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2016-08-01 21:03:44 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2016-08-05 00:28:48 +0800
commitc54e99a3f5888546ffa45ca31e955fee3f4d59f4 (patch)
treec27f9e23eab5946b16884e972a8874f59fc0a184 /test
parentaa4593cab3d60468e5ea4318012c5252ebbc7d13 (diff)
downloaddexon-solidity-c54e99a3f5888546ffa45ca31e955fee3f4d59f4.tar
dexon-solidity-c54e99a3f5888546ffa45ca31e955fee3f4d59f4.tar.gz
dexon-solidity-c54e99a3f5888546ffa45ca31e955fee3f4d59f4.tar.bz2
dexon-solidity-c54e99a3f5888546ffa45ca31e955fee3f4d59f4.tar.lz
dexon-solidity-c54e99a3f5888546ffa45ca31e955fee3f4d59f4.tar.xz
dexon-solidity-c54e99a3f5888546ffa45ca31e955fee3f4d59f4.tar.zst
dexon-solidity-c54e99a3f5888546ffa45ca31e955fee3f4d59f4.zip
Include Unicode tests in the scanner
Diffstat (limited to 'test')
-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()
}