diff --git a/libcxx/test/std/containers/associative/map/compare.three_way.pass.cpp b/libcxx/test/std/containers/associative/map/map.nonmember/compare.three_way.pass.cpp rename from libcxx/test/std/containers/associative/map/compare.three_way.pass.cpp rename to libcxx/test/std/containers/associative/map/map.nonmember/compare.three_way.pass.cpp diff --git a/libcxx/test/std/containers/associative/map/map.nonmember/compare.three_way.verify.cpp b/libcxx/test/std/containers/associative/map/map.nonmember/compare.three_way.verify.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/containers/associative/map/map.nonmember/compare.three_way.verify.cpp @@ -0,0 +1,61 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++03, c++11, c++14, c++17 + +// + +// class map + +// template +// synth-three-way-result> +// operator<=>(const map& x, +// const map& y); + +#include + +#include "test_allocator.h" + +int main(int, char**) { + // Mismatching allocators + { + std::map, std::allocator> s1; + std::map, test_allocator> s2; + // expected-error-re@*:* {{{{(static_assert|static assertion)}} failed due to requirement 'is_same>::value'{{.*}}Allocator::value_type must be same type as value_type}} + s1 <=> s2; + // expected-error-re@*:* {{{{(static_assert|static assertion)}} failed due to requirement 'is_same>::value'{{.*}}Allocator::value_type must be same type as value_type}} + s2 <=> s1; + } + // Mismatching comparision functions + { + std::map> s1; + std::map> s2; + // expected-error@+1 {{invalid operands to binary expression}} + s1 <=> s2; + // expected-error@+1 {{invalid operands to binary expression}} + s2 <=> s1; + } + { + std::map> s1; + std::map> s2; + // expected-error@+1 {{invalid operands to binary expression}} + s1 <=> s2; + // expected-error@+1 {{invalid operands to binary expression}} + s2 <=> s1; + } + // Mismatching types + { + std::map s1; + std::map s2; + // expected-error@+1 {{invalid operands to binary expression}} + s1 <=> s2; + // expected-error@+1 {{invalid operands to binary expression}} + s2 <=> s1; + } + + return 0; +} diff --git a/libcxx/test/std/containers/associative/multimap/compare.three_way.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.nonmember/compare.three_way.pass.cpp rename from libcxx/test/std/containers/associative/multimap/compare.three_way.pass.cpp rename to libcxx/test/std/containers/associative/multimap/multimap.nonmember/compare.three_way.pass.cpp diff --git a/libcxx/test/std/containers/associative/multimap/multimap.nonmember/compare.three_way.verify.cpp b/libcxx/test/std/containers/associative/multimap/multimap.nonmember/compare.three_way.verify.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/containers/associative/multimap/multimap.nonmember/compare.three_way.verify.cpp @@ -0,0 +1,61 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// UNSUPPORTED: c++03, c++11, c++14, c++17 + +// + +// class multimap + +// template +// synth-three-way-result> +// operator<=>(const multimap& x, +// const multimap& y); + +#include + +#include "test_allocator.h" + +int main(int, char**) { + // Mismatching allocators + { + std::multimap, std::allocator> s1; + std::multimap, test_allocator> s2; + // expected-error-re@*:* {{{{(static_assert|static assertion)}} failed due to requirement 'is_same>::value'{{.*}}Allocator::value_type must be same type as value_type}} + s1 <=> s2; + // expected-error-re@*:* {{{{(static_assert|static assertion)}} failed due to requirement 'is_same>::value'{{.*}}Allocator::value_type must be same type as value_type}} + s2 <=> s1; + } + // Mismatching comparision functions + { + std::multimap> s1; + std::multimap> s2; + // expected-error@+1 {{invalid operands to binary expression}} + s1 <=> s2; + // expected-error@+1 {{invalid operands to binary expression}} + s2 <=> s1; + } + { + std::multimap> s1; + std::multimap> s2; + // expected-error@+1 {{invalid operands to binary expression}} + s1 <=> s2; + // expected-error@+1 {{invalid operands to binary expression}} + s2 <=> s1; + } + // Mismatching types + { + std::multimap s1; + std::multimap s2; + // expected-error@+1 {{invalid operands to binary expression}} + s1 <=> s2; + // expected-error@+1 {{invalid operands to binary expression}} + s2 <=> s1; + } + + return 0; +} diff --git a/libcxx/test/support/test_container_comparisons.h b/libcxx/test/support/test_container_comparisons.h --- a/libcxx/test/support/test_container_comparisons.h +++ b/libcxx/test/support/test_container_comparisons.h @@ -10,6 +10,7 @@ #ifndef TEST_CONTAINER_COMPARISONS #define TEST_CONTAINER_COMPARISONS +#include #include #include "test_comparisons.h" @@ -84,103 +85,109 @@ } // Implementation detail of `test_ordered_map_container_spaceship` -template