]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2506] add another test for getting numbers
authorJINMEI Tatuya <jinmei@isc.org>
Mon, 3 Dec 2012 21:41:33 +0000 (13:41 -0800)
committerJINMEI Tatuya <jinmei@isc.org>
Mon, 3 Dec 2012 21:41:33 +0000 (13:41 -0800)
src/lib/dns/tests/master_lexer_unittest.cc

index 2e7002f4aa9a7fa8f19e6b4decad3451a6e2b5d5..b2415dab8681dc7d902498d0a1375308094547fe 100644 (file)
@@ -373,6 +373,7 @@ TEST_F(MasterLexerTest, getNextTokenNumber) {
     ss << "\n";
     ss << "4294967296 ";        // =2^32, out of range
     ss << "not-a-number ";
+    ss << "123abc "; // starting with digits, but resulting in a string
     ss << "86400";
     lexer.pushSource(ss);
 
@@ -392,6 +393,11 @@ TEST_F(MasterLexerTest, getNextTokenNumber) {
     // The unexpected string should have been "ungotten".  Re-read and skip it.
     EXPECT_EQ(MasterToken::STRING, lexer.getNextToken().getType());
 
+    // Expecting a number, but see a string.
+    lexerErrorCheck(lexer, MasterToken::NUMBER, MasterToken::BAD_NUMBER);
+    // The unexpected string should have been "ungotten".  Re-read and skip it.
+    EXPECT_EQ(MasterToken::STRING, lexer.getNextToken().getType());
+
     // Unless we specify NUMBER, decimal number string should be recognized
     // as a string.
     EXPECT_EQ("86400",