Kernel improvements (#485)
* **New Features** * Added public accessors for querying module/device start and ready state. * **Refactor** * Internal state moved to opaque internal objects; module/device/driver initializers now explicitly initialize internal pointers. * Lifecycle handling updated to construct/destruct internal state and use accessors. * **Tests** * Tests updated to use public accessors and explicit construct/destruct lifecycle calls. * **Chores** * Test build/include paths and small metadata updated.
This commit is contained in:
committed by
GitHub
parent
1757af859c
commit
79e43b093a
@@ -0,0 +1,36 @@
|
||||
#include "doctest.h"
|
||||
#include <Tactility/PubSub.h>
|
||||
|
||||
using namespace tt;
|
||||
|
||||
TEST_CASE("PubSub publishing with no subscriptions should not crash") {
|
||||
PubSub<int> pubsub;
|
||||
pubsub.publish(1);
|
||||
}
|
||||
|
||||
TEST_CASE("PubSub subscription receives published data") {
|
||||
PubSub<int> pubsub;
|
||||
int value = 0;
|
||||
|
||||
auto subscription = pubsub.subscribe([&value](auto newValue) {
|
||||
value = newValue;
|
||||
});
|
||||
pubsub.publish(1);
|
||||
|
||||
pubsub.unsubscribe(subscription);
|
||||
|
||||
CHECK_EQ(value, 1);
|
||||
}
|
||||
|
||||
TEST_CASE("PubSub unsubscribed subscription does not receive published data") {
|
||||
PubSub<int> pubsub;
|
||||
int value = 0;
|
||||
|
||||
auto subscription = pubsub.subscribe([&value](auto newValue) {
|
||||
value = newValue;
|
||||
});
|
||||
pubsub.unsubscribe(subscription);
|
||||
pubsub.publish(1);
|
||||
|
||||
CHECK_EQ(value, 0);
|
||||
}
|
||||
Reference in New Issue
Block a user