BIND 10 trac2506, updated. 2f554072bc7b82a18d898073802f545305a90110 [2506] add another test for getting numbers

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Dec 3 21:47:05 UTC 2012


The branch, trac2506 has been updated
       via  2f554072bc7b82a18d898073802f545305a90110 (commit)
       via  191d96a58702a5a3059993a1287136833ec94a4e (commit)
      from  d4b9c33282199c912e6f795f6bbfddde12510795 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 2f554072bc7b82a18d898073802f545305a90110
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Mon Dec 3 13:41:33 2012 -0800

    [2506] add another test for getting numbers

commit 191d96a58702a5a3059993a1287136833ec94a4e
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Mon Dec 3 13:38:01 2012 -0800

    [2506] add some comments of how eolCheck() works, and unify skipping 2nd \n.

-----------------------------------------------------------------------

Summary of changes:
 src/lib/dns/tests/master_lexer_unittest.cc |   25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/dns/tests/master_lexer_unittest.cc b/src/lib/dns/tests/master_lexer_unittest.cc
index b751da8..b2415da 100644
--- a/src/lib/dns/tests/master_lexer_unittest.cc
+++ b/src/lib/dns/tests/master_lexer_unittest.cc
@@ -300,6 +300,11 @@ lexerErrorCheck(MasterLexer& lexer, MasterToken::Type expect,
 }
 
 // Common checks regarding expected/unexpected end-of-line
+//
+// The 'lexer' should be at a position before two consecutive '\n's.
+// The first one will be recognized, and the second one will be considered an
+// unexpected token.  Then this helper consumes the second '\n', so the caller
+// can continue the test after these '\n's.
 void
 eolCheck(MasterLexer& lexer, MasterToken::Type expect) {
     // If EOL is found and eol_ok is true, we get it.
@@ -313,9 +318,14 @@ eolCheck(MasterLexer& lexer, MasterToken::Type expect) {
 
     // And also check the error token set in the exception object.
     lexerErrorCheck(lexer, expect, MasterToken::UNEXPECTED_END);
+
+    // Then skip the 2nd '\n'
+    EXPECT_EQ(MasterToken::END_OF_LINE, lexer.getNextToken().getType());
 }
 
 // Common checks regarding expected/unexpected end-of-file
+//
+// The 'lexer' should be at a position just before an end-of-file.
 void
 eofCheck(MasterLexer& lexer, MasterToken::Type expect) {
     EXPECT_EQ(MasterToken::END_OF_FILE,
@@ -335,9 +345,6 @@ TEST_F(MasterLexerTest, getNextTokenString) {
               lexer.getNextToken(MasterToken::STRING).getString());
     eolCheck(lexer, MasterToken::STRING);
 
-    // Skip the 2nd '\n'
-    EXPECT_EQ(MasterToken::END_OF_LINE, lexer.getNextToken().getType());
-
     // Same set of tests but for end-of-file
     EXPECT_EQ("another-string",
               lexer.getNextToken(MasterToken::STRING, true).getString());
@@ -355,9 +362,6 @@ TEST_F(MasterLexerTest, getNextTokenQString) {
               lexer.getNextToken(MasterToken::QSTRING).getString());
     eolCheck(lexer, MasterToken::QSTRING);
 
-    // Skip the 2nd '\n'
-    EXPECT_EQ(MasterToken::END_OF_LINE, lexer.getNextToken().getType());
-
     // Expecting a quoted string but see a normal string.  It's okay.
     EXPECT_EQ("normal-string",
               lexer.getNextToken(MasterToken::QSTRING).getString());
@@ -369,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);
 
@@ -377,9 +382,6 @@ TEST_F(MasterLexerTest, getNextTokenNumber) {
               lexer.getNextToken(MasterToken::NUMBER).getNumber());
     eolCheck(lexer, MasterToken::NUMBER);
 
-    // Skip the 2nd '\n'
-    EXPECT_EQ(MasterToken::END_OF_LINE, lexer.getNextToken().getType());
-
     // Expecting a number, but it's too big for uint32.
     lexerErrorCheck(lexer, MasterToken::NUMBER,
                     MasterToken::NUMBER_OUT_OF_RANGE);
@@ -391,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",



More information about the bind10-changes mailing list