mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-30 05:27:55 +00:00
[#1139] Added function to erase class
This commit is contained in:
parent
879116c595
commit
d6d1e806df
@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2014-2017 Internet Systems Consortium, Inc. ("ISC")
|
||||
// Copyright (C) 2014-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
|
||||
@ -30,6 +30,12 @@ ClientClasses::ClientClasses(const std::string& class_names)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ClientClasses::erase(const ClientClass& class_name) {
|
||||
list_.remove(class_name);
|
||||
static_cast<void>(set_.erase(class_name));
|
||||
}
|
||||
|
||||
std::string
|
||||
ClientClasses::toText(const std::string& separator) const {
|
||||
std::stringstream s;
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2014-2017 Internet Systems Consortium, Inc. ("ISC")
|
||||
// Copyright (C) 2014-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
|
||||
@ -64,6 +64,11 @@ namespace dhcp {
|
||||
set_.insert(class_name);
|
||||
}
|
||||
|
||||
/// @brief Erase element by name.
|
||||
///
|
||||
/// @param class_name The name of the class to erase.
|
||||
void erase(const ClientClass& class_name);
|
||||
|
||||
/// @brief Check if classes is empty.
|
||||
bool empty() const {
|
||||
return (list_.empty());
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2011-2017 Internet Systems Consortium, Inc. ("ISC")
|
||||
// Copyright (C) 2011-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
|
||||
@ -131,3 +131,21 @@ TEST(ClassifyTest, ClientClassesToText) {
|
||||
// Check non-standard separator.
|
||||
EXPECT_EQ("alpha.gamma.beta", classes.toText("."));
|
||||
}
|
||||
|
||||
// Check that selected class can be erased.
|
||||
TEST(ClassifyTest, Erase) {
|
||||
ClientClasses classes;
|
||||
|
||||
classes.insert("alpha");
|
||||
classes.insert("beta");
|
||||
EXPECT_TRUE(classes.contains("alpha"));
|
||||
EXPECT_TRUE(classes.contains("beta"));
|
||||
|
||||
classes.erase("beta");
|
||||
EXPECT_TRUE(classes.contains("alpha"));
|
||||
EXPECT_FALSE(classes.contains("beta"));
|
||||
|
||||
classes.erase("alpha");
|
||||
EXPECT_FALSE(classes.contains("alpha"));
|
||||
EXPECT_FALSE(classes.contains("beta"));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user