mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-15 04:30:33 +00:00
Fix test in Ubuntu 16.04
This commit is contained in:
parent
2f05ba4726
commit
fcaf4cfa50
@ -66,11 +66,12 @@ TEST(MatioTest, WriteAndReadDoubles)
|
||||
matvar_read = Mat_VarRead(matfp_read, "x");
|
||||
double *x_read = reinterpret_cast<double*>(matvar_read->data);
|
||||
Mat_Close(matfp_read);
|
||||
Mat_VarFree(matvar_read);
|
||||
|
||||
for(int i = 0; i < 10; i++)
|
||||
{
|
||||
EXPECT_DOUBLE_EQ(x[i], x_read[i]);
|
||||
}
|
||||
Mat_VarFree(matvar_read);
|
||||
ASSERT_EQ(remove(filename.c_str()), 0);
|
||||
}
|
||||
|
||||
@ -79,8 +80,8 @@ TEST(MatioTest, WriteAndReadGrComplex)
|
||||
{
|
||||
// Write a .mat file
|
||||
mat_t *matfp;
|
||||
matvar_t *matvar;
|
||||
std::string filename = "./test2.mat";
|
||||
matvar_t *matvar1;
|
||||
std::string filename = "./test3.mat";
|
||||
matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73);
|
||||
ASSERT_FALSE(reinterpret_cast<long*>(matfp) == NULL) << "Error creating .mat file";
|
||||
|
||||
@ -98,15 +99,15 @@ TEST(MatioTest, WriteAndReadGrComplex)
|
||||
|
||||
struct mat_complex_split_t x = {x_real, x_imag};
|
||||
size_t dims[2] = {static_cast<size_t>(size), 1};
|
||||
matvar = Mat_VarCreate("x", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, &x, MAT_F_COMPLEX);
|
||||
ASSERT_FALSE(reinterpret_cast<long*>(matvar) == NULL) << "Error creating variable for ’x’";
|
||||
matvar1 = Mat_VarCreate("x", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, &x, MAT_F_COMPLEX);
|
||||
ASSERT_FALSE(reinterpret_cast<long*>(matvar1) == NULL) << "Error creating variable for ’x’";
|
||||
|
||||
std::vector<gr_complex> y_v = { {1.1, -10}, {2, -9}, {3, -8}, {4, -7}, {5, 6}, {6, -5}, {7, -4}, {8, 3}, {9, 2}, {10, 1}};
|
||||
const unsigned int size_y = y_v.size();
|
||||
std::vector<gr_complex> x2 = { {1.1, -10}, {2, -9}, {3, -8}, {4, -7}, {5, 6}, {6, -5}, {7, -4}, {8, 3}, {9, 2}, {10, 1}};
|
||||
const unsigned int size_y = x2.size();
|
||||
float y_real[size_y];
|
||||
float y_imag[size_y];
|
||||
i = 0;
|
||||
for (std::vector<gr_complex>::const_iterator it = y_v.cbegin(); it != y_v.cend(); it++)
|
||||
for (std::vector<gr_complex>::const_iterator it = x2.cbegin(); it != x2.cend(); it++)
|
||||
{
|
||||
y_real[i] = it->real();
|
||||
y_imag[i] = it->imag();
|
||||
@ -115,14 +116,14 @@ TEST(MatioTest, WriteAndReadGrComplex)
|
||||
|
||||
struct mat_complex_split_t y = {y_real, y_imag};
|
||||
size_t dims_y[2] = {static_cast<size_t>(size_y), 1};
|
||||
matvar_t *matvar_y;
|
||||
matvar_y = Mat_VarCreate("y", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims_y, &y, MAT_F_COMPLEX);
|
||||
ASSERT_FALSE(reinterpret_cast<long*>(matvar_y) == NULL) << "Error creating variable for ’y’";
|
||||
matvar_t *matvar2;
|
||||
matvar2 = Mat_VarCreate("y", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims_y, &y, MAT_F_COMPLEX);
|
||||
ASSERT_FALSE(reinterpret_cast<long*>(matvar2) == NULL) << "Error creating variable for ’y’";
|
||||
|
||||
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarWrite(matfp, matvar_y, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarWrite(matfp, matvar2, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||
Mat_VarFree(matvar);
|
||||
Mat_VarFree(matvar_y);
|
||||
Mat_VarFree(matvar2);
|
||||
|
||||
Mat_Close(matfp);
|
||||
|
||||
@ -154,5 +155,5 @@ TEST(MatioTest, WriteAndReadGrComplex)
|
||||
EXPECT_FLOAT_EQ(x_v[i].real(), x_v_read[i].real());
|
||||
EXPECT_FLOAT_EQ(x_v[i].imag(), x_v_read[i].imag());
|
||||
}
|
||||
//ASSERT_EQ(remove(filename.c_str()), 0);
|
||||
ASSERT_EQ(remove(filename.c_str()), 0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user