summaryrefslogtreecommitdiffstats
path: root/libcxx/test/containers/sequences/array
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2010-05-11 19:42:16 +0000
committerHoward Hinnant <hhinnant@apple.com>2010-05-11 19:42:16 +0000
commit3e519524c118651123eecf60c2bbc5d65ad9bac3 (patch)
treeb2dd4168cfe448920a602cd7d2e40f95da187153 /libcxx/test/containers/sequences/array
parent9132c59d43b6c590c9bb33496eebf9f192d6857a (diff)
downloadbcm5719-llvm-3e519524c118651123eecf60c2bbc5d65ad9bac3.tar.gz
bcm5719-llvm-3e519524c118651123eecf60c2bbc5d65ad9bac3.zip
libcxx initial import
llvm-svn: 103490
Diffstat (limited to 'libcxx/test/containers/sequences/array')
-rw-r--r--libcxx/test/containers/sequences/array/array.cons/default.pass.cpp31
-rw-r--r--libcxx/test/containers/sequences/array/array.cons/initializer_list.pass.cpp34
-rw-r--r--libcxx/test/containers/sequences/array/array.data/data.pass.cpp34
-rw-r--r--libcxx/test/containers/sequences/array/array.data/data_const.pass.cpp34
-rw-r--r--libcxx/test/containers/sequences/array/array.fill/fill.pass.cpp36
-rw-r--r--libcxx/test/containers/sequences/array/array.size/size.pass.cpp31
-rw-r--r--libcxx/test/containers/sequences/array/array.special/swap.pass.cpp43
-rw-r--r--libcxx/test/containers/sequences/array/array.swap/swap.pass.cpp43
-rw-r--r--libcxx/test/containers/sequences/array/array.tuple/get.pass.cpp28
-rw-r--r--libcxx/test/containers/sequences/array/array.tuple/get_const.pass.cpp27
-rw-r--r--libcxx/test/containers/sequences/array/array.tuple/tuple_element.pass.cpp33
-rw-r--r--libcxx/test/containers/sequences/array/array.tuple/tuple_size.pass.cpp28
-rw-r--r--libcxx/test/containers/sequences/array/array.zero/tested_elsewhere.pass.cpp18
-rw-r--r--libcxx/test/containers/sequences/array/begin.pass.cpp31
-rw-r--r--libcxx/test/containers/sequences/array/types.pass.cpp62
-rw-r--r--libcxx/test/containers/sequences/array/version.pass.cpp20
16 files changed, 533 insertions, 0 deletions
diff --git a/libcxx/test/containers/sequences/array/array.cons/default.pass.cpp b/libcxx/test/containers/sequences/array/array.cons/default.pass.cpp
new file mode 100644
index 00000000000..c8fc3aafdee
--- /dev/null
+++ b/libcxx/test/containers/sequences/array/array.cons/default.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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/containers/sequences/array/array.cons/initializer_list.pass.cpp b/libcxx/test/containers/sequences/array/array.cons/initializer_list.pass.cpp
new file mode 100644
index 00000000000..f5542831009
--- /dev/null
+++ b/libcxx/test/containers/sequences/array/array.cons/initializer_list.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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/containers/sequences/array/array.data/data.pass.cpp b/libcxx/test/containers/sequences/array/array.data/data.pass.cpp
new file mode 100644
index 00000000000..147fe9eda11
--- /dev/null
+++ b/libcxx/test/containers/sequences/array/array.data/data.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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();
+ }
+}
diff --git a/libcxx/test/containers/sequences/array/array.data/data_const.pass.cpp b/libcxx/test/containers/sequences/array/array.data/data_const.pass.cpp
new file mode 100644
index 00000000000..63d2fcb410c
--- /dev/null
+++ b/libcxx/test/containers/sequences/array/array.data/data_const.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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();
+ }
+}
diff --git a/libcxx/test/containers/sequences/array/array.fill/fill.pass.cpp b/libcxx/test/containers/sequences/array/array.fill/fill.pass.cpp
new file mode 100644
index 00000000000..d8c3918446b
--- /dev/null
+++ b/libcxx/test/containers/sequences/array/array.fill/fill.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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/containers/sequences/array/array.size/size.pass.cpp b/libcxx/test/containers/sequences/array/array.size/size.pass.cpp
new file mode 100644
index 00000000000..3f9d7b9ff58
--- /dev/null
+++ b/libcxx/test/containers/sequences/array/array.size/size.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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);
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 0> C;
+ C c = {};
+ assert(c.size() == 0);
+ }
+}
diff --git a/libcxx/test/containers/sequences/array/array.special/swap.pass.cpp b/libcxx/test/containers/sequences/array/array.special/swap.pass.cpp
new file mode 100644
index 00000000000..4b0a47f1372
--- /dev/null
+++ b/libcxx/test/containers/sequences/array/array.special/swap.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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/containers/sequences/array/array.swap/swap.pass.cpp b/libcxx/test/containers/sequences/array/array.swap/swap.pass.cpp
new file mode 100644
index 00000000000..447077569f5
--- /dev/null
+++ b/libcxx/test/containers/sequences/array/array.swap/swap.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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/containers/sequences/array/array.tuple/get.pass.cpp b/libcxx/test/containers/sequences/array/array.tuple/get.pass.cpp
new file mode 100644
index 00000000000..8fc28c7db7a
--- /dev/null
+++ b/libcxx/test/containers/sequences/array/array.tuple/get.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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<1>(c) = 5.5;
+ assert(c[0] == 1);
+ assert(c[1] == 5.5);
+ assert(c[2] == 3.5);
+ }
+}
diff --git a/libcxx/test/containers/sequences/array/array.tuple/get_const.pass.cpp b/libcxx/test/containers/sequences/array/array.tuple/get_const.pass.cpp
new file mode 100644
index 00000000000..6380bc8c038
--- /dev/null
+++ b/libcxx/test/containers/sequences/array/array.tuple/get_const.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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);
+ }
+}
diff --git a/libcxx/test/containers/sequences/array/array.tuple/tuple_element.pass.cpp b/libcxx/test/containers/sequences/array/array.tuple/tuple_element.pass.cpp
new file mode 100644
index 00000000000..fd58ed76681
--- /dev/null
+++ b/libcxx/test/containers/sequences/array/array.tuple/tuple_element.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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/containers/sequences/array/array.tuple/tuple_size.pass.cpp b/libcxx/test/containers/sequences/array/array.tuple/tuple_size.pass.cpp
new file mode 100644
index 00000000000..403fbd3807d
--- /dev/null
+++ b/libcxx/test/containers/sequences/array/array.tuple/tuple_size.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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/containers/sequences/array/array.zero/tested_elsewhere.pass.cpp b/libcxx/test/containers/sequences/array/array.zero/tested_elsewhere.pass.cpp
new file mode 100644
index 00000000000..9dc64a0f46a
--- /dev/null
+++ b/libcxx/test/containers/sequences/array/array.zero/tested_elsewhere.pass.cpp
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// support for zero-sized array
+
+#include <array>
+
+int main()
+{
+}
diff --git a/libcxx/test/containers/sequences/array/begin.pass.cpp b/libcxx/test/containers/sequences/array/begin.pass.cpp
new file mode 100644
index 00000000000..98f456fc9ca
--- /dev/null
+++ b/libcxx/test/containers/sequences/array/begin.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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 = c.begin();
+ assert(*i == 1);
+ assert(&*i == c.data());
+ *i = 5.5;
+ assert(c[0] == 5.5);
+ }
+ {
+ }
+}
diff --git a/libcxx/test/containers/sequences/array/types.pass.cpp b/libcxx/test/containers/sequences/array/types.pass.cpp
new file mode 100644
index 00000000000..f1f200f4e4b
--- /dev/null
+++ b/libcxx/test/containers/sequences/array/types.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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/containers/sequences/array/version.pass.cpp b/libcxx/test/containers/sequences/array/version.pass.cpp
new file mode 100644
index 00000000000..fed0e116c86
--- /dev/null
+++ b/libcxx/test/containers/sequences/array/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+#include <array>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
OpenPOWER on IntegriCloud