drogon/lib/tests/unittests/PubSubServiceUnittest.cc

19 lines
700 B
C++
Raw Normal View History

2021-05-27 12:09:57 +00:00
#include <drogon/PubSubService.h>
#include <drogon/drogon_test.h>
DROGON_TEST(PubSubServiceTest)
{
drogon::PubSubService<std::string> service;
auto id = service.subscribe("topic1",
[TEST_CTX](const std::string &topic,
const std::string &message) {
CHECK(topic == "topic1");
CHECK(message == "hello world");
});
service.publish("topic1", "hello world");
service.publish("topic2", "hello world");
CHECK(service.size() == 1UL);
2021-05-27 12:09:57 +00:00
service.unsubscribe("topic1", id);
CHECK(service.size() == 0UL);
2021-05-27 12:09:57 +00:00
}