OptionDefinitionTest() { }
};
+// The purpose of this test is to verify that OptionDefinition
+// constructor initializes its members correctly.
TEST_F(OptionDefinitionTest, constructor) {
// Specify the option data type as string. This should get converted
// to enum value returned by getType().
);
}
+// The purpose of this test is to verify that various data fields
+// can be specified for an option definition when this definition
+// is marked as 'record' and that fields can't be added if option
+// definition is not marked as 'record'.
TEST_F(OptionDefinitionTest, addRecordField) {
// We can only add fields to record if the option type has been
// specified as 'record'. We try all other types but 'record'
EXPECT_THROW(opt_def.addRecordField(invalid_type), isc::BadValue);
}
+// The purpose of this test is to check that validate() function
+// reports errors for invalid option definitions.
TEST_F(OptionDefinitionTest, validate) {
// Not supported option type string is not allowed.
OptionDefinition opt_def1("OPTION_CLIENTID", D6O_CLIENTID, "non-existent-type");
EXPECT_THROW(opt_def6.validate(), isc::BadValue);
}
+// The purpose of this test is to verify that option definition
+// that comprises array of IPv6 addresses will return an instance
+// of option with a list of IPv6 addresses.
TEST_F(OptionDefinitionTest, ipv6AddressArray) {
OptionDefinition opt_def("OPTION_NIS_SERVERS", D6O_NIS_SERVERS,
"ipv6-address", true);
);
}
-// This test checks that a vector of strings, holding IPv6 addresses,
-// can be used to create option instance with the optionFactory function.
+// The purpose of this test is to verify that option definition
+// that comprises array of IPv6 addresses will return an instance
+// of option with a list of IPv6 addresses. Array of IPv6 addresses
+// is specified as a vector of strings (each string represents single
+// IPv6 address).
TEST_F(OptionDefinitionTest, ipv6AddressArrayTokenized) {
OptionDefinition opt_def("OPTION_NIS_SERVERS", D6O_NIS_SERVERS,
"ipv6-address", true);
EXPECT_TRUE(std::equal(addrs.begin(), addrs.end(), addrs_returned.begin()));
}
+// The purpose of this test is to verify that option definition
+// that comprises array of IPv4 addresses will return an instance
+// of option with a list of IPv4 addresses.
TEST_F(OptionDefinitionTest, ipv4AddressArray) {
OptionDefinition opt_def("OPTION_NAME_SERVERS", D6O_NIS_SERVERS,
"ipv4-address", true);
isc::OutOfRange);
}
-// This test checks that a vector of strings, holding IPv4 addresses,
-// can be used to create option instance with the optionFactory function.
+// The purpose of this test is to verify that option definition
+// that comprises array of IPv4 addresses will return an instance
+// of option with a list of IPv4 addresses. The array of IPv4 addresses
+// is specified as a vector of strings (each string represents single
+// IPv4 address).
TEST_F(OptionDefinitionTest, ipv4AddressArrayTokenized) {
OptionDefinition opt_def("OPTION_NIS_SERVERS", DHO_NIS_SERVERS,
"ipv4-address", true);
EXPECT_TRUE(std::equal(addrs.begin(), addrs.end(), addrs_returned.begin()));
}
+// The purpose of thie test is to verify that option definition for
+// 'empty' option can be created and that it returns 'empty' option.
TEST_F(OptionDefinitionTest, empty) {
OptionDefinition opt_def("OPTION_RAPID_COMMIT", D6O_RAPID_COMMIT, "empty");
EXPECT_EQ(0, option_v4->getData().size());
}
+// The purpose of this test is to verify that definition can be
+// creates for the option that holds binary data.
TEST_F(OptionDefinitionTest, binary) {
// Binary option is the one that is represented by the generic
// Option class. In fact all options can be represented by this
buf.begin()));
}
+// The purpose of this test is to verify that definition can be
+// creates for the option that holds binary data and that the
+// binary data can be specified in 'comma separated values'
+// format.
TEST_F(OptionDefinitionTest, binaryTokenized) {
OptionDefinition opt_def("OPTION_FOO", 1000, "binary", true);
buf.begin()));
}
-
+// The purpose of this test is to verify that definition can be created
+// for option that comprises record of data. In this particular test
+// the IA_NA option is used. This option comprises three uint32 fields.
TEST_F(OptionDefinitionTest, recordIA6) {
// This option consists of IAID, T1 and T2 fields (each 4 bytes long).
const int option6_ia_len = 12;
// Get the factory function pointer.
- OptionDefinition opt_def("OPTION_IA_NA", D6O_IA_NA, "record", true);
+ OptionDefinition opt_def("OPTION_IA_NA", D6O_IA_NA, "record", false);
// Each data field is uint32.
for (int i = 0; i < 3; ++i) {
EXPECT_NO_THROW(opt_def.addRecordField("uint32"));
);
}
+// The purpose of this test is to verify that definition can be created
+// for option that comprises record of data. In this particular test
+// the IAADDR option is used.
TEST_F(OptionDefinitionTest, recordIAAddr6) {
// This option consists of IPV6 Address (16 bytes) and preferred-lifetime and
// valid-lifetime fields (each 4 bytes long).
);
}
+// The purpose of this test is to verify that definition can be created
+// for option that comprises record of data. In this particular test
+// the IAADDR option is used. The data for the option is speicifed as
+// a vector of strings. Each string carries the data for the corresponding
+// data field.
TEST_F(OptionDefinitionTest, recordIAAddr6Tokenized) {
// This option consists of IPV6 Address (16 bytes) and preferred-lifetime and
// valid-lifetime fields (each 4 bytes long).
);
}
-TEST_F(OptionDefinitionTest, integerInvalidType) {
- // The template function factoryInteger<> accepts integer values only
- // as template typename. Here we try passing different type and
- // see if it rejects it.
- OptionBuffer buf(1);
- EXPECT_THROW(
- OptionDefinition::factoryInteger<bool>(Option::V6, D6O_PREFERENCE,
- buf.begin(), buf.end()),
- isc::dhcp::InvalidDataType
- );
-}
-
+// The purpose of this test is to verify that definition for option that
+// comprises single uint8 value can be created and that this definition
+// can be used to create an option with single uint8 value.
TEST_F(OptionDefinitionTest, uint8) {
OptionDefinition opt_def("OPTION_PREFERENCE", D6O_PREFERENCE, "uint8");
// @todo Add more cases for DHCPv4
}
+// The purpose of this test is to verify that definition for option that
+// comprises single uint8 value can be created and that this definition
+// can be used to create an option with single uint8 value.
TEST_F(OptionDefinitionTest, uint8Tokenized) {
OptionDefinition opt_def("OPTION_PREFERENCE", D6O_PREFERENCE, "uint8");
// @todo Add more cases for DHCPv4
}
-
+// The purpose of this test is to verify that definition for option that
+// comprises single uint16 value can be created and that this definition
+// can be used to create an option with single uint16 value.
TEST_F(OptionDefinitionTest, uint16) {
OptionDefinition opt_def("OPTION_ELAPSED_TIME", D6O_ELAPSED_TIME, "uint16");
// @todo Add more cases for DHCPv4
}
+// The purpose of this test is to verify that definition for option that
+// comprises single uint16 value can be created and that this definition
+// can be used to create an option with single uint16 value.
TEST_F(OptionDefinitionTest, uint16Tokenized) {
OptionDefinition opt_def("OPTION_ELAPSED_TIME", D6O_ELAPSED_TIME, "uint16");
}
+// The purpose of this test is to verify that definition for option that
+// comprises single uint32 value can be created and that this definition
+// can be used to create an option with single uint32 value.
TEST_F(OptionDefinitionTest, uint32) {
OptionDefinition opt_def("OPTION_CLT_TIME", D6O_CLT_TIME, "uint32");
// @todo Add more cases for DHCPv4
}
+// The purpose of this test is to verify that definition for option that
+// comprises single uint32 value can be created and that this definition
+// can be used to create an option with single uint32 value.
TEST_F(OptionDefinitionTest, uint32Tokenized) {
OptionDefinition opt_def("OPTION_CLT_TIME", D6O_CLT_TIME, "uint32");
// @todo Add more cases for DHCPv4
}
+// The purpose of this test is to verify that definition for option that
+// comprises array of uint16 values can be created and that this definition
+// can be used to create option with an array of uint16 values.
TEST_F(OptionDefinitionTest, uint16Array) {
// Let's define some dummy option.
const uint16_t opt_code = 79;
);
}
+// The purpose of this test is to verify that definition for option that
+// comprises array of uint16 values can be created and that this definition
+// can be used to create option with an array of uint16 values.
TEST_F(OptionDefinitionTest, uint16ArrayTokenized) {
// Let's define some dummy option.
const uint16_t opt_code = 79;
EXPECT_EQ(12, values[2]);
}
-
+// The purpose of this test is to verify that definition for option that
+// comprises array of uint32 values can be created and that this definition
+// can be used to create option with an array of uint32 values.
TEST_F(OptionDefinitionTest, uint32Array) {
// Let's define some dummy option.
const uint16_t opt_code = 80;
);
}
+// The purpose of this test is to verify that definition for option that
+// comprises array of uint32 values can be created and that this definition
+// can be used to create option with an array of uint32 values.
TEST_F(OptionDefinitionTest, uint32ArrayTokenized) {
// Let's define some dummy option.
const uint16_t opt_code = 80;
EXPECT_EQ(1111, values[3]);
}
+// The purpose of this test is to verify that the definition can be created
+// for the option that comprises string value in the UTF8 format.
TEST_F(OptionDefinitionTest, utf8StringTokenized) {
// Let's create some dummy option.
const uint16_t opt_code = 80;
EXPECT_TRUE(std::equal(ref_data.begin(), ref_data.end(), data.begin()));
}
+// The purpose of this test is to check that non-integer data type can't
+// be used for factoryInteger function.
+TEST_F(OptionDefinitionTest, integerInvalidType) {
+ // The template function factoryInteger<> accepts integer values only
+ // as template typename. Here we try passing different type and
+ // see if it rejects it.
+ OptionBuffer buf(1);
+ EXPECT_THROW(
+ OptionDefinition::factoryInteger<bool>(Option::V6, D6O_PREFERENCE,
+ buf.begin(), buf.end()),
+ isc::dhcp::InvalidDataType
+ );
+}
+
+// The purpose of this test is to verify that helper methods
+// haveIA6Format and haveIAAddr6Format can be used to determine
+// IA_NA and IAADDR option formats.
TEST_F(OptionDefinitionTest, recognizeFormat) {
// IA_NA option format.
OptionDefinition opt_def1("OPTION_IA_NA", D6O_IA_NA, "record");