From c5760fdf1bb81716d1833b6bfd8f82bde82a5e19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Dutheillet-Lamonth=C3=A9zie?= Date: Wed, 28 Aug 2024 11:43:31 +0200 Subject: [PATCH] #105: apply guideline to prefer struct over class for test classes --- tests/unit/api/basic_serializer.h | 2 +- tests/unit/api/test_info.cc | 2 +- tests/unit/api/test_object_communicator.cc | 2 +- tests/unit/api/test_object_info.cc | 2 +- tests/unit/api/test_object_work.cc | 2 +- tests/unit/api/test_phase_work.cc | 2 +- tests/unit/api/test_rank.cc | 2 +- tests/unit/deps/test_vtk.cc | 2 +- tests/unit/generator.h | 2 +- tests/unit/render/test_parse_render.cc | 2 +- tests/unit/render/test_standalone_app.cc | 2 +- tests/unit/util.h | 6 +++++- 12 files changed, 16 insertions(+), 12 deletions(-) diff --git a/tests/unit/api/basic_serializer.h b/tests/unit/api/basic_serializer.h index ae48bc997..56179afc6 100644 --- a/tests/unit/api/basic_serializer.h +++ b/tests/unit/api/basic_serializer.h @@ -49,7 +49,7 @@ namespace vt::tv::tests::unit::api { * items to the inner map. This is useful to test api calls to serialization methods. */ template -class BasicSerializer { +struct BasicSerializer { public: void operator|(const TSerializable& item) { items[n] = item; diff --git a/tests/unit/api/test_info.cc b/tests/unit/api/test_info.cc index d6a35307a..42b8b576b 100644 --- a/tests/unit/api/test_info.cc +++ b/tests/unit/api/test_info.cc @@ -73,7 +73,7 @@ struct InfoTestParam { /** * Provides unit tests for the vt::tv::api::Info class */ -class InfoTest : public ::testing::TestWithParam { }; +struct InfoTest : public ::testing::TestWithParam { }; /** * Test Info:getNumRanks returns same number of ranks as defined in the sample diff --git a/tests/unit/api/test_object_communicator.cc b/tests/unit/api/test_object_communicator.cc index 61941aab6..312e717bb 100644 --- a/tests/unit/api/test_object_communicator.cc +++ b/tests/unit/api/test_object_communicator.cc @@ -51,7 +51,7 @@ namespace vt::tv::tests::unit::api { /** * Provides unit tests for the vt::tv::api::ObjectCommunicator class */ -class ObjectCommunicatorTest : public ::testing::Test { +struct ObjectCommunicatorTest : public ::testing::Test { public: ObjectCommunicator comm_0 = ObjectCommunicator(0); diff --git a/tests/unit/api/test_object_info.cc b/tests/unit/api/test_object_info.cc index b46c068c3..2a23c782a 100644 --- a/tests/unit/api/test_object_info.cc +++ b/tests/unit/api/test_object_info.cc @@ -50,7 +50,7 @@ namespace vt::tv::tests::unit::api { /** * Provides unit tests for the vt::tv::api::ObjectInfo class */ -class ObjectInfoTest : public ::testing::Test { +struct ObjectInfoTest : public ::testing::Test { public: ObjectInfo object_0 = ObjectInfo( 6, // id diff --git a/tests/unit/api/test_object_work.cc b/tests/unit/api/test_object_work.cc index 311058927..68d4ed40e 100644 --- a/tests/unit/api/test_object_work.cc +++ b/tests/unit/api/test_object_work.cc @@ -51,7 +51,7 @@ namespace vt::tv::tests::unit::api { /** * Provides unit tests for the vt::tv::api::ObjectWork class */ -class ObjectWorkTest : public ::testing::Test { +struct ObjectWorkTest : public ::testing::Test { public: ObjectWork object_0 = ObjectWork( 12, 10.0, {{3, 12.0}}, Generator::makeQOIVariants(3, "user_", "_value"), diff --git a/tests/unit/api/test_phase_work.cc b/tests/unit/api/test_phase_work.cc index 8bfb7676e..a1c701957 100644 --- a/tests/unit/api/test_phase_work.cc +++ b/tests/unit/api/test_phase_work.cc @@ -54,7 +54,7 @@ using ObjectWorkMap = std::unordered_map; /** * Provides unit tests for the vt::tv::api::PhaseWork class */ -class PhaseWorkTest : public ::testing::Test { +struct PhaseWorkTest : public ::testing::Test { public: PhaseWorkTest() { objects_0 = Generator::makeObjects(10); diff --git a/tests/unit/api/test_rank.cc b/tests/unit/api/test_rank.cc index f2e641449..25b3abcb0 100644 --- a/tests/unit/api/test_rank.cc +++ b/tests/unit/api/test_rank.cc @@ -50,7 +50,7 @@ namespace vt::tv::tests::unit::api { /** * Provides unit tests for the vt::tv::api::Rank class */ -class RankTest : public ::testing::Test { +struct RankTest : public ::testing::Test { public: // 6 objects with 2.0 load std::unordered_map objects = diff --git a/tests/unit/deps/test_vtk.cc b/tests/unit/deps/test_vtk.cc index 82da71f6c..96f465264 100644 --- a/tests/unit/deps/test_vtk.cc +++ b/tests/unit/deps/test_vtk.cc @@ -61,7 +61,7 @@ namespace vt::tv::tests::unit::deps { /** * Provides unit tests for the Vtk functions called from vt-tv */ -class VtkTest : public ::testing::Test { +struct VtkTest : public ::testing::Test { void SetUp() override { // This test is not testing vt-tv src. // That's why it is skipped. But it might be useful locally. diff --git a/tests/unit/generator.h b/tests/unit/generator.h index 0b9442c51..0cf25c851 100644 --- a/tests/unit/generator.h +++ b/tests/unit/generator.h @@ -60,7 +60,7 @@ namespace vt::tv::tests::unit { * Testing Helper class that provide useful static methods to be used by the different * unit tests classes related to the api to generate some data in memory. */ -class Generator { +struct Generator { public: /** * Make a map of new objects diff --git a/tests/unit/render/test_parse_render.cc b/tests/unit/render/test_parse_render.cc index a8c085767..bbf2e7e8c 100644 --- a/tests/unit/render/test_parse_render.cc +++ b/tests/unit/render/test_parse_render.cc @@ -64,7 +64,7 @@ using Util = vt::tv::tests::unit::Util; /** * Provides unit tests for the vt::tv::utility::ParseRender class to test with config file input */ -class ParseRenderTest : public ::testing::TestWithParam { +struct ParseRenderTest : public ::testing::TestWithParam { void SetUp() override { // Make the output directory for these tests std::filesystem::create_directory(fmt::format("{}/output", SRC_DIR)); diff --git a/tests/unit/render/test_standalone_app.cc b/tests/unit/render/test_standalone_app.cc index c10d933b1..5997fc15f 100644 --- a/tests/unit/render/test_standalone_app.cc +++ b/tests/unit/render/test_standalone_app.cc @@ -51,7 +51,7 @@ namespace vt::tv::tests::unit::render { * Provides unit tests for the standalone vt-tv app. * It is similar to the ParseRender tests except it runs as a separate process. */ -class StandaloneAppTest +struct StandaloneAppTest : public ::testing::TestWithParam> { void SetUp() override { // This test is not testing vt-tv src. diff --git a/tests/unit/util.h b/tests/unit/util.h index 388a2d226..65b6fdaca 100644 --- a/tests/unit/util.h +++ b/tests/unit/util.h @@ -64,10 +64,11 @@ namespace vt::tv::tests::unit { /** * Utility methods */ -class Util { +struct Util { public: /** * \brief Execute a command on the underlying system and returns exit code and output + * * \throws {@link std::runtime_error} if an error occurs while opening the process */ static std::tuple exec(const char* cmd) { @@ -94,9 +95,12 @@ class Util { /** * \brief Resolves a directory absolute path. + * * \param[in] base_path Prepends "{base_path}/" to the path if path is relative * \param[in] path The path as either a relative or an absolute path * \param[in] add_trailing_sep Appends a trailing "/" char at the end of the path if not exist + * + * \return the absolute path to the directory */ static std::string resolveDir( std::string base_path, std::string path, bool add_trailing_sep = false) {