unit tests: Load_npy_matrix
This commit is contained in:
@@ -3,6 +3,10 @@
|
||||
//
|
||||
#include <gtest/gtest.h>
|
||||
#include "library.h"
|
||||
#include "npy.hpp"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <filesystem>
|
||||
|
||||
// Demonstrate some basic assertions.
|
||||
TEST(HelloTest, BasicAssertions) {
|
||||
@@ -12,4 +16,24 @@ TEST(HelloTest, BasicAssertions) {
|
||||
EXPECT_EQ(7 * 6, 42);
|
||||
printf("asdf");
|
||||
hello();
|
||||
}
|
||||
}
|
||||
|
||||
TEST(HelloTest, Load_npy_matrix) {
|
||||
// "C:\\Users\\david\\Documents\\src\\libpasada\\cmake-build-debug\\google-tests"
|
||||
std::cout << std::filesystem::current_path() << std::endl;
|
||||
const std::string path {"test1/data1.npy"};
|
||||
npy::npy_data d = npy::read_npy<double>(path);
|
||||
std::vector<double> data = d.data;
|
||||
std::vector<unsigned long> shape = d.shape;
|
||||
bool fortran_order = d.fortran_order;
|
||||
|
||||
std::vector<unsigned long> expect_shape {2, 2};
|
||||
std::vector<double> expect_data {1.0, 2.0, 3.0, 4.0};
|
||||
|
||||
EXPECT_EQ(shape, expect_shape);
|
||||
EXPECT_EQ(fortran_order, false);
|
||||
EXPECT_DOUBLE_EQ(data[0], expect_data[0]);
|
||||
EXPECT_DOUBLE_EQ(data[1], expect_data[1]);
|
||||
EXPECT_DOUBLE_EQ(data[2], expect_data[2]);
|
||||
EXPECT_DOUBLE_EQ(data[3], expect_data[3]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user