]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[4097a] Added a ClientClasses iteration unit test
authorFrancis Dupont <fdupont@isc.org>
Fri, 20 Nov 2015 15:12:27 +0000 (16:12 +0100)
committerFrancis Dupont <fdupont@isc.org>
Fri, 20 Nov 2015 15:12:27 +0000 (16:12 +0100)
src/lib/dhcp/tests/classify_unittest.cc

index e1a8d4c59941053c2345d7c20a7156bbea030f8e..d6e5ee895c1ab9a3d68ff826b98084669f7c763d 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2011-2014 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2011-2015 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
@@ -85,3 +85,33 @@ TEST(ClassifyTest, ClientClassesFromString) {
         EXPECT_TRUE(classes.empty());
     }
 }
+
+// Check if one can iterate over a ClientClasses object
+TEST(ClassifyTest, ClientClassesIterator) {
+    ClientClasses classes("alpha, beta, gamma");
+    size_t count = 0;
+    bool seenalpha = false;
+    bool seenbeta = false;
+    bool seengamma = false;
+    bool seendelta = false;
+    for (ClientClasses::const_iterator it = classes.begin();
+         it != classes.end(); ++it) {
+        ++count;
+        if (*it == "alpha") {
+            seenalpha = true;
+        } else if (*it == "beta") {
+            seenbeta = true;
+        } else if (*it == "gamma") {
+            seengamma = true;
+        } else if (*it == "delta") {
+            seendelta = true;
+        } else {
+            ADD_FAILURE() << "Got unexpected " << *it;
+        }
+    }
+    EXPECT_EQ(count, classes.size());
+    EXPECT_TRUE(seenalpha);
+    EXPECT_TRUE(seenbeta);
+    EXPECT_TRUE(seengamma);
+    EXPECT_FALSE(seendelta);
+}