🛠️🐜 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.

28 lines
602 B

  1. #include <gtest/gtest.h>
  2. #include <entt/core/attribute.h>
  3. #include <entt/core/utility.hpp>
  4. #include <entt/signal/dispatcher.hpp>
  5. #include <entt/signal/sigh.hpp>
  6. #include "types.h"
  7. ENTT_API void trigger(entt::dispatcher &);
  8. struct listener {
  9. void on(message msg) {
  10. value = msg.payload;
  11. }
  12. int value{};
  13. };
  14. TEST(Lib, Dispatcher) {
  15. entt::dispatcher dispatcher;
  16. listener listener;
  17. ASSERT_EQ(listener.value, 0);
  18. dispatcher.sink<message>().connect<entt::overload<void(message)>(&listener::on)>(listener);
  19. trigger(dispatcher);
  20. ASSERT_EQ(listener.value, 42);
  21. }