From 33edc9751cedbd5e4bbd45c3279309d4e1ec6465 Mon Sep 17 00:00:00 2001 From: Paul Dreik Date: Mon, 6 Jul 2026 08:25:30 +0200 Subject: [PATCH] fix unit-algorithms test reliance on implementation specific behaviour (#5236) the standard only specifies that the first elements are sorted. this caused my experimental C++ standard library implementation to fail. Signed-off-by: Paul Dreik --- tests/src/unit-algorithms.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/src/unit-algorithms.cpp b/tests/src/unit-algorithms.cpp index 0aac52f0b..a5d99eea0 100644 --- a/tests/src/unit-algorithms.cpp +++ b/tests/src/unit-algorithms.cpp @@ -229,7 +229,10 @@ TEST_CASE("algorithms") { json j = {13, 29, 3, {{"one", 1}, {"two", 2}}, true, false, {1, 2, 3}, "foo", "baz", nullptr}; std::partial_sort(j.begin(), j.begin() + 4, j.end()); - CHECK(j == json({nullptr, false, true, 3, {{"one", 1}, {"two", 2}}, 29, {1, 2, 3}, "foo", "baz", 13})); + // only the first four elements are expected to be sorted, the rest are + // unspecified by the standard + const json expected({nullptr, false, true, 3}); + CHECK(std::equal(j.begin(), j.begin() + 4, begin(expected))); } }