C++ conversion (#80)

Converted project to C++
This commit is contained in:
Ken Van Hoeylandt
2024-11-22 20:26:08 +01:00
committed by GitHub
parent 6d80144e12
commit 85e26636a3
488 changed files with 6017 additions and 39466 deletions
+36
View File
@@ -0,0 +1,36 @@
#include "doctest.h"
#include "TactilityCore.h"
#include "Dispatcher.h"
using namespace tt;
void increment_callback(void* context) {
auto* counter = (uint32_t*)context;
(*counter)++;
}
TEST_CASE("dispatcher should not call callback if consume isn't called") {
Dispatcher dispatcher;
uint32_t counter = 0;
dispatcher.dispatch(&increment_callback, &counter);
delay_tick(10);
CHECK_EQ(counter, 0);
}
TEST_CASE("dispatcher should be able to dealloc when message is not consumed") {
auto* dispatcher = new Dispatcher();
uint32_t counter = 0;
dispatcher->dispatch(increment_callback, &counter);
delete dispatcher;
}
TEST_CASE("dispatcher should call callback when consume is called") {
Dispatcher dispatcher;
uint32_t counter = 0;
dispatcher.dispatch(increment_callback, &counter);
dispatcher.consume(100);
CHECK_EQ(counter, 1);
}