Skip to content

Commit

Permalink
#105: apply guideline to prefer struct over class for test classes
Browse files Browse the repository at this point in the history
  • Loading branch information
tlamonthezie committed Sep 4, 2024
1 parent 4c9160b commit c5760fd
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion tests/unit/api/basic_serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename TSerializable>
class BasicSerializer {
struct BasicSerializer {
public:
void operator|(const TSerializable& item) {
items[n] = item;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/api/test_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ struct InfoTestParam {
/**
* Provides unit tests for the vt::tv::api::Info class
*/
class InfoTest : public ::testing::TestWithParam<InfoTestParam> { };
struct InfoTest : public ::testing::TestWithParam<InfoTestParam> { };

/**
* Test Info:getNumRanks returns same number of ranks as defined in the sample
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/api/test_object_communicator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/api/test_object_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/api/test_object_work.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/api/test_phase_work.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ using ObjectWorkMap = std::unordered_map<ElementIDType, ObjectWork>;
/**
* 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);
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/api/test_rank.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<ElementIDType, ObjectWork> objects =
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/deps/test_vtk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/render/test_parse_render.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> {
struct ParseRenderTest : public ::testing::TestWithParam<std::string> {
void SetUp() override {
// Make the output directory for these tests
std::filesystem::create_directory(fmt::format("{}/output", SRC_DIR));
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/render/test_standalone_app.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::tuple<std::string, int>> {
void SetUp() override {
// This test is not testing vt-tv src.
Expand Down
6 changes: 5 additions & 1 deletion tests/unit/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<int, std::string> exec(const char* cmd) {
Expand All @@ -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) {
Expand Down

0 comments on commit c5760fd

Please sign in to comment.