✅ improved test coverage
This commit is contained in:
parent
e191dd833f
commit
7c2a187258
2 changed files with 16 additions and 0 deletions
|
@ -31,6 +31,14 @@ SOFTWARE.
|
||||||
#include "json.hpp"
|
#include "json.hpp"
|
||||||
using nlohmann::json;
|
using nlohmann::json;
|
||||||
|
|
||||||
|
// helper function to check std::less<json::value_t>
|
||||||
|
// see http://en.cppreference.com/w/cpp/utility/functional/less
|
||||||
|
template <typename A, typename B, typename U = std::less<json::value_t>>
|
||||||
|
bool f(A a, B b, U u = U())
|
||||||
|
{
|
||||||
|
return u(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE("lexicographical comparison operators")
|
TEST_CASE("lexicographical comparison operators")
|
||||||
{
|
{
|
||||||
SECTION("types")
|
SECTION("types")
|
||||||
|
@ -69,6 +77,7 @@ TEST_CASE("lexicographical comparison operators")
|
||||||
CAPTURE(j);
|
CAPTURE(j);
|
||||||
// check precomputed values
|
// check precomputed values
|
||||||
CHECK(operator<(j_types[i], j_types[j]) == expected[i][j]);
|
CHECK(operator<(j_types[i], j_types[j]) == expected[i][j]);
|
||||||
|
CHECK(f(j_types[i], j_types[j]) == expected[i][j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -359,6 +359,13 @@ TEST_CASE("deserialization")
|
||||||
CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error);
|
CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error);
|
||||||
CHECK(not json::accept(std::begin(v), std::end(v)));
|
CHECK(not json::accept(std::begin(v), std::end(v)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("case 16")
|
||||||
|
{
|
||||||
|
uint8_t v[] = {'{', '1', ',', ','};
|
||||||
|
CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error);
|
||||||
|
CHECK(not json::accept(std::begin(v), std::end(v)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue