From 2f753c6ea07f31501102b41e65417f9535620c19 Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Sun, 16 Feb 2025 15:10:13 -0500 Subject: [PATCH] test(tests/meshIO): added basic test suite for meshIO just tests the constuctor, getMesh, and isLoaded method. This confirms that a basic spherical mesh can be loaded in correctly --- tests/meshIO/meshIOTest.cpp | 26 ++++++++++++++++++++++++++ tests/meshIO/meson.build | 22 ++++++++++++++++++++++ tests/meson.build | 1 + 3 files changed, 49 insertions(+) create mode 100644 tests/meshIO/meshIOTest.cpp create mode 100644 tests/meshIO/meson.build diff --git a/tests/meshIO/meshIOTest.cpp b/tests/meshIO/meshIOTest.cpp new file mode 100644 index 0000000..1ed55d1 --- /dev/null +++ b/tests/meshIO/meshIOTest.cpp @@ -0,0 +1,26 @@ +#include +#include "meshIO.h" +#include +#include +#include "mfem.hpp" + +std::string EXAMPLE_FILENAME = std::string(getenv("MESON_SOURCE_ROOT")) + "/src/resources/mesh/sphere.msh"; + + +class meshIOTest : public ::testing::Test {}; + +TEST_F(meshIOTest, DefaultConstructor) { + EXPECT_NO_THROW(MeshIO meshIO(EXAMPLE_FILENAME)); +} + +TEST_F(meshIOTest, IsLoaded) { + MeshIO meshIO(EXAMPLE_FILENAME); + EXPECT_EQ(meshIO.IsLoaded(), true); +} + +TEST_F(meshIOTest, GetMesh) { + MeshIO meshIO(EXAMPLE_FILENAME); + mfem::Mesh& mesh = meshIO.GetMesh(); + EXPECT_EQ(mesh.GetNE(), 670); + EXPECT_EQ(mesh.GetNV(), 201); +} \ No newline at end of file diff --git a/tests/meshIO/meson.build b/tests/meshIO/meson.build new file mode 100644 index 0000000..6db5297 --- /dev/null +++ b/tests/meshIO/meson.build @@ -0,0 +1,22 @@ +# Test files for mesh +test_sources = [ + 'meshIOTest.cpp', +] + +foreach test_file : test_sources + exe_name = test_file.split('.')[0] + message('Building test: ' + exe_name) + + # Create an executable target for each test + test_exe = executable( + exe_name, + test_file, + dependencies: [gtest_dep, mfem_dep], + include_directories: include_directories('../../src/meshIO/public'), + link_with: libmeshIO, # Link the dobj library + install_rpath: '@loader_path/../../src' # Ensure runtime library path resolves correctly + ) + + # Add the executable as a test + test(exe_name, test_exe) +endforeach diff --git a/tests/meson.build b/tests/meson.build index 45693ff..162daab 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -6,6 +6,7 @@ gtest_nomain_dep = dependency('gtest', main: false, required : true) subdir('dobj') subdir('const') subdir('opatIO') +subdir('meshIO') # Subdirectories for sandbox tests subdir('dobj_sandbox')