summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/containers/sequences/array
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2014-12-20 01:40:03 +0000
committerEric Fiselier <eric@efcs.ca>2014-12-20 01:40:03 +0000
commit5a83710e371fe68a06e6e3876c6a2c8b820a8976 (patch)
treeafde4c82ad6704681781c5cd49baa3fbd05c85db /libcxx/test/std/containers/sequences/array
parentf11e8eab527fba316c64112f6e05de1a79693a3e (diff)
downloadbcm5719-llvm-5a83710e371fe68a06e6e3876c6a2c8b820a8976.tar.gz
bcm5719-llvm-5a83710e371fe68a06e6e3876c6a2c8b820a8976.zip
Move test into test/std subdirectory.
llvm-svn: 224658
Diffstat (limited to 'libcxx/test/std/containers/sequences/array')
-rw-r--r--libcxx/test/std/containers/sequences/array/array.cons/default.pass.cpp31
-rw-r--r--libcxx/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp34
-rw-r--r--libcxx/test/std/containers/sequences/array/array.data/data.pass.cpp35
-rw-r--r--libcxx/test/std/containers/sequences/array/array.data/data_const.pass.cpp35
-rw-r--r--libcxx/test/std/containers/sequences/array/array.fill/fill.pass.cpp36
-rw-r--r--libcxx/test/std/containers/sequences/array/array.size/size.pass.cpp53
-rw-r--r--libcxx/test/std/containers/sequences/array/array.special/swap.pass.cpp43
-rw-r--r--libcxx/test/std/containers/sequences/array/array.swap/swap.pass.cpp43
-rw-r--r--libcxx/test/std/containers/sequences/array/array.tuple/get.fail.cpp25
-rw-r--r--libcxx/test/std/containers/sequences/array/array.tuple/get.pass.cpp52
-rw-r--r--libcxx/test/std/containers/sequences/array/array.tuple/get_const.pass.cpp37
-rw-r--r--libcxx/test/std/containers/sequences/array/array.tuple/get_rv.pass.cpp29
-rw-r--r--libcxx/test/std/containers/sequences/array/array.tuple/tuple_element.pass.cpp33
-rw-r--r--libcxx/test/std/containers/sequences/array/array.tuple/tuple_size.pass.cpp28
-rw-r--r--libcxx/test/std/containers/sequences/array/array.zero/tested_elsewhere.pass.cpp18
-rw-r--r--libcxx/test/std/containers/sequences/array/at.pass.cpp67
-rw-r--r--libcxx/test/std/containers/sequences/array/begin.pass.cpp32
-rw-r--r--libcxx/test/std/containers/sequences/array/front_back.pass.cpp62
-rw-r--r--libcxx/test/std/containers/sequences/array/indexing.pass.cpp60
-rw-r--r--libcxx/test/std/containers/sequences/array/iterators.pass.cpp110
-rw-r--r--libcxx/test/std/containers/sequences/array/types.pass.cpp62
-rw-r--r--libcxx/test/std/containers/sequences/array/version.pass.cpp20
22 files changed, 945 insertions, 0 deletions
diff --git a/libcxx/test/std/containers/sequences/array/array.cons/default.pass.cpp b/libcxx/test/std/containers/sequences/array/array.cons/default.pass.cpp
new file mode 100644
index 00000000000..7bc62b759c3
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/array.cons/default.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// array();
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c;
+ assert(c.size() == 3);
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 0> C;
+ C c;
+ assert(c.size() == 0);
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp
new file mode 100644
index 00000000000..b9775eef067
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// Construct with initizializer list
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+ assert(c.size() == 3);
+ assert(c[0] == 1);
+ assert(c[1] == 2);
+ assert(c[2] == 3.5);
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 0> C;
+ C c = {};
+ assert(c.size() == 0);
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/array/array.data/data.pass.cpp b/libcxx/test/std/containers/sequences/array/array.data/data.pass.cpp
new file mode 100644
index 00000000000..08e4fd39d37
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/array.data/data.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// T *data();
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+ T* p = c.data();
+ assert(p[0] == 1);
+ assert(p[1] == 2);
+ assert(p[2] == 3.5);
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 0> C;
+ C c = {};
+ T* p = c.data();
+ (void)p; // to placate scan-build
+ }
+}
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
new file mode 100644
index 00000000000..8eb9762dcb8
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/array.data/data_const.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// const T* data() const;
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ const C c = {1, 2, 3.5};
+ const T* p = c.data();
+ assert(p[0] == 1);
+ assert(p[1] == 2);
+ assert(p[2] == 3.5);
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 0> C;
+ const C c = {};
+ const T* p = c.data();
+ (void)p; // to placate scan-build
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/array/array.fill/fill.pass.cpp b/libcxx/test/std/containers/sequences/array/array.fill/fill.pass.cpp
new file mode 100644
index 00000000000..675f4950062
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/array.fill/fill.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// void fill(const T& u);
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+ c.fill(5.5);
+ assert(c.size() == 3);
+ assert(c[0] == 5.5);
+ assert(c[1] == 5.5);
+ assert(c[2] == 5.5);
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 0> C;
+ C c = {};
+ c.fill(5.5);
+ assert(c.size() == 0);
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/array/array.size/size.pass.cpp b/libcxx/test/std/containers/sequences/array/array.size/size.pass.cpp
new file mode 100644
index 00000000000..fe5a0d5c8db
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/array.size/size.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <class T, size_t N> constexpr size_type array<T,N>::size();
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+ assert(c.size() == 3);
+ assert(c.max_size() == 3);
+ assert(!c.empty());
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 0> C;
+ C c = {};
+ assert(c.size() == 0);
+ assert(c.max_size() == 0);
+ assert(c.empty());
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ constexpr C c = {1, 2, 3.5};
+ static_assert(c.size() == 3, "");
+ static_assert(c.max_size() == 3, "");
+ static_assert(!c.empty(), "");
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 0> C;
+ constexpr C c = {};
+ static_assert(c.size() == 0, "");
+ static_assert(c.max_size() == 0, "");
+ static_assert(c.empty(), "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/array/array.special/swap.pass.cpp b/libcxx/test/std/containers/sequences/array/array.special/swap.pass.cpp
new file mode 100644
index 00000000000..08e437739ee
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/array.special/swap.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <class T, size_t N> void swap(array<T,N>& x, array<T,N>& y);
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c1 = {1, 2, 3.5};
+ C c2 = {4, 5, 6.5};
+ swap(c1, c2);
+ assert(c1.size() == 3);
+ assert(c1[0] == 4);
+ assert(c1[1] == 5);
+ assert(c1[2] == 6.5);
+ assert(c2.size() == 3);
+ assert(c2[0] == 1);
+ assert(c2[1] == 2);
+ assert(c2[2] == 3.5);
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 0> C;
+ C c1 = {};
+ C c2 = {};
+ swap(c1, c2);
+ assert(c1.size() == 0);
+ assert(c2.size() == 0);
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/array/array.swap/swap.pass.cpp b/libcxx/test/std/containers/sequences/array/array.swap/swap.pass.cpp
new file mode 100644
index 00000000000..c7a4cb8df38
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/array.swap/swap.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// void swap(array& a);
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c1 = {1, 2, 3.5};
+ C c2 = {4, 5, 6.5};
+ c1.swap(c2);
+ assert(c1.size() == 3);
+ assert(c1[0] == 4);
+ assert(c1[1] == 5);
+ assert(c1[2] == 6.5);
+ assert(c2.size() == 3);
+ assert(c2[0] == 1);
+ assert(c2[1] == 2);
+ assert(c2[2] == 3.5);
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 0> C;
+ C c1 = {};
+ C c2 = {};
+ c1.swap(c2);
+ assert(c1.size() == 0);
+ assert(c2.size() == 0);
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/array/array.tuple/get.fail.cpp b/libcxx/test/std/containers/sequences/array/array.tuple/get.fail.cpp
new file mode 100644
index 00000000000..4f4fbcf93af
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/array.tuple/get.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <size_t I, class T, size_t N> T& get(array<T, N>& a);
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+ std::get<3>(c) = 5.5; // Can't get element 3!
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/array/array.tuple/get.pass.cpp b/libcxx/test/std/containers/sequences/array/array.tuple/get.pass.cpp
new file mode 100644
index 00000000000..d9e242cd420
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/array.tuple/get.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <size_t I, class T, size_t N> T& get(array<T, N>& a);
+
+#include <array>
+#include <cassert>
+
+#if __cplusplus > 201103L
+struct S {
+ std::array<int, 3> a;
+ int k;
+ constexpr S() : a{1,2,3}, k(std::get<2>(a)) {}
+ };
+
+constexpr std::array<int, 2> getArr () { return { 3, 4 }; }
+#endif
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+ std::get<1>(c) = 5.5;
+ assert(c[0] == 1);
+ assert(c[1] == 5.5);
+ assert(c[2] == 3.5);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ constexpr C c = {1, 2, 3.5};
+ static_assert(std::get<0>(c) == 1, "");
+ static_assert(std::get<1>(c) == 2, "");
+ static_assert(std::get<2>(c) == 3.5, "");
+ }
+ {
+ static_assert(S().k == 3, "");
+ static_assert(std::get<1>(getArr()) == 4, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/array/array.tuple/get_const.pass.cpp b/libcxx/test/std/containers/sequences/array/array.tuple/get_const.pass.cpp
new file mode 100644
index 00000000000..1cbdfa4ff39
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/array.tuple/get_const.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <size_t I, class T, size_t N> const T& get(const array<T, N>& a);
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ const C c = {1, 2, 3.5};
+ assert(std::get<0>(c) == 1);
+ assert(std::get<1>(c) == 2);
+ assert(std::get<2>(c) == 3.5);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ constexpr const C c = {1, 2, 3.5};
+ static_assert(std::get<0>(c) == 1, "");
+ static_assert(std::get<1>(c) == 2, "");
+ static_assert(std::get<2>(c) == 3.5, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/array/array.tuple/get_rv.pass.cpp b/libcxx/test/std/containers/sequences/array/array.tuple/get_rv.pass.cpp
new file mode 100644
index 00000000000..869c1ec9c2d
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/array.tuple/get_rv.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <size_t I, class T, size_t N> T&& get(array<T, N>&& a);
+
+#include <array>
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unique_ptr<double> T;
+ typedef std::array<T, 1> C;
+ C c = {std::unique_ptr<double>(new double(3.5))};
+ T t = std::get<0>(std::move(c));
+ assert(*t == 3.5);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/array/array.tuple/tuple_element.pass.cpp b/libcxx/test/std/containers/sequences/array/array.tuple/tuple_element.pass.cpp
new file mode 100644
index 00000000000..cd1dad60ade
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/array.tuple/tuple_element.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// tuple_element<I, array<T, N> >::type
+
+#include <array>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ static_assert((std::is_same<std::tuple_element<0, C>::type, T>::value), "");
+ static_assert((std::is_same<std::tuple_element<1, C>::type, T>::value), "");
+ static_assert((std::is_same<std::tuple_element<2, C>::type, T>::value), "");
+ }
+ {
+ typedef int T;
+ typedef std::array<T, 3> C;
+ static_assert((std::is_same<std::tuple_element<0, C>::type, T>::value), "");
+ static_assert((std::is_same<std::tuple_element<1, C>::type, T>::value), "");
+ static_assert((std::is_same<std::tuple_element<2, C>::type, T>::value), "");
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/array/array.tuple/tuple_size.pass.cpp b/libcxx/test/std/containers/sequences/array/array.tuple/tuple_size.pass.cpp
new file mode 100644
index 00000000000..83394b1e0c9
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/array.tuple/tuple_size.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// tuple_size<array<T, N> >::value
+
+#include <array>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ static_assert((std::tuple_size<C>::value == 3), "");
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 0> C;
+ static_assert((std::tuple_size<C>::value == 0), "");
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/array/array.zero/tested_elsewhere.pass.cpp b/libcxx/test/std/containers/sequences/array/array.zero/tested_elsewhere.pass.cpp
new file mode 100644
index 00000000000..0aa2f50d8b4
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/array.zero/tested_elsewhere.pass.cpp
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// support for zero-sized array
+
+#include <array>
+
+int main()
+{
+}
diff --git a/libcxx/test/std/containers/sequences/array/at.pass.cpp b/libcxx/test/std/containers/sequences/array/at.pass.cpp
new file mode 100644
index 00000000000..b5cf8a5aaa8
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/at.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// reference operator[] (size_type)
+// const_reference operator[] (size_type); // constexpr in C++14
+// reference at (size_type)
+// const_reference at (size_type); // constexpr in C++14
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+ C::reference r1 = c.at(0);
+ assert(r1 == 1);
+ r1 = 5.5;
+ assert(c.front() == 5.5);
+
+ C::reference r2 = c.at(2);
+ assert(r2 == 3.5);
+ r2 = 7.5;
+ assert(c.back() == 7.5);
+
+ try { (void) c.at(3); }
+ catch (const std::out_of_range &) {}
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ const C c = {1, 2, 3.5};
+ C::const_reference r1 = c.at(0);
+ assert(r1 == 1);
+
+ C::const_reference r2 = c.at(2);
+ assert(r2 == 3.5);
+
+ try { (void) c.at(3); }
+ catch (const std::out_of_range &) {}
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ constexpr C c = {1, 2, 3.5};
+
+ constexpr T t1 = c.at(0);
+ static_assert (t1 == 1, "");
+
+ constexpr T t2 = c.at(2);
+ static_assert (t2 == 3.5, "");
+ }
+#endif
+
+}
diff --git a/libcxx/test/std/containers/sequences/array/begin.pass.cpp b/libcxx/test/std/containers/sequences/array/begin.pass.cpp
new file mode 100644
index 00000000000..9cba0d6fceb
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/begin.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// iterator begin();
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+ C::iterator i;
+ i = c.begin();
+ assert(*i == 1);
+ assert(&*i == c.data());
+ *i = 5.5;
+ assert(c[0] == 5.5);
+ }
+ {
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/array/front_back.pass.cpp b/libcxx/test/std/containers/sequences/array/front_back.pass.cpp
new file mode 100644
index 00000000000..45a963b9947
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/front_back.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// reference front();
+// reference back();
+// const_reference front(); // constexpr in C++14
+// const_reference back(); // constexpr in C++14
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+
+ C::reference r1 = c.front();
+ assert(r1 == 1);
+ r1 = 5.5;
+ assert(c[0] == 5.5);
+
+ C::reference r2 = c.back();
+ assert(r2 == 3.5);
+ r2 = 7.5;
+ assert(c[2] == 7.5);
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ const C c = {1, 2, 3.5};
+ C::const_reference r1 = c.front();
+ assert(r1 == 1);
+
+ C::const_reference r2 = c.back();
+ assert(r2 == 3.5);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ constexpr C c = {1, 2, 3.5};
+
+ constexpr T t1 = c.front();
+ static_assert (t1 == 1, "");
+
+ constexpr T t2 = c.back();
+ static_assert (t2 == 3.5, "");
+ }
+#endif
+
+}
diff --git a/libcxx/test/std/containers/sequences/array/indexing.pass.cpp b/libcxx/test/std/containers/sequences/array/indexing.pass.cpp
new file mode 100644
index 00000000000..e4dda0dc5cf
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/indexing.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// reference operator[] (size_type)
+// const_reference operator[] (size_type); // constexpr in C++14
+// reference at (size_type)
+// const_reference at (size_type); // constexpr in C++14
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+ C::reference r1 = c[0];
+ assert(r1 == 1);
+ r1 = 5.5;
+ assert(c.front() == 5.5);
+
+ C::reference r2 = c[2];
+ assert(r2 == 3.5);
+ r2 = 7.5;
+ assert(c.back() == 7.5);
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ const C c = {1, 2, 3.5};
+ C::const_reference r1 = c[0];
+ assert(r1 == 1);
+ C::const_reference r2 = c[2];
+ assert(r2 == 3.5);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ constexpr C c = {1, 2, 3.5};
+
+ constexpr T t1 = c[0];
+ static_assert (t1 == 1, "");
+
+ constexpr T t2 = c[2];
+ static_assert (t2 == 3.5, "");
+ }
+#endif
+
+}
diff --git a/libcxx/test/std/containers/sequences/array/iterators.pass.cpp b/libcxx/test/std/containers/sequences/array/iterators.pass.cpp
new file mode 100644
index 00000000000..98997d8c26d
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/iterators.pass.cpp
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// iterator, const_iterator
+
+#include <array>
+#include <iterator>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::array<int, 5> C;
+ C c;
+ C::iterator i;
+ i = c.begin();
+ C::const_iterator j;
+ j = c.cbegin();
+ assert(i == j);
+ }
+ {
+ typedef std::array<int, 0> C;
+ C c;
+ C::iterator i;
+ i = c.begin();
+ C::const_iterator j;
+ j = c.cbegin();
+ assert(i == j);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ {
+ typedef std::array<int, 5> C;
+ C::iterator ii1{}, ii2{};
+ C::iterator ii4 = ii1;
+ C::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+ assert ( ii1 == cii );
+
+ assert ( !(ii1 != ii2 ));
+ assert ( !(ii1 != cii ));
+
+ C c;
+ assert ( c.begin() == std::begin(c));
+ assert ( c.cbegin() == std::cbegin(c));
+ assert ( c.rbegin() == std::rbegin(c));
+ assert ( c.crbegin() == std::crbegin(c));
+ assert ( c.end() == std::end(c));
+ assert ( c.cend() == std::cend(c));
+ assert ( c.rend() == std::rend(c));
+ assert ( c.crend() == std::crend(c));
+
+ assert ( std::begin(c) != std::end(c));
+ assert ( std::rbegin(c) != std::rend(c));
+ assert ( std::cbegin(c) != std::cend(c));
+ assert ( std::crbegin(c) != std::crend(c));
+ }
+ {
+ typedef std::array<int, 0> C;
+ C::iterator ii1{}, ii2{};
+ C::iterator ii4 = ii1;
+ C::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+
+ assert (!(ii1 != ii2 ));
+
+ assert ( (ii1 == cii ));
+ assert ( (cii == ii1 ));
+ assert (!(ii1 != cii ));
+ assert (!(cii != ii1 ));
+ assert (!(ii1 < cii ));
+ assert (!(cii < ii1 ));
+ assert ( (ii1 <= cii ));
+ assert ( (cii <= ii1 ));
+ assert (!(ii1 > cii ));
+ assert (!(cii > ii1 ));
+ assert ( (ii1 >= cii ));
+ assert ( (cii >= ii1 ));
+ assert (cii - ii1 == 0);
+ assert (ii1 - cii == 0);
+
+ C c;
+ assert ( c.begin() == std::begin(c));
+ assert ( c.cbegin() == std::cbegin(c));
+ assert ( c.rbegin() == std::rbegin(c));
+ assert ( c.crbegin() == std::crbegin(c));
+ assert ( c.end() == std::end(c));
+ assert ( c.cend() == std::cend(c));
+ assert ( c.rend() == std::rend(c));
+ assert ( c.crend() == std::crend(c));
+
+ assert ( std::begin(c) == std::end(c));
+ assert ( std::rbegin(c) == std::rend(c));
+ assert ( std::cbegin(c) == std::cend(c));
+ assert ( std::crbegin(c) == std::crend(c));
+ }
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/array/types.pass.cpp b/libcxx/test/std/containers/sequences/array/types.pass.cpp
new file mode 100644
index 00000000000..065ade959d0
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/types.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <class T, size_t N >
+// struct array
+// {
+// // types:
+// typedef T& reference;
+// typedef const T& const_reference;
+// typedef implementation defined iterator;
+// typedef implementation defined const_iterator;
+// typedef T value_type;
+// typedef T* pointer;
+// typedef size_t size_type;
+// typedef ptrdiff_t difference_type;
+// typedef T value_type;
+// typedef std::reverse_iterator<iterator> reverse_iterator;
+// typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+
+#include <array>
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 10> C;
+ static_assert((std::is_same<C::reference, T&>::value), "");
+ static_assert((std::is_same<C::const_reference, const T&>::value), "");
+ static_assert((std::is_same<C::iterator, T*>::value), "");
+ static_assert((std::is_same<C::const_iterator, const T*>::value), "");
+ static_assert((std::is_same<C::pointer, T*>::value), "");
+ static_assert((std::is_same<C::const_pointer, const T*>::value), "");
+ static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<C::reverse_iterator, std::reverse_iterator<C::iterator> >::value), "");
+ static_assert((std::is_same<C::const_reverse_iterator, std::reverse_iterator<C::const_iterator> >::value), "");
+ }
+ {
+ typedef int* T;
+ typedef std::array<T, 0> C;
+ static_assert((std::is_same<C::reference, T&>::value), "");
+ static_assert((std::is_same<C::const_reference, const T&>::value), "");
+ static_assert((std::is_same<C::iterator, T*>::value), "");
+ static_assert((std::is_same<C::const_iterator, const T*>::value), "");
+ static_assert((std::is_same<C::pointer, T*>::value), "");
+ static_assert((std::is_same<C::const_pointer, const T*>::value), "");
+ static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<C::reverse_iterator, std::reverse_iterator<C::iterator> >::value), "");
+ static_assert((std::is_same<C::const_reverse_iterator, std::reverse_iterator<C::const_iterator> >::value), "");
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/array/version.pass.cpp b/libcxx/test/std/containers/sequences/array/version.pass.cpp
new file mode 100644
index 00000000000..b89a8dd8cca
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+#include <array>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
OpenPOWER on IntegriCloud