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 **ppList, const char* addr, const uint16_t port,
32 OCTransportAdapter adapter, OicSecDoxm_t *doxm);
37 OCProvisionDev_t* gList = NULL;
40 TEST(ProvisionListTest, Addition)
42 OCProvisionDev_t* el = NULL;
43 OCStackResult res = OC_STACK_ERROR;
44 OicSecDoxm_t* pDoxm = NULL;
48 res = AddDevice(&gList, "10.20.30.40", 5684, OC_DEFAULT_ADAPTER, pDoxm);
49 EXPECT_TRUE(OC_STACK_OK == res);
50 EXPECT_TRUE(NULL != gList);
52 LL_FOREACH(gList,el){ ++cnt; };
53 //LL_COUNT(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, pDoxm);
58 EXPECT_TRUE(OC_STACK_OK == res);
59 EXPECT_TRUE(NULL != gList);
62 LL_FOREACH(gList,el){ ++cnt; };
63 //LL_COUNT(gList, el, cnt);
64 EXPECT_TRUE(1 == cnt);
66 // Differnet node must be inserted
67 res = AddDevice(&gList, "110.120.130.140", 6789, OC_DEFAULT_ADAPTER, pDoxm);
68 EXPECT_TRUE(OC_STACK_OK == res);
69 EXPECT_TRUE(NULL != gList);
72 LL_FOREACH(gList,el){ ++cnt; };
73 //LL_COUNT(gList, el, cnt);
74 EXPECT_TRUE(2 == cnt);
78 TEST(ProvisionListTest, Deletion)
80 OCProvisionDev_t* el = NULL;
84 DeleteDeviceList(&gList);
87 LL_FOREACH(gList,el){ ++cnt; };
88 //LL_COUNT(gList, el, cnt);
89 EXPECT_TRUE(0 == cnt);