tests: better test initializing allowing for better printing (#5379)

Co-authored-by: Nerixyz <nerixdev@outlook.de>
This commit is contained in:
pajlada
2024-05-05 15:01:07 +02:00
committed by GitHub
parent a88a2ac65c
commit 401feac0aa
41 changed files with 198 additions and 178 deletions
+43 -2
View File
@@ -4,12 +4,12 @@
#include "providers/twitch/pubsubmessages/AutoMod.hpp"
#include "providers/twitch/pubsubmessages/Whisper.hpp"
#include "providers/twitch/TwitchAccount.hpp"
#include "TestHelpers.hpp"
#include "Test.hpp"
#include <gtest/gtest.h>
#include <QString>
#include <chrono>
#include <mutex>
#include <optional>
using namespace chatterino;
@@ -33,6 +33,47 @@ using namespace std::chrono_literals;
#ifdef RUN_PUBSUB_TESTS
template <typename T>
class ReceivedMessage
{
mutable std::mutex mutex;
bool isSet{false};
T t;
public:
ReceivedMessage() = default;
explicit operator bool() const
{
std::unique_lock lock(this->mutex);
return this->isSet;
}
ReceivedMessage &operator=(const T &newT)
{
std::unique_lock lock(this->mutex);
this->isSet = true;
this->t = newT;
return *this;
}
bool operator==(const T &otherT) const
{
std::unique_lock lock(this->mutex);
return this->t == otherT;
}
const T *operator->() const
{
return &this->t;
}
};
class FTest : public PubSub
{
public: