Squashed 'external/entt/entt/' content from commit fef92113
git-subtree-dir: external/entt/entt git-subtree-split: fef921132cae7588213d0f9bcd2fb9c8ffd8b7fc
This commit is contained in:
8
test/lib/emitter/lib.cpp
Normal file
8
test/lib/emitter/lib.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include <entt/core/attribute.h>
|
||||
#include "types.h"
|
||||
|
||||
ENTT_API void emit(test_emitter &emitter) {
|
||||
emitter.publish(event{});
|
||||
emitter.publish(message{42});
|
||||
emitter.publish(message{3});
|
||||
}
|
21
test/lib/emitter/main.cpp
Normal file
21
test/lib/emitter/main.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <entt/core/attribute.h>
|
||||
#include "types.h"
|
||||
|
||||
ENTT_API void emit(test_emitter &);
|
||||
|
||||
TEST(Lib, Emitter) {
|
||||
test_emitter emitter;
|
||||
int value{};
|
||||
|
||||
ASSERT_EQ(value, 0);
|
||||
|
||||
emitter.on<message>([&](message msg, test_emitter &owner) {
|
||||
value = msg.payload;
|
||||
owner.erase<message>();
|
||||
});
|
||||
|
||||
emit(emitter);
|
||||
|
||||
ASSERT_EQ(value, 42);
|
||||
}
|
16
test/lib/emitter/types.h
Normal file
16
test/lib/emitter/types.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef ENTT_LIB_EMITTER_TYPES_H
|
||||
#define ENTT_LIB_EMITTER_TYPES_H
|
||||
|
||||
#include <entt/core/attribute.h>
|
||||
#include <entt/signal/emitter.hpp>
|
||||
|
||||
struct ENTT_API test_emitter
|
||||
: entt::emitter<test_emitter> {};
|
||||
|
||||
struct ENTT_API message {
|
||||
int payload;
|
||||
};
|
||||
|
||||
struct ENTT_API event {};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user