Michal 'vorner' Vaner 13 years ago
parent
commit
373eda27fc
2 changed files with 12 additions and 4 deletions
  1. 1 3
      src/lib/util/buffer.h
  2. 11 1
      src/lib/util/tests/buffer_unittest.cc

+ 1 - 3
src/lib/util/buffer.h

@@ -380,9 +380,7 @@ public:
     /// \param pos The position in the buffer to be returned.
     uint8_t operator[](size_t pos) const
     {
-        if (pos >= size_) {
-            isc_throw(InvalidBufferPosition, "read at invalid position");
-        }
+        assert (pos < size_);
         return (buffer_[pos]);
     }
     //@}

+ 11 - 1
src/lib/util/tests/buffer_unittest.cc

@@ -182,7 +182,17 @@ TEST_F(BufferTest, outputBufferReadat) {
     for (int i = 0; i < sizeof(testdata); i ++) {
         EXPECT_EQ(testdata[i], obuffer[i]);
     }
-    EXPECT_THROW(obuffer[sizeof(testdata)], isc::util::InvalidBufferPosition);
+#ifdef EXPECT_DEATH
+    // We use assert now, so we check it dies
+    EXPECT_DEATH({
+        try {
+            obuffer[sizeof(testdata)];
+        } catch (...) {
+            // Prevent exceptions killing the application, we need
+            // to make sure it dies the real hard way
+        }
+        }, "");
+#endif
 }
 
 TEST_F(BufferTest, outputBufferClear) {