Browse Source

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

Mukund Sivaraman 12 years ago
parent
commit
8aa5e22a0f
2 changed files with 4 additions and 2 deletions
  1. 1 1
      src/lib/dns/inputsource.cc
  2. 3 1
      src/lib/dns/tests/inputsource_unittest.cc

+ 1 - 1
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_--;
     }
 }
 

+ 3 - 1
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());