src/internet/test/ipv4-address-generator-test-suite.cc
author Vedran Miletić <rivanvx@gmail.com>
Tue, 02 Aug 2011 17:42:33 -0400
changeset 7385 10beb0e53130
parent 7176 9f2663992e99
child 9079 1e5921e6507d
permissions -rw-r--r--
standardize emacs c++ mode comments
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7385
10beb0e53130 standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents: 7176
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
     2
/*
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
     3
 * Copyright (c) 2008 University of Washington
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
     4
 *
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
     8
 *
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    12
 * GNU General Public License for more details.
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    13
 *
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    17
 */
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    18
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    19
#include "ns3/test.h"
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    20
#include "ns3/ipv4-address-generator.h"
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    21
#include "ns3/simulation-singleton.h"
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    22
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    23
namespace ns3 {
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    24
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    25
class NetworkNumberAllocatorTestCase : public TestCase
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    26
{
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    27
public:
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    28
  NetworkNumberAllocatorTestCase ();
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    29
  virtual void DoRun (void);
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    30
  virtual void DoTeardown (void);
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    31
};
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    32
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    33
NetworkNumberAllocatorTestCase::NetworkNumberAllocatorTestCase ()
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    34
  : TestCase ("Make sure the network number allocator is working on some of network prefixes.")
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7005
diff changeset
    35
{
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7005
diff changeset
    36
}
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7005
diff changeset
    37
void
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    38
NetworkNumberAllocatorTestCase::DoTeardown (void)
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    39
{
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    40
  Ipv4AddressGenerator::Reset ();
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    41
}
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7005
diff changeset
    42
void
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    43
NetworkNumberAllocatorTestCase::DoRun (void)
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    44
{
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    45
  Ipv4Address network;
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    46
  Ipv4AddressGenerator::Init (Ipv4Address ("1.0.0.0"), Ipv4Mask ("255.0.0.0"),
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7005
diff changeset
    47
                              Ipv4Address ("0.0.0.0"));
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    48
  network = Ipv4AddressGenerator::GetNetwork (Ipv4Mask ("255.0.0.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    49
  NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("1.0.0.0"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    50
  network = Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.0.0.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    51
  NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("2.0.0.0"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    52
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7005
diff changeset
    53
  Ipv4AddressGenerator::Init (Ipv4Address ("0.1.0.0"),
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7005
diff changeset
    54
                              Ipv4Mask ("255.255.0.0"), Ipv4Address ("0.0.0.0"));
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    55
  network = Ipv4AddressGenerator::GetNetwork (Ipv4Mask ("255.255.0.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    56
  NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("0.1.0.0"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    57
  network = Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.255.0.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    58
  NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("0.2.0.0"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    59
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    60
  Ipv4AddressGenerator::Init (Ipv4Address ("0.0.1.0"),
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7005
diff changeset
    61
                              Ipv4Mask ("255.255.255.0"), Ipv4Address ("0.0.0.0"));
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    62
  network = Ipv4AddressGenerator::GetNetwork (Ipv4Mask ("255.255.255.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    63
  NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("0.0.1.0"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    64
  network = Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.255.255.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    65
  NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("0.0.2.0"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    66
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    67
  network = Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.0.0.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    68
  NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("3.0.0.0"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    69
  network = Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.255.0.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    70
  NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("0.3.0.0"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    71
  network = Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.255.255.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    72
  NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("0.0.3.0"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    73
}
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    74
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    75
class AddressAllocatorTestCase : public TestCase
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    76
{
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    77
public:
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    78
  AddressAllocatorTestCase ();
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    79
private:
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    80
  virtual void DoRun (void);
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    81
  virtual void DoTeardown (void);
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    82
};
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    83
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    84
AddressAllocatorTestCase::AddressAllocatorTestCase ()
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    85
  : TestCase ("Sanity check on allocation of addresses")
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7005
diff changeset
    86
{
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7005
diff changeset
    87
}
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    88
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    89
void
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    90
AddressAllocatorTestCase::DoRun (void)
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    91
{
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    92
  Ipv4Address address;
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    93
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    94
  Ipv4AddressGenerator::Init (Ipv4Address ("1.0.0.0"), Ipv4Mask ("255.0.0.0"),
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7005
diff changeset
    95
                              Ipv4Address ("0.0.0.3"));
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    96
  address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.0.0.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    97
  NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("1.0.0.3"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    98
  address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.0.0.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    99
  NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("1.0.0.4"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   100
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   101
  Ipv4AddressGenerator::Init (Ipv4Address ("0.1.0.0"),
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7005
diff changeset
   102
                              Ipv4Mask ("255.255.0.0"), Ipv4Address ("0.0.0.3"));
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   103
  address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.0.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   104
  NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.1.0.3"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   105
  address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.0.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   106
  NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.1.0.4"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   107
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   108
  Ipv4AddressGenerator::Init (Ipv4Address ("0.0.1.0"),
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7005
diff changeset
   109
                              Ipv4Mask ("255.255.255.0"), Ipv4Address ("0.0.0.3"));
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   110
  address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.255.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   111
  NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.0.1.3"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   112
  address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.255.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   113
  NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.0.1.4"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   114
}
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   115
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   116
void 
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   117
AddressAllocatorTestCase::DoTeardown (void)
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   118
{
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   119
  Ipv4AddressGenerator::Reset ();
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   120
  Simulator::Destroy ();
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   121
}
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   122
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   123
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   124
class NetworkAndAddressTestCase : public TestCase
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   125
{
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   126
public:
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   127
  NetworkAndAddressTestCase ();
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   128
  virtual void DoRun (void);
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   129
  virtual void DoTeardown (void);
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   130
};
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   131
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   132
NetworkAndAddressTestCase::NetworkAndAddressTestCase ()
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   133
  : TestCase ("Make sure Network and address allocation play together.")
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7005
diff changeset
   134
{
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7005
diff changeset
   135
}
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   136
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7005
diff changeset
   137
void
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   138
NetworkAndAddressTestCase::DoTeardown (void)
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   139
{
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   140
  Ipv4AddressGenerator::Reset ();
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   141
  Simulator::Destroy ();
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   142
}
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   143
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   144
void
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   145
NetworkAndAddressTestCase::DoRun (void)
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   146
{
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   147
  Ipv4Address address;
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   148
  Ipv4Address network;
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   149
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   150
  Ipv4AddressGenerator::Init (Ipv4Address ("3.0.0.0"), Ipv4Mask ("255.0.0.0"),
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7005
diff changeset
   151
                              Ipv4Address ("0.0.0.3"));
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   152
  address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.0.0.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   153
  NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("3.0.0.3"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   154
  address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.0.0.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   155
  NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("3.0.0.4"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   156
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   157
  network = Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.0.0.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   158
  NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("4.0.0.0"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   159
  address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.0.0.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   160
  NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("4.0.0.5"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   161
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   162
  Ipv4AddressGenerator::Init (Ipv4Address ("0.3.0.0"), 
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7005
diff changeset
   163
                              Ipv4Mask ("255.255.0.0"), Ipv4Address ("0.0.0.3"));
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   164
  address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.0.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   165
  NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.3.0.3"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   166
  address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.0.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   167
  NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.3.0.4"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   168
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   169
  network = Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.255.0.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   170
  NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("0.4.0.0"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   171
  address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.0.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   172
  NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.4.0.5"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   173
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   174
  Ipv4AddressGenerator::Init (Ipv4Address ("0.0.3.0"),
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7005
diff changeset
   175
                              Ipv4Mask ("255.255.255.0"), Ipv4Address ("0.0.0.3"));
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   176
  address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.255.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   177
  NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.0.3.3"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   178
  address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.255.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   179
  NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.0.3.4"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   180
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   181
  network = Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.255.255.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   182
  NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("0.0.4.0"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   183
  address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.255.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   184
  NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.0.4.5"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   185
}
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   186
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   187
class ExampleAddressGeneratorTestCase : public TestCase
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   188
{
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   189
public:
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   190
  ExampleAddressGeneratorTestCase ();
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   191
private:
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   192
  virtual void DoRun (void);
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   193
  virtual void DoTeardown (void);
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   194
};
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   195
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   196
ExampleAddressGeneratorTestCase::ExampleAddressGeneratorTestCase ()
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   197
  : TestCase ("A quick kindof-semi-almost-real example")
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7005
diff changeset
   198
{
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7005
diff changeset
   199
}
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   200
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   201
void
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   202
ExampleAddressGeneratorTestCase::DoTeardown (void)
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   203
{
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   204
  Ipv4AddressGenerator::Reset ();
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   205
}
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   206
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   207
void
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   208
ExampleAddressGeneratorTestCase::DoRun (void)
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   209
{
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   210
  Ipv4Address address;
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   211
  //
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   212
  // First, initialize our /24 network to 192.168.0.0 and begin 
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   213
  // allocating with ip address 0.0.0.3 out of that prefix.
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   214
  //
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   215
  Ipv4AddressGenerator::Init (Ipv4Address ("192.168.0.0"),
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7005
diff changeset
   216
                              Ipv4Mask ("255.255.255.0"), Ipv4Address ("0.0.0.3"));
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   217
  address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.255.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   218
  NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("192.168.0.3"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   219
  address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.255.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   220
  NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("192.168.0.4"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   221
  address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.255.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   222
  NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("192.168.0.5"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   223
  //
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   224
  // Allocate the next network out of our /24 network (this should be 
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   225
  // 192.168.1.0) and begin allocating with IP address 0.0.0.3 out of that
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   226
  // prefix.
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   227
  //
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   228
  Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.255.255.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   229
  Ipv4AddressGenerator::InitAddress (Ipv4Address ("0.0.0.3"),
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7005
diff changeset
   230
                                     Ipv4Mask ("255.255.255.0"));
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   231
  //
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   232
  // The first address we should get is the previous numbers ORed together, which
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   233
  // is 192.168.1.3, of course.
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   234
  //
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   235
  address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.255.0"));
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   236
  NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("192.168.1.3"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   237
}
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   238
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   239
class AddressCollisionTestCase : public TestCase
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   240
{
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   241
public:
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   242
  AddressCollisionTestCase ();
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   243
private:
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   244
  void DoRun (void);
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   245
  void DoTeardown (void);
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   246
};
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   247
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   248
AddressCollisionTestCase::AddressCollisionTestCase ()
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   249
  : TestCase ("Make sure that the address collision logic works.")
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7005
diff changeset
   250
{
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7005
diff changeset
   251
}
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   252
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   253
void
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   254
AddressCollisionTestCase::DoTeardown (void)
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   255
{
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   256
  Ipv4AddressGenerator::Reset ();
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   257
  Simulator::Destroy ();
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   258
}
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   259
void
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   260
AddressCollisionTestCase::DoRun (void)
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   261
{
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   262
  Ipv4AddressGenerator::AddAllocated ("0.0.0.5");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   263
  Ipv4AddressGenerator::AddAllocated ("0.0.0.10");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   264
  Ipv4AddressGenerator::AddAllocated ("0.0.0.15");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   265
  Ipv4AddressGenerator::AddAllocated ("0.0.0.20");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   266
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   267
  Ipv4AddressGenerator::AddAllocated ("0.0.0.4");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   268
  Ipv4AddressGenerator::AddAllocated ("0.0.0.3");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   269
  Ipv4AddressGenerator::AddAllocated ("0.0.0.2");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   270
  Ipv4AddressGenerator::AddAllocated ("0.0.0.1");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   271
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   272
  Ipv4AddressGenerator::AddAllocated ("0.0.0.6");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   273
  Ipv4AddressGenerator::AddAllocated ("0.0.0.7");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   274
  Ipv4AddressGenerator::AddAllocated ("0.0.0.8");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   275
  Ipv4AddressGenerator::AddAllocated ("0.0.0.9");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   276
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   277
  Ipv4AddressGenerator::AddAllocated ("0.0.0.11");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   278
  Ipv4AddressGenerator::AddAllocated ("0.0.0.12");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   279
  Ipv4AddressGenerator::AddAllocated ("0.0.0.13");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   280
  Ipv4AddressGenerator::AddAllocated ("0.0.0.14");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   281
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   282
  Ipv4AddressGenerator::AddAllocated ("0.0.0.19");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   283
  Ipv4AddressGenerator::AddAllocated ("0.0.0.18");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   284
  Ipv4AddressGenerator::AddAllocated ("0.0.0.17");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   285
  Ipv4AddressGenerator::AddAllocated ("0.0.0.16");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   286
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   287
  Ipv4AddressGenerator::TestMode ();
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   288
  bool added = Ipv4AddressGenerator::AddAllocated ("0.0.0.21");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   289
  NS_TEST_EXPECT_MSG_EQ (added, true, "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   290
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   291
  added = Ipv4AddressGenerator::AddAllocated ("0.0.0.4");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   292
  NS_TEST_EXPECT_MSG_EQ (added, false, "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   293
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   294
  added = Ipv4AddressGenerator::AddAllocated ("0.0.0.9");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   295
  NS_TEST_EXPECT_MSG_EQ (added, false, "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   296
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   297
  added = Ipv4AddressGenerator::AddAllocated ("0.0.0.16");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   298
  NS_TEST_EXPECT_MSG_EQ (added, false, "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   299
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   300
  added = Ipv4AddressGenerator::AddAllocated ("0.0.0.21");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   301
  NS_TEST_EXPECT_MSG_EQ (added, false, "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   302
}
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   303
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   304
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   305
static class Ipv4AddressGeneratorTestSuite : public TestSuite
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   306
{
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   307
public:
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   308
  Ipv4AddressGeneratorTestSuite ()
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   309
    : TestSuite ("ipv4-address-generator")
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   310
  {
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   311
    AddTestCase (new NetworkNumberAllocatorTestCase ());
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   312
    AddTestCase (new AddressAllocatorTestCase ());
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   313
    AddTestCase (new NetworkAndAddressTestCase ());
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   314
    AddTestCase (new ExampleAddressGeneratorTestCase ());
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   315
    AddTestCase (new AddressCollisionTestCase ());
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   316
  }
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   317
} g_ipv4AddressGeneratorTestSuite;
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   318
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   319
} // namespace ns3
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   320