💩 first try on #1045

This commit is contained in:
Niels Lohmann 2018-04-10 08:29:07 +02:00
parent acf10d9af7
commit 8d8f890771
No known key found for this signature in database
GPG key ID: 7F3CEA63AE251B69
3 changed files with 55 additions and 0 deletions

View file

@ -1615,4 +1615,25 @@ TEST_CASE("regression tests")
float_json j2 = {1000.0, 2000.0, 3000.0};
CHECK(float_json::from_ubjson(float_json::to_ubjson(j2, true, true)) == j2);
}
SECTION("issue #1045 - Using STL algorithms with JSON containers with expected results?")
{
json diffs = nlohmann::json::array();
json m1{{"key1", 42}};
json m2{{"key2", 42}};
auto p1 = m1.items();
auto p2 = m2.items();
using it_type = decltype(p1.begin());
std::set_difference(
p1.begin(), p1.end(),
p2.begin(), p2.end(),
std::inserter(diffs, diffs.end()), [&](const it_type & e1, const it_type & e2) -> bool
{
return (e1.key() < e2.key()) and (e1.value() < e2.value());
});
CHECK(diffs.size() == 2);
}
}