🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
630 B

  1. #define CR_HOST
  2. #include <gtest/gtest.h>
  3. #include <cr.h>
  4. #include <entt/signal/dispatcher.hpp>
  5. #include <entt/signal/sigh.hpp>
  6. #include "types.h"
  7. struct listener {
  8. void on(message msg) {
  9. value = msg.payload;
  10. }
  11. int value{};
  12. };
  13. TEST(Lib, Dispatcher) {
  14. entt::dispatcher dispatcher;
  15. listener listener;
  16. ASSERT_EQ(listener.value, 0);
  17. dispatcher.sink<message>().connect<&listener::on>(listener);
  18. cr_plugin ctx;
  19. cr_plugin_load(ctx, PLUGIN);
  20. ctx.userdata = &dispatcher;
  21. cr_plugin_update(ctx);
  22. ASSERT_EQ(listener.value, 42);
  23. dispatcher = {};
  24. cr_plugin_close(ctx);
  25. }