diff --git a/test/sources/libcxx/MultiSetTests.h b/test/sources/libcxx/MultiSetTests.h index 00b58799..1aae0251 100644 --- a/test/sources/libcxx/MultiSetTests.h +++ b/test/sources/libcxx/MultiSetTests.h @@ -108,6 +108,12 @@ LIBCXX_TEST_BEGIN(insert_node_type_hint) #include "multiset/insert_node_type_hint.pass.cpp" LIBCXX_TEST_END +#if TEST_STD_VER >= 23 +LIBCXX_TEST_BEGIN(insert_range) +#include "multiset/insert_range.pass.cpp" +LIBCXX_TEST_END +#endif + LIBCXX_TEST_BEGIN(insert_rv) #include "multiset/insert_rv.pass.cpp" LIBCXX_TEST_END @@ -208,6 +214,12 @@ LIBCXX_TEST_BEGIN(cons_dtor_noexcept) #include "multiset/multiset.cons/dtor_noexcept.pass.cpp" LIBCXX_TEST_END +#if TEST_STD_VER >= 23 +LIBCXX_TEST_BEGIN(cons_from_range) +#include "multiset/multiset.cons/from_range.pass.cpp" +LIBCXX_TEST_END +#endif + LIBCXX_TEST_BEGIN(cons_initializer_list) #include "multiset/multiset.cons/initializer_list.pass.cpp" LIBCXX_TEST_END diff --git a/test/sources/libcxx/multiset/insert_range.pass.cpp b/test/sources/libcxx/multiset/insert_range.pass.cpp new file mode 100644 index 00000000..ed88bcd6 --- /dev/null +++ b/test/sources/libcxx/multiset/insert_range.pass.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Modified for https://github.com/morzhovets/momo project. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 +// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC. +// ADDITIONAL_COMPILE_FLAGS(gcc-style-warnings): -Wno-missing-field-initializers + +// + +// template R> +// void insert_range(R&& rg); // C++23 + +int main(int, char**) { + for_all_iterators_and_allocators([]() { + test_map_set_insert_range, Alloc>, int, Iter, Sent>(/*allow_duplicates=*/true); + }); + + static_assert(test_set_constraints_insert_range()); + + test_set_insert_range_move_only(); + + test_set_insert_range_exception_safety_throwing_copy(); + test_assoc_set_insert_range_exception_safety_throwing_allocator(); + + return 0; +} diff --git a/test/sources/libcxx/multiset/multiset.cons/deduct.pass.cpp b/test/sources/libcxx/multiset/multiset.cons/deduct.pass.cpp index 16003563..d962ad36 100644 --- a/test/sources/libcxx/multiset/multiset.cons/deduct.pass.cpp +++ b/test/sources/libcxx/multiset/multiset.cons/deduct.pass.cpp @@ -31,6 +31,15 @@ // template // multiset(initializer_list, Allocator) // -> multiset, Allocator>; +// +// template>, +// class Allocator = allocator>> +// multiset(from_range_t, R&&, Compare = Compare(), Allocator = Allocator()) +// -> multiset, Compare, Allocator>; +// +// template +// multiset(from_range_t, R&&, Allocator) +// -> multiset, less>, Allocator>; struct NotAnAllocator { friend bool operator<(NotAnAllocator, NotAnAllocator) { return false; } @@ -189,6 +198,35 @@ int main(int, char **) { } #endif +#if TEST_STD_VER >= 23 + { + using Range = std::array; + using Comp = std::greater; + using DefaultComp = std::less; + using Alloc = test_allocator; + + { // (from_range, range) + momo::stdish::multiset c(std::from_range, Range()); + static_assert(std::is_same_v>); + } + + { // (from_range, range, comp) + momo::stdish::multiset c(std::from_range, Range(), Comp()); + static_assert(std::is_same_v>); + } + + { // (from_range, range, comp, alloc) + momo::stdish::multiset c(std::from_range, Range(), Comp(), Alloc()); + static_assert(std::is_same_v>); + } + + { // (from_range, range, alloc) + momo::stdish::multiset c(std::from_range, Range(), Alloc()); + static_assert(std::is_same_v>); + } + } +#endif + //#if MOMO_VERSION_MAJOR > 3 #if !(defined(TEST_MSVC) && _MSC_VER < 1930) && !(defined(TEST_GCC) && __GNUC__ < 11) AssociativeContainerDeductionGuidesSfinaeAway>(); diff --git a/test/sources/libcxx/multiset/multiset.cons/from_range.pass.cpp b/test/sources/libcxx/multiset/multiset.cons/from_range.pass.cpp new file mode 100644 index 00000000..f96fe35c --- /dev/null +++ b/test/sources/libcxx/multiset/multiset.cons/from_range.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Modified for https://github.com/morzhovets/momo project. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 + +// template R> +// multiset(from_range_t, R&& rg, const Compare& comp = Compare(), const Allocator& = Allocator()); // C++23 +// +// template R> +// multiset(from_range_t, R&& rg, const Allocator& a)) +// : multiset(from_range, std::forward(rg), Compare(), a) { } // C++23 + +void test_duplicates() { + std::array input = {1, 2, 3, 3, 3, 4, 2, 1, 2}; + auto c = std::multiset(std::from_range, input); + assert(std::ranges::is_permutation(input, c)); +} + +int main(int, char**) { + for_all_iterators_and_allocators([]() { + test_associative_set, Alloc>(); + }); + test_associative_set_move_only(); + test_duplicates(); + + static_assert(test_set_constraints()); + + test_set_exception_safety_throwing_copy(); + test_set_exception_safety_throwing_allocator(); + + return 0; +}