Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tests): rework tests in numerous ways #3059

Merged
merged 2 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup! feat(tests): rework tests in numerous ways
  • Loading branch information
ns6089 authored and ReenigneArcher committed Aug 22, 2024
commit 02393258874bcb2ca6f0b95ba1c409ebe15f3f39
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
Loading