From 5a83710e371fe68a06e6e3876c6a2c8b820a8976 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Sat, 20 Dec 2014 01:40:03 +0000 Subject: Move test into test/std subdirectory. llvm-svn: 224658 --- .../dynarray/dynarray.overview/indexing.pass.cpp | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 libcxx/test/std/containers/sequences/dynarray/dynarray.overview/indexing.pass.cpp (limited to 'libcxx/test/std/containers/sequences/dynarray/dynarray.overview/indexing.pass.cpp') diff --git a/libcxx/test/std/containers/sequences/dynarray/dynarray.overview/indexing.pass.cpp b/libcxx/test/std/containers/sequences/dynarray/dynarray.overview/indexing.pass.cpp new file mode 100644 index 00000000000..7317a2023cb --- /dev/null +++ b/libcxx/test/std/containers/sequences/dynarray/dynarray.overview/indexing.pass.cpp @@ -0,0 +1,71 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// dynarray.overview + +// const_reference at(size_type n) const; +// reference at(size_type n); + +#include <__config> + +#if _LIBCPP_STD_VER > 11 + +#include +#include + +#include +#include +#include + +using std::experimental::dynarray; + +template +void dyn_test_const ( const dynarray &dyn, const std::initializer_list &vals ) { + const T *data = dyn.data (); + auto it = vals.begin (); + for ( size_t i = 0; i < dyn.size(); ++i, ++it ) { + assert ( data + i == &dyn[i]); + assert ( *it == dyn[i]); + } + } + +template +void dyn_test ( dynarray &dyn, const std::initializer_list &vals ) { + T *data = dyn.data (); + auto it = vals.begin (); + for ( size_t i = 0; i < dyn.size(); ++i, ++it ) { + assert ( data + i == &dyn[i]); + assert ( *it == dyn[i]); + } + } + + +template +void test ( std::initializer_list vals ) { + typedef dynarray dynA; + + dynA d1 ( vals ); + dyn_test ( d1, vals ); + dyn_test_const ( d1, vals ); + } + +int main() +{ + test ( { 1, 1, 2, 3, 5, 8 } ); + test ( { 1., 1., 2., 3., 5., 8. } ); + test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"), + std::string("5"), std::string("8")} ); + + test ( {} ); + test> ( {} ); + test ( {} ); +} +#else +int main() {} +#endif -- cgit v1.2.3