1 //******************************************************************
3 // Copyright 2015 Intel Mobile Communications GmbH All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
22 #include <gtest/gtest.h>
23 #include <OCHeaderOption.h>
24 #include <OCException.h>
25 #include <StringConstants.h>
31 namespace OCHeaderOptionTests
35 TEST(OCHeaderOptionTest, ConstructorValidRangeTest)
37 // Note: this test just assures that none of these
38 // constructors throw an exception
39 for(uint16_t i = HeaderOption::MIN_HEADER_OPTIONID;
40 i < HeaderOption::MAX_HEADER_OPTIONID;
43 HeaderOption::OCHeaderOption{i, ""};
47 TEST(OCHeaderOptionTest, ConstructorTooLowOptionIdTest)
49 for(uint16_t i = 0; i < HeaderOption::MIN_HEADER_OPTIONID; ++i)
51 if (HeaderOption::IF_MATCH_OPTION_ID != i
52 && HeaderOption::IF_NONE_MATCH_OPTION_ID != i
53 && HeaderOption::LOCATION_PATH_OPTION_ID != i
54 && HeaderOption::LOCATION_QUERY_OPTION_ID != i)
57 HeaderOption::OCHeaderOption(i,""),
63 TEST(OCHeaderOptionTest, ConstructorTooHighOptionIdTest)
65 for(uint16_t i = HeaderOption::MAX_HEADER_OPTIONID +1 ; i <UINT16_MAX;++i)
68 HeaderOption::OCHeaderOption(i,""),
73 TEST(OCHeaderOptionTest, OptionIDTest)
75 HeaderOption::OCHeaderOption opt {HeaderOption::MIN_HEADER_OPTIONID + 5, ""};
76 EXPECT_EQ(HeaderOption::MIN_HEADER_OPTIONID + 5, opt.getOptionID());
79 TEST(OCHeaderOptionTest, OptionDataTest)
81 std::string optionData {"134kl5jt iopdfgj;lwe45 puiondj;vlk345t89o sdkl;ag"};
82 HeaderOption::OCHeaderOption opt {HeaderOption::MIN_HEADER_OPTIONID, optionData};
83 EXPECT_EQ(optionData, opt.getOptionData());
86 } //namespace OCHeaderOptionTests