|
@@ -170,6 +170,8 @@ TEST_F(Pkt6Test, packUnpack) {
|
|
|
delete clone;
|
|
|
}
|
|
|
|
|
|
+// This test verifies that options can be added (addOption()), retrieved
|
|
|
+// (getOption(), getOptions()) and deleted (delOption()).
|
|
|
TEST_F(Pkt6Test, addGetDelOptions) {
|
|
|
Pkt6* parent = new Pkt6(DHCPV6_SOLICIT, random() );
|
|
|
|
|
@@ -190,6 +192,25 @@ TEST_F(Pkt6Test, addGetDelOptions) {
|
|
|
// now there are 2 options of type 2
|
|
|
parent->addOption(opt3);
|
|
|
|
|
|
+ Option::OptionCollection options = parent->getOptions(2);
|
|
|
+ EXPECT_EQ(2, options.size()); // there should be 2 instances
|
|
|
+
|
|
|
+ // both options must be of type 2 and there must not be
|
|
|
+ // any other type returned
|
|
|
+ for (Option::OptionCollection::const_iterator x= options.begin();
|
|
|
+ x != options.end(); ++x) {
|
|
|
+ EXPECT_EQ(2, x->second->getType());
|
|
|
+ }
|
|
|
+
|
|
|
+ // Try to get a single option. Normally for singular options
|
|
|
+ // it is better to use getOption(), but getOptions() must work
|
|
|
+ // as well
|
|
|
+ options = parent->getOptions(1);
|
|
|
+ ASSERT_EQ(1, options.size());
|
|
|
+
|
|
|
+ EXPECT_EQ(1, (*options.begin()).second->getType());
|
|
|
+ EXPECT_EQ(opt1, options.begin()->second);
|
|
|
+
|
|
|
// let's delete one of them
|
|
|
EXPECT_EQ(true, parent->delOption(2));
|
|
|
|
|
@@ -205,6 +226,10 @@ TEST_F(Pkt6Test, addGetDelOptions) {
|
|
|
// let's try to delete - should fail
|
|
|
EXPECT_TRUE(false == parent->delOption(2));
|
|
|
|
|
|
+ // Finally try to get a non-existent option
|
|
|
+ options = parent->getOptions(1234);
|
|
|
+ EXPECT_EQ(0, options.size());
|
|
|
+
|
|
|
delete parent;
|
|
|
}
|
|
|
|