From: Mukund Sivaraman Date: Mon, 29 Oct 2012 02:47:40 +0000 (+0530) Subject: [2369] Check as much as possible that line numbers are decremented correctly X-Git-Tag: trac2487_base~18^2~30 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7fb91131cdfc5778e241cb247e3c2713dfe2ca3a;p=thirdparty%2Fkea.git [2369] Check as much as possible that line numbers are decremented correctly --- diff --git a/src/lib/dns/tests/inputsource_unittest.cc b/src/lib/dns/tests/inputsource_unittest.cc index 6298c21123..45a9b864c2 100644 --- a/src/lib/dns/tests/inputsource_unittest.cc +++ b/src/lib/dns/tests/inputsource_unittest.cc @@ -144,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