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");
|
2021-06-09 11:14:15 +00:00
|
|
|
CHECK(service.size() == 1UL);
|
2021-05-27 12:09:57 +00:00
|
|
|
service.unsubscribe("topic1", id);
|
2021-06-09 11:14:15 +00:00
|
|
|
CHECK(service.size() == 0UL);
|
2021-05-27 12:09:57 +00:00
|
|
|
}
|