summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/language.support/support.initlist
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/language.support/support.initlist
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/language.support/support.initlist')
-rw-r--r--libcxx/test/std/language.support/support.initlist/support.initlist.access/access.pass.cpp62
-rw-r--r--libcxx/test/std/language.support/support.initlist/support.initlist.cons/default.pass.cpp29
-rw-r--r--libcxx/test/std/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp59
-rw-r--r--libcxx/test/std/language.support/support.initlist/types.pass.cpp37
-rw-r--r--libcxx/test/std/language.support/support.initlist/version.pass.cpp20
5 files changed, 207 insertions, 0 deletions
diff --git a/libcxx/test/std/language.support/support.initlist/support.initlist.access/access.pass.cpp b/libcxx/test/std/language.support/support.initlist/support.initlist.access/access.pass.cpp
new file mode 100644
index 00000000000..2f0720639c6
--- /dev/null
+++ b/libcxx/test/std/language.support/support.initlist/support.initlist.access/access.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.
+//
+//===----------------------------------------------------------------------===//
+
+// template<class E> class initializer_list;
+
+// const E* begin() const;
+// const E* end() const;
+// size_t size() const;
+
+#include <initializer_list>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+struct A
+{
+ A(std::initializer_list<int> il)
+ {
+ const int* b = il.begin();
+ const int* e = il.end();
+ assert(il.size() == 3);
+ assert(e - b == il.size());
+ assert(*b++ == 3);
+ assert(*b++ == 2);
+ assert(*b++ == 1);
+ }
+};
+
+#if _LIBCPP_STD_VER > 11
+struct B
+{
+ constexpr B(std::initializer_list<int> il)
+ {
+ const int* b = il.begin();
+ const int* e = il.end();
+ assert(il.size() == 3);
+ assert(e - b == il.size());
+ assert(*b++ == 3);
+ assert(*b++ == 2);
+ assert(*b++ == 1);
+ }
+};
+
+#endif // _LIBCPP_STD_VER > 11
+
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ A test1 = {3, 2, 1};
+#endif
+#if _LIBCPP_STD_VER > 11
+ constexpr B test2 = {3, 2, 1};
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/libcxx/test/std/language.support/support.initlist/support.initlist.cons/default.pass.cpp b/libcxx/test/std/language.support/support.initlist/support.initlist.cons/default.pass.cpp
new file mode 100644
index 00000000000..7822a62206a
--- /dev/null
+++ b/libcxx/test/std/language.support/support.initlist/support.initlist.cons/default.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.
+//
+//===----------------------------------------------------------------------===//
+
+// template<class E> class initializer_list;
+
+// initializer_list();
+
+#include <initializer_list>
+#include <cassert>
+
+struct A {};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ std::initializer_list<A> il;
+ assert(il.size() == 0);
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#if _LIBCPP_STD_VER > 11
+ constexpr std::initializer_list<A> il2;
+ static_assert(il2.size() == 0, "");
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/libcxx/test/std/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp b/libcxx/test/std/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp
new file mode 100644
index 00000000000..5fcd28f9156
--- /dev/null
+++ b/libcxx/test/std/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <initializer_list>
+
+// template<class E> const E* begin(initializer_list<E> il);
+
+#include <initializer_list>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+struct A
+{
+ A(std::initializer_list<int> il)
+ {
+ const int* b = begin(il);
+ const int* e = end(il);
+ assert(il.size() == 3);
+ assert(e - b == il.size());
+ assert(*b++ == 3);
+ assert(*b++ == 2);
+ assert(*b++ == 1);
+ }
+};
+
+#if _LIBCPP_STD_VER > 11
+struct B
+{
+ constexpr B(std::initializer_list<int> il)
+ {
+ const int* b = begin(il);
+ const int* e = end(il);
+ assert(il.size() == 3);
+ assert(e - b == il.size());
+ assert(*b++ == 3);
+ assert(*b++ == 2);
+ assert(*b++ == 1);
+ }
+};
+
+#endif // _LIBCPP_STD_VER > 11
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ A test1 = {3, 2, 1};
+#endif
+#if _LIBCPP_STD_VER > 11
+ constexpr B test2 = {3, 2, 1};
+#endif // _LIBCPP_STD_VER > 11
+}
diff --git a/libcxx/test/std/language.support/support.initlist/types.pass.cpp b/libcxx/test/std/language.support/support.initlist/types.pass.cpp
new file mode 100644
index 00000000000..835830055ff
--- /dev/null
+++ b/libcxx/test/std/language.support/support.initlist/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// template<class E>
+// class initializer_list
+// {
+// public:
+// typedef E value_type;
+// typedef const E& reference;
+// typedef const E& const_reference;
+// typedef size_t size_type;
+//
+// typedef const E* iterator;
+// typedef const E* const_iterator;
+
+#include <initializer_list>
+#include <type_traits>
+
+struct A {};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ static_assert((std::is_same<std::initializer_list<A>::value_type, A>::value), "");
+ static_assert((std::is_same<std::initializer_list<A>::reference, const A&>::value), "");
+ static_assert((std::is_same<std::initializer_list<A>::const_reference, const A&>::value), "");
+ static_assert((std::is_same<std::initializer_list<A>::size_type, std::size_t>::value), "");
+ static_assert((std::is_same<std::initializer_list<A>::iterator, const A*>::value), "");
+ static_assert((std::is_same<std::initializer_list<A>::const_iterator, const A*>::value), "");
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/language.support/support.initlist/version.pass.cpp b/libcxx/test/std/language.support/support.initlist/version.pass.cpp
new file mode 100644
index 00000000000..f3f08cd1f86
--- /dev/null
+++ b/libcxx/test/std/language.support/support.initlist/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <initializer_list>
+
+#include <initializer_list>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
OpenPOWER on IntegriCloud