| 12345678910111213141516171819202122232425262728293031323334 |
- #define CR_HOST
- #include <gtest/gtest.h>
- #include <common/boxed_type.h>
- #include <cr.h>
- #include <entt/signal/dispatcher.hpp>
- struct listener {
- void on(test::boxed_int msg) {
- value = msg.value;
- }
- int value{};
- };
- TEST(Lib, Dispatcher) {
- entt::dispatcher dispatcher;
- listener listener;
- ASSERT_EQ(listener.value, 0);
- dispatcher.sink<test::boxed_int>().connect<&listener::on>(listener);
- cr_plugin ctx;
- cr_plugin_load(ctx, PLUGIN);
- ctx.userdata = &dispatcher;
- cr_plugin_update(ctx);
- ASSERT_EQ(listener.value, 4);
- dispatcher = {};
- cr_plugin_close(ctx);
- }
|