Commit e2850e90 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[3560] Client classes may now be created from the csv string.

parent 46918f31
......@@ -14,7 +14,7 @@ CLEANFILES = *.gcno *.gcda
lib_LTLIBRARIES = libkea-dhcp++.la
libkea_dhcp___la_SOURCES =
libkea_dhcp___la_SOURCES += classify.h
libkea_dhcp___la_SOURCES += classify.cc classify.h
libkea_dhcp___la_SOURCES += dhcp6.h dhcp4.h
libkea_dhcp___la_SOURCES += duid.cc duid.h
libkea_dhcp___la_SOURCES += hwaddr.cc hwaddr.h
......
......@@ -53,6 +53,17 @@ namespace dhcp {
/// documentation. See http://www.cplusplus.com/reference/set/set/.
class ClientClasses : public std::set<ClientClass> {
public:
/// @brief Default constructor.
ClientClasses() : std::set<ClientClass>() {
}
/// @brief Constructor from comma separated values.
///
/// @param class_names A string containing a client classes separated
/// with commas. The class names are trimmed before insertion to the set.
ClientClasses(const std::string& class_names);
/// @brief returns if class x belongs to the defined classes
///
/// @param x client class to be checked
......
// Copyright (C) 2011-2013 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2011-2014 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
......@@ -36,8 +36,7 @@ TEST(ClassifyTest, ClientClasses) {
EXPECT_FALSE(classes.contains(""));
EXPECT_FALSE(classes.contains("alpha"));
EXPECT_FALSE(classes.contains("beta"));
EXPECT_FALSE(classes.contains("gamma"));
EXPECT_FALSE(classes.contains("gamma"));
classes.insert("beta");
EXPECT_FALSE(classes.contains(""));
EXPECT_FALSE(classes.contains("alpha"));
......@@ -50,3 +49,23 @@ TEST(ClassifyTest, ClientClasses) {
EXPECT_TRUE (classes.contains("beta"));
EXPECT_TRUE (classes.contains("gamma"));
}
// Check if ClientClasses object can be created from the string of comma
// separated values.
TEST(ClassifyTest, ClientClassesFromString) {
{
ClientClasses classes("alpha, beta, gamma");
EXPECT_FALSE(classes.contains(""));
EXPECT_TRUE(classes.contains("alpha"));
EXPECT_TRUE(classes.contains("beta"));
EXPECT_TRUE(classes.contains("gamma"));
}
{
ClientClasses classes("alpha, , beta ,");
EXPECT_TRUE(classes.contains("alpha"));
EXPECT_FALSE(classes.contains(""));
EXPECT_TRUE(classes.contains("beta"));
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment