diff --git a/test/sources/LibcxxMultiMapTests.h b/test/sources/LibcxxMultiMapTests.h index 6387e5cb6..be8d5689b 100644 --- a/test/sources/LibcxxMultiMapTests.h +++ b/test/sources/LibcxxMultiMapTests.h @@ -22,6 +22,10 @@ LIBCXX_TEST_BEGIN(iterator) #include "libcxx/multimap/iterator.pass.cpp" LIBCXX_TEST_END +LIBCXX_TEST_BEGIN(iterator_types) +#include "libcxx/multimap/iterator_types.pass.cpp" +LIBCXX_TEST_END + //LIBCXX_TEST_BEGIN(max_size) //#include "libcxx/multimap/max_size.pass.cpp" //LIBCXX_TEST_END @@ -206,6 +210,10 @@ LIBCXX_TEST_BEGIN(ops_contains) #include "libcxx/multimap/multimap.ops/contains.pass.cpp" LIBCXX_TEST_END +LIBCXX_TEST_BEGIN(ops_contains_transparent) +#include "libcxx/multimap/multimap.ops/contains_transparent.pass.cpp" +LIBCXX_TEST_END + LIBCXX_TEST_BEGIN(ops_count) #include "libcxx/multimap/multimap.ops/count.pass.cpp" LIBCXX_TEST_END diff --git a/test/sources/LibcxxTreeMultiMapTester.cpp b/test/sources/LibcxxTreeMultiMapTester.cpp index 586ab2afb..a93b5befe 100644 --- a/test/sources/LibcxxTreeMultiMapTester.cpp +++ b/test/sources/LibcxxTreeMultiMapTester.cpp @@ -18,36 +18,54 @@ #include "../../include/momo/stdish/map.h" -#define LIBCXX_TEST_PREFIX "libcxx_test_tree_multimap" namespace libcxx_test_tree_multimap { -template, - typename TAllocator = std::allocator>> -using multimap = momo::stdish::multimap, false>>, - momo::MemManagerStd, - momo::TreeMapKeyValueTraits, false>, - momo::TreeMapSettings>>; -#include "LibcxxMultiMapTests.h" + +namespace std +{ + using namespace ::std; + + template, + typename TAllocator = std::allocator>> + using multimap = momo::stdish::multimap, false>>, + momo::MemManagerStd, + momo::TreeMapKeyValueTraits, false>, + momo::TreeMapSettings>>; } + +using std::multimap; + +#define LIBCXX_TEST_PREFIX "libcxx_test_tree_multimap" +#include "LibcxxMultiMapTests.h" #undef LIBCXX_TEST_PREFIX +} -#define LIBCXX_TEST_PREFIX "libcxx_test_tree_multimap_vp" namespace libcxx_test_tree_multimap_vp { -template, - typename TAllocator = std::allocator>> -using multimap = momo::stdish::multimap, true>>, - momo::MemManagerStd, - momo::TreeMapKeyValueTraits, true>, - momo::TreeMapSettings>>; -#include "LibcxxMultiMapTests.h" + +namespace std +{ + using namespace ::std; + + template, + typename TAllocator = std::allocator>> + using multimap = momo::stdish::multimap, true>>, + momo::MemManagerStd, + momo::TreeMapKeyValueTraits, true>, + momo::TreeMapSettings>>; } + +using std::multimap; + +#define LIBCXX_TEST_PREFIX "libcxx_test_tree_multimap_vp" +#include "LibcxxMultiMapTests.h" #undef LIBCXX_TEST_PREFIX +} #endif // TEST_LIBCXX_TREE_MAP diff --git a/test/sources/libcxx/multimap/iterator_types.pass.cpp b/test/sources/libcxx/multimap/iterator_types.pass.cpp new file mode 100644 index 000000000..0d06e1a7c --- /dev/null +++ b/test/sources/libcxx/multimap/iterator_types.pass.cpp @@ -0,0 +1,68 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + + +template +void testMap() { + typedef typename Map::difference_type Diff; + { +#ifdef LIBCPP_HAS_BAD_NEWS_FOR_MOMO + typedef typename Map::iterator It; +#else + typedef std::iterator_traits It; +#endif +#ifdef LIBCPP_HAS_BAD_NEWS_FOR_MOMO + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +#endif + static_assert((std::is_same::value), ""); + } + { +#ifdef LIBCPP_HAS_BAD_NEWS_FOR_MOMO + typedef typename Map::const_iterator It; +#else + typedef std::iterator_traits It; +#endif +#ifdef LIBCPP_HAS_BAD_NEWS_FOR_MOMO + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +#endif + static_assert((std::is_same::value), ""); + } +} + + +int main(int, char**) { + { + typedef std::multimap Map; + typedef std::pair ValueTp; + testMap(); + } + { + typedef std::pair ValueTp; + typedef test_allocator Alloc; + typedef std::multimap, Alloc> Map; + testMap(); + } +#if TEST_STD_VER >= 11 + { + typedef std::pair ValueTp; + typedef min_allocator Alloc; + typedef std::multimap, Alloc> Map; + testMap, min_pointer>(); + } +#endif + + return 0; +} diff --git a/test/sources/libcxx/multimap/multimap.ops/contains.pass.cpp b/test/sources/libcxx/multimap/multimap.ops/contains.pass.cpp index 8018dae16..2394a6f97 100644 --- a/test/sources/libcxx/multimap/multimap.ops/contains.pass.cpp +++ b/test/sources/libcxx/multimap/multimap.ops/contains.pass.cpp @@ -12,9 +12,6 @@ // UNSUPPORTED: c++03, c++11, c++14, c++17 -//#include -//#include - // // bool contains(const key_type& x) const; @@ -32,21 +29,21 @@ void test(B bad, Pairs... args) { struct E { int a = 1; double b = 1; char c = 1; }; -void main() +int main(int, char**) { { - test, std::pair >( + test, std::pair >( 'e', std::make_pair('a', 10), std::make_pair('b', 11), std::make_pair('c', 12), std::make_pair('d', 13)); - test, std::pair >( + test, std::pair >( 'e', std::make_pair('a', 'a'), std::make_pair('b', 'a'), std::make_pair('c', 'a'), std::make_pair('d', 'b')); -#ifndef LIBCPP_HAS_NO_TRANSPARENT_OPERATORS - test>, std::pair >( - int8_t{-1}, std::make_pair(1, E{}), std::make_pair(2, E{}), + test, std::pair >( + -1, std::make_pair(1, E{}), std::make_pair(2, E{}), std::make_pair(3, E{}), std::make_pair(4, E{})); -#endif } + + return 0; } diff --git a/test/sources/libcxx/multimap/multimap.ops/contains_transparent.pass.cpp b/test/sources/libcxx/multimap/multimap.ops/contains_transparent.pass.cpp new file mode 100644 index 000000000..8be10d53b --- /dev/null +++ b/test/sources/libcxx/multimap/multimap.ops/contains_transparent.pass.cpp @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// + +// template bool contains(const K& x) const; // C++20 + +struct Comp { + using is_transparent = void; + + bool operator()(const std::pair& lhs, + const std::pair& rhs) const { + return lhs < rhs; + } + + bool operator()(const std::pair& lhs, int rhs) const { + return lhs.first < rhs; + } + + bool operator()(int lhs, const std::pair& rhs) const { + return lhs < rhs.first; + } +}; + +template +void test() { + Container s{{{2, 1}, 1}, {{1, 2}, 2}, {{1, 3}, 3}, {{1, 4}, 4}, {{2, 2}, 5}}; + + assert(s.contains(1)); + assert(!s.contains(-1)); +} + +int main(int, char**) { + test, int, Comp> >(); + + return 0; +}