diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2016-08-16 22:31:23 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2016-08-16 22:31:23 +0800 |
commit | ec3298535ebe1d6602df9196b81c92d4a88b4821 (patch) | |
tree | f09308a0955b9fb08736b8afa59a381cb909e232 /test | |
parent | 970260bf0f8b9cdfd46c6956c14e267788ffdc0f (diff) | |
download | dexon-solidity-ec3298535ebe1d6602df9196b81c92d4a88b4821.tar dexon-solidity-ec3298535ebe1d6602df9196b81c92d4a88b4821.tar.gz dexon-solidity-ec3298535ebe1d6602df9196b81c92d4a88b4821.tar.bz2 dexon-solidity-ec3298535ebe1d6602df9196b81c92d4a88b4821.tar.lz dexon-solidity-ec3298535ebe1d6602df9196b81c92d4a88b4821.tar.xz dexon-solidity-ec3298535ebe1d6602df9196b81c92d4a88b4821.tar.zst dexon-solidity-ec3298535ebe1d6602df9196b81c92d4a88b4821.zip |
Introduce hex literals (#832)
* Introduce hex keyword token
* Support hex literals
* Include tests for hex literals
* Document hex literals
Diffstat (limited to 'test')
-rw-r--r-- | test/libsolidity/SolidityScanner.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityScanner.cpp b/test/libsolidity/SolidityScanner.cpp index 624614d2..31b75f25 100644 --- a/test/libsolidity/SolidityScanner.cpp +++ b/test/libsolidity/SolidityScanner.cpp @@ -324,6 +324,42 @@ BOOST_AUTO_TEST_CASE(invalid_short_unicode_string_escape) BOOST_CHECK_EQUAL(scanner.next(), Token::Illegal); } +BOOST_AUTO_TEST_CASE(valid_hex_literal) +{ + Scanner scanner(CharStream("{ hex\"00112233FF\"")); + BOOST_CHECK_EQUAL(scanner.currentToken(), Token::LBrace); + BOOST_CHECK_EQUAL(scanner.next(), Token::StringLiteral); + BOOST_CHECK_EQUAL(scanner.currentLiteral(), std::string("\x00\x11\x22\x33\xFF", 5)); +} + +BOOST_AUTO_TEST_CASE(invalid_short_hex_literal) +{ + Scanner scanner(CharStream("{ hex\"00112233F\"")); + BOOST_CHECK_EQUAL(scanner.currentToken(), Token::LBrace); + BOOST_CHECK_EQUAL(scanner.next(), Token::Illegal); +} + +BOOST_AUTO_TEST_CASE(invalid_hex_literal_with_space) +{ + Scanner scanner(CharStream("{ hex\"00112233FF \"")); + BOOST_CHECK_EQUAL(scanner.currentToken(), Token::LBrace); + BOOST_CHECK_EQUAL(scanner.next(), Token::Illegal); +} + +BOOST_AUTO_TEST_CASE(invalid_hex_literal_with_wrong_quotes) +{ + Scanner scanner(CharStream("{ hex\"00112233FF'")); + BOOST_CHECK_EQUAL(scanner.currentToken(), Token::LBrace); + BOOST_CHECK_EQUAL(scanner.next(), Token::Illegal); +} + +BOOST_AUTO_TEST_CASE(invalid_hex_literal_nonhex_string) +{ + Scanner scanner(CharStream("{ hex\"hello\"")); + BOOST_CHECK_EQUAL(scanner.currentToken(), Token::LBrace); + BOOST_CHECK_EQUAL(scanner.next(), Token::Illegal); +} + BOOST_AUTO_TEST_SUITE_END() |