Browse Source

[trac613] avoid the obvious form of self assignment to silence cppcheck.

JINMEI Tatuya 14 years ago
parent
commit
a9e9a2b26f

+ 4 - 3
src/lib/dns/tests/name_unittest.cc

@@ -288,9 +288,10 @@ TEST_F(NameTest, assignment) {
     delete copy2;
     EXPECT_EQ(copy3, example_name);
 
-    // Self assignment
-    copy = copy;
-    EXPECT_EQ(copy, example_name);
+    // Self assignment (via a reference to silence cppcheck)
+    Name& copyref(copy);
+    copyref = copy;
+    EXPECT_EQ(example_name, copyref);
 }
 
 TEST_F(NameTest, toText) {

+ 4 - 3
src/lib/dns/tests/rdata_unittest.cc

@@ -223,9 +223,10 @@ TEST_F(Rdata_Unknown_Test, assignment) {
     delete copy2;
     EXPECT_EQ(0, copy3.compare(rdata_unknown));
 
-    // Self assignment
-    copy = copy;
-    EXPECT_EQ(0, copy.compare(rdata_unknown));
+    // Self assignment (via a reference to silence cppcheck)
+    generic::Generic& copyref(copy);
+    copyref = copy;
+    EXPECT_EQ(0, copyref.compare(rdata_unknown));
 }
 
 TEST_F(Rdata_Unknown_Test, toText) {

+ 4 - 3
src/lib/dns/tests/tsigkey_unittest.cc

@@ -100,9 +100,10 @@ TEST_F(TSIGKeyTest, assignment) {
     delete copy2;
     compareTSIGKeys(original, copy3);
 
-    // self assignment
-    copy = copy;
-    compareTSIGKeys(original, copy);
+    // self assignment (via a reference to silence cppcheck)
+    TSIGKey& copyref(copy);
+    copyref = copy;
+    compareTSIGKeys(original, copyref);
 }
 
 class TSIGKeyRingTest : public ::testing::Test {