From 3ec5a7fa999e11a8dc2b3f8fadd58b8375edf43a Mon Sep 17 00:00:00 2001 From: "jaesick.shin" Date: Wed, 31 Aug 2016 17:00:36 +0900 Subject: [PATCH] Add unittest for NSUnregistertopic Case. check the Unregistertopic case. Change-Id: I0f182ce9b9e8b60b708740a35ea0880f1c537344 Signed-off-by: jaesick.shin Reviewed-on: https://gerrit.iotivity.org/gerrit/11207 Tested-by: jenkins-iotivity Reviewed-by: Uze Choi Tested-by: Uze Choi --- service/notification/unittest/NSProviderTest.cpp | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/service/notification/unittest/NSProviderTest.cpp b/service/notification/unittest/NSProviderTest.cpp index 399c200..24e50f3 100755 --- a/service/notification/unittest/NSProviderTest.cpp +++ b/service/notification/unittest/NSProviderTest.cpp @@ -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(); -- 2.7.4