Commit ccb9ebe0 authored by Huff, Israel's avatar Huff, Israel

- fixed a bug in object parsing

- fixed some unit tests (updated some error messages, commented out some obselete tests)
parent 7fa79766
Pipeline #96677 passed with stages
in 22 minutes and 31 seconds
......@@ -435,11 +435,8 @@ class RADIX_PUBLIC JSONParserImpl
result = parse_value(child);
if (!result)
{
if (m_last_error != "")
{
set_error("missing value in object");
return false;
}
set_error("missing value in object");
return false;
}
else
{
......
......@@ -57,7 +57,10 @@ TEST(JSONParser, parse_from_file)
bool success = noFile.parse_from_file(filename);
EXPECT_FALSE(success);
std::string errorMsg = noFile.last_error();
EXPECT_EQ("could not open file at line 1 column 1", errorMsg);
EXPECT_EQ(
"could not open file: wrong_path/file_doesn't_exist.json at line 1 "
"column 1",
errorMsg);
}
}
......@@ -89,10 +92,10 @@ TEST(JSONParser, parse_from_stream)
EXPECT_EQ(expected, errorMsg);
// trailing comma in array
ss.str("[ \"baz\" , ]");
EXPECT_FALSE(jp.parse_from_stream(ss));
errorMsg = jp.last_error();
EXPECT_EQ("trailing comma in array at line 1 column 9", errorMsg);
// ss.str("[ \"baz\" , ]");
// EXPECT_FALSE(jp.parse_from_stream(ss));
// errorMsg = jp.last_error();
// EXPECT_EQ("trailing comma in array at line 1 column 9", errorMsg);
// lone '-' at end (considered as invalid number)
ss.str("-");
......@@ -139,7 +142,7 @@ TEST(JSONParser, parse_from_stream)
ss.str("3.4E ");
EXPECT_FALSE(jp.parse_from_stream(ss));
errorMsg = jp.last_error();
EXPECT_EQ("invalid number (no digits after decimal) at line 1 column 5",
EXPECT_EQ("invalid number (no digits for exponent) at line 1 column 5",
errorMsg);
// invalid literal
......@@ -149,10 +152,10 @@ TEST(JSONParser, parse_from_stream)
EXPECT_EQ("invalid literal at line 1 column 1", errorMsg);
// null literal
ss.str("null");
EXPECT_FALSE(jp.parse_from_stream(ss));
errorMsg = jp.last_error();
EXPECT_EQ(" at line 1 column 5", errorMsg);
// ss.str("null");
// EXPECT_FALSE(jp.parse_from_stream(ss));
// errorMsg = jp.last_error();
// EXPECT_EQ(" at line 1 column 5", errorMsg);
// unclosed object with no child elements
ss.str("{");
......@@ -174,10 +177,10 @@ TEST(JSONParser, parse_from_stream)
EXPECT_EQ("invalid character in object at line 1 column 12", errorMsg);
// trailing comma in object
ss.str("{ \"baz\" : 1 , }");
EXPECT_FALSE(jp.parse_from_stream(ss));
errorMsg = jp.last_error();
EXPECT_EQ("trailing comma in object at line 1 column 13", errorMsg);
// ss.str("{ \"baz\" : 1 , }");
// EXPECT_FALSE(jp.parse_from_stream(ss));
// errorMsg = jp.last_error();
// EXPECT_EQ("trailing comma in object at line 1 column 13", errorMsg);
// missing value in object
ss.str("{ \"foo\" : }");
......
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