1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
11 // template<class T> class valarray;
13 // void swap(valarray& v);
19 #include "test_macros.h"
25 T a1
[] = {1, 2, 3, 4, 5};
26 T a2
[] = {6, 7, 8, 9, 10, 11, 12};
27 const unsigned N1
= sizeof(a1
)/sizeof(a1
[0]);
28 const unsigned N2
= sizeof(a2
)/sizeof(a2
[0]);
29 std::valarray
<T
> v1(a1
, N1
);
30 std::valarray
<T
> v2(a2
, N2
);
31 std::valarray
<T
> v1_save
= v1
;
32 std::valarray
<T
> v2_save
= v2
;
34 assert(v1
.size() == v2_save
.size());
35 for (std::size_t i
= 0; i
< v1
.size(); ++i
)
36 assert(v1
[i
] == v2_save
[i
]);
37 assert(v2
.size() == v1_save
.size());
38 for (std::size_t i
= 0; i
< v2
.size(); ++i
)
39 assert(v2
[i
] == v1_save
[i
]);
43 T a1
[] = {1, 2, 3, 4, 5};
44 const unsigned N1
= sizeof(a1
)/sizeof(a1
[0]);
45 std::valarray
<T
> v1(a1
, N1
);
47 std::valarray
<T
> v1_save
= v1
;
48 std::valarray
<T
> v2_save
= v2
;
50 assert(v1
.size() == v2_save
.size());
51 for (std::size_t i
= 0; i
< v1
.size(); ++i
)
52 assert(v1
[i
] == v2_save
[i
]);
53 assert(v2
.size() == v1_save
.size());
54 for (std::size_t i
= 0; i
< v2
.size(); ++i
)
55 assert(v2
[i
] == v1_save
[i
]);
59 T a2
[] = {6, 7, 8, 9, 10, 11, 12};
60 const unsigned N2
= sizeof(a2
)/sizeof(a2
[0]);
62 std::valarray
<T
> v2(a2
, N2
);
63 std::valarray
<T
> v1_save
= v1
;
64 std::valarray
<T
> v2_save
= v2
;
66 assert(v1
.size() == v2_save
.size());
67 for (std::size_t i
= 0; i
< v1
.size(); ++i
)
68 assert(v1
[i
] == v2_save
[i
]);
69 assert(v2
.size() == v1_save
.size());
70 for (std::size_t i
= 0; i
< v2
.size(); ++i
)
71 assert(v2
[i
] == v1_save
[i
]);
77 std::valarray
<T
> v1_save
= v1
;
78 std::valarray
<T
> v2_save
= v2
;
80 assert(v1
.size() == v2_save
.size());
81 for (std::size_t i
= 0; i
< v1
.size(); ++i
)
82 assert(v1
[i
] == v2_save
[i
]);
83 assert(v2
.size() == v1_save
.size());
84 for (std::size_t i
= 0; i
< v2
.size(); ++i
)
85 assert(v2
[i
] == v1_save
[i
]);