Commit 9cfd314b authored by Mandeep Shetty's avatar Mandeep Shetty Committed by Erich Keane

Added unit tests for OCSetPlatformInfo()

Unit tests exercise code paths to check for mandatory fields and
length constraints on some fields.

Change-Id: Ic15e1717b8743a4168b7c3d9cd67edbc5621dc3a
Signed-off-by: default avatarMandeep Shetty <mandeep.shetty@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1032Reviewed-by: default avatarJoseph Morrow <joseph.l.morrow@intel.com>
Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: default avatarErich Keane <erich.keane@intel.com>
parent 421a1ca4
......@@ -180,6 +180,71 @@ TEST(StackStart, StackStartSuccessiveInits)
EXPECT_EQ(OC_STACK_OK, OCStop());
}
TEST(StackStart, SetPlatformInfoValid)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
EXPECT_EQ(OC_STACK_OK, OCInit("127.0.0.1", 5683, OC_SERVER));
OCPlatformInfo info = {};
info.platformID = (char *) "platform_id";
info.manufacturerName = (char *) "manufac_name";
EXPECT_EQ(OC_STACK_OK, OCSetPlatformInfo(info));
EXPECT_EQ(OC_STACK_OK, OCStop());
}
TEST(StackStart, SetPlatformInfoWithNoPlatformID)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
EXPECT_EQ(OC_STACK_OK, OCInit("127.0.0.1", 5683, OC_SERVER));
OCPlatformInfo info = {};
info.manufacturerName = (char *) "manufac_name";
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCSetPlatformInfo(info));
EXPECT_EQ(OC_STACK_OK, OCStop());
}
TEST(StackStart, SetPlatformInfoWithNoManufacturerName)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
EXPECT_EQ(OC_STACK_OK, OCInit("127.0.0.1", 5683, OC_SERVER));
OCPlatformInfo info = {};
info.platformID = (char *) "platform_id";
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCSetPlatformInfo(info));
EXPECT_EQ(OC_STACK_OK, OCStop());
}
TEST(StackStart, SetPlatformInfoWithTooLongManufacName)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
EXPECT_EQ(OC_STACK_OK, OCInit("127.0.0.1", 5683, OC_SERVER));
OCPlatformInfo info = {};
info.platformID = (char *) "platform_id";
info.manufacturerName = (char *) "extremelylongmanufacturername";
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCSetPlatformInfo(info));
EXPECT_EQ(OC_STACK_OK, OCStop());
}
TEST(StackStart, SetPlatformInfoWithTooLongManufacURL)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
EXPECT_EQ(OC_STACK_OK, OCInit("127.0.0.1", 5683, OC_SERVER));
OCPlatformInfo info = {};
info.platformID = (char *) "platform_id";
info.manufacturerName = (char *) "extremelylongmanufacturername";
info.manufacturerUrl = (char *)"www.foooooooooooooooo.baaaaaaaaaaaaar";
EXPECT_EQ(OC_STACK_INVALID_PARAM, OCSetPlatformInfo(info));
EXPECT_EQ(OC_STACK_OK, OCStop());
}
TEST(StackDiscovery, DISABLED_DoResourceDeviceDiscovery)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment