BIND 10 trac2369, updated. 7fb91131cdfc5778e241cb247e3c2713dfe2ca3a [2369] Check as much as possible that line numbers are decremented correctly

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Oct 29 02:48:53 UTC 2012


The branch, trac2369 has been updated
       via  7fb91131cdfc5778e241cb247e3c2713dfe2ca3a (commit)
       via  8aa5e22a0fc048058c3b45d1c2fc76065e0ac8bd (commit)
      from  29ff6bebc9eef580849d063cfb58bc8e053a03e6 (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 7fb91131cdfc5778e241cb247e3c2713dfe2ca3a
Author: Mukund Sivaraman <muks at isc.org>
Date:   Mon Oct 29 08:17:40 2012 +0530

    [2369] Check as much as possible that line numbers are decremented correctly

commit 8aa5e22a0fc048058c3b45d1c2fc76065e0ac8bd
Author: Mukund Sivaraman <muks at isc.org>
Date:   Mon Oct 29 08:11:06 2012 +0530

    [2369] Fix test, skipping backwards before doing newline check

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

Summary of changes:
 src/lib/dns/inputsource.cc                |    2 +-
 src/lib/dns/tests/inputsource_unittest.cc |   27 ++++++++++++++++++++++++++-
 2 files changed, 27 insertions(+), 2 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/dns/inputsource.cc b/src/lib/dns/inputsource.cc
index a93993b..faa7a2f 100644
--- a/src/lib/dns/inputsource.cc
+++ b/src/lib/dns/inputsource.cc
@@ -55,10 +55,10 @@ InputSource::ungetChar() {
     } else if (buffer_pos_ == 0) {
         isc_throw(OutOfRange, "Cannot skip before the start of buffer");
     } else {
+        buffer_pos_--;
         if (buffer_[buffer_pos_] == '\n') {
             line_--;
         }
-        buffer_pos_--;
     }
 }
 
diff --git a/src/lib/dns/tests/inputsource_unittest.cc b/src/lib/dns/tests/inputsource_unittest.cc
index 274c16e..45a9b86 100644
--- a/src/lib/dns/tests/inputsource_unittest.cc
+++ b/src/lib/dns/tests/inputsource_unittest.cc
@@ -132,8 +132,10 @@ TEST_F(InputSourceTest, lines) {
     EXPECT_TRUE(source_.atEOF());
     EXPECT_EQ(4, source_.getCurrentLine());
 
-    // Go backwards 1 character, skipping the last '\n'.
+    // Go backwards 2 characters, skipping the last EOF and '\n'.
     source_.ungetChar();
+    source_.ungetChar();
+
     EXPECT_FALSE(source_.atEOF());
     EXPECT_EQ(3, source_.getCurrentLine());
 
@@ -142,6 +144,29 @@ TEST_F(InputSourceTest, lines) {
     // Now we are back to where we started.
     EXPECT_EQ(1, source_.getCurrentLine());
     EXPECT_FALSE(source_.atEOF());
+
+    // Now check that line numbers are decremented properly (as much as
+    // possible using the available API).
+    while (!source_.atEOF()) {
+        source_.getChar();
+    }
+    line = source_.getCurrentLine();
+
+    // Now, we are at EOF.
+    EXPECT_TRUE(source_.atEOF());
+    EXPECT_EQ(4, line);
+
+    EXPECT_THROW({
+        while (true) {
+            source_.ungetChar();
+            EXPECT_TRUE(((line == source_.getCurrentLine()) ||
+                         ((line - 1) == source_.getCurrentLine())));
+            line = source_.getCurrentLine();
+        }
+    }, isc::OutOfRange);
+
+    // Now we are back to where we started.
+    EXPECT_EQ(1, source_.getCurrentLine());
 }
 
 } // end namespace



More information about the bind10-changes mailing list