Browse Source

[2369] Rename exception to UngetBeforeBeginning

Mukund Sivaraman 12 years ago
parent
commit
6b8bf7d03e

+ 2 - 1
src/lib/dns/master_lexer_inputsource.cc

@@ -90,7 +90,8 @@ InputSource::ungetChar() {
     if (at_eof_) {
         at_eof_ = false;
     } else if (buffer_pos_ == 0) {
-        isc_throw(UngetError, "Cannot skip before the start of buffer");
+        isc_throw(UngetBeforeBeginning,
+                  "Cannot skip before the start of buffer");
     } else {
         buffer_pos_--;
         if (buffer_[buffer_pos_] == '\n') {

+ 6 - 2
src/lib/dns/master_lexer_inputsource.h

@@ -73,8 +73,8 @@ public:
 
     /// \brief Exception thrown when ungetChar() is made to go before
     /// the start of buffer.
-    struct UngetError : public OutOfRange {
-        UngetError(const char* file, size_t line, const char* what) :
+    struct UngetBeforeBeginning : public OutOfRange {
+        UngetBeforeBeginning(const char* file, size_t line, const char* what) :
             OutOfRange(file, line, what)
         {}
     };
@@ -85,6 +85,10 @@ public:
 
     /// \brief Skips backward a single character in the input
     /// source. The last-read character is unget.
+    ///
+    /// \throws UngetBeforeBeginning if we go backwards past the start
+    /// of reading, or backwards past the last time compact() was
+    /// called.
     void ungetChar();
 
     /// Forgets everything read so far, and skips back to the position

+ 6 - 6
src/lib/dns/tests/master_lexer_inputsource_unittest.cc

@@ -102,7 +102,7 @@ TEST_F(InputSourceTest, getAndUngetChar) {
     }
 
     // Skipping past the start of buffer should throw.
-    EXPECT_THROW(source_.ungetChar(), InputSource::UngetError);
+    EXPECT_THROW(source_.ungetChar(), InputSource::UngetBeforeBeginning);
 }
 
 // ungetAll() should skip back to the place where the InputSource
@@ -128,7 +128,7 @@ TEST_F(InputSourceTest, compact) {
     source_.compact();
 
     // Ungetting here must throw.
-    EXPECT_THROW(source_.ungetChar(), InputSource::UngetError);
+    EXPECT_THROW(source_.ungetChar(), InputSource::UngetBeforeBeginning);
 
     for (size_t i = 0; i < str_length_; i++) {
         EXPECT_EQ(str_[i], source_.getChar());
@@ -156,7 +156,7 @@ TEST_F(InputSourceTest, compact) {
     source_.ungetChar();
 
     // Ungetting here must throw.
-    EXPECT_THROW(source_.ungetChar(), InputSource::UngetError);
+    EXPECT_THROW(source_.ungetChar(), InputSource::UngetBeforeBeginning);
 
     EXPECT_EQ(-1, source_.getChar());
     EXPECT_TRUE(source_.atEOF());
@@ -181,7 +181,7 @@ TEST_F(InputSourceTest, compactDuring) {
     source_.compact();
 
     // Ungetting here must throw.
-    EXPECT_THROW(source_.ungetChar(), InputSource::UngetError);
+    EXPECT_THROW(source_.ungetChar(), InputSource::UngetBeforeBeginning);
 
     for (size_t i = 13; i < str_length_; i++) {
         EXPECT_EQ(str_[i], source_.getChar());
@@ -201,7 +201,7 @@ TEST_F(InputSourceTest, compactDuring) {
     source_.ungetAll();
 
     // Ungetting here must throw.
-    EXPECT_THROW(source_.ungetChar(), InputSource::UngetError);
+    EXPECT_THROW(source_.ungetChar(), InputSource::UngetBeforeBeginning);
 
     for (size_t i = 13; i < str_length_; i++) {
         EXPECT_EQ(str_[i], source_.getChar());
@@ -263,7 +263,7 @@ TEST_F(InputSourceTest, lines) {
                          ((line - 1) == source_.getCurrentLine())));
             line = source_.getCurrentLine();
         }
-    }, InputSource::UngetError);
+    }, InputSource::UngetBeforeBeginning);
 
     // Now we are back to where we started.
     EXPECT_EQ(1, source_.getCurrentLine());