-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7d13e81
commit 359112f
Showing
4 changed files
with
176 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
test/sources/libcxx/unord.map/unord.map.cnstr/from_range.pass.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// 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<container-compatible-range<value_type> R> | ||
// unordered_map(from_range_t, R&& rg, size_type n = see below, | ||
// const hasher& hf = hasher(), const key_equal& eql = key_equal(), | ||
// const allocator_type& a = allocator_type()); // C++23 | ||
// | ||
// template<container-compatible-range<value_type> R> | ||
// unordered_map(from_range_t, R&& rg, size_type n, const allocator_type& a) | ||
// : unordered_map(from_range, std::forward<R>(rg), n, hasher(), key_equal(), a) { } // C++23 | ||
// | ||
// template<container-compatible-range<value_type> R> | ||
// unordered_map(from_range_t, R&& rg, size_type n, const hasher& hf, const allocator_type& a) | ||
// : unordered_map(from_range, std::forward<R>(rg), n, hf, key_equal(), a) { } // C++23 | ||
|
||
void test_duplicates() { | ||
using T = std::pair<const int, char>; | ||
|
||
std::array input = { | ||
T{1, 'a'}, T{2, 'a'}, T{3, 'a'}, T{3, 'b'}, T{3, 'c'}, T{2, 'b'}, T{4, 'a'} | ||
}; | ||
std::array expected = { | ||
T{1, 'a'}, T{2, 'a'}, T{3, 'a'}, T{4, 'a'} | ||
}; | ||
auto c = std::unordered_map<int, char>(std::from_range, input); | ||
assert(std::ranges::is_permutation(expected, c)); | ||
} | ||
|
||
int main(int, char**) { | ||
using T = std::pair<const int, int>; | ||
for_all_iterators_and_allocators<T>([]<class Iter, class Sent, class Alloc>() { | ||
test_unordered_map<std::unordered_map, int, int, Iter, Sent, test_hash<int>, test_equal_to<int>, Alloc>(); | ||
}); | ||
test_unordered_map_move_only<std::unordered_map>(); | ||
test_duplicates(); | ||
|
||
static_assert(test_map_constraints<std::unordered_map, int, int, double, double>()); | ||
|
||
test_map_exception_safety_throwing_copy<std::unordered_map>(); | ||
test_map_exception_safety_throwing_allocator<std::unordered_map, int, int>(); | ||
|
||
return 0; | ||
} |
39 changes: 39 additions & 0 deletions
39
test/sources/libcxx/unord.map/unord.map.modifiers/insert_range.pass.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// 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 | ||
|
||
// <unordered_map> | ||
|
||
// template<container-compatible-range<value_type> R> | ||
// void insert_range(R&& rg); // C++23 | ||
|
||
int main(int, char**) { | ||
// Note: we want to use a pair with non-const elements for input (an assignable type is a lot more convenient) but | ||
// have to use the exact `value_type` of the map (that is, `pair<const K, V>`) for the allocator. | ||
using Pair = std::pair<int, char>; | ||
using ConstPair = std::pair<const int, char>; | ||
for_all_iterators_and_allocators<ConstPair, const Pair*>([]<class Iter, class Sent, class Alloc>() { | ||
test_map_set_insert_range<std::unordered_map<int, char, test_hash<int>, test_equal_to<int>, Alloc>, Pair, Iter, Sent>(); | ||
}); | ||
|
||
static_assert(test_map_constraints_insert_range<std::unordered_map, int, int, char, double>()); | ||
|
||
test_map_insert_range_move_only<std::unordered_map>(); | ||
|
||
test_map_insert_range_exception_safety_throwing_copy<std::unordered_map>(); | ||
test_unord_map_insert_range_exception_safety_throwing_allocator<std::unordered_map, int, int>(); | ||
|
||
return 0; | ||
} |