]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1211] Addressed comments
authorFrancis Dupont <fdupont@isc.org>
Mon, 15 Jun 2020 14:02:40 +0000 (16:02 +0200)
committerFrancis Dupont <fdupont@isc.org>
Mon, 15 Jun 2020 15:43:16 +0000 (15:43 +0000)
src/lib/dhcpsrv/tests/cfg_option_unittest.cc
src/lib/dns/tests/labelsequence_unittest.cc

index 10f128b06c07f6d993bfa434190131fd676b9fa3..93ea8aa6e4eb9aefe82501daead7d95a15753d44 100644 (file)
@@ -77,6 +77,31 @@ TEST(OptionDescriptorTest, createCopy) {
     EXPECT_EQ(context, desc_copy->getContext());
 }
 
+// This test verifies that the OptionDescriptor assignment operator
+// does the shallow copy.
+TEST(OptionDescriptorTest, assign) {
+    // Create a persistent option descriptor.
+    auto desc = OptionDescriptor::create(true);
+    ASSERT_TRUE(desc);
+
+    // Create another option descriptor.
+    OptionPtr option = Option::create(Option::V4, 234);
+    ElementPtr context = Element::createMap();
+    context->set("name", Element::create("value"));
+    auto desc1 = OptionDescriptor::create(option, true, "value", context);
+    ASSERT_TRUE(desc1);
+
+    // Assign the option descriptor.
+    desc = desc1;
+
+    // Check it.
+    ASSERT_TRUE(desc);
+    EXPECT_EQ(option, desc->option_);
+    EXPECT_TRUE(desc->persistent_);
+    EXPECT_EQ("value", desc->formatted_value_);
+    EXPECT_EQ(context, desc->getContext());
+}
+
 /// This class fixture for testing @c CfgOption class, holding option
 /// configuration.
 class CfgOptionTest : public ::testing::Test {
index 6db3cefbf67a62af83771322b4dcd32e0916f0e4..15650fac07eb426352d6929b1417842618c3ad37 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2012-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2020 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -82,6 +82,18 @@ public:
     LabelSequence ls9, ls10, ls11, ls12;
 };
 
+// Check the assignment operator.
+TEST_F(LabelSequenceTest, assign) {
+    // Create the label sequence with example.org (n1 name).
+    LabelSequence ls(n1);
+    EXPECT_TRUE(ls == ls1);
+
+    // Assign the label sequence to example.com (n2 name).
+    ls = ls2;
+    EXPECT_FALSE(ls == ls1);
+    EXPECT_TRUE(ls == ls2);
+}
+
 // Basic equality tests
 TEST_F(LabelSequenceTest, equals_sensitive) {
     EXPECT_TRUE(ls1.equals(ls1, true));