From 30ceb2f5b35a1260ea6bf0f5a16b1ac2902fcf4d Mon Sep 17 00:00:00 2001 From: Giovanni La Mura Date: Tue, 11 Feb 2025 11:45:59 +0100 Subject: [PATCH] Prepare valgrind output tests --- src/libnptm/outputs.cpp | 2 ++ src/testing/test_outputs.cpp | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/libnptm/outputs.cpp b/src/libnptm/outputs.cpp index bc0c7fdc..1f50f1a0 100644 --- a/src/libnptm/outputs.cpp +++ b/src/libnptm/outputs.cpp @@ -692,6 +692,8 @@ ClusterOutputInfo::ClusterOutputInfo(const std::string &hdf5_file_name) { status = hdf_file->read("VEC_DIR_MULC", str_type, vec_dir_mulc); vec_dir_mulclr = new double[16 * ndirs * xi_block_size]; status = hdf_file->read("VEC_DIR_MULCLR", str_type, vec_dir_mulclr); + status = hdf_file->close(); + delete hdf_file; } else { if (hdf_file != NULL) delete hdf_file; UnrecognizedFormatException ex("Error: " + hdf5_file_name + " not recognized as a valid HDF5 file!"); diff --git a/src/testing/test_outputs.cpp b/src/testing/test_outputs.cpp index 1cacbca8..63f5a3ef 100644 --- a/src/testing/test_outputs.cpp +++ b/src/testing/test_outputs.cpp @@ -22,17 +22,31 @@ using namespace std; +int test_cluster_hdf5_output(); int test_cluster_case_3(); int main() { int result = 0; - // result += test_sphere(); // 1 if failed + result += test_cluster_hdf5_output(); // 1 if failed // result += test_cluster_devel(); // 10 if failed result += test_cluster_case_3(); // 100 if failed // result += test_inclusion(); // 1000 if failed return result; } +int test_cluster_hdf5_output() { + int result = 0; + try { + const string hdf5_file = "../../test_data/cluster/c_OCLU_24.hd5"; + ClusterOutputInfo *oi = new ClusterOutputInfo(hdf5_file); + oi->write("c_OCLU_24", "LEGACY"); + delete oi; + } catch (const exception& ex) { + result = 1; + } + return result; +} + int test_cluster_case_3() { int result = 0; try { -- GitLab