From 54d697e8970ffd397a96f6c6e4e2df7a82f8c168 Mon Sep 17 00:00:00 2001 From: Oskari Timperi Date: Sun, 19 Feb 2017 13:44:25 +0200 Subject: Add interop test: subscribe_failure_test --- test/interop/CMakeLists.txt | 1 + test/interop/subscribe_failure_test.c | 28 ++++++++++++++++++++++++++++ test/interop/topics.c | 5 +++++ 3 files changed, 34 insertions(+) create mode 100644 test/interop/subscribe_failure_test.c (limited to 'test') diff --git a/test/interop/CMakeLists.txt b/test/interop/CMakeLists.txt index 7b3e7bc..f35ca04 100644 --- a/test/interop/CMakeLists.txt +++ b/test/interop/CMakeLists.txt @@ -15,3 +15,4 @@ ADD_INTEROP_TEST(offline_message_queueing_test) ADD_INTEROP_TEST(overlapping_subscriptions_test) ADD_INTEROP_TEST(keepalive_test) ADD_INTEROP_TEST(redelivery_on_reconnect_test) +ADD_INTEROP_TEST(subscribe_failure_test) diff --git a/test/interop/subscribe_failure_test.c b/test/interop/subscribe_failure_test.c new file mode 100644 index 0000000..84d3ebc --- /dev/null +++ b/test/interop/subscribe_failure_test.c @@ -0,0 +1,28 @@ +#include "greatest.h" +#include "testclient.h" +#include "cleanup.c" +#include "topics.c" + +TEST subscribe_failure_test() +{ + TestClient *client; + + client = TestClientNew("clienta"); + ASSERT(TestClientConnect(client, "localhost", 1883, 60, 1)); + ASSERT_FALSE(TestClientSubscribe(client, nosubscribe_topics[0], 2)); + ASSERT_EQ(MqttSubscriptionFailure, client->subStatus); + TestClientDisconnect(client); + TestClientFree(client); + + PASS(); +} + +GREATEST_MAIN_DEFS(); + +int main(int argc, char **argv) +{ + GREATEST_MAIN_BEGIN(); + cleanup(); + RUN_TEST(subscribe_failure_test); + GREATEST_MAIN_END(); +} diff --git a/test/interop/topics.c b/test/interop/topics.c index 3c75e92..dcab1d6 100644 --- a/test/interop/topics.c +++ b/test/interop/topics.c @@ -7,3 +7,8 @@ const char *wildtopics[] = { "TopicA/+", "+/C", "#", "/#", "/+", "+/+", "TopicA/#" }; + +const char *nosubscribe_topics[] = +{ + "test/nosubscribe" +}; -- cgit v1.2.3