Browse Source

[1602] rename split methods

leftSplit() -> stripLeft()
rightSplit() -> stripRight()
Jelte Jansen 13 years ago
parent
commit
cb28f3c419

+ 4 - 4
src/lib/dns/labelsequence.cc

@@ -51,18 +51,18 @@ LabelSequence::equals(const LabelSequence& other, bool case_sensitive) const {
 }
 
 void
-LabelSequence::leftSplit(size_t i) {
+LabelSequence::stripLeft(size_t i) {
     if (i >= getLabelCount()) {
-        isc_throw(OutOfRange, "Cannot split to zero or less labels; " << i <<
+        isc_throw(OutOfRange, "Cannot strip to zero or less labels; " << i <<
                               " (labelcount: " << getLabelCount() << ")");
     }
     first_label_ += i;
 }
 
 void
-LabelSequence::rightSplit(size_t i) {
+LabelSequence::stripRight(size_t i) {
     if (i >= getLabelCount()) {
-        isc_throw(OutOfRange, "Cannot split to zero or less labels; " << i <<
+        isc_throw(OutOfRange, "Cannot strip to zero or less labels; " << i <<
                               " (labelcount: " << getLabelCount() << ")");
     }
     last_label_ -= i;

+ 7 - 6
src/lib/dns/labelsequence.h

@@ -24,16 +24,17 @@ namespace dns {
 /// \brief Light-weight Accessor to Name object
 ///
 /// The purpose of this class is to easily match Names and parts of Names,
-/// without needing to copy the underlying data on each split.
+/// without needing to copy the underlying data on each label strip.
 ///
 /// It can only work on existing Name objects, and the Name object MUST
 /// remain in scope during the entire lifetime of its associated
 /// LabelSequence(s).
 ///
 /// Upon creation of a LabelSequence, it records the offsets of the
-/// labels in the wireformat data of the Name. When split() is called on
-/// the LabelSequence, no changes in the Name's data occur, but the
-/// internal pointers of the LabelSequence are modified.
+/// labels in the wireformat data of the Name. When stripLeft() or
+/// stripRight() is called on the LabelSequence, no changes in the
+/// Name's data occur, but the internal pointers of the
+/// LabelSequence are modified.
 ///
 /// LabelSequences can be compared to other LabelSequences, and their
 /// data can be requested (which then points to part of the original
@@ -88,7 +89,7 @@ public:
     ///           of labels currently pointed to by this LabelSequence
     ///
     /// \param i The number of labels to remove.
-    void leftSplit(size_t i);
+    void stripLeft(size_t i);
 
     /// \brief Remove labels from the end of this LabelSequence
     ///
@@ -99,7 +100,7 @@ public:
     ///           of labels currently pointed to by this LabelSequence
     ///
     /// \param i The number of labels to remove.
-    void rightSplit(size_t i);
+    void stripRight(size_t i);
 
     /// \brief Returns the current number of labels for this LabelSequence
     ///

+ 36 - 36
src/lib/dns/tests/labelsequence_unittest.cc

@@ -143,89 +143,89 @@ TEST_F(LabelSequenceTest, getData) {
     getDataCheck("\000", 1, ls7);
 };
 
-TEST_F(LabelSequenceTest, leftSplit) {
+TEST_F(LabelSequenceTest, stripLeft) {
     EXPECT_TRUE(ls1.equals(ls3));
-    ls1.leftSplit(0);
+    ls1.stripLeft(0);
     getDataCheck("\007example\003org\000", 13, ls1);
     EXPECT_TRUE(ls1.equals(ls3));
-    ls1.leftSplit(1);
+    ls1.stripLeft(1);
     getDataCheck("\003org\000", 5, ls1);
     EXPECT_FALSE(ls1.equals(ls3));
-    ls1.leftSplit(1);
+    ls1.stripLeft(1);
     getDataCheck("\000", 1, ls1);
     EXPECT_TRUE(ls1.equals(ls7));
 
-    ls2.leftSplit(2);
+    ls2.stripLeft(2);
     getDataCheck("\000", 1, ls2);
     EXPECT_TRUE(ls2.equals(ls7));
 }
 
-TEST_F(LabelSequenceTest, rightSplit) {
+TEST_F(LabelSequenceTest, stripRight) {
     EXPECT_TRUE(ls1.equals(ls3));
-    ls1.rightSplit(1);
+    ls1.stripRight(1);
     getDataCheck("\007example\003org", 12, ls1);
     EXPECT_FALSE(ls1.equals(ls3));
-    ls1.rightSplit(1);
+    ls1.stripRight(1);
     getDataCheck("\007example", 8, ls1);
     EXPECT_FALSE(ls1.equals(ls3));
 
     ASSERT_FALSE(ls1.equals(ls2));
-    ls2.rightSplit(2);
+    ls2.stripRight(2);
     getDataCheck("\007example", 8, ls2);
     EXPECT_TRUE(ls1.equals(ls2));
 }
 
-TEST_F(LabelSequenceTest, split_oor) {
-    EXPECT_THROW(ls1.leftSplit(100), isc::OutOfRange);
-    EXPECT_THROW(ls1.leftSplit(5), isc::OutOfRange);
-    EXPECT_THROW(ls1.leftSplit(4), isc::OutOfRange);
-    EXPECT_THROW(ls1.leftSplit(3), isc::OutOfRange);
+TEST_F(LabelSequenceTest, stripOutOfRange) {
+    EXPECT_THROW(ls1.stripLeft(100), isc::OutOfRange);
+    EXPECT_THROW(ls1.stripLeft(5), isc::OutOfRange);
+    EXPECT_THROW(ls1.stripLeft(4), isc::OutOfRange);
+    EXPECT_THROW(ls1.stripLeft(3), isc::OutOfRange);
     getDataCheck("\007example\003org\000", 13, ls1);
 
-    EXPECT_THROW(ls1.rightSplit(100), isc::OutOfRange);
-    EXPECT_THROW(ls1.rightSplit(5), isc::OutOfRange);
-    EXPECT_THROW(ls1.rightSplit(4), isc::OutOfRange);
-    EXPECT_THROW(ls1.rightSplit(3), isc::OutOfRange);
+    EXPECT_THROW(ls1.stripRight(100), isc::OutOfRange);
+    EXPECT_THROW(ls1.stripRight(5), isc::OutOfRange);
+    EXPECT_THROW(ls1.stripRight(4), isc::OutOfRange);
+    EXPECT_THROW(ls1.stripRight(3), isc::OutOfRange);
     getDataCheck("\007example\003org\000", 13, ls1);
 }
 
 TEST_F(LabelSequenceTest, getLabelCount) {
     EXPECT_EQ(3, ls1.getLabelCount());
-    ls1.leftSplit(0);
+    ls1.stripLeft(0);
     EXPECT_EQ(3, ls1.getLabelCount());
-    ls1.leftSplit(1);
+    ls1.stripLeft(1);
     EXPECT_EQ(2, ls1.getLabelCount());
-    ls1.leftSplit(1);
+    ls1.stripLeft(1);
     EXPECT_EQ(1, ls1.getLabelCount());
 
     EXPECT_EQ(3, ls2.getLabelCount());
-    ls2.rightSplit(1);
+    ls2.stripRight(1);
     EXPECT_EQ(2, ls2.getLabelCount());
-    ls2.rightSplit(1);
+    ls2.stripRight(1);
     EXPECT_EQ(1, ls2.getLabelCount());
 
     EXPECT_EQ(3, ls3.getLabelCount());
-    ls3.rightSplit(2);
+    ls3.stripRight(2);
     EXPECT_EQ(1, ls3.getLabelCount());
 
     EXPECT_EQ(5, ls4.getLabelCount());
-    ls4.rightSplit(3);
+    ls4.stripRight(3);
     EXPECT_EQ(2, ls4.getLabelCount());
 
     EXPECT_EQ(3, ls5.getLabelCount());
-    ls5.leftSplit(2);
+    ls5.stripLeft(2);
     EXPECT_EQ(1, ls5.getLabelCount());
 }
 
 TEST_F(LabelSequenceTest, comparePart) {
     EXPECT_FALSE(ls1.equals(ls8));
 
-    // Split root label from example.org.
-    ls1.rightSplit(1);
-    // Split foo from foo.example.org.bar.
-    ls8.leftSplit(1);
-    // Split bar. (i.e. bar and root) too
-    ls8.rightSplit(2);
+    // strip root label from example.org.
+    ls1.stripRight(1);
+    // strip foo from foo.example.org.bar.
+    ls8.stripLeft(1);
+    // strip bar. (i.e. bar and root) too
+    ls8.stripRight(2);
 
     EXPECT_TRUE(ls1.equals(ls8));
 
@@ -238,16 +238,16 @@ TEST_F(LabelSequenceTest, comparePart) {
 TEST_F(LabelSequenceTest, isAbsolute) {
     ASSERT_TRUE(ls1.isAbsolute());
 
-    ls1.leftSplit(1);
+    ls1.stripLeft(1);
     ASSERT_TRUE(ls1.isAbsolute());
-    ls1.rightSplit(1);
+    ls1.stripRight(1);
     ASSERT_FALSE(ls1.isAbsolute());
 
     ASSERT_TRUE(ls2.isAbsolute());
-    ls2.rightSplit(1);
+    ls2.stripRight(1);
     ASSERT_FALSE(ls2.isAbsolute());
 
     ASSERT_TRUE(ls3.isAbsolute());
-    ls3.leftSplit(2);
+    ls3.stripLeft(2);
     ASSERT_TRUE(ls3.isAbsolute());
 }