fixed test case

This commit is contained in:
Niels 2016-04-17 22:34:39 +02:00
parent 6268287940
commit 1dee40a969
3 changed files with 13 additions and 37 deletions

View file

@ -8986,25 +8986,15 @@ basic_json_parser_63:
} }
/* /*
This function is only to be called from the unflatten() The following code is only reached if there exists a
function. There, j is initially of type null. reference token _and_ the current value is primitive. In
this case, we have an error situation, because primitive
- In case the reference tokens are empty, a reference to values may only occur as single value; that is, with an
j is returned and overwritten by the desired value by empty list of reference tokens.
the unflatten() function.
- If there are reference tokens, the null value of j will
be changed to an object or array after reading the first
reference token.
- All subsequent tokens work on arrays or objects and will
not change the type of j.
Consequently, the type of @a j will always be null,
object, or array. Hence, the following line is
unreachable.
*/ */
default: default:
{ {
break; // LCOV_EXCL_LINE throw std::domain_error("invalid value to unflatten");
} }
} }
} }
@ -9462,8 +9452,6 @@ basic_json_parser_63:
@complexity Linear in the size the JSON value. @complexity Linear in the size the JSON value.
@throws std::domain_error
@liveexample{The following code shows how a flattened JSON object is @liveexample{The following code shows how a flattened JSON object is
unflattened into the original nested JSON object.,unflatten} unflattened into the original nested JSON object.,unflatten}

View file

@ -8296,25 +8296,15 @@ class basic_json
} }
/* /*
This function is only to be called from the unflatten() The following code is only reached if there exists a
function. There, j is initially of type null. reference token _and_ the current value is primitive. In
this case, we have an error situation, because primitive
- In case the reference tokens are empty, a reference to values may only occur as single value; that is, with an
j is returned and overwritten by the desired value by empty list of reference tokens.
the unflatten() function.
- If there are reference tokens, the null value of j will
be changed to an object or array after reading the first
reference token.
- All subsequent tokens work on arrays or objects and will
not change the type of j.
Consequently, the type of @a j will always be null,
object, or array. Hence, the following line is
unreachable.
*/ */
default: default:
{ {
break; // LCOV_EXCL_LINE throw std::domain_error("invalid value to unflatten");
} }
} }
} }
@ -8772,8 +8762,6 @@ class basic_json
@complexity Linear in the size the JSON value. @complexity Linear in the size the JSON value.
@throws std::domain_error
@liveexample{The following code shows how a flattened JSON object is @liveexample{The following code shows how a flattened JSON object is
unflattened into the original nested JSON object.,unflatten} unflattened into the original nested JSON object.,unflatten}

View file

@ -12368,7 +12368,7 @@ TEST_CASE("JSON pointers")
// error for conflicting values // error for conflicting values
json j_error = {{"", 42}, {"/foo", 17}}; json j_error = {{"", 42}, {"/foo", 17}};
CHECK_THROWS_AS(j_error.unflatten(), std::domain_error); CHECK_THROWS_AS(j_error.unflatten(), std::domain_error);
CHECK_THROWS_WITH(j_error.unflatten(), "unresolved reference token 'foo'"); CHECK_THROWS_WITH(j_error.unflatten(), "invalid value to unflatten");
// explicit roundtrip check // explicit roundtrip check
CHECK(j.flatten().unflatten() == j); CHECK(j.flatten().unflatten() == j);