initial
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
#define CR_HOST
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <cr.h>
|
||||
#include <entt/signal/dispatcher.hpp>
|
||||
#include <entt/signal/sigh.hpp>
|
||||
#include "../../../common/boxed_type.h"
|
||||
#include "../../../common/listener.h"
|
||||
|
||||
TEST(Lib, Dispatcher) {
|
||||
entt::dispatcher dispatcher;
|
||||
test::listener<test::boxed_int> listener;
|
||||
|
||||
ASSERT_EQ(listener.value, 0);
|
||||
|
||||
dispatcher.sink<test::boxed_int>().connect<&test::listener<test::boxed_int>::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);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#include <cr.h>
|
||||
#include <entt/signal/dispatcher.hpp>
|
||||
#include "../../../common/boxed_type.h"
|
||||
#include "../../../common/empty.h"
|
||||
|
||||
CR_EXPORT int cr_main(cr_plugin *ctx, cr_op operation) {
|
||||
switch(operation) {
|
||||
case CR_STEP:
|
||||
static_cast<entt::dispatcher *>(ctx->userdata)->trigger<test::empty>();
|
||||
static_cast<entt::dispatcher *>(ctx->userdata)->trigger(test::boxed_int{4});
|
||||
break;
|
||||
case CR_CLOSE:
|
||||
case CR_LOAD:
|
||||
case CR_UNLOAD:
|
||||
// nothing to do here, this is only a test.
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#include <entt/core/attribute.h>
|
||||
#include <entt/signal/dispatcher.hpp>
|
||||
#include "../../../common/boxed_type.h"
|
||||
#include "../../../common/empty.h"
|
||||
|
||||
ENTT_API void trigger(entt::dispatcher &dispatcher) {
|
||||
dispatcher.trigger<test::empty>();
|
||||
dispatcher.trigger(test::boxed_int{2});
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <entt/core/attribute.h>
|
||||
#include <entt/core/utility.hpp>
|
||||
#include <entt/signal/dispatcher.hpp>
|
||||
#include <entt/signal/sigh.hpp>
|
||||
#include "../../../common/boxed_type.h"
|
||||
#include "../../../common/listener.h"
|
||||
|
||||
ENTT_API void trigger(entt::dispatcher &);
|
||||
|
||||
TEST(Lib, Dispatcher) {
|
||||
entt::dispatcher dispatcher;
|
||||
test::listener<test::boxed_int> listener;
|
||||
|
||||
ASSERT_EQ(listener.value, 0);
|
||||
|
||||
dispatcher.sink<test::boxed_int>().connect<entt::overload<void(test::boxed_int)>(&test::listener<test::boxed_int>::on)>(listener);
|
||||
trigger(dispatcher);
|
||||
|
||||
ASSERT_EQ(listener.value, 2);
|
||||
}
|
||||
Reference in New Issue
Block a user