aboutsummaryrefslogtreecommitdiff
path: root/test/interop/dollar_topics_test.c
blob: d7cb1309b3821924a79e06b008b698c7fe108869 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "greatest.h"
#include "testclient.h"
#include "cleanup.c"
#include "topics.c"
#include <bstrlib/bstrlib.h>

TEST dollar_topics_test()
{
    TestClient *client;
    bstring topic;

    topic = bfromcstr("$");
    bcatcstr(topic, topics[1]);

    client = TestClientNew("clientb");
    ASSERT(TestClientConnect(client, "localhost", 1883, 60, 0));
    ASSERT(TestClientSubscribe(client, wildtopics[5], 2));
    ASSERT(TestClientWait(client, 1000));
    ASSERT(TestClientPublish(client, 1, 0, bdata(topic), ""));
    ASSERT(TestClientWait(client, 2000));
    TestClientDisconnect(client);
    ASSERT_EQ(0, TestClientMessageCount(client));
    TestClientFree(client);

    bdestroy(topic);

    PASS();
}

GREATEST_MAIN_DEFS();

int main(int argc, char **argv)
{
    GREATEST_MAIN_BEGIN();
    cleanup();
    RUN_TEST(dollar_topics_test);
    GREATEST_MAIN_END();
}