From d7b275e519edae7722c5c327dcf81a49263b6095 Mon Sep 17 00:00:00 2001 From: Coleman Kendrick <6309092+ckendrick@users.noreply.github.com> Date: Thu, 16 May 2024 09:06:10 -0600 Subject: [PATCH] Fix issue with Database class (#276) * Add test for writeSnapshot/endSamples in CI * Fix test return value * Remove unused status variable * Fix bug with assert statements in BasisReader * Remove unused function --- .github/workflows/run_tests/action.yml | 1 + lib/linalg/BasisReader.cpp | 6 +++--- lib/utils/Database.cpp | 6 ------ lib/utils/Database.h | 1 - unit_tests/smoke_static.cpp | 4 +--- 5 files changed, 5 insertions(+), 13 deletions(-) diff --git a/.github/workflows/run_tests/action.yml b/.github/workflows/run_tests/action.yml index 8413a880b..994f45af3 100644 --- a/.github/workflows/run_tests/action.yml +++ b/.github/workflows/run_tests/action.yml @@ -7,6 +7,7 @@ runs: ./tests/test_Vector ./tests/test_Matrix mpirun -n 3 --oversubscribe ./tests/test_Matrix + ./tests/smoke_static ./tests/test_DEIM ./tests/test_GNAT ./tests/test_QDEIM diff --git a/lib/linalg/BasisReader.cpp b/lib/linalg/BasisReader.cpp index 1fdb11e65..b6e26eed8 100644 --- a/lib/linalg/BasisReader.cpp +++ b/lib/linalg/BasisReader.cpp @@ -103,7 +103,7 @@ BasisReader::getSpatialBasis( int num_cols = getNumSamples("basis"); char tmp[100]; - CAROM_VERIFY(0 < start_col <= num_cols); + CAROM_VERIFY(0 < start_col && start_col <= num_cols); CAROM_VERIFY(start_col <= end_col && end_col <= num_cols); int num_cols_to_read = end_col - start_col + 1; @@ -177,7 +177,7 @@ BasisReader::getTemporalBasis( int num_cols = getNumSamples("temporal_basis"); char tmp[100]; - CAROM_VERIFY(0 < start_col <= num_cols); + CAROM_VERIFY(0 < start_col && start_col <= num_cols); CAROM_VERIFY(start_col <= end_col && end_col <= num_cols); int num_cols_to_read = end_col - start_col + 1; @@ -351,7 +351,7 @@ BasisReader::getSnapshotMatrix( int num_rows = getDim("snapshot"); int num_cols = getNumSamples("snapshot"); - CAROM_VERIFY(0 < start_col <= num_cols); + CAROM_VERIFY(0 < start_col && start_col <= num_cols); CAROM_VERIFY(start_col <= end_col && end_col <= num_cols); int num_cols_to_read = end_col - start_col + 1; diff --git a/lib/utils/Database.cpp b/lib/utils/Database.cpp index df2cb01b6..b7f34f578 100644 --- a/lib/utils/Database.cpp +++ b/lib/utils/Database.cpp @@ -16,12 +16,6 @@ namespace CAROM { -bool fileExists(const std::string& name) -{ - std::ifstream f(name.c_str()); - return f.good(); - // ifstream f will be closed upon the end of the function. -} Database::Database() { diff --git a/lib/utils/Database.h b/lib/utils/Database.h index 1008f391d..f9cf0678c 100644 --- a/lib/utils/Database.h +++ b/lib/utils/Database.h @@ -20,7 +20,6 @@ namespace CAROM { -bool fileExists(const std::string& name); /** * Class Database is an abstract base class that provides basic ability to diff --git a/unit_tests/smoke_static.cpp b/unit_tests/smoke_static.cpp index 856dc71c7..5e03c1707 100644 --- a/unit_tests/smoke_static.cpp +++ b/unit_tests/smoke_static.cpp @@ -53,8 +53,6 @@ main( return 1; } - bool status = false; - // Define the values for the first sample. double vals0[6] = {1.0, 6.0, 3.0, 8.0, 17.0, 9.0}; @@ -144,5 +142,5 @@ main( // Finalize MPI and return. MPI_Finalize(); - return !status; + return 0; }