src/internet/test/ipv4-address-helper-test-suite.cc
author Tom Henderson <tomh@tomh.org>
Sun, 22 May 2011 23:18:47 -0700
changeset 7256 b04ba6772f8c
parent 7176 9f2663992e99
child 7385 10beb0e53130
permissions -rw-r--r--
rerun check-style.py at default level to enforce space after function name
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
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/ipv4-address-helper.h"
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    22
#include "ns3/simulator.h"
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    23
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    24
namespace ns3 {
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    25
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    26
class NetworkAllocatorHelperTestCase : public TestCase
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    27
{
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    28
public:
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    29
  NetworkAllocatorHelperTestCase ();
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    30
private:
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    31
  virtual void DoRun (void);
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    32
  virtual void DoTeardown (void);
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    33
};
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    34
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    35
NetworkAllocatorHelperTestCase::NetworkAllocatorHelperTestCase ()
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    36
  : TestCase ("Make sure the network allocator part is working on some common network prefixes.")
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7005
diff changeset
    37
{
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7005
diff changeset
    38
}
7005
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
void
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    41
NetworkAllocatorHelperTestCase::DoTeardown (void)
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    42
{
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    43
  Ipv4AddressGenerator::Reset ();
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    44
  Simulator::Destroy ();
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    45
}
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    46
void
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    47
NetworkAllocatorHelperTestCase::DoRun (void)
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    48
{
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    49
  Ipv4Address address;
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    50
  Ipv4Address network;
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    51
  Ipv4AddressHelper h;
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    52
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    53
  h.SetBase ("1.0.0.0", "255.0.0.0");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7176
diff changeset
    54
  network = h.NewNetwork ();
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    55
  NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("2.0.0.0"), "XXX");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7176
diff changeset
    56
  address = h.NewAddress ();
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    57
  NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("2.0.0.1"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    58
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    59
  h.SetBase ("0.1.0.0", "255.255.0.0");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7176
diff changeset
    60
  network = h.NewNetwork ();
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    61
  NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("0.2.0.0"), "XXX");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7176
diff changeset
    62
  address = h.NewAddress ();
7005
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 (address, Ipv4Address ("0.2.0.1"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    64
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    65
  h.SetBase ("0.0.1.0", "255.255.255.0");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7176
diff changeset
    66
  network = h.NewNetwork ();
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    67
  NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("0.0.2.0"), "XXX");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7176
diff changeset
    68
  address = h.NewAddress ();
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    69
  NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.0.2.1"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    70
}
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    71
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    72
class AddressAllocatorHelperTestCase : public TestCase
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
public:
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    75
  AddressAllocatorHelperTestCase ();
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    76
private:
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    77
  virtual void DoRun (void);
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    78
  virtual void DoTeardown (void);
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    79
};
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    80
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    81
AddressAllocatorHelperTestCase::AddressAllocatorHelperTestCase ()
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    82
  : TestCase ("Make sure the address allocator part is working")
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7005
diff changeset
    83
{
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7005
diff changeset
    84
}
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    85
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    86
void
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    87
AddressAllocatorHelperTestCase::DoTeardown (void)
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
  Ipv4AddressGenerator::Reset ();
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    90
  Simulator::Destroy ();
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
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    93
void
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    94
AddressAllocatorHelperTestCase::DoRun (void)
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    95
{
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    96
  Ipv4Address network;
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    97
  Ipv4Address address;
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    98
  Ipv4AddressHelper h;
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    99
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   100
  h.SetBase ("1.0.0.0", "255.0.0.0", "0.0.0.3");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7176
diff changeset
   101
  address = h.NewAddress ();
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   102
  NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("1.0.0.3"), "XXX");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7176
diff changeset
   103
  address = h.NewAddress ();
7005
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 ("1.0.0.4"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   105
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   106
  h.SetBase ("0.1.0.0", "255.255.0.0", "0.0.0.3");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7176
diff changeset
   107
  address = h.NewAddress ();
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   108
  NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.1.0.3"), "XXX");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7176
diff changeset
   109
  address = h.NewAddress ();
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   110
  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
   111
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   112
  h.SetBase ("0.0.1.0", "255.255.255.0", "0.0.0.3");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7176
diff changeset
   113
  address = h.NewAddress ();
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   114
  NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.0.1.3"), "XXX");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7176
diff changeset
   115
  address = h.NewAddress ();
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   116
  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
   117
}
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
class ResetAllocatorHelperTestCase : public TestCase
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   120
{
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   121
public:
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   122
  ResetAllocatorHelperTestCase ();
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   123
  virtual void DoRun (void);
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   124
  virtual void DoTeardown (void);
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
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   127
ResetAllocatorHelperTestCase::ResetAllocatorHelperTestCase ()
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   128
  : TestCase ("Make sure the reset to base behavior is working")
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7005
diff changeset
   129
{
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7005
diff changeset
   130
}
7005
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
void
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   133
ResetAllocatorHelperTestCase::DoRun (void)
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   134
{
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   135
  Ipv4Address network;
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   136
  Ipv4Address address;
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   137
  Ipv4AddressHelper h;
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   138
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
  // We're going to use some of the same addresses allocated above, 
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   141
  // so reset the Ipv4AddressGenerator to make it forget we did.
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
  h.SetBase ("1.0.0.0", "255.0.0.0", "0.0.0.3");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7176
diff changeset
   145
  address = h.NewAddress ();
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   146
  NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("1.0.0.3"), "XXX");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7176
diff changeset
   147
  address = h.NewAddress ();
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   148
  NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("1.0.0.4"), "XXX");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7176
diff changeset
   149
  network = h.NewNetwork ();
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   150
  NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("2.0.0.0"), "XXX");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7176
diff changeset
   151
  address = h.NewAddress ();
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   152
  NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("2.0.0.3"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   153
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   154
  h.SetBase ("0.1.0.0", "255.255.0.0", "0.0.0.3");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7176
diff changeset
   155
  address = h.NewAddress ();
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   156
  NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.1.0.3"), "XXX");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7176
diff changeset
   157
  address = h.NewAddress ();
7005
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 (address, Ipv4Address ("0.1.0.4"), "XXX");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7176
diff changeset
   159
  network = h.NewNetwork ();
7005
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 (network, Ipv4Address ("0.2.0.0"), "XXX");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7176
diff changeset
   161
  address = h.NewAddress ();
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   162
  NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.2.0.3"), "XXX");
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   163
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   164
  h.SetBase ("0.0.1.0", "255.255.255.0", "0.0.0.3");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7176
diff changeset
   165
  address = h.NewAddress ();
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   166
  NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.0.1.3"), "XXX");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7176
diff changeset
   167
  address = h.NewAddress ();
7005
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   168
  NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.0.1.4"), "XXX");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7176
diff changeset
   169
  network = h.NewNetwork ();
7005
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.0.2.0"), "XXX");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7176
diff changeset
   171
  address = h.NewAddress ();
7005
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.0.2.3"), "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
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   175
void
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   176
ResetAllocatorHelperTestCase::DoTeardown (void)
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   177
{
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   178
  Ipv4AddressGenerator::Reset ();
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   179
  Simulator::Destroy ();
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
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   182
static class Ipv4AddressHelperTestSuite : public TestSuite
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   183
{
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   184
public:
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   185
  Ipv4AddressHelperTestSuite ()
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   186
    : TestSuite ("ipv4-address-helper", UNIT) 
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   187
  {
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   188
    AddTestCase (new NetworkAllocatorHelperTestCase ());
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   189
    AddTestCase (new AddressAllocatorHelperTestCase ());
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   190
    AddTestCase (new ResetAllocatorHelperTestCase ());
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   191
  }
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   192
} g_ipv4AddressHelperTestSuite;
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   193
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   194
} // namespace ns3
ef2b6bc2bf46 Move tests from internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   195