From: Tomek Mrugalski Date: Tue, 4 Jul 2017 19:14:29 +0000 (+0200) Subject: [5286] Added unit-tests to test if intX types are handled. X-Git-Tag: trac5227_base~24^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0aa6243ae3b6c3267e2ad52bddd17eaa2603450c;p=thirdparty%2Fkea.git [5286] Added unit-tests to test if intX types are handled. --- diff --git a/src/bin/dhcp4/tests/config_parser_unittest.cc b/src/bin/dhcp4/tests/config_parser_unittest.cc index f997ef2535..970a98796c 100644 --- a/src/bin/dhcp4/tests/config_parser_unittest.cc +++ b/src/bin/dhcp4/tests/config_parser_unittest.cc @@ -1995,6 +1995,31 @@ TEST_F(Dhcp4ParserTest, optionDefInvalidRecordType) { EXPECT_TRUE(errorContainsPosition(status, "")); } +/// The purpose of this test is to verify that various integer types +/// are supported. +TEST_F(Dhcp4ParserTest, optionIntegerTypes) { + // Configuration string. The third of the record fields + // is invalid. It is "sting" instead of "string". + std::string config = + "{ \"option-def\": [ {" + " \"name\": \"foo\"," + " \"code\": 100," + " \"type\": \"record\"," + " \"record-types\": \"uint8,uint16,uint32,int8,int16,int32\"," + " \"space\": \"isc\"" + " } ]" + "}"; + ConstElementPtr json; + ASSERT_NO_THROW(json = parseOPTION_DEF(config)); + + // Use the configuration string to create new option definition. + ConstElementPtr status; + EXPECT_NO_THROW(status = configureDhcp4Server(*srv_, json)); + ASSERT_TRUE(status); + // Expecting parsing error (error code 1). + checkResult(status, 0); +} + /// The goal of this test is to verify that the invalid encapsulated /// option space name is not accepted. TEST_F(Dhcp4ParserTest, optionDefInvalidEncapsulatedSpace) { diff --git a/src/bin/dhcp6/tests/config_parser_unittest.cc b/src/bin/dhcp6/tests/config_parser_unittest.cc index 777e0147b4..5d39b4468e 100644 --- a/src/bin/dhcp6/tests/config_parser_unittest.cc +++ b/src/bin/dhcp6/tests/config_parser_unittest.cc @@ -2393,6 +2393,32 @@ TEST_F(Dhcp6ParserTest, optionDefInvalidRecordType) { EXPECT_TRUE(errorContainsPosition(status, "")); } +/// The purpose of this test is to verify that various integer types +/// are supported. +TEST_F(Dhcp6ParserTest, optionIntegerTypes) { + // Configuration string. The third of the record fields + // is invalid. It is "sting" instead of "string". + std::string config = + "{ \"option-def\": [ {" + " \"name\": \"foo\"," + " \"code\": 100," + " \"type\": \"record\"," + " \"record-types\": \"uint8,uint16,uint32,int8,int16,int32\"," + " \"space\": \"isc\"" + " } ]" + "}"; + ConstElementPtr json; + ASSERT_NO_THROW(json = parseOPTION_DEF(config)); + + // Use the configuration string to create new option definition. + ConstElementPtr status; + EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json)); + ASSERT_TRUE(status); + // Expecting parsing error (error code 1). + checkResult(status, 0); +} + + /// The goal of this test is to verify that the invalid encapsulated /// option space name is not accepted. TEST_F(Dhcp6ParserTest, optionDefInvalidEncapsulatedSpace) {