From: Francis Dupont Date: Mon, 15 Jun 2020 14:02:40 +0000 (+0200) Subject: [#1211] Addressed comments X-Git-Tag: Kea-1.7.9~68 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ff51545c56f07bdaa017d60db5c57a0f1ba3978a;p=thirdparty%2Fkea.git [#1211] Addressed comments --- diff --git a/src/lib/dhcpsrv/tests/cfg_option_unittest.cc b/src/lib/dhcpsrv/tests/cfg_option_unittest.cc index 10f128b06c..93ea8aa6e4 100644 --- a/src/lib/dhcpsrv/tests/cfg_option_unittest.cc +++ b/src/lib/dhcpsrv/tests/cfg_option_unittest.cc @@ -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 { diff --git a/src/lib/dns/tests/labelsequence_unittest.cc b/src/lib/dns/tests/labelsequence_unittest.cc index 6db3cefbf6..15650fac07 100644 --- a/src/lib/dns/tests/labelsequence_unittest.cc +++ b/src/lib/dns/tests/labelsequence_unittest.cc @@ -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));