summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/containers/sequences/array
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/std/containers/sequences/array')
-rw-r--r--libcxx/test/std/containers/sequences/array/array.data/data_const.pass.cpp14
-rw-r--r--libcxx/test/std/containers/sequences/array/iterators.pass.cpp33
2 files changed, 47 insertions, 0 deletions
diff --git a/libcxx/test/std/containers/sequences/array/array.data/data_const.pass.cpp b/libcxx/test/std/containers/sequences/array/array.data/data_const.pass.cpp
index 58840e94089..5be082eeb84 100644
--- a/libcxx/test/std/containers/sequences/array/array.data/data_const.pass.cpp
+++ b/libcxx/test/std/containers/sequences/array/array.data/data_const.pass.cpp
@@ -14,6 +14,8 @@
#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"
@@ -36,4 +38,16 @@ int main()
const T* p = c.data();
(void)p; // to placate scan-build
}
+#if TEST_STD_VER > 14
+ {
+ typedef std::array<int, 5> C;
+ constexpr C c1{0,1,2,3,4};
+ constexpr const C c2{0,1,2,3,4};
+
+ static_assert ( c1.data() == &c1[0], "");
+ static_assert ( *c1.data() == c1[0], "");
+ static_assert ( c2.data() == &c2[0], "");
+ static_assert ( *c2.data() == c2[0], "");
+ }
+#endif
}
diff --git a/libcxx/test/std/containers/sequences/array/iterators.pass.cpp b/libcxx/test/std/containers/sequences/array/iterators.pass.cpp
index 1f9904e1fa7..7d9050800de 100644
--- a/libcxx/test/std/containers/sequences/array/iterators.pass.cpp
+++ b/libcxx/test/std/containers/sequences/array/iterators.pass.cpp
@@ -17,6 +17,10 @@
#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"
+
int main()
{
{
@@ -109,4 +113,33 @@ int main()
}
}
#endif
+#if TEST_STD_VER > 14
+ {
+ typedef std::array<int, 5> C;
+ constexpr C c{0,1,2,3,4};
+
+ static_assert ( c.begin() == std::begin(c), "");
+ static_assert ( c.cbegin() == std::cbegin(c), "");
+ static_assert ( c.end() == std::end(c), "");
+ static_assert ( c.cend() == std::cend(c), "");
+
+ static_assert ( c.rbegin() == std::rbegin(c), "");
+ static_assert ( c.crbegin() == std::crbegin(c), "");
+ static_assert ( c.rend() == std::rend(c), "");
+ static_assert ( c.crend() == std::crend(c), "");
+
+ static_assert ( std::begin(c) != std::end(c), "");
+ static_assert ( std::rbegin(c) != std::rend(c), "");
+ static_assert ( std::cbegin(c) != std::cend(c), "");
+ static_assert ( std::crbegin(c) != std::crend(c), "");
+
+ static_assert ( *c.begin() == 0, "");
+ static_assert ( *c.rbegin() == 4, "");
+
+ static_assert ( *std::begin(c) == 0, "" );
+ static_assert ( *std::cbegin(c) == 0, "" );
+ static_assert ( *std::rbegin(c) == 4, "" );
+ static_assert ( *std::crbegin(c) == 4, "" );
+ }
+#endif
}
OpenPOWER on IntegriCloud