Add unittest for NSUnregistertopic Case.
authorjaesick.shin <jaesick.shin@samsung.com>
Wed, 31 Aug 2016 08:00:36 +0000 (17:00 +0900)
committerUze Choi <uzchoi@samsung.com>
Fri, 2 Sep 2016 02:41:12 +0000 (02:41 +0000)
check the Unregistertopic case.

Change-Id: I0f182ce9b9e8b60b708740a35ea0880f1c537344
Signed-off-by: jaesick.shin <jaesick.shin@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/11207
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Tested-by: Uze Choi <uzchoi@samsung.com>
service/notification/unittest/NSProviderTest.cpp

index 399c200..24e50f3 100755 (executable)
@@ -363,6 +363,41 @@ TEST_F(NotificationProviderTest, ExpectEqualAddedTopicsAndRegisteredTopics)
     EXPECT_EQ(isSame, true);
 }
 
+TEST_F(NotificationProviderTest, ExpectEqualUnregisteredTopicsAndRegisteredTopics)
+{
+    std::string str("TEST1");
+    std::string str2("TEST2");
+    NSProviderRegisterTopic(str.c_str());
+    NSProviderRegisterTopic(str2.c_str());
+    NSProviderUnregisterTopic(str2.c_str());
+
+    std::unique_lock< std::mutex > lock{ mutexForCondition };
+    responseCon.wait_for(lock, std::chrono::milliseconds(1000));
+
+    bool isSame = true;
+    NSTopicLL * topics = NSProviderGetTopics();
+
+    if(!topics)
+    {
+        printf("topic is NULL\n");
+        isSame = false;
+    }
+    else
+    {
+        NSTopicLL * iter = topics;
+        std::string compStr(iter->topicName);
+
+        printf("str = %s, compStr = %s\n", str.c_str(), iter->topicName);
+
+        if(str.compare(compStr) == 0)
+        {
+            isSame = true;
+        }
+    }
+
+    EXPECT_EQ(isSame, true);
+}
+
 TEST_F(NotificationProviderTest, CancelObserves)
 {
     bool ret = g_consumerSimul.cancelObserves();