]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[1975] Make sure we handle set::iterator correctly
authorMichal 'vorner' Vaner <michal.vaner@nic.cz>
Tue, 12 Jun 2012 12:28:55 +0000 (14:28 +0200)
committerMichal 'vorner' Vaner <michal.vaner@nic.cz>
Tue, 12 Jun 2012 12:28:55 +0000 (14:28 +0200)
There was a possible problem in mock data source with decreasing a
begin() iterator.

src/lib/datasrc/tests/container_unittest.cc

index 83c0c8855dfd8f17416a8d62aefd7682e667b951..533878d3dcdb2e546bc07582dbc874f3150c8bbc 100644 (file)
@@ -81,6 +81,9 @@ public:
             return (FindResult(result::NOTFOUND, ZoneFinderPtr()));
         }
         set<Name>::const_iterator it(zones.upper_bound(name));
+        if (it == zones.begin()) {
+            return (FindResult(result::NOTFOUND, ZoneFinderPtr()));
+        }
         -- it;
         NameComparisonResult compar(it->compare(name));
         const ZoneFinderPtr finder(new Finder(*it));
@@ -242,6 +245,8 @@ TEST_F(ContainerTest, selfTest) {
               ds_[0]->findZone(Name("sub.example.org")).code);
     EXPECT_EQ(result::NOTFOUND, ds_[0]->findZone(Name("org")).code);
     EXPECT_EQ(result::NOTFOUND, ds_[1]->findZone(Name("example.org")).code);
+    EXPECT_EQ(result::NOTFOUND, ds_[0]->findZone(Name("aaa")).code);
+    EXPECT_EQ(result::NOTFOUND, ds_[0]->findZone(Name("zzz")).code);
 }
 
 // Test the container we create with empty configuration is, in fact, empty