internet: Extend Ipv{4,6} Address Generator test suite

This commit is contained in:
Stefano Avallone
2023-07-29 15:26:46 +02:00
committed by Stefano Avallone
parent 1503ca9e9b
commit 64b90eded5
2 changed files with 20 additions and 0 deletions

View File

@@ -323,18 +323,28 @@ AddressCollisionTestCase::DoRun()
Ipv4AddressGenerator::AddAllocated("0.0.0.16");
Ipv4AddressGenerator::TestMode();
bool allocated = Ipv4AddressGenerator::IsAddressAllocated("0.0.0.21");
NS_TEST_EXPECT_MSG_EQ(allocated, false, "0.0.0.21 should not be already allocated");
bool added = Ipv4AddressGenerator::AddAllocated("0.0.0.21");
NS_TEST_EXPECT_MSG_EQ(added, true, "400");
allocated = Ipv4AddressGenerator::IsAddressAllocated("0.0.0.4");
NS_TEST_EXPECT_MSG_EQ(allocated, true, "0.0.0.4 should be already allocated");
added = Ipv4AddressGenerator::AddAllocated("0.0.0.4");
NS_TEST_EXPECT_MSG_EQ(added, false, "401");
allocated = Ipv4AddressGenerator::IsAddressAllocated("0.0.0.9");
NS_TEST_EXPECT_MSG_EQ(allocated, true, "0.0.0.9 should be already allocated");
added = Ipv4AddressGenerator::AddAllocated("0.0.0.9");
NS_TEST_EXPECT_MSG_EQ(added, false, "402");
allocated = Ipv4AddressGenerator::IsAddressAllocated("0.0.0.16");
NS_TEST_EXPECT_MSG_EQ(allocated, true, "0.0.0.16 should be already allocated");
added = Ipv4AddressGenerator::AddAllocated("0.0.0.16");
NS_TEST_EXPECT_MSG_EQ(added, false, "403");
allocated = Ipv4AddressGenerator::IsAddressAllocated("0.0.0.21");
NS_TEST_EXPECT_MSG_EQ(allocated, true, "0.0.0.21 should be already allocated");
added = Ipv4AddressGenerator::AddAllocated("0.0.0.21");
NS_TEST_EXPECT_MSG_EQ(added, false, "404");
}

View File

@@ -315,18 +315,28 @@ AddressCollision6TestCase::DoRun()
Ipv6AddressGenerator::AddAllocated("0::0:16");
Ipv6AddressGenerator::TestMode();
bool allocated = Ipv6AddressGenerator::IsAddressAllocated("0::0:21");
NS_TEST_EXPECT_MSG_EQ(allocated, false, "0::0:21 should not be already allocated");
bool added = Ipv6AddressGenerator::AddAllocated("0::0:21");
NS_TEST_EXPECT_MSG_EQ(added, true, "address should get allocated");
allocated = Ipv6AddressGenerator::IsAddressAllocated("0::0:4");
NS_TEST_EXPECT_MSG_EQ(allocated, true, "0::0:4 should be already allocated");
added = Ipv6AddressGenerator::AddAllocated("0::0:4");
NS_TEST_EXPECT_MSG_EQ(added, false, "address should not get allocated");
allocated = Ipv6AddressGenerator::IsAddressAllocated("0::0:9");
NS_TEST_EXPECT_MSG_EQ(allocated, true, "0::0:9 should be already allocated");
added = Ipv6AddressGenerator::AddAllocated("0::0:9");
NS_TEST_EXPECT_MSG_EQ(added, false, "address should not get allocated");
allocated = Ipv6AddressGenerator::IsAddressAllocated("0::0:16");
NS_TEST_EXPECT_MSG_EQ(allocated, true, "0::0:16 should be already allocated");
added = Ipv6AddressGenerator::AddAllocated("0::0:16");
NS_TEST_EXPECT_MSG_EQ(added, false, "address should not get allocated");
allocated = Ipv6AddressGenerator::IsAddressAllocated("0::0:21");
NS_TEST_EXPECT_MSG_EQ(allocated, true, "0::0:21 should be already allocated");
added = Ipv6AddressGenerator::AddAllocated("0::0:21");
NS_TEST_EXPECT_MSG_EQ(added, false, "address should not get allocated");
}