Skip to content

Commit

Permalink
fixup! feat(tests): rework tests in numerous ways
Browse files Browse the repository at this point in the history
  • Loading branch information
ns6089 committed Aug 22, 2024
1 parent ae2c3e7 commit b20d022
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
20 changes: 8 additions & 12 deletions tests/tests_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,22 @@
#include <src/logging.h>
#include <src/platform/common.h>

template <class T>
struct PlatformTestSuite: testing::Test {
static std::unique_ptr<platf::deinit_t> &
get_platform_deinit() {
static std::unique_ptr<platf::deinit_t> deinit;
return deinit;
}

static void
SetUpTestSuite() {
auto &deinit = get_platform_deinit();
ASSERT_FALSE(platf_deinit);
BOOST_LOG(tests) << "Setting up platform test suite";
deinit = platf::init();
ASSERT_TRUE(deinit);
platf_deinit = platf::init();
ASSERT_TRUE(platf_deinit);
}

static void
TearDownTestSuite() {
auto &deinit = get_platform_deinit();
deinit = {};
ASSERT_TRUE(platf_deinit);
platf_deinit = {};
BOOST_LOG(tests) << "Tore down platform test suite";
}

private:
inline static std::unique_ptr<platf::deinit_t> platf_deinit;
};
2 changes: 1 addition & 1 deletion tests/unit/test_audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

using namespace audio;

struct AudioTest: PlatformTestSuite<AudioTest>, testing::WithParamInterface<std::tuple<std::basic_string_view<char>, config_t>> {
struct AudioTest: PlatformTestSuite, testing::WithParamInterface<std::tuple<std::basic_string_view<char>, config_t>> {
void
SetUp() override {
m_config = std::get<1>(GetParam());
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_mouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "../tests_common.h"

struct MouseHIDTest: PlatformTestSuite<MouseHIDTest>, testing::WithParamInterface<util::point_t> {
struct MouseHIDTest: PlatformTestSuite, testing::WithParamInterface<util::point_t> {
void
SetUp() override {
#ifdef _WIN32
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "../tests_common.h"

struct EncoderTest: PlatformTestSuite<EncoderTest>, testing::WithParamInterface<video::encoder_t *> {
struct EncoderTest: PlatformTestSuite, testing::WithParamInterface<video::encoder_t *> {
void
SetUp() override {
auto &encoder = *GetParam();
Expand Down

0 comments on commit b20d022

Please sign in to comment.