Skip to content

Commit

Permalink
Fix for building tests with GCC 4.8
Browse files Browse the repository at this point in the history
  • Loading branch information
henryiii committed Sep 26, 2018
1 parent 7807ae2 commit 79c58ea
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ json j_from_ubjson = json::from_ubjson(v_ubjson);

Though it's 2018 already, the support for C++11 is still a bit sparse. Currently, the following compilers are known to work:

- GCC 4.9 - 8.2 (and possibly later)
- GCC 4.8 - 8.2 (and possibly later)
- Clang 3.4 - 6.1 (and possibly later)
- Intel C++ Compiler 17.0.2 (and possibly later)
- Microsoft Visual C++ 2015 / Build Tools 14.0.25123.0 (and possibly later)
Expand All @@ -853,7 +853,7 @@ I would be happy to learn about other compilers/versions.

Please note:

- GCC 4.8 has a bug [57824](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57824)): raw strings cannot be the arguments to macros. Don't use raw strings directly in macros with this compiler.
- GCC 4.8 has a bug [57824](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57824)): multiline raw strings cannot be the arguments to macros. Don't use multiline raw strings directly in macros with this compiler.
- Android defaults to using very old compilers and C++ libraries. To fix this, add the following to your `Application.mk`. This will switch to the LLVM C++ library, the Clang compiler, and enable C++11 and other features disabled by default.

```
Expand Down
28 changes: 17 additions & 11 deletions test/src/unit-regression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1427,20 +1427,26 @@ TEST_CASE("regression tests")
}
})"_json;

CHECK_THROWS_AS(model.patch(R"([{"op": "move",
"from": "/one/two/three",
"path": "/a/b/c"}])"_json), json::out_of_range&);
CHECK_THROWS_WITH(model.patch(R"([{"op": "move",
"from": "/one/two/three",
"path": "/a/b/c"}])"_json),
auto p1 = R"([{"op": "move",
"from": "/one/two/three",
"path": "/a/b/c"}])"_json;
CHECK_THROWS_AS(model.patch(p1), json::out_of_range&);

auto p2 = R"([{"op": "move",
"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");

CHECK_THROWS_AS(model.patch(R"([{"op": "copy",
"from": "/one/two/three",
"path": "/a/b/c"}])"_json), json::out_of_range&);
CHECK_THROWS_WITH(model.patch(R"([{"op": "copy",
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),
"path": "/a/b/c"}])"_json;
CHECK_THROWS_WITH(model.patch(p4),
"[json.exception.out_of_range.403] key 'a' not found");
}

Expand Down
11 changes: 7 additions & 4 deletions test/src/unit-testsuites.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ TEST_CASE("RFC 7159 examples")
SECTION("13 Examples")
{
{
CHECK_NOTHROW(json(R"(
auto json_contents = R"(
{
"Image": {
"Width": 800,
Expand All @@ -420,11 +420,13 @@ TEST_CASE("RFC 7159 examples")
"IDs": [116, 943, 234, 38793]
}
}
)"));
)";

CHECK_NOTHROW(json(json_contents));
}

{
CHECK_NOTHROW(json(R"(
auto json_contents = R"(
[
{
"precision": "zip",
Expand All @@ -446,7 +448,8 @@ TEST_CASE("RFC 7159 examples")
"Zip": "94085",
"Country": "US"
}
])"));
])";
CHECK_NOTHROW(json(json_contents));
}

CHECK(json::parse("\"Hello world!\"") == json("Hello world!"));
Expand Down

0 comments on commit 79c58ea

Please sign in to comment.