Initial commit

This commit is contained in:
Yervant7
2024-01-16 19:28:29 -03:00
commit 8c0524dc0f
9054 changed files with 1081727 additions and 0 deletions
@@ -0,0 +1,89 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <valarray>
// template<class T> class valarray;
// valarray& operator=(const valarray& v);
#include <valarray>
#include <cassert>
#include <cstddef>
#include "test_macros.h"
struct S
{
S() : x_(0) { default_ctor_called = true; }
S(int x) : x_(x) {}
int x_;
static bool default_ctor_called;
};
bool S::default_ctor_called = false;
bool operator==(const S& lhs, const S& rhs)
{
return lhs.x_ == rhs.x_;
}
int main(int, char**)
{
{
typedef int T;
T a[] = {1, 2, 3, 4, 5};
const unsigned N = sizeof(a)/sizeof(a[0]);
std::valarray<T> v(a, N);
std::valarray<T> v2;
v2 = v;
assert(v2.size() == v.size());
for (std::size_t i = 0; i < v2.size(); ++i)
assert(v2[i] == v[i]);
}
{
typedef double T;
T a[] = {1, 2.5, 3, 4.25, 5};
const unsigned N = sizeof(a)/sizeof(a[0]);
std::valarray<T> v(a, N);
std::valarray<T> v2;
v2 = v;
assert(v2.size() == v.size());
for (std::size_t i = 0; i < v2.size(); ++i)
assert(v2[i] == v[i]);
}
{
typedef std::valarray<double> T;
T a[] = {T(1), T(2), T(3), T(4), T(5)};
const unsigned N = sizeof(a)/sizeof(a[0]);
std::valarray<T> v(a, N);
std::valarray<T> v2(a, N-2);
v2 = v;
assert(v2.size() == v.size());
for (unsigned i = 0; i < N; ++i)
{
assert(v2[i].size() == v[i].size());
for (std::size_t j = 0; j < v[i].size(); ++j)
assert(v2[i][j] == v[i][j]);
}
}
{
typedef S T;
T a[] = {T(1), T(2), T(3), T(4), T(5)};
const unsigned N = sizeof(a)/sizeof(a[0]);
std::valarray<T> v(a, N);
std::valarray<T> v2;
v2 = v;
assert(v2.size() == v.size());
for (std::size_t i = 0; i < v2.size(); ++i)
assert(v2[i] == v[i]);
assert(!S::default_ctor_called);
}
return 0;
}
@@ -0,0 +1,61 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <valarray>
// template<class T> class valarray;
// valarray& operator=(const gslice_array<value_type>& ga);
#include <valarray>
#include <cassert>
#include "test_macros.h"
int main(int, char**)
{
int a[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
36, 37, 38, 39, 40};
std::valarray<int> v1(a, sizeof(a)/sizeof(a[0]));
std::size_t sz[] = {2, 4, 3};
std::size_t st[] = {19, 4, 1};
typedef std::valarray<std::size_t> sizes;
typedef std::valarray<std::size_t> strides;
std::valarray<int> v(24);
v = v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
strides(st, sizeof(st)/sizeof(st[0])))];
assert(v.size() == 24);
assert(v[ 0] == 3);
assert(v[ 1] == 4);
assert(v[ 2] == 5);
assert(v[ 3] == 7);
assert(v[ 4] == 8);
assert(v[ 5] == 9);
assert(v[ 6] == 11);
assert(v[ 7] == 12);
assert(v[ 8] == 13);
assert(v[ 9] == 15);
assert(v[10] == 16);
assert(v[11] == 17);
assert(v[12] == 22);
assert(v[13] == 23);
assert(v[14] == 24);
assert(v[15] == 26);
assert(v[16] == 27);
assert(v[17] == 28);
assert(v[18] == 30);
assert(v[19] == 31);
assert(v[20] == 32);
assert(v[21] == 34);
assert(v[22] == 35);
assert(v[23] == 36);
return 0;
}
@@ -0,0 +1,61 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <valarray>
// template<class T> class valarray;
// valarray& operator=(const indirect_array<value_type>& ia);
#include <valarray>
#include <cassert>
#include "test_macros.h"
int main(int, char**)
{
int a[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
36, 37, 38, 39, 40};
const std::size_t N1 = sizeof(a)/sizeof(a[0]);
std::size_t s[] = { 3, 4, 5, 7, 8, 9, 11, 12, 13, 15, 16, 17,
22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
const std::size_t S = sizeof(s)/sizeof(s[0]);
std::valarray<int> v1(a, N1);
std::valarray<std::size_t> ia(s, S);
std::valarray<int> v(24);
v = v1[ia];
assert(v.size() == 24);
assert(v[ 0] == 3);
assert(v[ 1] == 4);
assert(v[ 2] == 5);
assert(v[ 3] == 7);
assert(v[ 4] == 8);
assert(v[ 5] == 9);
assert(v[ 6] == 11);
assert(v[ 7] == 12);
assert(v[ 8] == 13);
assert(v[ 9] == 15);
assert(v[10] == 16);
assert(v[11] == 17);
assert(v[12] == 22);
assert(v[13] == 23);
assert(v[14] == 24);
assert(v[15] == 26);
assert(v[16] == 27);
assert(v[17] == 28);
assert(v[18] == 30);
assert(v[19] == 31);
assert(v[20] == 32);
assert(v[21] == 34);
assert(v[22] == 35);
assert(v[23] == 36);
return 0;
}
@@ -0,0 +1,87 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03
// <valarray>
// template<class T> class valarray;
// valarray& operator=(initializer_list<value_type> il);
#include <valarray>
#include <cassert>
#include <cstddef>
#include "test_macros.h"
struct S
{
S() : x_(0) { default_ctor_called = true; }
S(int x) : x_(x) {}
int x_;
static bool default_ctor_called;
};
bool S::default_ctor_called = false;
bool operator==(const S& lhs, const S& rhs)
{
return lhs.x_ == rhs.x_;
}
int main(int, char**)
{
{
typedef int T;
T a[] = {1, 2, 3, 4, 5};
const unsigned N = sizeof(a)/sizeof(a[0]);
std::valarray<T> v2;
v2 = {1, 2, 3, 4, 5};
assert(v2.size() == N);
for (std::size_t i = 0; i < v2.size(); ++i)
assert(v2[i] == a[i]);
}
{
typedef double T;
T a[] = {1, 2.5, 3, 4.25, 5};
const unsigned N = sizeof(a)/sizeof(a[0]);
std::valarray<T> v2;
v2 = {1, 2.5, 3, 4.25, 5};
assert(v2.size() == N);
for (std::size_t i = 0; i < v2.size(); ++i)
assert(v2[i] == a[i]);
}
{
typedef std::valarray<double> T;
T a[] = {T(1), T(2), T(3), T(4), T(5)};
const unsigned N = sizeof(a)/sizeof(a[0]);
std::valarray<T> v2(a, N-2);
v2 = {T(1), T(2), T(3), T(4), T(5)};
assert(v2.size() == N);
for (unsigned i = 0; i < N; ++i)
{
assert(v2[i].size() == a[i].size());
for (std::size_t j = 0; j < a[i].size(); ++j)
assert(v2[i][j] == a[i][j]);
}
}
{
typedef S T;
T a[] = {T(1), T(2), T(3), T(4), T(5)};
const unsigned N = sizeof(a)/sizeof(a[0]);
std::valarray<T> v2;
v2 = {T(1), T(2), T(3), T(4), T(5)};
assert(v2.size() == N);
for (std::size_t i = 0; i < v2.size(); ++i)
assert(v2[i] == a[i]);
assert(!S::default_ctor_called);
}
return 0;
}
@@ -0,0 +1,38 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <valarray>
// template<class T> class valarray;
// valarray& operator=(const mask_array<value_type>& ma);
#include <valarray>
#include <cassert>
#include "test_macros.h"
int main(int, char**)
{
int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
bool b[N1] = {true, false, false, true, true, false,
false, true, false, false, false, true};
std::valarray<int> v1(a1, N1);
std::valarray<bool> vb(b, N1);
std::valarray<int> v2(5);
v2 = v1[vb];
assert(v2.size() == 5);
assert(v2[ 0] == 0);
assert(v2[ 1] == 3);
assert(v2[ 2] == 4);
assert(v2[ 3] == 7);
assert(v2[ 4] == 11);
return 0;
}
@@ -0,0 +1,67 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03
// <valarray>
// template<class T> class valarray;
// valarray& operator=(valarray&& v);
#include <valarray>
#include <cassert>
#include <cstddef>
#include "test_macros.h"
int main(int, char**)
{
{
typedef int T;
T a[] = {1, 2, 3, 4, 5};
const unsigned N = sizeof(a)/sizeof(a[0]);
std::valarray<T> v(a, N);
std::valarray<T> v2;
v2 = std::move(v);
assert(v2.size() == N);
assert(v.size() == 0);
for (std::size_t i = 0; i < v2.size(); ++i)
assert(v2[i] == a[i]);
}
{
typedef double T;
T a[] = {1, 2.5, 3, 4.25, 5};
const unsigned N = sizeof(a)/sizeof(a[0]);
std::valarray<T> v(a, N);
std::valarray<T> v2;
v2 = std::move(v);
assert(v2.size() == N);
assert(v.size() == 0);
for (std::size_t i = 0; i < v2.size(); ++i)
assert(v2[i] == a[i]);
}
{
typedef std::valarray<double> T;
T a[] = {T(1), T(2), T(3), T(4), T(5)};
const unsigned N = sizeof(a)/sizeof(a[0]);
std::valarray<T> v(a, N);
std::valarray<T> v2(a, N-2);
v2 = std::move(v);
assert(v2.size() == N);
assert(v.size() == 0);
for (unsigned i = 0; i < N; ++i)
{
assert(v2[i].size() == a[i].size());
for (std::size_t j = 0; j < a[i].size(); ++j)
assert(v2[i][j] == a[i][j]);
}
}
return 0;
}
@@ -0,0 +1,34 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <valarray>
// template<class T> class valarray;
// valarray& operator=(const slice_array<value_type>& sa);
#include <valarray>
#include <cassert>
#include "test_macros.h"
int main(int, char**)
{
int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
std::valarray<int> v1(a, sizeof(a)/sizeof(a[0]));
std::valarray<int> v(5);
v = v1[std::slice(1, 5, 3)];
assert(v.size() == 5);
assert(v[0] == 1);
assert(v[1] == 4);
assert(v[2] == 7);
assert(v[3] == 10);
assert(v[4] == 13);
return 0;
}
@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <valarray>
// template<class T> class valarray;
// valarray& operator=(const value_type& x);
// Validate whether the container can be copy-assigned with an ADL-hijacking operator&
#include <valarray>
#include "test_macros.h"
#include "operator_hijacker.h"
void test() {
std::valarray<operator_hijacker> vo;
std::valarray<operator_hijacker> v;
v = vo;
}
@@ -0,0 +1,35 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <valarray>
// template<class T> class valarray;
// valarray& operator=(const value_type& x);
#include <valarray>
#include <cassert>
#include <cstddef>
#include "test_macros.h"
int main(int, char**)
{
{
typedef int T;
T a[] = {1, 2, 3, 4, 5};
const unsigned N = sizeof(a)/sizeof(a[0]);
std::valarray<T> v(a, N);
v = 7;
assert(v.size() == N);
for (std::size_t i = 0; i < v.size(); ++i)
assert(v[i] == 7);
}
return 0;
}