1 // Copyright 2015 Intel Mobile Communications GmbH All Rights Reserved.
3 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
17 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
19 #include "gtest/gtest.h"
21 #include "srmutility.h"
22 #include "oic_string.h"
24 //ParseRestQuery Tests
25 TEST(ParseRestQueryTest, ParseRestQueryEmpty)
27 unsigned char query[] = "";
28 OicParseQueryIter_t parseIter = OicParseQueryIter_t();
29 ParseQueryIterInit(query, &parseIter);
30 EXPECT_EQ(NULL, GetNextQuery(&parseIter));
34 TEST(ParseRestQueryTest, ParseSingleRestQuery)
36 char attr[10], val[10];
37 unsigned char query[] = "owned=false";
39 OicParseQueryIter_t parseIter = OicParseQueryIter_t();
40 ParseQueryIterInit(query, &parseIter);
41 EXPECT_NE((OicParseQueryIter_t *)NULL, GetNextQuery(&parseIter));
43 OICStrcpyPartial(attr, sizeof(attr), (char *)parseIter.attrPos, parseIter.attrLen);
44 OICStrcpyPartial(val, sizeof(val), (char *)parseIter.valPos, parseIter.valLen);
45 printf("\nAttribute: %s value: %s\n\n", attr, val);
48 TEST(ParseRestQueryTest, ParseRestMultipleQuery)
50 char attr[10], val[10];
51 unsigned char query[] = "oxm=0;owned=true;owner=owner1";
53 OicParseQueryIter_t parseIter = OicParseQueryIter_t();
54 ParseQueryIterInit(query, &parseIter);
56 while(GetNextQuery(&parseIter))
58 EXPECT_NE(static_cast<size_t>(0), parseIter.pi.segment_length);
60 OICStrcpyPartial(attr, sizeof(attr), (char *)parseIter.attrPos, parseIter.attrLen);
61 OICStrcpyPartial(val, sizeof(val), (char *)parseIter.valPos, parseIter.valLen);
62 printf("Attribute: %s value: %s\n", attr, val);
68 #if defined(__WITH_DTLS__) || defined (__WITH_TLS__)
69 TEST(SetUuidSeedTest, NullParam)
71 EXPECT_EQ(OC_STACK_INVALID_PARAM, SetDeviceIdSeed(NULL, 0));
74 TEST(SetUuidSeedTest, InvalidParam)
76 uint8_t seed[1024] = {0};
78 EXPECT_EQ(OC_STACK_INVALID_PARAM, SetDeviceIdSeed(seed, 0));
79 EXPECT_EQ(OC_STACK_INVALID_PARAM, SetDeviceIdSeed(seed, sizeof(seed)));
82 TEST(SetUuidSeedTest, ValidValue)
84 uint8_t seed[8] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
85 EXPECT_EQ(OC_STACK_OK, SetDeviceIdSeed(seed, sizeof(seed)));