Skip to content

Commit 3a225ef

Browse files
committed
Update the changes to the array tests (that I committed yesterday) to use the test_comparison routines that I committed last week. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@338797 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 88f5d7a commit 3a225ef

File tree

1 file changed

+8
-55
lines changed

1 file changed

+8
-55
lines changed

test/std/containers/sequences/array/compare.pass.cpp

Lines changed: 8 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -23,59 +23,12 @@
2323
#include <cassert>
2424

2525
#include "test_macros.h"
26+
#include "test_comparisons.h"
2627

2728
// std::array is explicitly allowed to be initialized with A a = { init-list };.
2829
// Disable the missing braces warning for this reason.
2930
#include "disable_missing_braces_warning.h"
3031

31-
template <class Array>
32-
void test_compare(const Array& LHS, const Array& RHS) {
33-
typedef std::vector<typename Array::value_type> Vector;
34-
const Vector LHSV(LHS.begin(), LHS.end());
35-
const Vector RHSV(RHS.begin(), RHS.end());
36-
assert((LHS == RHS) == (LHSV == RHSV));
37-
assert((LHS != RHS) == (LHSV != RHSV));
38-
assert((LHS < RHS) == (LHSV < RHSV));
39-
assert((LHS <= RHS) == (LHSV <= RHSV));
40-
assert((LHS > RHS) == (LHSV > RHSV));
41-
assert((LHS >= RHS) == (LHSV >= RHSV));
42-
}
43-
44-
#if TEST_STD_VER > 17
45-
template <class Array>
46-
constexpr bool constexpr_compare(const Array &lhs, const Array &rhs, bool isEqual, bool isLess)
47-
{
48-
if (isEqual)
49-
{
50-
if (!(lhs == rhs)) return false;
51-
if ( (lhs != rhs)) return false;
52-
if ( (lhs < rhs)) return false;
53-
if (!(lhs <= rhs)) return false;
54-
if ( (lhs > rhs)) return false;
55-
if (!(lhs >= rhs)) return false;
56-
}
57-
else if (isLess)
58-
{
59-
if ( (lhs == rhs)) return false;
60-
if (!(lhs != rhs)) return false;
61-
if (!(lhs < rhs)) return false;
62-
if (!(lhs <= rhs)) return false;
63-
if ( (lhs > rhs)) return false;
64-
if ( (lhs >= rhs)) return false;
65-
}
66-
else // greater
67-
{
68-
if ( (lhs == rhs)) return false;
69-
if (!(lhs != rhs)) return false;
70-
if ( (lhs < rhs)) return false;
71-
if ( (lhs <= rhs)) return false;
72-
if (!(lhs > rhs)) return false;
73-
if (!(lhs >= rhs)) return false;
74-
}
75-
return true;
76-
}
77-
#endif
78-
7932
int main()
8033
{
8134
{
@@ -85,25 +38,25 @@ int main()
8538
C c2 = {1, 2, 3};
8639
C c3 = {3, 2, 1};
8740
C c4 = {1, 2, 1};
88-
test_compare(c1, c2);
89-
test_compare(c1, c3);
90-
test_compare(c1, c4);
41+
assert(testComparisons6(c1, c2, true, false));
42+
assert(testComparisons6(c1, c3, false, true));
43+
assert(testComparisons6(c1, c4, false, false));
9144
}
9245
{
9346
typedef int T;
9447
typedef std::array<T, 0> C;
9548
C c1 = {};
9649
C c2 = {};
97-
test_compare(c1, c2);
50+
assert(testComparisons6(c1, c2, true, false));
9851
}
9952

10053
#if TEST_STD_VER > 17
10154
{
10255
constexpr std::array<int, 3> a1 = {1, 2, 3};
10356
constexpr std::array<int, 3> a2 = {2, 3, 4};
104-
static_assert(constexpr_compare(a1, a1, true, false), "");
105-
static_assert(constexpr_compare(a1, a2, false, true), "");
106-
static_assert(constexpr_compare(a2, a1, false, false), "");
57+
static_assert(testComparisons6(a1, a1, true, false), "");
58+
static_assert(testComparisons6(a1, a2, false, true), "");
59+
static_assert(testComparisons6(a2, a1, false, false), "");
10760
}
10861
#endif
10962
}

0 commit comments

Comments
 (0)