Browse Source

[trac1072] review comments

Jelte Jansen 14 years ago
parent
commit
ec45081d78
2 changed files with 6 additions and 2 deletions
  1. 1 2
      src/lib/cc/data.cc
  2. 5 0
      src/lib/cc/tests/data_unittests.cc

+ 1 - 2
src/lib/cc/data.cc

@@ -456,8 +456,7 @@ from_stringstream_map(std::istream &in, const std::string& file, int& line,
     char c = in.peek();
     if (c == EOF) {
         throwJSONError(std::string("Unterminated map, <string> or } expected"), file, line, pos);
-    }
-    if (c == '}') {
+    } else if (c == '}') {
         // empty map, skip closing curly
         c = in.get();
     } else {

+ 5 - 0
src/lib/cc/tests/data_unittests.cc

@@ -409,6 +409,11 @@ TEST(Element, to_and_from_wire) {
     EXPECT_THROW(Element::fromJSON("[ 1, 2, }"), isc::data::JSONError);
     EXPECT_THROW(Element::fromJSON("[ 1, 2, {}"), isc::data::JSONError);
     EXPECT_THROW(Element::fromJSON("[ 1, 2, { ]"), isc::data::JSONError);
+    EXPECT_THROW(Element::fromJSON("[ "), isc::data::JSONError);
+    EXPECT_THROW(Element::fromJSON("{{}}"), isc::data::JSONError);
+    EXPECT_THROW(Element::fromJSON("{[]}"), isc::data::JSONError);
+    EXPECT_THROW(Element::fromJSON("{ \"a\", \"b\" }"), isc::data::JSONError);
+    EXPECT_THROW(Element::fromJSON("[ \"a\": \"b\" ]"), isc::data::JSONError);
 }
 
 ConstElementPtr