diff options
| author | Oskari Timperi <oskari.timperi@iki.fi> | 2017-02-19 00:32:05 +0200 |
|---|---|---|
| committer | Oskari Timperi <oskari.timperi@iki.fi> | 2017-02-19 00:32:05 +0200 |
| commit | 56b14eb55d3078d38e07bc22aae73e73017b1257 (patch) | |
| tree | 82260e91c808ce05903749a3e0d571efc2a4c470 /test/interop/overlapping_subscriptions_test.c | |
| parent | 751480833388b1e56bbe7c24b523bf98d9d04383 (diff) | |
| download | mqtt-56b14eb55d3078d38e07bc22aae73e73017b1257.tar.gz mqtt-56b14eb55d3078d38e07bc22aae73e73017b1257.zip | |
Add more interop tests
Diffstat (limited to 'test/interop/overlapping_subscriptions_test.c')
| -rw-r--r-- | test/interop/overlapping_subscriptions_test.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/test/interop/overlapping_subscriptions_test.c b/test/interop/overlapping_subscriptions_test.c new file mode 100644 index 0000000..c6e5da0 --- /dev/null +++ b/test/interop/overlapping_subscriptions_test.c @@ -0,0 +1,48 @@ +#include "greatest.h" +#include "testclient.h" +#include "cleanup.c" +#include "topics.c" + +TEST overlapping_subscriptions_test() +{ + TestClient *client; + int count; + + client = TestClientNew("clienta"); + ASSERT(TestClientConnect(client, "localhost", 1883, 60, 1)); + ASSERT(TestClientSubscribe(client, wildtopics[6], 2)); + ASSERT(TestClientSubscribe(client, wildtopics[0], 1)); + ASSERT(TestClientPublish(client, 2, 0, topics[3], + "overlapping topic filters")); + ASSERT(TestClientWait(client, 1000)); + TestClientDisconnect(client); + count = TestClientMessageCount(client); + ASSERT(count == 1 || count == 2); + if (count == 1) + { + printf("this server sends one message for for all matching " + "overlapping subscriptions, not one for each\n"); + ASSERT_EQ(2, SIMPLEQ_FIRST(&client->messages)->qos); + } + else + { + printf("this server sends one message per each matching overlapping " + "subscription\n"); + int qos1 = SIMPLEQ_FIRST(&client->messages)->qos; + int qos2 = SIMPLEQ_NEXT(SIMPLEQ_FIRST(&client->messages), chain)->qos; + ASSERT((qos1 == 1 && qos2 == 2) || (qos1 == 2 && qos2 == 1)); + } + TestClientFree(client); + + PASS(); +} + +GREATEST_MAIN_DEFS(); + +int main(int argc, char **argv) +{ + GREATEST_MAIN_BEGIN(); + cleanup(); + RUN_TEST(overlapping_subscriptions_test); + GREATEST_MAIN_END(); +} |
