[svn] commit: r788 - in /trunk/src/lib/dns/cpp: name.h name_unittest.cc

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Feb 10 21:07:38 UTC 2010


Author: jinmei
Date: Wed Feb 10 21:07:37 2010
New Revision: 788

Log:
added test/documentation for operator= and copy constructor
(trac ticket #47, reviewed by Evan)

Modified:
    trunk/src/lib/dns/cpp/name.h
    trunk/src/lib/dns/cpp/name_unittest.cc

Modified: trunk/src/lib/dns/cpp/name.h
==============================================================================
--- trunk/src/lib/dns/cpp/name.h (original)
+++ trunk/src/lib/dns/cpp/name.h Wed Feb 10 21:07:37 2010
@@ -261,7 +261,11 @@
     /// \param buffer A buffer storing the wire format data.
     /// \param downcase Whether to convert upper case alphabets to lower case.
     explicit Name(InputBuffer& buffer, bool downcase = false);
-    //@}
+    ///
+    /// We use the default copy constructor intentionally.
+    //@}
+    /// We use the default copy assignment operator intentionally.
+    ///
 
     ///
     /// \name Getter Methods

Modified: trunk/src/lib/dns/cpp/name_unittest.cc
==============================================================================
--- trunk/src/lib/dns/cpp/name_unittest.cc (original)
+++ trunk/src/lib/dns/cpp/name_unittest.cc Wed Feb 10 21:07:37 2010
@@ -266,6 +266,36 @@
                                   25).getLabelCount());
 }
 
+TEST_F(NameTest, copyConstruct)
+{
+    Name copy(example_name);
+    EXPECT_EQ(copy, example_name);
+
+    // Check the copied data is valid even after the original is deleted
+    Name* copy2 = new Name(example_name);
+    Name copy3(*copy2);
+    delete copy2;
+    EXPECT_EQ(copy3, example_name);
+}
+
+TEST_F(NameTest, assignment)
+{
+    Name copy(".");
+    copy = example_name;
+    EXPECT_EQ(copy, example_name);
+
+    // Check if the copied data is valid even after the original is deleted
+    Name* copy2 = new Name(example_name);
+    Name copy3(".");
+    copy3 = *copy2;
+    delete copy2;
+    EXPECT_EQ(copy3, example_name);
+
+    // Self assignment
+    copy = copy;
+    EXPECT_EQ(copy, example_name);
+}
+
 TEST_F(NameTest, toText)
 {
     // tests derived from BIND9




More information about the bind10-changes mailing list