Skip to content

Commit

Permalink
Switched to the external tatami_test library for testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
LTLA committed Nov 25, 2024
1 parent 220910e commit 8b2e57d
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 60 deletions.
19 changes: 5 additions & 14 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/ec4fed93217bc2830959bb8e86798c1d86956949.zip
tatami_test
GIT_REPOSITORY https://github.com/tatami-inc/tatami_test
GIT_TAG master
)

# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)

# Avoid installing GoogleTest when installing this project.
option(INSTALL_GTEST "Enable installation of googletest." OFF)

FetchContent_MakeAvailable(googletest)

enable_testing()
FetchContent_MakeAvailable(tatami_test)

add_executable(libtest src/load_matrix.cpp)

target_link_libraries(libtest gtest_main tatami_mtx)
target_link_libraries(libtest tatami_mtx tatami_test)

include(CheckIncludeFiles)
check_include_files(filesystem HAVE_CXX_FS)
Expand Down
92 changes: 46 additions & 46 deletions tests/src/load_matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,17 @@ TEST_F(LoadMatrixInputTest, SimpleBuffer) {
auto out = tatami_mtx::load_matrix_from_text_buffer<double, int>(buffer.data(), buffer.size(), opt);
EXPECT_FALSE(out->prefer_rows());
EXPECT_TRUE(out->sparse());
tatami_test::test_simple_row_access(out.get(), ref.get());
tatami_test::test_simple_column_access(out.get(), ref.get());
tatami_test::test_simple_row_access(*out, *ref);
tatami_test::test_simple_column_access(*out, *ref);
}

// Automatic.
{
auto out = tatami_mtx::load_matrix_from_some_buffer<double, int>(buffer.data(), buffer.size(), opt);
EXPECT_FALSE(out->prefer_rows());
EXPECT_TRUE(out->sparse());
tatami_test::test_simple_row_access(out.get(), ref.get());
tatami_test::test_simple_column_access(out.get(), ref.get());
tatami_test::test_simple_row_access(*out, *ref);
tatami_test::test_simple_column_access(*out, *ref);
}
}

Expand All @@ -155,17 +155,17 @@ TEST_F(LoadMatrixInputTest, SimpleText) {
auto out = tatami_mtx::load_matrix_from_text_file<double, int>(path.c_str(), opt);
EXPECT_TRUE(out->prefer_rows());
EXPECT_TRUE(out->sparse());
tatami_test::test_simple_row_access(out.get(), ref.get());
tatami_test::test_simple_column_access(out.get(), ref.get());
tatami_test::test_simple_row_access(*out, *ref);
tatami_test::test_simple_column_access(*out, *ref);
}

// Automatic.
{
auto out = tatami_mtx::load_matrix_from_some_file<double, int>(path.c_str(), opt);
EXPECT_TRUE(out->prefer_rows());
EXPECT_TRUE(out->sparse());
tatami_test::test_simple_row_access(out.get(), ref.get());
tatami_test::test_simple_column_access(out.get(), ref.get());
tatami_test::test_simple_row_access(*out, *ref);
tatami_test::test_simple_column_access(*out, *ref);
}
}

Expand All @@ -184,17 +184,17 @@ TEST_F(LoadMatrixInputTest, ZlibBuffer) {
auto out = tatami_mtx::load_matrix_from_zlib_buffer<double, int>(buffer.data(), buffer.size(), opt);
EXPECT_FALSE(out->prefer_rows());
EXPECT_TRUE(out->sparse());
tatami_test::test_simple_row_access(out.get(), ref.get());
tatami_test::test_simple_column_access(out.get(), ref.get());
tatami_test::test_simple_row_access(*out, *ref);
tatami_test::test_simple_column_access(*out, *ref);
}

// Automatic.
{
auto out = tatami_mtx::load_matrix_from_some_buffer<double, int>(buffer.data(), buffer.size(), opt);
EXPECT_FALSE(out->prefer_rows());
EXPECT_TRUE(out->sparse());
tatami_test::test_simple_row_access(out.get(), ref.get());
tatami_test::test_simple_column_access(out.get(), ref.get());
tatami_test::test_simple_row_access(*out, *ref);
tatami_test::test_simple_column_access(*out, *ref);
}
}

Expand All @@ -213,17 +213,17 @@ TEST_F(LoadMatrixInputTest, GzipFile) {
auto out = tatami_mtx::load_matrix_from_gzip_file<double, int>(path.c_str(), opt);
EXPECT_TRUE(out->prefer_rows());
EXPECT_TRUE(out->sparse());
tatami_test::test_simple_row_access(out.get(), ref.get());
tatami_test::test_simple_column_access(out.get(), ref.get());
tatami_test::test_simple_row_access(*out, *ref);
tatami_test::test_simple_column_access(*out, *ref);
}

// Automatic.
{
auto out = tatami_mtx::load_matrix_from_some_file<double, int>(path.c_str(), opt);
EXPECT_TRUE(out->prefer_rows());
EXPECT_TRUE(out->sparse());
tatami_test::test_simple_row_access(out.get(), ref.get());
tatami_test::test_simple_column_access(out.get(), ref.get());
tatami_test::test_simple_row_access(*out, *ref);
tatami_test::test_simple_column_access(*out, *ref);
}
}

Expand All @@ -247,8 +247,8 @@ TEST_F(LoadMatrixIndexTest, Index8) {
auto out = tatami_mtx::load_matrix_from_text_buffer<double, int>(buffer.data(), buffer.size(), opt);
EXPECT_FALSE(out->prefer_rows());
EXPECT_TRUE(out->sparse());
tatami_test::test_simple_row_access(out.get(), ref.get());
tatami_test::test_simple_column_access(out.get(), ref.get());
tatami_test::test_simple_row_access(*out, *ref);
tatami_test::test_simple_column_access(*out, *ref);
}

TEST_F(LoadMatrixIndexTest, Index16) {
Expand All @@ -264,8 +264,8 @@ TEST_F(LoadMatrixIndexTest, Index16) {
auto out = tatami_mtx::load_matrix_from_text_buffer<double, int>(buffer.data(), buffer.size(), opt);
EXPECT_FALSE(out->prefer_rows());
EXPECT_TRUE(out->sparse());
tatami_test::test_simple_row_access(out.get(), ref.get());
tatami_test::test_simple_column_access(out.get(), ref.get());
tatami_test::test_simple_row_access(*out, *ref);
tatami_test::test_simple_column_access(*out, *ref);
}

TEST_F(LoadMatrixIndexTest, Index32) {
Expand All @@ -281,8 +281,8 @@ TEST_F(LoadMatrixIndexTest, Index32) {
auto out = tatami_mtx::load_matrix_from_text_buffer<double, int>(buffer.data(), buffer.size(), opt);
EXPECT_FALSE(out->prefer_rows());
EXPECT_TRUE(out->sparse());
tatami_test::test_simple_row_access(out.get(), ref.get());
tatami_test::test_simple_column_access(out.get(), ref.get());
tatami_test::test_simple_row_access(*out, *ref);
tatami_test::test_simple_column_access(*out, *ref);
}

TEST_F(LoadMatrixIndexTest, IndexCustom) {
Expand All @@ -299,8 +299,8 @@ TEST_F(LoadMatrixIndexTest, IndexCustom) {
auto out = tatami_mtx::load_matrix_from_text_buffer<double, int, tatami_mtx::Automatic, uint32_t>(buffer.data(), buffer.size(), opt);
EXPECT_FALSE(out->prefer_rows());
EXPECT_TRUE(out->sparse());
tatami_test::test_simple_row_access(out.get(), ref.get());
tatami_test::test_simple_column_access(out.get(), ref.get());
tatami_test::test_simple_row_access(*out, *ref);
tatami_test::test_simple_column_access(*out, *ref);
}

/*********************************************
Expand All @@ -320,8 +320,8 @@ TEST_F(LoadMatrixIndexTest, TempIndex8) {
auto out = tatami_mtx::load_matrix_from_text_buffer<double, int>(buffer.data(), buffer.size(), opt);
EXPECT_TRUE(out->prefer_rows());
EXPECT_TRUE(out->sparse());
tatami_test::test_simple_row_access(out.get(), ref.get());
tatami_test::test_simple_column_access(out.get(), ref.get());
tatami_test::test_simple_row_access(*out, *ref);
tatami_test::test_simple_column_access(*out, *ref);
}

TEST_F(LoadMatrixIndexTest, TempIndex16) {
Expand All @@ -338,8 +338,8 @@ TEST_F(LoadMatrixIndexTest, TempIndex16) {
auto out = tatami_mtx::load_matrix_from_text_buffer<double, int>(buffer.data(), buffer.size(), opt);
EXPECT_TRUE(out->prefer_rows());
EXPECT_TRUE(out->sparse());
tatami_test::test_simple_row_access(out.get(), ref.get());
tatami_test::test_simple_column_access(out.get(), ref.get());
tatami_test::test_simple_row_access(*out, *ref);
tatami_test::test_simple_column_access(*out, *ref);
}

TEST_F(LoadMatrixIndexTest, TempIndex32) {
Expand All @@ -355,8 +355,8 @@ TEST_F(LoadMatrixIndexTest, TempIndex32) {
auto out = tatami_mtx::load_matrix_from_text_buffer<double, int>(buffer.data(), buffer.size(), opt);
EXPECT_TRUE(out->prefer_rows());
EXPECT_TRUE(out->sparse());
tatami_test::test_simple_row_access(out.get(), ref.get());
tatami_test::test_simple_column_access(out.get(), ref.get());
tatami_test::test_simple_row_access(*out, *ref);
tatami_test::test_simple_column_access(*out, *ref);
}

/******************************************
Expand All @@ -379,8 +379,8 @@ TEST_F(LoadMatrixIntegerTypeTest, CoordinateAutomatic) {
auto out = tatami_mtx::load_matrix_from_text_buffer<double, int>(buffer.data(), buffer.size(), opt);
EXPECT_TRUE(out->prefer_rows());
EXPECT_TRUE(out->sparse());
tatami_test::test_simple_row_access(out.get(), ref.get());
tatami_test::test_simple_column_access(out.get(), ref.get());
tatami_test::test_simple_row_access(*out, *ref);
tatami_test::test_simple_column_access(*out, *ref);
}

TEST_F(LoadMatrixIntegerTypeTest, CoordinateCustom) {
Expand All @@ -396,8 +396,8 @@ TEST_F(LoadMatrixIntegerTypeTest, CoordinateCustom) {
auto out = tatami_mtx::load_matrix_from_text_buffer<double, int, int32_t>(buffer.data(), buffer.size(), opt);
EXPECT_FALSE(out->prefer_rows());
EXPECT_TRUE(out->sparse());
tatami_test::test_simple_row_access(out.get(), ref.get());
tatami_test::test_simple_column_access(out.get(), ref.get());
tatami_test::test_simple_row_access(*out, *ref);
tatami_test::test_simple_column_access(*out, *ref);
}

TEST_F(LoadMatrixIntegerTypeTest, ArrayAutomatic) {
Expand All @@ -413,8 +413,8 @@ TEST_F(LoadMatrixIntegerTypeTest, ArrayAutomatic) {
auto out = tatami_mtx::load_matrix_from_text_buffer<double, int>(buffer.data(), buffer.size(), opt);
EXPECT_TRUE(out->prefer_rows());
EXPECT_FALSE(out->sparse());
tatami_test::test_simple_row_access(out.get(), ref.get());
tatami_test::test_simple_column_access(out.get(), ref.get());
tatami_test::test_simple_row_access(*out, *ref);
tatami_test::test_simple_column_access(*out, *ref);
}

TEST_F(LoadMatrixIntegerTypeTest, ArrayCustom) {
Expand All @@ -431,8 +431,8 @@ TEST_F(LoadMatrixIntegerTypeTest, ArrayCustom) {
auto out = tatami_mtx::load_matrix_from_text_buffer<double, int, int32_t>(buffer.data(), buffer.size(), opt);
EXPECT_FALSE(out->prefer_rows());
EXPECT_FALSE(out->sparse());
tatami_test::test_simple_row_access(out.get(), ref.get());
tatami_test::test_simple_column_access(out.get(), ref.get());
tatami_test::test_simple_row_access(*out, *ref);
tatami_test::test_simple_column_access(*out, *ref);
}

/****************************************
Expand All @@ -454,8 +454,8 @@ TEST_F(LoadMatrixFloatTypeTest, CoordinateAutomatic) {
auto out = tatami_mtx::load_matrix_from_text_buffer<double, int>(buffer.data(), buffer.size(), opt);
EXPECT_TRUE(out->prefer_rows());
EXPECT_TRUE(out->sparse());
tatami_test::test_simple_row_access(out.get(), ref.get());
tatami_test::test_simple_column_access(out.get(), ref.get());
tatami_test::test_simple_row_access(*out, *ref);
tatami_test::test_simple_column_access(*out, *ref);
}

TEST_F(LoadMatrixFloatTypeTest, CoordinateCustom) {
Expand All @@ -471,8 +471,8 @@ TEST_F(LoadMatrixFloatTypeTest, CoordinateCustom) {
auto out = tatami_mtx::load_matrix_from_text_buffer<double, int, double>(buffer.data(), buffer.size(), opt);
EXPECT_FALSE(out->prefer_rows());
EXPECT_TRUE(out->sparse());
tatami_test::test_simple_row_access(out.get(), ref.get());
tatami_test::test_simple_column_access(out.get(), ref.get());
tatami_test::test_simple_row_access(*out, *ref);
tatami_test::test_simple_column_access(*out, *ref);
}

TEST_F(LoadMatrixFloatTypeTest, ArrayAutomatic) {
Expand All @@ -489,8 +489,8 @@ TEST_F(LoadMatrixFloatTypeTest, ArrayAutomatic) {
auto out = tatami_mtx::load_matrix_from_text_buffer<double, int>(buffer.data(), buffer.size(), opt);
EXPECT_TRUE(out->prefer_rows());
EXPECT_FALSE(out->sparse());
tatami_test::test_simple_row_access(out.get(), ref.get());
tatami_test::test_simple_column_access(out.get(), ref.get());
tatami_test::test_simple_row_access(*out, *ref);
tatami_test::test_simple_column_access(*out, *ref);
}

TEST_F(LoadMatrixFloatTypeTest, ArrayCustom) {
Expand All @@ -507,6 +507,6 @@ TEST_F(LoadMatrixFloatTypeTest, ArrayCustom) {
auto out = tatami_mtx::load_matrix_from_text_buffer<double, int, double>(buffer.data(), buffer.size(), opt);
EXPECT_FALSE(out->prefer_rows());
EXPECT_FALSE(out->sparse());
tatami_test::test_simple_row_access(out.get(), ref.get());
tatami_test::test_simple_column_access(out.get(), ref.get());
tatami_test::test_simple_row_access(*out, *ref);
tatami_test::test_simple_column_access(*out, *ref);
}

0 comments on commit 8b2e57d

Please sign in to comment.