test: share as much as possible

This commit is contained in:
Michele Caini
2023-01-18 10:29:37 +01:00
parent f94de1c069
commit 831054bff1
33 changed files with 48 additions and 104 deletions

View File

@@ -0,0 +1,10 @@
#ifndef ENTT_LIB_DISPATCHER_COMMON_TYPES_H
#define ENTT_LIB_DISPATCHER_COMMON_TYPES_H
struct message {
int payload;
};
struct event {};
#endif

View File

@@ -4,7 +4,7 @@
#include <cr.h>
#include <entt/signal/dispatcher.hpp>
#include <entt/signal/sigh.hpp>
#include "types.h"
#include "../common/types.h"
struct listener {
void on(message msg) {

View File

@@ -1,6 +1,6 @@
#include <cr.h>
#include <entt/signal/dispatcher.hpp>
#include "types.h"
#include "../common/types.h"
CR_EXPORT int cr_main(cr_plugin *ctx, cr_op operation) {
switch(operation) {

View File

@@ -1,10 +0,0 @@
#ifndef ENTT_LIB_DISPATCHER_PLUGIN_TYPES_H
#define ENTT_LIB_DISPATCHER_PLUGIN_TYPES_H
struct message {
int payload;
};
struct event {};
#endif

View File

@@ -1,6 +1,6 @@
#include <entt/core/attribute.h>
#include <entt/signal/dispatcher.hpp>
#include "types.h"
#include "../common/types.h"
ENTT_API void trigger(entt::dispatcher &dispatcher) {
dispatcher.trigger<event>();

View File

@@ -3,7 +3,7 @@
#include <entt/core/utility.hpp>
#include <entt/signal/dispatcher.hpp>
#include <entt/signal/sigh.hpp>
#include "types.h"
#include "../common/types.h"
ENTT_API void trigger(entt::dispatcher &);

View File

@@ -1,10 +0,0 @@
#ifndef ENTT_LIB_DISPATCHER_TYPES_H
#define ENTT_LIB_DISPATCHER_TYPES_H
struct message {
int payload;
};
struct event {};
#endif

View File

@@ -1,5 +1,5 @@
#ifndef ENTT_LIB_EMITTER_PLUGIN_TYPES_H
#define ENTT_LIB_EMITTER_PLUGIN_TYPES_H
#ifndef ENTT_LIB_EMITTER_COMMON_TYPES_H
#define ENTT_LIB_EMITTER_COMMON_TYPES_H
#include <entt/signal/emitter.hpp>

View File

@@ -2,7 +2,7 @@
#include <gtest/gtest.h>
#include <cr.h>
#include "types.h"
#include "../common/types.h"
TEST(Lib, Emitter) {
test_emitter emitter;

View File

@@ -1,5 +1,5 @@
#include <cr.h>
#include "types.h"
#include "../common/types.h"
CR_EXPORT int cr_main(cr_plugin *ctx, cr_op operation) {
switch(operation) {

View File

@@ -1,5 +1,5 @@
#include <entt/core/attribute.h>
#include "types.h"
#include "../common/types.h"
ENTT_API void emit(test_emitter &emitter) {
emitter.publish(event{});

View File

@@ -1,6 +1,6 @@
#include <gtest/gtest.h>
#include <entt/core/attribute.h>
#include "types.h"
#include "../common/types.h"
ENTT_API void emit(test_emitter &);

View File

@@ -1,15 +0,0 @@
#ifndef ENTT_LIB_EMITTER_TYPES_H
#define ENTT_LIB_EMITTER_TYPES_H
#include <entt/signal/emitter.hpp>
struct test_emitter
: entt::emitter<test_emitter> {};
struct message {
int payload;
};
struct event {};
#endif

View File

@@ -0,0 +1,8 @@
#ifndef ENTT_LIB_LOCATOR_COMMON_TYPES_H
#define ENTT_LIB_LOCATOR_COMMON_TYPES_H
struct service {
int value;
};
#endif

View File

@@ -3,6 +3,7 @@
#include <gtest/gtest.h>
#include <cr.h>
#include <entt/locator/locator.hpp>
#include "../common/types.h"
#include "types.h"
TEST(Lib, Locator) {

View File

@@ -1,5 +1,6 @@
#include <cr.h>
#include <entt/locator/locator.hpp>
#include "../common/types.h"
#include "types.h"
CR_EXPORT int cr_main(cr_plugin *ctx, cr_op operation) {

View File

@@ -3,10 +3,6 @@
#include <entt/locator/locator.hpp>
struct service {
int value;
};
struct userdata {
typename entt::locator<service>::node_type handle;
int value;

View File

@@ -1,6 +1,6 @@
#include <entt/core/attribute.h>
#include <entt/locator/locator.hpp>
#include "types.h"
#include "../common/types.h"
ENTT_API void set_up(const entt::locator<service>::node_type &handle) {
entt::locator<service>::reset(handle);

View File

@@ -1,7 +1,7 @@
#include <gtest/gtest.h>
#include <entt/core/attribute.h>
#include <entt/locator/locator.hpp>
#include "types.h"
#include "../common/types.h"
ENTT_API void set_up(const entt::locator<service>::node_type &);
ENTT_API void use_service(int);

View File

@@ -1,8 +0,0 @@
#ifndef ENTT_LIB_LOCATOR_TYPES_H
#define ENTT_LIB_LOCATOR_TYPES_H
struct service {
int value;
};
#endif

View File

@@ -1,5 +1,5 @@
#ifndef ENTT_LIB_REGISTRY_TYPES_H
#define ENTT_LIB_REGISTRY_TYPES_H
#ifndef ENTT_LIB_META_COMMON_TYPES_H
#define ENTT_LIB_META_COMMON_TYPES_H
struct position {
int x;

View File

@@ -4,6 +4,7 @@
#include <entt/meta/context.hpp>
#include <entt/meta/factory.hpp>
#include <entt/meta/meta.hpp>
#include "../common/types.h"
#include "types.h"
position create_position(int x, int y) {

View File

@@ -4,16 +4,6 @@
#include <entt/locator/locator.hpp>
#include <entt/meta/meta.hpp>
struct position {
int x;
int y;
};
struct velocity {
double dx;
double dy;
};
struct userdata {
entt::locator<entt::meta_ctx>::node_type ctx;
entt::meta_any any;

View File

@@ -3,6 +3,7 @@
#include <entt/meta/context.hpp>
#include <entt/meta/factory.hpp>
#include <entt/meta/meta.hpp>
#include "../common/types.h"
#include "types.h"
position create_position(int x, int y) {

View File

@@ -1,5 +1,5 @@
#ifndef ENTT_LIB_META_PLUGIN_TYPES_STD_H
#define ENTT_LIB_META_PLUGIN_TYPES_STD_H
#ifndef ENTT_LIB_META_PLUGIN_STD_TYPES_H
#define ENTT_LIB_META_PLUGIN_STD_TYPES_H
#include <type_traits>
#include <entt/core/hashed_string.hpp>
@@ -17,15 +17,8 @@ struct custom_type_hash;
} \
}
struct position {
int x;
int y;
};
struct velocity {
double dx;
double dy;
};
struct position;
struct velocity;
struct userdata {
entt::locator<entt::meta_ctx>::node_type ctx;

View File

@@ -2,7 +2,7 @@
#include <entt/core/hashed_string.hpp>
#include <entt/meta/factory.hpp>
#include <entt/meta/meta.hpp>
#include "types.h"
#include "../common/types.h"
position create_position(int x, int y) {
return position{x, y};

View File

@@ -4,7 +4,7 @@
#include <entt/meta/factory.hpp>
#include <entt/meta/meta.hpp>
#include <entt/meta/resolve.hpp>
#include "types.h"
#include "../common/types.h"
ENTT_API void share(entt::locator<entt::meta_ctx>::node_type);
ENTT_API void set_up();

View File

@@ -1,14 +0,0 @@
#ifndef ENTT_LIB_META_TYPES_H
#define ENTT_LIB_META_TYPES_H
struct position {
int x;
int y;
};
struct velocity {
double dx;
double dy;
};
#endif

View File

@@ -1,5 +1,5 @@
#ifndef ENTT_LIB_REGISTRY_PLUGIN_TYPES_H
#define ENTT_LIB_REGISTRY_PLUGIN_TYPES_H
#ifndef ENTT_LIB_REGISTRY_COMMON_TYPES_H
#define ENTT_LIB_REGISTRY_COMMON_TYPES_H
struct position {
int x;

View File

@@ -3,7 +3,7 @@
#include <gtest/gtest.h>
#include <cr.h>
#include <entt/entity/registry.hpp>
#include "types.h"
#include "../common/types.h"
TEST(Lib, Registry) {
entt::registry registry;

View File

@@ -1,6 +1,6 @@
#include <cr.h>
#include <entt/entity/registry.hpp>
#include "types.h"
#include "../common/types.h"
CR_EXPORT int cr_main(cr_plugin *ctx, cr_op operation) {
switch(operation) {

View File

@@ -1,6 +1,6 @@
#include <entt/core/attribute.h>
#include <entt/entity/registry.hpp>
#include "types.h"
#include "../common/types.h"
ENTT_API void update_position(entt::registry &registry) {
registry.view<position, velocity>().each([](auto &pos, auto &vel) {

View File

@@ -2,7 +2,7 @@
#include <entt/core/attribute.h>
#include <entt/entity/entity.hpp>
#include <entt/entity/registry.hpp>
#include "types.h"
#include "../common/types.h"
ENTT_API void update_position(entt::registry &);
ENTT_API void emplace_velocity(entt::registry &);