unit tests: Load_npy_matrix
This commit is contained in:
@@ -4,12 +4,14 @@ set(CMAKE_CXX_STANDARD 20)
|
|||||||
|
|
||||||
# 'lib' is the folder with Google Test sources
|
# 'lib' is the folder with Google Test sources
|
||||||
add_subdirectory(lib)
|
add_subdirectory(lib)
|
||||||
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
|
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR} libnpy/include)
|
||||||
|
|
||||||
# 'Google_Tests_run' is the target name
|
# 'Google_Tests_run' is the target name
|
||||||
# 'test1.cpp test2.cpp' are source files with tests
|
# 'test1.cpp test2.cpp' are source files with tests
|
||||||
add_executable(Google_Tests_run test1.cpp)
|
add_executable(Google_Tests_run test1.cpp)
|
||||||
|
|
||||||
|
file(COPY test1/data1.npy DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/test1)
|
||||||
|
|
||||||
target_link_libraries(Google_Tests_run pasada)
|
target_link_libraries(Google_Tests_run pasada)
|
||||||
#target_include_directories(Google_Tests_run PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/pasada-lib/include")
|
#target_include_directories(Google_Tests_run PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/pasada-lib/include")
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,10 @@
|
|||||||
//
|
//
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include "library.h"
|
#include "library.h"
|
||||||
|
#include "npy.hpp"
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
// Demonstrate some basic assertions.
|
// Demonstrate some basic assertions.
|
||||||
TEST(HelloTest, BasicAssertions) {
|
TEST(HelloTest, BasicAssertions) {
|
||||||
@@ -12,4 +16,24 @@ TEST(HelloTest, BasicAssertions) {
|
|||||||
EXPECT_EQ(7 * 6, 42);
|
EXPECT_EQ(7 * 6, 42);
|
||||||
printf("asdf");
|
printf("asdf");
|
||||||
hello();
|
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]);
|
||||||
|
}
|
||||||
|
|||||||
BIN
google-tests/test1/data1.npy
Normal file
BIN
google-tests/test1/data1.npy
Normal file
Binary file not shown.
Reference in New Issue
Block a user