1 /* *****************************************************************
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 * *****************************************************************/
20 #include "gtest/gtest.h"
21 #include "pmutility.h"
31 extern OCStackResult AddDevice(OCProvisionDev_t **ppDevicesList, const char* addr,
32 const uint16_t port, OCTransportAdapter adapter,
33 OCConnectivityType connType, OicSecDoxm_t *doxm);
38 OCProvisionDev_t* gList = NULL;
41 TEST(ProvisionListTest, Addition)
43 OCProvisionDev_t* el = NULL;
44 OCStackResult res = OC_STACK_ERROR;
45 OicSecDoxm_t* pDoxm = NULL;
49 res = AddDevice(&gList, "10.20.30.40", 5684, OC_DEFAULT_ADAPTER, CT_IP_USE_V4, pDoxm);
50 EXPECT_TRUE(OC_STACK_OK == res);
51 EXPECT_TRUE(NULL != gList);
53 LL_FOREACH(gList,el){ ++cnt; };
54 EXPECT_TRUE(1 == cnt);
56 // Same node must not be inserted
57 res = AddDevice(&gList, "10.20.30.40", 5684, OC_ADAPTER_IP, CT_IP_USE_V4, pDoxm);
58 EXPECT_TRUE(OC_STACK_OK == res);
59 EXPECT_TRUE(NULL != gList);
62 LL_FOREACH(gList,el){ ++cnt; };
63 EXPECT_TRUE(1 == cnt);
65 // Differnet node must be inserted
66 res = AddDevice(&gList, "110.120.130.140", 6789, OC_DEFAULT_ADAPTER, CT_IP_USE_V4, pDoxm);
67 EXPECT_TRUE(OC_STACK_OK == res);
68 EXPECT_TRUE(NULL != gList);
71 LL_FOREACH(gList,el){ ++cnt; };
72 EXPECT_TRUE(2 == cnt);
76 TEST(ProvisionListTest, Deletion)
78 OCProvisionDev_t* el = NULL;
82 PMDeleteDeviceList(gList);
85 LL_FOREACH(gList,el){ ++cnt; };
86 EXPECT_TRUE(0 == cnt);