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 --- .../valarray.members/apply_value.pass.cpp | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 libcxx/test/std/numerics/numarray/template.valarray/valarray.members/apply_value.pass.cpp (limited to 'libcxx/test/std/numerics/numarray/template.valarray/valarray.members/apply_value.pass.cpp') diff --git a/libcxx/test/std/numerics/numarray/template.valarray/valarray.members/apply_value.pass.cpp b/libcxx/test/std/numerics/numarray/template.valarray/valarray.members/apply_value.pass.cpp new file mode 100644 index 00000000000..dc7a1a100a2 --- /dev/null +++ b/libcxx/test/std/numerics/numarray/template.valarray/valarray.members/apply_value.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// 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 valarray; + +// valarray apply(value_type f(value_type)) const; + +#include +#include + +typedef int T; + +T f(T t) {return t + 5;} + +int main() +{ + { + T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + T a2[] = {6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; + const unsigned N1 = sizeof(a1)/sizeof(a1[0]); + std::valarray v1(a1, N1); + std::valarray v2 = v1.apply(f); + assert(v2.size() == N1); + for (unsigned i = 0; i < N1; ++i) + assert(v2[i] == a2[i]); + } + { + const unsigned N1 = 0; + std::valarray v1; + std::valarray v2 = v1.apply(f); + assert(v2.size() == N1); + } + { + T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + T a2[] = {7, 9, 11, 13, 15, 17, 19, 21, 23, 25}; + const unsigned N1 = sizeof(a1)/sizeof(a1[0]); + std::valarray v1(a1, N1); + std::valarray v2 = (v1+v1).apply(f); + assert(v2.size() == N1); + for (unsigned i = 0; i < N1; ++i) + assert(v2[i] == a2[i]); + } +} -- cgit v1.2.3