Refactor unit tests to use more convenient doctest assertion macros (Part 2) (#3405)

* Refactor assertion and adjust expected error message

* Refactor assertion and adjust expected error message

* Refactor assertion and remove redundant local variable

* Refactor assertion and remove redundant local variable

* Rename local variable

* Apply formatting
pull/3418/head
Krzysiek Karbowiak 2022-04-01 14:38:17 +02:00 committed by GitHub
parent 66f6b4b6a0
commit 3b16057ffa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 21 deletions

View File

@ -770,9 +770,8 @@ TEST_CASE("regression tests 1")
std::stringstream ss;
ss << " ";
json j;
CHECK_THROWS_AS(ss >> j, json::parse_error&);
CHECK_THROWS_WITH(ss >> j,
"[json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal");
CHECK_THROWS_WITH_AS(ss >> j,
"[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal", json::parse_error&);
}
SECTION("one value")
@ -794,9 +793,8 @@ TEST_CASE("regression tests 1")
CHECK_NOTHROW(ss >> j);
CHECK(j == 222);
CHECK_THROWS_AS(ss >> j, json::parse_error&);
CHECK_THROWS_WITH(ss >> j,
"[json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal");
CHECK_THROWS_WITH_AS(ss >> j,
"[json.exception.parse_error.101] parse error at line 2, column 1: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal", json::parse_error&);
}
SECTION("whitespace + one value")
@ -1413,24 +1411,14 @@ TEST_CASE("regression tests 1")
auto p1 = R"([{"op": "move",
"from": "/one/two/three",
"path": "/a/b/c"}])"_json;
CHECK_THROWS_AS(model.patch(p1), json::out_of_range&);
CHECK_THROWS_WITH_AS(model.patch(p1),
"[json.exception.out_of_range.403] key 'a' not found", json::out_of_range&);
auto p2 = R"([{"op": "move",
auto p2 = R"([{"op": "copy",
"from": "/one/two/three",
"path": "/a/b/c"}])"_json;
CHECK_THROWS_WITH(model.patch(p2),
"[json.exception.out_of_range.403] key 'a' not found");
auto p3 = R"([{"op": "copy",
"from": "/one/two/three",
"path": "/a/b/c"}])"_json;
CHECK_THROWS_AS(model.patch(p3), json::out_of_range&);
auto p4 = R"([{"op": "copy",
"from": "/one/two/three",
"path": "/a/b/c"}])"_json;
CHECK_THROWS_WITH(model.patch(p4),
"[json.exception.out_of_range.403] key 'a' not found");
CHECK_THROWS_WITH_AS(model.patch(p2),
"[json.exception.out_of_range.403] key 'a' not found", json::out_of_range&);
}
SECTION("issue #961 - incorrect parsing of indefinite length CBOR strings")