Browse Source

[2506] add another test for getting numbers

JINMEI Tatuya 12 years ago
parent
commit
2f554072bc
1 changed files with 6 additions and 0 deletions
  1. 6 0
      src/lib/dns/tests/master_lexer_unittest.cc

+ 6 - 0
src/lib/dns/tests/master_lexer_unittest.cc

@@ -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",