Browse Source

[trac871] avoid using a hardcoded magic number in a test case

JINMEI Tatuya 14 years ago
parent
commit
89fcb0f002
1 changed files with 4 additions and 5 deletions
  1. 4 5
      src/lib/dns/tests/tsigrecord_unittest.cc

+ 4 - 5
src/lib/dns/tests/tsigrecord_unittest.cc

@@ -58,7 +58,7 @@ TEST_F(TSIGRecordTest, getName) {
 }
 
 TEST_F(TSIGRecordTest, getLength) {
-    // 85 = 17 + 26 + 16 + 24
+    // 85 = 17 + 26 + 16 + 26
     // len(www.example.com) = 17
     // len(hmac-md5.sig-alg.reg.int) = 26
     // len(MAC) = 16
@@ -82,10 +82,9 @@ TEST_F(TSIGRecordTest, recordToWire) {
 }
 
 TEST_F(TSIGRecordTest, recordToOLongToWire) {
-    // Rendering the test record requires a room of 85 bytes (see the
-    // getLength test).  By setting the limit to 84, it will fail, and
-    // the renderer will be marked as "truncated".
-    renderer.setLengthLimit(84);
+    // By setting the limit to "record length - 1", it will fail, and the
+    // renderer will be marked as "truncated".
+    renderer.setLengthLimit(test_record.getLength() - 1);
     EXPECT_FALSE(renderer.isTruncated()); // not marked before render attempt
     EXPECT_EQ(0, test_record.toWire(renderer));
     EXPECT_TRUE(renderer.isTruncated());