[debug] Use poison instead of undef to set a killed dbg.assign address [NFC] (#119760)
[llvm-project.git] / libcxx / test / std / numerics / numarray / template.valarray / valarray.cons / size.pass.cpp
blob21d4ee15f57c63070c98fc6baf4e75fa686d6add
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // <valarray>
11 // template<class T> class valarray;
13 // explicit valarray(size_t);
15 #include <valarray>
16 #include <cassert>
18 #include "test_macros.h"
20 struct S {
21 S() : x(1) {}
22 ~S() { ++cnt_dtor; }
23 int x;
24 static std::size_t cnt_dtor;
27 size_t S::cnt_dtor = 0;
29 int main(int, char**)
32 std::valarray<int> v(100);
33 assert(v.size() == 100);
34 for (int i = 0; i < 100; ++i)
35 assert(v[i] == 0);
38 std::valarray<double> v(100);
39 assert(v.size() == 100);
40 for (int i = 0; i < 100; ++i)
41 assert(v[i] == 0);
44 std::valarray<std::valarray<double> > v(100);
45 assert(v.size() == 100);
46 for (int i = 0; i < 100; ++i)
47 assert(v[i].size() == 0);
50 std::valarray<S> v(100);
51 assert(v.size() == 100);
52 for (int i = 0; i < 100; ++i)
53 assert(v[i].x == 1);
55 assert(S::cnt_dtor == 100);
57 return 0;