Browse Source

[2053] Add checks with long label sequences

Mukund Sivaraman 13 years ago
parent
commit
23ae3c2bbd
1 changed files with 55 additions and 0 deletions
  1. 55 0
      src/lib/dns/tests/labelsequence_unittest.cc

+ 55 - 0
src/lib/dns/tests/labelsequence_unittest.cc

@@ -313,6 +313,61 @@ TEST_F(LabelSequenceTest, toText) {
 
 
     EXPECT_EQ(".", ls7.toText());
     EXPECT_EQ(".", ls7.toText());
     EXPECT_THROW(ls7.stripLeft(1), isc::OutOfRange);
     EXPECT_THROW(ls7.stripLeft(1), isc::OutOfRange);
+
+    Name n_long1("012345678901234567890123456789"
+                 "012345678901234567890123456789012."
+                 "012345678901234567890123456789"
+                 "012345678901234567890123456789012."
+                 "012345678901234567890123456789"
+                 "012345678901234567890123456789012."
+                 "012345678901234567890123456789"
+                 "0123456789012345678901234567890");
+    LabelSequence ls_long1(n_long1);
+
+    EXPECT_EQ("012345678901234567890123456789"
+              "012345678901234567890123456789012."
+              "012345678901234567890123456789"
+              "012345678901234567890123456789012."
+              "012345678901234567890123456789"
+              "012345678901234567890123456789012."
+              "012345678901234567890123456789"
+              "0123456789012345678901234567890.", ls_long1.toText());
+    ls_long1.stripRight(1);
+    EXPECT_EQ("012345678901234567890123456789"
+              "012345678901234567890123456789012."
+              "012345678901234567890123456789"
+              "012345678901234567890123456789012."
+              "012345678901234567890123456789"
+              "012345678901234567890123456789012."
+              "012345678901234567890123456789"
+              "0123456789012345678901234567890", ls_long1.toText());
+
+    Name n_long2("0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9."
+                 "0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9."
+                 "0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9."
+                 "0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9."
+                 "0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9."
+                 "0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9."
+                 "0.1.2.3.4.5.6");
+    LabelSequence ls_long2(n_long2);
+
+    EXPECT_EQ("0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9."
+              "0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9."
+              "0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9."
+              "0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9."
+              "0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9."
+              "0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9."
+              "0.1.2.3.4.5.6.", ls_long2.toText());
+    ls_long2.stripRight(1);
+    EXPECT_EQ("0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9."
+              "0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9."
+              "0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9."
+              "0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9."
+              "0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9."
+              "0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9."
+              "0.1.2.3.4.5.6", ls_long2.toText());
+    ls_long2.stripRight(125);
+    EXPECT_EQ("0.1", ls_long2.toText());
 }
 }
 
 
 // The following are test data used in the getHash test below.  Normally
 // The following are test data used in the getHash test below.  Normally