Skip to content

Commit 037195f

Browse files
committed
tests
1 parent e6d0024 commit 037195f

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

libcxx/test/std/containers/container.adaptors/flat.map/op_compare.pass.cpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,27 @@
1616

1717
#include <algorithm>
1818
#include <cassert>
19+
#include <deque>
1920
#include <compare>
2021
#include <flat_map>
2122
#include <functional>
2223
#include <limits>
2324
#include <vector>
2425

26+
#include "MinSequenceContainer.h"
27+
#include "test_macros.h"
28+
#include "min_allocator.h"
29+
#include "test_allocator.h"
2530
#include "test_comparisons.h"
2631
#include "test_container_comparisons.h"
2732

28-
int main(int, char**) {
33+
template <class KeyContainer, class ValueContainer>
34+
void test() {
35+
using Key = typename KeyContainer::value_type;
36+
using Value = typename ValueContainer::value_type;
37+
2938
{
30-
using C = std::flat_map<int, int>;
39+
using C = std::flat_map<Key, Value>;
3140
C s1 = {{1, 1}};
3241
C s2 = {{2, 0}}; // {{1,1}} versus {{2,0}}
3342
ASSERT_SAME_TYPE(decltype(s1 <=> s2), std::strong_ordering);
@@ -44,7 +53,7 @@ int main(int, char**) {
4453
}
4554
{
4655
// Comparisons use value_type's native operators, not the comparator
47-
using C = std::flat_map<int, int, std::greater<int>>;
56+
using C = std::flat_map<Key, Value, std::greater<Key>>;
4857
C s1 = {{1, 1}};
4958
C s2 = {{2, 0}}; // {{1,1}} versus {{2,0}}
5059
ASSERT_SAME_TYPE(decltype(s1 <=> s2), std::strong_ordering);
@@ -59,6 +68,15 @@ int main(int, char**) {
5968
s2 = {{0, 0}, {1, 1}, {2, 3}}; // {{2,2},{1,1},{0,0}} versus {{2,3},{1,1},{0,0}}
6069
assert(testComparisons(s1, s2, false, true));
6170
}
71+
}
72+
73+
int main(int, char**) {
74+
test<std::vector<int>, std::vector<int>>();
75+
test<std::deque<int>, std::deque<int>>();
76+
test<MinSequenceContainer<int>, MinSequenceContainer<int>>();
77+
test<std::vector<int, min_allocator<int>>, std::vector<int, min_allocator<int>>>();
78+
test<std::vector<int, min_allocator<int>>, std::vector<int, min_allocator<int>>>();
79+
6280
{
6381
using C = std::flat_map<double, int>;
6482
C s1 = {{1, 1}};

0 commit comments

Comments
 (0)