From 64b90eded544d12f7e1458cdfde0306c6b10d5b4 Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Sat, 29 Jul 2023 15:26:46 +0200 Subject: [PATCH] internet: Extend Ipv{4,6} Address Generator test suite --- src/internet/test/ipv4-address-generator-test-suite.cc | 10 ++++++++++ src/internet/test/ipv6-address-generator-test-suite.cc | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/internet/test/ipv4-address-generator-test-suite.cc b/src/internet/test/ipv4-address-generator-test-suite.cc index 8f649c34a..7702b948c 100644 --- a/src/internet/test/ipv4-address-generator-test-suite.cc +++ b/src/internet/test/ipv4-address-generator-test-suite.cc @@ -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"); } diff --git a/src/internet/test/ipv6-address-generator-test-suite.cc b/src/internet/test/ipv6-address-generator-test-suite.cc index 3896e4f22..cfad9ef01 100644 --- a/src/internet/test/ipv6-address-generator-test-suite.cc +++ b/src/internet/test/ipv6-address-generator-test-suite.cc @@ -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"); }