]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2369] Check as much as possible that line numbers are decremented correctly
authorMukund Sivaraman <muks@isc.org>
Mon, 29 Oct 2012 02:47:40 +0000 (08:17 +0530)
committerMukund Sivaraman <muks@isc.org>
Mon, 29 Oct 2012 02:48:30 +0000 (08:18 +0530)
src/lib/dns/tests/inputsource_unittest.cc

index 6298c21123c88bd4e3c800ae370ef8b905b2b883..45a9b864c2109afa73f1e1572e50e0cef8f3e1e5 100644 (file)
@@ -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