From: Erich Keane Date: Thu, 26 Mar 2015 23:24:51 +0000 (-0700) Subject: Added OCHeaderOption unit tests X-Git-Tag: 1.2.0+RC1~1855^2~57 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=25378fba1d0fbe7b0b2df63068c66ac76421a465;p=platform%2Fupstream%2Fiotivity.git Added OCHeaderOption unit tests Adding a bunch of unit tests to completely validate the functionality of OCHeaderOption Change-Id: I53efd7e92b03a371f4a302e743128572195f1c29 Signed-off-by: Erich Keane Reviewed-on: https://gerrit.iotivity.org/gerrit/586 Tested-by: jenkins-iotivity Reviewed-by: Sakthivel Samidurai Reviewed-by: Sudarshan Prasad --- diff --git a/resource/unittests/OCHeaderOptionTest.cpp b/resource/unittests/OCHeaderOptionTest.cpp new file mode 100644 index 0000000..df1a5e3 --- /dev/null +++ b/resource/unittests/OCHeaderOptionTest.cpp @@ -0,0 +1,82 @@ +//****************************************************************** +// +// Copyright 2015 Intel Mobile Communications GmbH All Rights Reserved. +// +//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +#include +#include +#include +#include +#include + +namespace OC +{ + namespace test + { + namespace OCHeaderOptionTests + { + using namespace OC; + + TEST(OCHeaderOptionTest, ConstructorValidRangeTest) + { + // Note: this test just assures that none of these + // constructors throw an exception + for(uint16_t i = HeaderOption::MIN_HEADER_OPTIONID; + i < HeaderOption::MAX_HEADER_OPTIONID; + ++i) + { + HeaderOption::OCHeaderOption{i, ""}; + } + } + + TEST(OCHeaderOptionTest, ConstructorTooLowOptionIdTest) + { + for(uint16_t i = 0; i < HeaderOption::MIN_HEADER_OPTIONID; ++i) + { + ASSERT_THROW( + HeaderOption::OCHeaderOption(i,""), + OCException); + } + } + + TEST(OCHeaderOptionTest, ConstructorTooHighOptionIdTest) + { + for(uint16_t i = HeaderOption::MAX_HEADER_OPTIONID +1 ; i