From: Mukund Sivaraman Date: Mon, 29 Oct 2012 02:41:06 +0000 (+0530) Subject: [2369] Fix test, skipping backwards before doing newline check X-Git-Tag: trac2487_base~18^2~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8aa5e22a0fc048058c3b45d1c2fc76065e0ac8bd;p=thirdparty%2Fkea.git [2369] Fix test, skipping backwards before doing newline check --- diff --git a/src/lib/dns/inputsource.cc b/src/lib/dns/inputsource.cc index a93993b248..faa7a2f799 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 274c16efc8..6298c21123 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());