Remove complex arrays

This can be done with structs in an array_t
This commit is contained in:
2024-07-31 17:51:32 +02:00
parent c9670fcfc2
commit eca05f5c24
3 changed files with 1 additions and 333 deletions

View File

@@ -86,91 +86,3 @@ TEST(array, Set_Get_array_2d)
array_2d_free(x);
}
TEST(array, array_c_s_init)
{
array_c_s_t* x = array_c_s_init(2, sizeof(double));
EXPECT_EQ(array_c_s_get_rows(x), 2);
EXPECT_EQ(ARRAY_C_GET_REAL(x, 0, double), 0);
EXPECT_EQ(ARRAY_C_GET_REAL(x, 1, double), 0);
EXPECT_EQ(ARRAY_C_GET_IMAG(x, 0, double), 0);
EXPECT_EQ(ARRAY_C_GET_IMAG(x, 1, double), 0);
array_c_s_free(x);
}
TEST(array, Set_Get_array_C_S)
{
array_c_s_t* x = array_c_s_init(2, sizeof(double));
double _real = 1;
double _imaginary = 2;
array_c_s_set(x, 0, &_real, &_imaginary);
_real = 3;
_imaginary = 4;
array_c_s_set(x, 1, &_real, &_imaginary);
testing::internal::CaptureStderr();
array_c_s_set(x, 2, &_real, &_imaginary);
std::string output = testing::internal::GetCapturedStderr();
EXPECT_EQ(output, "array_c_s_set: index out of bounds: 2 > 2\n");
EXPECT_EQ(ARRAY_C_GET_REAL(x, 0, double), 1);
EXPECT_EQ(ARRAY_C_GET_IMAG(x, 0, double), 2);
EXPECT_EQ(ARRAY_C_GET_REAL(x, 1, double), 3);
EXPECT_EQ(ARRAY_C_GET_IMAG(x, 1, double), 4);
testing::internal::CaptureStderr();
array_c_get_real(x, 2);
output = testing::internal::GetCapturedStderr();
EXPECT_EQ(output, "array_c_get_real: index out of bounds: 2 > 2\n");
testing::internal::CaptureStderr();
array_c_get_imag(x, 2);
output = testing::internal::GetCapturedStderr();
EXPECT_EQ(output, "array_c_get_imag: index out of bounds: 2 > 2\n");
array_c_s_free(x);
}
TEST(array, array_c_p_init)
{
array_c_p_t* x = array_c_p_init(2, sizeof(double));
EXPECT_EQ(array_c_p_get_rows(x), 2);
EXPECT_EQ(ARRAY_C_GET_MAG(x, 0, double), 0);
EXPECT_EQ(ARRAY_C_GET_MAG(x, 1, double), 0);
EXPECT_EQ(ARRAY_C_GET_PHASE(x, 0, double), 0);
EXPECT_EQ(ARRAY_C_GET_PHASE(x, 1, double), 0);
array_c_p_free(x);
}
TEST(array, Set_Get_array_C_P)
{
array_c_p_t* x = array_c_p_init(2, sizeof(double));
double _mag = 1;
double _phase = 2;
array_c_p_set(x, 0, &_mag, &_phase);
_mag = 3;
_phase = 4;
array_c_p_set(x, 1, &_mag, &_phase);
testing::internal::CaptureStderr();
array_c_p_set(x, 2, &_mag, &_phase);
std::string output = testing::internal::GetCapturedStderr();
EXPECT_EQ(output, "array_c_p_set: index out of bounds: 2 > 2\n");
EXPECT_EQ(ARRAY_C_GET_MAG(x, 0, double), 1);
EXPECT_EQ(ARRAY_C_GET_PHASE(x, 0, double), 2);
EXPECT_EQ(ARRAY_C_GET_MAG(x, 1, double), 3);
EXPECT_EQ(ARRAY_C_GET_PHASE(x, 1, double), 4);
testing::internal::CaptureStderr();
array_c_get_phase(x, 2);
output = testing::internal::GetCapturedStderr();
EXPECT_EQ(output, "array_c_get_phase: index out of bounds: 2 > 2\n");
testing::internal::CaptureStderr();
array_c_get_mag(x, 2);
output = testing::internal::GetCapturedStderr();
EXPECT_EQ(output, "array_c_get_mag: index out of bounds: 2 > 2\n");
array_c_p_free(x);
}