Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / test / std / numerics / numarray / template.valarray / valarray.cons / move.pass.cpp
blob4c2101c39c8943fbedaa863b117bf4f95debb925
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 // UNSUPPORTED: c++03
11 // <valarray>
13 // template<class T> class valarray;
15 // valarray(const valarray<value_type>& v);
17 #include <valarray>
18 #include <utility>
19 #include <cassert>
20 #include <cstddef>
22 #include "test_macros.h"
24 int main(int, char**)
27 typedef int T;
28 T a[] = {1, 2, 3, 4, 5};
29 const unsigned N = sizeof(a)/sizeof(a[0]);
30 std::valarray<T> v(a, N);
31 std::valarray<T> v2 = std::move(v);
32 assert(v2.size() == N);
33 assert(v.size() == 0);
34 for (std::size_t i = 0; i < v2.size(); ++i)
35 assert(v2[i] == a[i]);
38 typedef double T;
39 T a[] = {1, 2.5, 3, 4.25, 5};
40 const unsigned N = sizeof(a)/sizeof(a[0]);
41 std::valarray<T> v(a, N);
42 std::valarray<T> v2 = std::move(v);
43 assert(v2.size() == N);
44 assert(v.size() == 0);
45 for (std::size_t i = 0; i < v2.size(); ++i)
46 assert(v2[i] == a[i]);
49 typedef std::valarray<double> T;
50 T a[] = {T(1), T(2), T(3), T(4), T(5)};
51 const unsigned N = sizeof(a)/sizeof(a[0]);
52 std::valarray<T> v(a, N);
53 std::valarray<T> v2 = std::move(v);
54 assert(v2.size() == N);
55 assert(v.size() == 0);
56 for (unsigned i = 0; i < N; ++i)
58 assert(v2[i].size() == a[i].size());
59 for (std::size_t j = 0; j < v2[i].size(); ++j)
60 assert(v2[i][j] == a[i][j]);
64 return 0;