Skip to content

Commit

Permalink
Make section names unique in loops, as catch doesn't support duplicate
Browse files Browse the repository at this point in the history
sections, see also catchorg/Catch2#816 (comment)

As a result, when built with gcc, loop iterations were skipped. When
built with clang, the test aborted with an assertion in catch.hpp
line 6222.

This also addresses the issues discussed here:
nlohmann#1032 (comment)

and here:
catchorg/Catch2#1241

Please note that this introduces new problems, as some of
the unit tests fail now - the library stores keys in
lexographical order, while the cbor/msgpack/ubjson examples
store them in original order.
  • Loading branch information
Michael Gmelin committed Jul 29, 2018
1 parent 3760a38 commit d5aaeb4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
10 changes: 5 additions & 5 deletions test/src/unit-cbor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1815,7 +1815,7 @@ TEST_CASE("CBOR roundtrips", "[hide]")
std::ifstream f_json(filename);
json j1 = json::parse(f_json);

SECTION("std::vector<uint8_t>")
SECTION(filename + ": std::vector<uint8_t>")
{
// parse CBOR file
std::ifstream f_cbor(filename + ".cbor", std::ios::binary);
Expand All @@ -1829,7 +1829,7 @@ TEST_CASE("CBOR roundtrips", "[hide]")
CHECK(j1 == j2);
}

SECTION("std::ifstream")
SECTION(filename + ": std::ifstream")
{
// parse CBOR file
std::ifstream f_cbor(filename + ".cbor", std::ios::binary);
Expand All @@ -1840,7 +1840,7 @@ TEST_CASE("CBOR roundtrips", "[hide]")
CHECK(j1 == j2);
}

SECTION("uint8_t* and size")
SECTION(filename + ": uint8_t* and size")
{
// parse CBOR file
std::ifstream f_cbor(filename + ".cbor", std::ios::binary);
Expand All @@ -1854,15 +1854,15 @@ TEST_CASE("CBOR roundtrips", "[hide]")
CHECK(j1 == j2);
}

SECTION("output to output adapters")
SECTION(filename + ": output to output adapters")
{
// parse CBOR file
std::ifstream f_cbor(filename + ".cbor", std::ios::binary);
std::vector<uint8_t> packed(
(std::istreambuf_iterator<char>(f_cbor)),
std::istreambuf_iterator<char>());

SECTION("std::vector<uint8_t>")
SECTION(filename + ": output adapters: std::vector<uint8_t>")
{
std::vector<uint8_t> vec;
json::to_cbor(j1, vec);
Expand Down
10 changes: 5 additions & 5 deletions test/src/unit-msgpack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1504,7 +1504,7 @@ TEST_CASE("MessagePack roundtrips", "[hide]")
std::ifstream f_json(filename);
json j1 = json::parse(f_json);

SECTION("std::vector<uint8_t>")
SECTION(filename + ": std::vector<uint8_t>")
{
// parse MessagePack file
std::ifstream f_msgpack(filename + ".msgpack", std::ios::binary);
Expand All @@ -1518,7 +1518,7 @@ TEST_CASE("MessagePack roundtrips", "[hide]")
CHECK(j1 == j2);
}

SECTION("std::ifstream")
SECTION(filename + ": std::ifstream")
{
// parse MessagePack file
std::ifstream f_msgpack(filename + ".msgpack", std::ios::binary);
Expand All @@ -1529,7 +1529,7 @@ TEST_CASE("MessagePack roundtrips", "[hide]")
CHECK(j1 == j2);
}

SECTION("uint8_t* and size")
SECTION(filename + ": uint8_t* and size")
{
// parse MessagePack file
std::ifstream f_msgpack(filename + ".msgpack", std::ios::binary);
Expand All @@ -1543,15 +1543,15 @@ TEST_CASE("MessagePack roundtrips", "[hide]")
CHECK(j1 == j2);
}

SECTION("output to output adapters")
SECTION(filename + ": output to output adapters")
{
// parse MessagePack file
std::ifstream f_msgpack(filename + ".msgpack", std::ios::binary);
std::vector<uint8_t> packed(
(std::istreambuf_iterator<char>(f_msgpack)),
std::istreambuf_iterator<char>());

SECTION("std::vector<uint8_t>")
SECTION(filename + ": output adapters: std::vector<uint8_t>")
{
std::vector<uint8_t> vec;
json::to_msgpack(j1, vec);
Expand Down
10 changes: 5 additions & 5 deletions test/src/unit-ubjson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2203,7 +2203,7 @@ TEST_CASE("UBJSON roundtrips", "[hide]")
std::ifstream f_json(filename);
json j1 = json::parse(f_json);

SECTION("std::vector<uint8_t>")
SECTION(filename + ": std::vector<uint8_t>")
{
// parse MessagePack file
std::ifstream f_ubjson(filename + ".ubjson", std::ios::binary);
Expand All @@ -2217,7 +2217,7 @@ TEST_CASE("UBJSON roundtrips", "[hide]")
CHECK(j1 == j2);
}

SECTION("std::ifstream")
SECTION(filename + ": std::ifstream")
{
// parse MessagePack file
std::ifstream f_ubjson(filename + ".ubjson", std::ios::binary);
Expand All @@ -2228,7 +2228,7 @@ TEST_CASE("UBJSON roundtrips", "[hide]")
CHECK(j1 == j2);
}

SECTION("uint8_t* and size")
SECTION(filename + ": uint8_t* and size")
{
// parse MessagePack file
std::ifstream f_ubjson(filename + ".ubjson", std::ios::binary);
Expand All @@ -2242,15 +2242,15 @@ TEST_CASE("UBJSON roundtrips", "[hide]")
CHECK(j1 == j2);
}

SECTION("output to output adapters")
SECTION(filename + ": output to output adapters")
{
// parse MessagePack file
std::ifstream f_ubjson(filename + ".ubjson", std::ios::binary);
std::vector<uint8_t> packed(
(std::istreambuf_iterator<char>(f_ubjson)),
std::istreambuf_iterator<char>());

SECTION("std::vector<uint8_t>")
SECTION(filename + ": output adapters: std::vector<uint8_t>")
{
std::vector<uint8_t> vec;
json::to_ubjson(j1, vec);
Expand Down

0 comments on commit d5aaeb4

Please sign in to comment.