Add unit tests
This commit is contained in:
parent
5fe8b92951
commit
504acef0b8
@ -15,6 +15,7 @@ using nlohmann::json;
|
|||||||
using namespace nlohmann::literals; // NOLINT(google-build-using-namespace)
|
using namespace nlohmann::literals; // NOLINT(google-build-using-namespace)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <map>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
TEST_CASE("JSON pointers")
|
TEST_CASE("JSON pointers")
|
||||||
@ -697,6 +698,32 @@ TEST_CASE("JSON pointers")
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("less-than comparison")
|
||||||
|
{
|
||||||
|
auto ptr1 = json::json_pointer("/foo/a");
|
||||||
|
auto ptr2 = json::json_pointer("/foo/b");
|
||||||
|
|
||||||
|
CHECK(ptr1 < ptr2);
|
||||||
|
CHECK_FALSE(ptr2 < ptr1);
|
||||||
|
|
||||||
|
// build with C++20
|
||||||
|
// JSON_HAS_CPP_20
|
||||||
|
#if JSON_HAS_THREE_WAY_COMPARISON
|
||||||
|
CHECK((ptr1 <=> ptr2) == std::strong_ordering::less); // *NOPAD*
|
||||||
|
CHECK(ptr2 > ptr1);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("usable as map key")
|
||||||
|
{
|
||||||
|
auto ptr = json::json_pointer("/foo");
|
||||||
|
std::map<json::json_pointer, int> m;
|
||||||
|
|
||||||
|
m[ptr] = 42;
|
||||||
|
|
||||||
|
CHECK(m.find(ptr) != m.end());
|
||||||
|
}
|
||||||
|
|
||||||
SECTION("backwards compatibility and mixing")
|
SECTION("backwards compatibility and mixing")
|
||||||
{
|
{
|
||||||
json j = R"(
|
json j = R"(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user