From 10ccee39de8882f7b3b7d54263660e31f06a9323 Mon Sep 17 00:00:00 2001 From: tomc271 Date: Tue, 10 Jun 2025 12:49:11 +0100 Subject: [PATCH 1/4] Add nx, ny, nz as optional arguments to FakeMeshFixture constructor --- tests/unit/fake_mesh_fixture.hxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/fake_mesh_fixture.hxx b/tests/unit/fake_mesh_fixture.hxx index 42f7be5446..2b4c164675 100644 --- a/tests/unit/fake_mesh_fixture.hxx +++ b/tests/unit/fake_mesh_fixture.hxx @@ -27,8 +27,8 @@ /// using MyTest = FakeMeshFixture; class FakeMeshFixture : public ::testing::Test { public: - FakeMeshFixture() - : mesh_m(nx, ny, nz, mpi), mesh_staggered_m(nx, ny, nz, mpi), + FakeMeshFixture(int nx_ = nx, int ny_ = ny, int nz_ = nz) + : mesh_m(nx_, ny_, nz_, mpi), mesh_staggered_m(nx_, ny_, nz_, mpi), mesh_staggered(&mesh_staggered_m) { bout::globals::mpi = &mpi; From f69ccdc5ebbd3b289822bb6b08d67deffebf1019 Mon Sep 17 00:00:00 2001 From: tomc271 Date: Thu, 12 Jun 2025 12:38:34 +0100 Subject: [PATCH 2/4] Use type alias FakeMeshFixture = FakeMeshFixture_tmpl<3, 5, 7> as a shim to allow FakeMeshFixture to be used with default values for nx, ny, nz --- tests/unit/fake_mesh_fixture.hxx | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/tests/unit/fake_mesh_fixture.hxx b/tests/unit/fake_mesh_fixture.hxx index 2b4c164675..68b0ac83b1 100644 --- a/tests/unit/fake_mesh_fixture.hxx +++ b/tests/unit/fake_mesh_fixture.hxx @@ -25,10 +25,14 @@ /// alias to make a new test: /// /// using MyTest = FakeMeshFixture; -class FakeMeshFixture : public ::testing::Test { +/// +/// Type alias FakeMeshFixture = FakeMeshFixture_tmpl<3, 5, 7>; +/// is used as a shim to allow FakeMeshFixture to be used with default values for nx, ny, nz +template +class FakeMeshFixture_tmpl : public ::testing::Test { public: - FakeMeshFixture(int nx_ = nx, int ny_ = ny, int nz_ = nz) - : mesh_m(nx_, ny_, nz_, mpi), mesh_staggered_m(nx_, ny_, nz_, mpi), + FakeMeshFixture_tmpl() + : mesh_m(NX, NY, NZ, mpi), mesh_staggered_m(NX, NY, NZ, mpi), mesh_staggered(&mesh_staggered_m) { bout::globals::mpi = &mpi; @@ -108,21 +112,21 @@ public: mesh_staggered_m.setCoordinates(test_coords_staggered, CELL_ZLOW); } - FakeMeshFixture(const FakeMeshFixture&) = delete; - FakeMeshFixture& operator=(const FakeMeshFixture&) = delete; - FakeMeshFixture(FakeMeshFixture&&) = delete; - FakeMeshFixture& operator=(FakeMeshFixture&&) = delete; + FakeMeshFixture_tmpl(const FakeMeshFixture_tmpl&) = delete; + FakeMeshFixture_tmpl& operator=(const FakeMeshFixture_tmpl&) = delete; + FakeMeshFixture_tmpl(FakeMeshFixture_tmpl&&) = delete; + FakeMeshFixture_tmpl& operator=(FakeMeshFixture_tmpl&&) = delete; - ~FakeMeshFixture() override { + ~FakeMeshFixture_tmpl() override { bout::globals::mesh = nullptr; bout::globals::mpi = nullptr; Options::cleanup(); } - static constexpr int nx = 3; - static constexpr int ny = 5; - static constexpr int nz = 7; + static constexpr int nx = NX; + static constexpr int ny = NY; + static constexpr int nz = NZ; private: std::shared_ptr test_coords{nullptr}; @@ -139,3 +143,5 @@ public: // Public pointer to our staggered mesh Mesh* mesh_staggered; // NOLINT }; + +using FakeMeshFixture = FakeMeshFixture_tmpl<3, 5, 7>; From d3bd5f9b017b6dbcf59cd211642bd5d75bce28e9 Mon Sep 17 00:00:00 2001 From: tomc271 <58003025+tomc271@users.noreply.github.com> Date: Mon, 23 Jun 2025 15:25:19 +0000 Subject: [PATCH 3/4] Apply clang-format changes --- tests/unit/fake_mesh_fixture.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/fake_mesh_fixture.hxx b/tests/unit/fake_mesh_fixture.hxx index 68b0ac83b1..d717cfb826 100644 --- a/tests/unit/fake_mesh_fixture.hxx +++ b/tests/unit/fake_mesh_fixture.hxx @@ -28,7 +28,7 @@ /// /// Type alias FakeMeshFixture = FakeMeshFixture_tmpl<3, 5, 7>; /// is used as a shim to allow FakeMeshFixture to be used with default values for nx, ny, nz -template +template class FakeMeshFixture_tmpl : public ::testing::Test { public: FakeMeshFixture_tmpl() From d7cdc65e6f9de35499d50efd0429cc6d27ab96ee Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Mon, 23 Jun 2025 16:36:47 +0100 Subject: [PATCH 4/4] Small tidy of test class docstring --- tests/unit/fake_mesh_fixture.hxx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/unit/fake_mesh_fixture.hxx b/tests/unit/fake_mesh_fixture.hxx index d717cfb826..2758dbe416 100644 --- a/tests/unit/fake_mesh_fixture.hxx +++ b/tests/unit/fake_mesh_fixture.hxx @@ -26,8 +26,11 @@ /// /// using MyTest = FakeMeshFixture; /// -/// Type alias FakeMeshFixture = FakeMeshFixture_tmpl<3, 5, 7>; -/// is used as a shim to allow FakeMeshFixture to be used with default values for nx, ny, nz +/// Type alias `FakeMeshFixture = FakeMeshFixture_tmpl<3, 5, 7>` +/// is used as a shim to allow FakeMeshFixture to be used with default values for nx, ny, nz. +/// Use this template class directly to use different sized grid: +/// +/// using MyTest = FakeMeshFixture_tmpl<7, 9, 11>; template class FakeMeshFixture_tmpl : public ::testing::Test { public: