Browse Source

[1975] Make sure we handle set::iterator correctly

There was a possible problem in mock data source with decreasing a
begin() iterator.
Michal 'vorner' Vaner 13 years ago
parent
commit
3800f59cba
1 changed files with 5 additions and 0 deletions
  1. 5 0
      src/lib/datasrc/tests/container_unittest.cc

+ 5 - 0
src/lib/datasrc/tests/container_unittest.cc

@@ -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