hyprutils/tests/signal.cpp

28 lines
507 B
C++
Raw Normal View History

2024-06-08 19:37:15 +02:00
#include <hyprutils/signal/Signal.hpp>
#include <hyprutils/memory/WeakPtr.hpp>
#include "shared.hpp"
using namespace Hyprutils::Signal;
using namespace Hyprutils::Memory;
int main(int argc, char** argv, char** envp) {
2024-09-25 23:44:05 +02:00
int ret = 0;
2024-06-08 19:37:15 +02:00
CSignal signal;
2024-09-25 23:44:05 +02:00
int data = 0;
auto listener = signal.registerListener([&](std::any d) { data = 1; });
2024-06-08 19:37:15 +02:00
signal.emit();
EXPECT(data, 1);
data = 0;
listener.reset();
signal.emit();
EXPECT(data, 0);
return ret;
}