aboutsummaryrefslogtreecommitdiff
path: root/test/std/containers/sequences/array
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-01-19 10:05:35 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-01-19 10:05:35 +0000
commit6012fe9abb1f01b1b5b4ca908464804c21ff8602 (patch)
treea5232179237d9aaa3a03f9c783974fc5f09716c6 /test/std/containers/sequences/array
parent315d10f09ee888005b1da55e7bbb57d8a79b8447 (diff)
Notes
Diffstat (limited to 'test/std/containers/sequences/array')
-rw-r--r--test/std/containers/sequences/array/array.data/data.pass.cpp18
-rw-r--r--test/std/containers/sequences/array/array.data/data_const.pass.cpp12
-rw-r--r--test/std/containers/sequences/array/array.tuple/get.fail.cpp2
-rw-r--r--test/std/containers/sequences/array/array.tuple/tuple_element.fail.cpp2
-rw-r--r--test/std/containers/sequences/array/begin.pass.cpp16
-rw-r--r--test/std/containers/sequences/array/compare.pass.cpp33
-rw-r--r--test/std/containers/sequences/array/size_and_alignment.pass.cpp2
7 files changed, 48 insertions, 37 deletions
diff --git a/test/std/containers/sequences/array/array.data/data.pass.cpp b/test/std/containers/sequences/array/array.data/data.pass.cpp
index 714894308f00a..ba2c571ebacf0 100644
--- a/test/std/containers/sequences/array/array.data/data.pass.cpp
+++ b/test/std/containers/sequences/array/array.data/data.pass.cpp
@@ -13,12 +13,19 @@
#include <array>
#include <cassert>
+#include <cstddef> // for std::max_align_t
+
#include "test_macros.h"
// std::array is explicitly allowed to be initialized with A a = { init-list };.
// Disable the missing braces warning for this reason.
#include "disable_missing_braces_warning.h"
+struct NoDefault {
+ NoDefault(int) {}
+};
+
+
int main()
{
{
@@ -35,7 +42,7 @@ int main()
typedef std::array<T, 0> C;
C c = {};
T* p = c.data();
- assert(p != nullptr);
+ LIBCPP_ASSERT(p != nullptr);
}
{
typedef double T;
@@ -43,25 +50,22 @@ int main()
C c = {{}};
const T* p = c.data();
static_assert((std::is_same<decltype(c.data()), const T*>::value), "");
- assert(p != nullptr);
+ LIBCPP_ASSERT(p != nullptr);
}
{
typedef std::max_align_t T;
typedef std::array<T, 0> C;
const C c = {};
const T* p = c.data();
- assert(p != nullptr);
+ LIBCPP_ASSERT(p != nullptr);
std::uintptr_t pint = reinterpret_cast<std::uintptr_t>(p);
assert(pint % TEST_ALIGNOF(std::max_align_t) == 0);
}
{
- struct NoDefault {
- NoDefault(int) {}
- };
typedef NoDefault T;
typedef std::array<T, 0> C;
C c = {};
T* p = c.data();
- assert(p != nullptr);
+ LIBCPP_ASSERT(p != nullptr);
}
}
diff --git a/test/std/containers/sequences/array/array.data/data_const.pass.cpp b/test/std/containers/sequences/array/array.data/data_const.pass.cpp
index b99bf6af8627e..f46352564973f 100644
--- a/test/std/containers/sequences/array/array.data/data_const.pass.cpp
+++ b/test/std/containers/sequences/array/array.data/data_const.pass.cpp
@@ -13,6 +13,7 @@
#include <array>
#include <cassert>
+#include <cstddef> // for std::max_align_t
#include "test_macros.h"
@@ -20,6 +21,10 @@
// Disable the missing braces warning for this reason.
#include "disable_missing_braces_warning.h"
+struct NoDefault {
+ NoDefault(int) {}
+};
+
int main()
{
{
@@ -39,21 +44,18 @@ int main()
(void)p; // to placate scan-build
}
{
- struct NoDefault {
- NoDefault(int) {}
- };
typedef NoDefault T;
typedef std::array<T, 0> C;
const C c = {};
const T* p = c.data();
- assert(p != nullptr);
+ LIBCPP_ASSERT(p != nullptr);
}
{
typedef std::max_align_t T;
typedef std::array<T, 0> C;
const C c = {};
const T* p = c.data();
- assert(p != nullptr);
+ LIBCPP_ASSERT(p != nullptr);
std::uintptr_t pint = reinterpret_cast<std::uintptr_t>(p);
assert(pint % TEST_ALIGNOF(std::max_align_t) == 0);
}
diff --git a/test/std/containers/sequences/array/array.tuple/get.fail.cpp b/test/std/containers/sequences/array/array.tuple/get.fail.cpp
index 45e1d2b46b0f3..a7e56fccef019 100644
--- a/test/std/containers/sequences/array/array.tuple/get.fail.cpp
+++ b/test/std/containers/sequences/array/array.tuple/get.fail.cpp
@@ -31,6 +31,6 @@ int main()
typedef std::array<T, 3> C;
C c = {1, 2, 3.5};
std::get<3>(c) = 5.5; // expected-note {{requested here}}
- // expected-error@array:* {{static_assert failed "Index out of bounds in std::get<> (std::array)"}}
+ // expected-error-re@array:* {{static_assert failed{{( due to requirement '3U[L]{0,2} < 3U[L]{0,2}')?}} "Index out of bounds in std::get<> (std::array)"}}
}
}
diff --git a/test/std/containers/sequences/array/array.tuple/tuple_element.fail.cpp b/test/std/containers/sequences/array/array.tuple/tuple_element.fail.cpp
index c9fe695f9cbd2..2139fc1ad486d 100644
--- a/test/std/containers/sequences/array/array.tuple/tuple_element.fail.cpp
+++ b/test/std/containers/sequences/array/array.tuple/tuple_element.fail.cpp
@@ -30,6 +30,6 @@ int main()
typedef double T;
typedef std::array<T, 3> C;
std::tuple_element<3, C> foo; // expected-note {{requested here}}
- // expected-error@array:* {{static_assert failed "Index out of bounds in std::tuple_element<> (std::array)"}}
+ // expected-error-re@array:* {{static_assert failed{{( due to requirement '3U[L]{0,2} < 3U[L]{0,2}')?}} "Index out of bounds in std::tuple_element<> (std::array)"}}
}
}
diff --git a/test/std/containers/sequences/array/begin.pass.cpp b/test/std/containers/sequences/array/begin.pass.cpp
index 282a947fefeca..37c6b5eecde24 100644
--- a/test/std/containers/sequences/array/begin.pass.cpp
+++ b/test/std/containers/sequences/array/begin.pass.cpp
@@ -14,10 +14,16 @@
#include <array>
#include <cassert>
+#include "test_macros.h"
+
// std::array is explicitly allowed to be initialized with A a = { init-list };.
// Disable the missing braces warning for this reason.
#include "disable_missing_braces_warning.h"
+struct NoDefault {
+ NoDefault(int) {}
+};
+
int main()
{
@@ -33,12 +39,14 @@ int main()
assert(c[0] == 5.5);
}
{
- struct NoDefault {
- NoDefault(int) {}
- };
typedef NoDefault T;
typedef std::array<T, 0> C;
C c = {};
- assert(c.begin() == c.end());
+ C::iterator ib, ie;
+ ib = c.begin();
+ ie = c.end();
+ assert(ib == ie);
+ LIBCPP_ASSERT(ib != nullptr);
+ LIBCPP_ASSERT(ie != nullptr);
}
}
diff --git a/test/std/containers/sequences/array/compare.pass.cpp b/test/std/containers/sequences/array/compare.pass.cpp
index c8bcf75a0934a..5d2bdc50f2617 100644
--- a/test/std/containers/sequences/array/compare.pass.cpp
+++ b/test/std/containers/sequences/array/compare.pass.cpp
@@ -9,6 +9,7 @@
// <array>
+// These are all constexpr in C++20
// bool operator==(array<T, N> const&, array<T, N> const&);
// bool operator!=(array<T, N> const&, array<T, N> const&);
// bool operator<(array<T, N> const&, array<T, N> const&);
@@ -22,24 +23,12 @@
#include <cassert>
#include "test_macros.h"
+#include "test_comparisons.h"
// std::array is explicitly allowed to be initialized with A a = { init-list };.
// Disable the missing braces warning for this reason.
#include "disable_missing_braces_warning.h"
-template <class Array>
-void test_compare(const Array& LHS, const Array& RHS) {
- typedef std::vector<typename Array::value_type> Vector;
- const Vector LHSV(LHS.begin(), LHS.end());
- const Vector RHSV(RHS.begin(), RHS.end());
- assert((LHS == RHS) == (LHSV == RHSV));
- assert((LHS != RHS) == (LHSV != RHSV));
- assert((LHS < RHS) == (LHSV < RHSV));
- assert((LHS <= RHS) == (LHSV <= RHSV));
- assert((LHS > RHS) == (LHSV > RHSV));
- assert((LHS >= RHS) == (LHSV >= RHSV));
-}
-
int main()
{
{
@@ -49,15 +38,25 @@ int main()
C c2 = {1, 2, 3};
C c3 = {3, 2, 1};
C c4 = {1, 2, 1};
- test_compare(c1, c2);
- test_compare(c1, c3);
- test_compare(c1, c4);
+ assert(testComparisons6(c1, c2, true, false));
+ assert(testComparisons6(c1, c3, false, true));
+ assert(testComparisons6(c1, c4, false, false));
}
{
typedef int T;
typedef std::array<T, 0> C;
C c1 = {};
C c2 = {};
- test_compare(c1, c2);
+ assert(testComparisons6(c1, c2, true, false));
+ }
+
+#if TEST_STD_VER > 17
+ {
+ constexpr std::array<int, 3> a1 = {1, 2, 3};
+ constexpr std::array<int, 3> a2 = {2, 3, 4};
+ static_assert(testComparisons6(a1, a1, true, false), "");
+ static_assert(testComparisons6(a1, a2, false, true), "");
+ static_assert(testComparisons6(a2, a1, false, false), "");
}
+#endif
}
diff --git a/test/std/containers/sequences/array/size_and_alignment.pass.cpp b/test/std/containers/sequences/array/size_and_alignment.pass.cpp
index 966d063fe17a6..d73182bd5cace 100644
--- a/test/std/containers/sequences/array/size_and_alignment.pass.cpp
+++ b/test/std/containers/sequences/array/size_and_alignment.pass.cpp
@@ -58,8 +58,6 @@ struct TEST_ALIGNAS(TEST_ALIGNOF(std::max_align_t) * 2) TestType2 {
char data[1000];
};
-//static_assert(sizeof(void*) == 4, "");
-
int main() {
test_type<char>();
test_type<int>();