From: Jonathan Wakely Date: Thu, 29 Oct 2020 14:47:18 +0000 (+0000) Subject: libstdc++: Improve tests for constexpr algorithms X-Git-Tag: basepoints/gcc-12~3721 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8c84486bba104399b7e544cb1ba343646d39ea0a;p=thirdparty%2Fgcc.git libstdc++: Improve tests for constexpr algorithms These tests just return true without checking that the results of the algorithms. Although it should be safe to assume that the algorithms behave the same at compile-time as at run-time, we can use these tests to verify it. This replaces each 'return true' statement with a condition that depends on the basic functionality of the algorithm, such as returning an iterator to the right position. libstdc++-v3/ChangeLog: * testsuite/25_algorithms/all_of/constexpr.cc: Check result of the algorithm. * testsuite/25_algorithms/any_of/constexpr.cc: Likewise. * testsuite/25_algorithms/binary_search/constexpr.cc: Likewise. * testsuite/25_algorithms/copy_backward/constexpr.cc: Likewise. * testsuite/25_algorithms/count/constexpr.cc: Likewise. * testsuite/25_algorithms/equal/constexpr.cc: Likewise. * testsuite/25_algorithms/equal_range/constexpr.cc: Likewise. * testsuite/25_algorithms/fill/constexpr.cc: Likewise. * testsuite/25_algorithms/find_end/constexpr.cc: Likewise. * testsuite/25_algorithms/find_if/constexpr.cc: Likewise. * testsuite/25_algorithms/is_partitioned/constexpr.cc: Likewise. * testsuite/25_algorithms/is_permutation/constexpr.cc: Likewise. * testsuite/25_algorithms/is_sorted_until/constexpr.cc: Likewise. * testsuite/25_algorithms/lexicographical_compare/constexpr.cc: Likewise. * testsuite/25_algorithms/lower_bound/constexpr.cc: Likewise. * testsuite/25_algorithms/merge/constexpr.cc: Likewise. * testsuite/25_algorithms/mismatch/constexpr.cc: Likewise. * testsuite/25_algorithms/none_of/constexpr.cc: Likewise. * testsuite/25_algorithms/partition_copy/constexpr.cc: Likewise. * testsuite/25_algorithms/remove_copy/constexpr.cc: Likewise. * testsuite/25_algorithms/remove_copy_if/constexpr.cc: Likewise. * testsuite/25_algorithms/remove_if/constexpr.cc: Likewise. * testsuite/25_algorithms/replace_if/constexpr.cc: Likewise. * testsuite/25_algorithms/reverse/constexpr.cc: Likewise. * testsuite/25_algorithms/reverse_copy/constexpr.cc: Likewise. * testsuite/25_algorithms/rotate_copy/constexpr.cc: Likewise. * testsuite/25_algorithms/search/constexpr.cc: Likewise. * testsuite/25_algorithms/set_difference/constexpr.cc: Likewise. * testsuite/25_algorithms/set_intersection/constexpr.cc: Likewise. * testsuite/25_algorithms/set_symmetric_difference/constexpr.cc: Likewise. * testsuite/25_algorithms/set_union/constexpr.cc: Likewise. * testsuite/25_algorithms/unique_copy/constexpr.cc: Likewise. * testsuite/25_algorithms/upper_bound/constexpr.cc: Likewise. --- diff --git a/libstdc++-v3/testsuite/25_algorithms/all_of/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/all_of/constexpr.cc index 11f1a337c202..757eebc89b63 100644 --- a/libstdc++-v3/testsuite/25_algorithms/all_of/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/all_of/constexpr.cc @@ -23,13 +23,12 @@ constexpr std::array cae{{0, 2, 4, 6, 8, 10}}; -constexpr auto out2 = std::all_of(cae.begin(), cae.end(), +constexpr auto out1 = std::all_of(cae.begin(), cae.end(), [](int i){ return i % 2 == 0; }); -constexpr bool -test() -{ - return true; -} +static_assert(out1); + +constexpr auto out2 = std::all_of(cae.begin(), cae.end(), + [](int i){ return i != 8; }); -static_assert(test()); +static_assert(!out2); diff --git a/libstdc++-v3/testsuite/25_algorithms/any_of/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/any_of/constexpr.cc index 370f7f3614a7..dadd45061791 100644 --- a/libstdc++-v3/testsuite/25_algorithms/any_of/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/any_of/constexpr.cc @@ -29,7 +29,10 @@ test() const auto out3 = std::any_of(ca0.begin(), ca0.end(), [](int i){ return i % 2 == 0; }); - return true; + const auto out4 = std::any_of(ca0.begin(), ca0.end(), + [](int i){ return i == -1; }); + + return out3 && !out4; } static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/binary_search/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/binary_search/constexpr.cc index 0e355cc9ba7c..f82a6893b48f 100644 --- a/libstdc++-v3/testsuite/25_algorithms/binary_search/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/binary_search/constexpr.cc @@ -31,7 +31,10 @@ test() const auto out5 = std::binary_search(ca0.begin(), ca0.end(), 5, std::less()); - return true; + const auto out6 = std::binary_search(ca0.begin(), ca0.end(), 4.5, + std::less<>()); + + return out4 && out5 && !out6; } static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/copy_backward/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/copy_backward/constexpr.cc index 704dcf513c04..e97e30e07771 100644 --- a/libstdc++-v3/testsuite/25_algorithms/copy_backward/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/copy_backward/constexpr.cc @@ -30,7 +30,7 @@ test() const auto out7 = std::copy_backward(ca0.begin(), ca0.begin() + 8, ma0.begin() + 10); - return true; + return out7 == ma0.begin() + 2 && ma0[3] == 1; } static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/count/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/count/constexpr.cc index 6b6a2801207b..3b900a9ca07c 100644 --- a/libstdc++-v3/testsuite/25_algorithms/count/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/count/constexpr.cc @@ -28,7 +28,9 @@ test() const auto out8 = std::count(ca0.begin(), ca0.end(), 6); - return true; + const auto out9 = std::count(ca0.begin(), ca0.end(), 16); + + return out8 == 1 && out9 == 0; } static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/equal/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/equal/constexpr.cc index a3ebee5db908..ca1b7bc5bd96 100644 --- a/libstdc++-v3/testsuite/25_algorithms/equal/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/equal/constexpr.cc @@ -33,7 +33,12 @@ test() const auto outb = std::equal(ca0.begin(), ca0.end(), cas.begin(), [](int i, int j){ return i + 3 == j; }); - return true; + auto ca2 = ca0; + ca2[5] = -1; + + const auto outc = std::equal(ca0.begin(), ca0.end(), ca2.begin()); + + return outa && outb && !outc; } static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/equal_range/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/equal_range/constexpr.cc index 0bd1b0de48c9..2b46f5f67595 100644 --- a/libstdc++-v3/testsuite/25_algorithms/equal_range/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/equal_range/constexpr.cc @@ -28,7 +28,8 @@ test() const auto outc = std::equal_range(car.begin(), car.end(), 6); - return true; + return outc.first == (car.begin() + 6) + && outc.second == (car.begin() + 8); } static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/fill/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/fill/constexpr.cc index ec69a7f432a9..154e48b38491 100644 --- a/libstdc++-v3/testsuite/25_algorithms/fill/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/fill/constexpr.cc @@ -27,7 +27,7 @@ test() std::array ma0{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; std::fill(ma0.begin(), ma0.end(), 66); - return true; + return ma0[4] == 66 && ma0[7] == 66; } static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/find_end/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/find_end/constexpr.cc index c5ba3974cfde..9339ab06ae60 100644 --- a/libstdc++-v3/testsuite/25_algorithms/find_end/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/find_end/constexpr.cc @@ -24,7 +24,7 @@ constexpr bool test() { - constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; constexpr std::array cam{{4, 5, 6}}; constexpr std::array camm{{-4, -5, -6}}; @@ -35,7 +35,7 @@ test() camm.begin(), camm.end(), [](int i, int j){ return i + 1 == -j; }); - return true; + return outf == (ca0.begin() + 4) && outg == (ca0.begin() + 3); } static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/find_if/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/find_if/constexpr.cc index b4064e6f6907..6c88c49c75e4 100644 --- a/libstdc++-v3/testsuite/25_algorithms/find_if/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/find_if/constexpr.cc @@ -24,12 +24,12 @@ constexpr bool test() { - constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; const auto outj = std::find_if(ca0.begin(), ca0.end(), [](int i){ return i == 6; }); - return true; + return outj == (ca0.begin() + 6); } static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/is_partitioned/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/is_partitioned/constexpr.cc index deab94d019dc..163f9bd2d1d9 100644 --- a/libstdc++-v3/testsuite/25_algorithms/is_partitioned/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/is_partitioned/constexpr.cc @@ -29,7 +29,7 @@ test() const auto outs = std::is_partitioned(caeo.begin(), caeo.end(), [](int i){ return i % 2 == 0; }); - return true; + return outs; } static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/is_permutation/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/is_permutation/constexpr.cc index 1da8bbee30e3..1567c2658ff9 100644 --- a/libstdc++-v3/testsuite/25_algorithms/is_permutation/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/is_permutation/constexpr.cc @@ -29,7 +29,9 @@ test() const auto outt = std::is_permutation(ca0.begin(), ca0.end(), cap.begin()); - return true; + const auto outf = std::is_permutation(ca0.begin() + 1, ca0.end(), cap.begin()); + + return outt && !outf; } static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/is_sorted_until/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/is_sorted_until/constexpr.cc index d000e555ae79..3c540559c31a 100644 --- a/libstdc++-v3/testsuite/25_algorithms/is_sorted_until/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/is_sorted_until/constexpr.cc @@ -31,7 +31,10 @@ test() const auto outy = std::is_sorted_until(aus.begin(), aus.end(), std::less()); - return true; + const auto outz = std::is_sorted_until(outx - 1, aus.end(), + std::greater()); + + return outx == aus.begin() + 7 && outy == outx && outz == (outx + 1); } static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/constexpr.cc index 7046f4489d63..1d7502c27c6c 100644 --- a/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/constexpr.cc @@ -34,7 +34,7 @@ test() ca1.begin(), ca1.end(), std::less()); - return true; + return outz && outaa; } static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/lower_bound/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/lower_bound/constexpr.cc index 1b570a2ce546..ec5da9b32277 100644 --- a/libstdc++-v3/testsuite/25_algorithms/lower_bound/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/lower_bound/constexpr.cc @@ -31,7 +31,7 @@ test() const auto outcc = std::lower_bound(ca0.begin(), ca0.end(), 6, std::less()); - return true; + return outbb == (ca0.begin() + 6) && outcc == outbb; } static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/merge/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/merge/constexpr.cc index d46b5787b7c4..02493581635f 100644 --- a/libstdc++-v3/testsuite/25_algorithms/merge/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/merge/constexpr.cc @@ -31,12 +31,14 @@ test() const auto outdd = std::merge(ca0.begin(), ca0.end(), cas.begin(), cas.end(), out0.begin()); + if (outdd != out0.end()) + return false; const auto outee = std::merge(ca0.begin(), ca0.end(), camm.begin(), camm.end(), out0.begin(), [](int i, int j){ return i < j; }); - return true; + return outee == (out0.begin() + ca0.size() + camm.size()); } static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/mismatch/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/mismatch/constexpr.cc index 868bb41e1cb7..f2cc21d03d8d 100644 --- a/libstdc++-v3/testsuite/25_algorithms/mismatch/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/mismatch/constexpr.cc @@ -32,7 +32,8 @@ test() const auto outgg = std::mismatch(ca0.begin(), ca0.end(), cax.begin(), std::equal_to()); - return true; + return outff.first == (ca0.begin() + 6) && outff.second == (cax.begin() + 6) + && outgg == outff; } static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/none_of/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/none_of/constexpr.cc index cea4fc61f906..245ebe47dcb3 100644 --- a/libstdc++-v3/testsuite/25_algorithms/none_of/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/none_of/constexpr.cc @@ -29,7 +29,7 @@ test() const auto outhh = std::none_of(ca0.begin(), ca0.end(), [](int i){ return i > 12; }); - return true; + return outhh; } static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/partition_copy/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/partition_copy/constexpr.cc index e7cb3087b2cd..21685636ecdd 100644 --- a/libstdc++-v3/testsuite/25_algorithms/partition_copy/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/partition_copy/constexpr.cc @@ -32,7 +32,8 @@ test() out0.begin(), out1.begin(), [](int i){ return i % 2 == 0; }); - return true; + return outii.first == (out0.begin() + 6) && out0[1] == 2 + && outii.second == (out1.begin() + 6) && out1[1] == 3; } static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/remove_copy/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/remove_copy/constexpr.cc index 0474feccb097..e82a506abb0d 100644 --- a/libstdc++-v3/testsuite/25_algorithms/remove_copy/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/remove_copy/constexpr.cc @@ -24,12 +24,12 @@ constexpr bool test() { - constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; std::array out0{{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; const auto outmm = std::remove_copy(ca0.begin(), ca0.end(), out0.begin(), 6); - return true; + return outmm == out0.begin() + ca0.size() - 1; } static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/remove_copy_if/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/remove_copy_if/constexpr.cc index 813be78c1336..f8133fc24f5b 100644 --- a/libstdc++-v3/testsuite/25_algorithms/remove_copy_if/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/remove_copy_if/constexpr.cc @@ -30,7 +30,7 @@ test() const auto outnn = std::remove_copy_if(ca0.begin(), ca0.end(), out0.begin(), [](int i){ return i == 7; }); - return true; + return outnn == out0.begin() + ca0.size() - 1; } static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/remove_if/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/remove_if/constexpr.cc index c2d98f2a68ea..d590d4d5ea15 100644 --- a/libstdc++-v3/testsuite/25_algorithms/remove_if/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/remove_if/constexpr.cc @@ -29,7 +29,7 @@ test() const auto outll = std::remove_if(ac2.begin(), ac2.end(), [](int i){ return i == 7; }); - return true; + return outll == (ac2.end() - 1) && ac2[7] == 8; } static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/replace_if/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/replace_if/constexpr.cc index 6bcc0bd72ae0..4b293f48aa93 100644 --- a/libstdc++-v3/testsuite/25_algorithms/replace_if/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/replace_if/constexpr.cc @@ -28,7 +28,9 @@ test() std::replace_if(ar0.begin(), ar0.end(), [](int i){ return i % 2 == 1; }, 42); - return true; + std::array ar1{{0, 42, 2, 42, 4, 42, 6, 6, 8, 42, 42, 42}}; + + return ar0 == ar1; } static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/reverse/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/reverse/constexpr.cc index ba1f47b6127a..15140014a093 100644 --- a/libstdc++-v3/testsuite/25_algorithms/reverse/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/reverse/constexpr.cc @@ -23,8 +23,6 @@ constexpr bool test() { - auto ok = true; - std::array ar0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; std::reverse(ar0.begin() + 2, ar0.begin() + 9); diff --git a/libstdc++-v3/testsuite/25_algorithms/reverse_copy/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/reverse_copy/constexpr.cc index 86214e1d30ea..9a85e591edd8 100644 --- a/libstdc++-v3/testsuite/25_algorithms/reverse_copy/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/reverse_copy/constexpr.cc @@ -29,7 +29,7 @@ test() const auto outqq = std::reverse_copy(ca0.rbegin(), ca0.rend(), out0.begin()); - return true; + return outqq == (out0.begin() + ca0.size()) && out0[3] == 3; } static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/rotate_copy/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/rotate_copy/constexpr.cc index f8377b8a24c4..8d9d966ba030 100644 --- a/libstdc++-v3/testsuite/25_algorithms/rotate_copy/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/rotate_copy/constexpr.cc @@ -30,7 +30,7 @@ test() const auto outrr = std::rotate_copy(ca0.begin(), ca0.begin() + 6, ca0.end(), out0.begin()); - return true; + return outrr == (out0.begin() + ca0.size()) && out0[3] == 9 && out0[8] == 2; } static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/search/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/search/constexpr.cc index e34194cfc5db..557234ec8197 100644 --- a/libstdc++-v3/testsuite/25_algorithms/search/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/search/constexpr.cc @@ -24,7 +24,7 @@ constexpr bool test() { - constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; + constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; constexpr std::array cam{{4, 5, 6}}; const auto outtt = std::search(ca0.begin(), ca0.end(), @@ -35,7 +35,7 @@ test() = std::search(ca0.begin(), ca0.end(), std::default_searcher(cam.begin(), cam.end())); - return true; + return outtt == (ca0.begin() + 4) && outtt2 == outtt; } static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/set_difference/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/set_difference/constexpr.cc index ef0f7184604f..f66c957df80b 100644 --- a/libstdc++-v3/testsuite/25_algorithms/set_difference/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/set_difference/constexpr.cc @@ -29,13 +29,16 @@ test() std::array out0{{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; const auto outvv = std::set_difference(ca0.begin(), ca0.end(), - cas.begin(), cas.end(), out0.begin()); + cas.begin(), cas.end(), + out0.begin()); const auto outww = std::set_difference(ca0.begin(), ca0.end(), cas.begin(), cas.end(), - out0.begin(), std::less()); + outvv, + std::less()); - return true; + + return outvv == (out0.begin() + 3) && outww == (outvv + 3); } static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/set_intersection/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/set_intersection/constexpr.cc index b415020943a5..720e8a5a6c06 100644 --- a/libstdc++-v3/testsuite/25_algorithms/set_intersection/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/set_intersection/constexpr.cc @@ -36,7 +36,7 @@ test() cas.begin(), cas.end(), out0.begin(), std::less()); - return true; + return outxx == (out0.begin() + 9) && outyy == outxx; } static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/constexpr.cc index ef0f7184604f..0505aaf25198 100644 --- a/libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/constexpr.cc @@ -25,17 +25,19 @@ constexpr bool test() { constexpr std::array ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}}; - constexpr std::array cas{{3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}}; + constexpr std::array cas{{4, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13}}; std::array out0{{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; - const auto outvv = std::set_difference(ca0.begin(), ca0.end(), - cas.begin(), cas.end(), out0.begin()); + const auto outvv = std::set_symmetric_difference(ca0.begin(), ca0.end(), + cas.begin(), cas.end(), + out0.begin()); - const auto outww = std::set_difference(ca0.begin(), ca0.end(), - cas.begin(), cas.end(), - out0.begin(), std::less()); + const auto outww = std::set_symmetric_difference(ca0.begin(), ca0.end(), + cas.begin(), cas.end(), + out0.begin(), + std::less()); - return true; + return outvv == (out0.begin() + 8) && outww == outvv; } static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/set_union/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/set_union/constexpr.cc index fccfe2099d7f..87f3f27f9e10 100644 --- a/libstdc++-v3/testsuite/25_algorithms/set_union/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/set_union/constexpr.cc @@ -29,13 +29,14 @@ test() std::array out0{{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; const auto out11 = std::set_union(ca0.begin(), ca0.end(), - cas.begin(), cas.end(), out0.begin()); + cas.begin(), cas.end(), + out0.begin()); const auto out22 = std::set_union(ca0.begin(), ca0.end(), cas.begin(), cas.end(), out0.begin(), std::less()); - return true; + return out11 == (out0.begin() + 15) && out22 == out11; } static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/unique_copy/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/unique_copy/constexpr.cc index 167dc55add66..ee372b8488d0 100644 --- a/libstdc++-v3/testsuite/25_algorithms/unique_copy/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/unique_copy/constexpr.cc @@ -29,10 +29,11 @@ test() const auto out55 = std::unique_copy(ar3.begin(), ar3.end(), out0.begin()); - const auto out66 = std::unique_copy(ar3.begin(), ar3.end(), out0.begin(), + const auto out66 = std::unique_copy(ar3.begin(), ar3.end(), out55, std::equal_to()); - return true; + return out55 == (out0.begin() + 10) && out0[7] == 8 + && out66 == (out55 + 10) ; // && out0[19] == 11; } static_assert(test()); diff --git a/libstdc++-v3/testsuite/25_algorithms/upper_bound/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/upper_bound/constexpr.cc index 8dedb6bd615f..3479116c210d 100644 --- a/libstdc++-v3/testsuite/25_algorithms/upper_bound/constexpr.cc +++ b/libstdc++-v3/testsuite/25_algorithms/upper_bound/constexpr.cc @@ -31,7 +31,7 @@ test() const auto out88 = std::upper_bound(ca0.begin(), ca0.end(), 6, std::less()); - return true; + return out77 == (ca0.begin() + 7) && out88 == out77; } static_assert(test());