author | Vedran Miletić <rivanvx@gmail.com> |
Sat, 01 Sep 2012 20:57:21 +0200 | |
changeset 9063 | 32755d0516f4 |
parent 7385 | 10beb0e53130 |
child 9266 | d26408b17360 |
permissions | -rw-r--r-- |
7385
10beb0e53130
standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents:
7256
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
2 |
/* |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
3 |
* Copyright (c) 2007 INESC Porto |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
4 |
* |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
8 |
* |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
13 |
* |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
17 |
* |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
18 |
* Author: Gustavo J. A. M. Carneiro <gjc@inescporto.pt> |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
19 |
*/ |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
20 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
21 |
#include "ns3/test.h" |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
22 |
#include "ns3/olsr-header.h" |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
23 |
#include "ns3/packet.h" |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
24 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
25 |
namespace ns3 { |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
26 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
27 |
class OlsrEmfTestCase : public TestCase { |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
28 |
public: |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
29 |
OlsrEmfTestCase (); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
30 |
virtual void DoRun (void); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
31 |
}; |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
32 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
33 |
OlsrEmfTestCase::OlsrEmfTestCase () |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
34 |
: TestCase ("Check Emf olsr time conversion") |
7184
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
35 |
{ |
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
36 |
} |
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
37 |
void |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
38 |
OlsrEmfTestCase::DoRun (void) |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
39 |
{ |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
40 |
for (int time = 1; time <= 30; time++) |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
41 |
{ |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
42 |
uint8_t emf = olsr::SecondsToEmf (time); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
43 |
double seconds = olsr::EmfToSeconds (emf); |
9063
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7385
diff
changeset
|
44 |
NS_TEST_ASSERT_MSG_EQ ((seconds < 0 || std::fabs (seconds - time) > 0.1), false, |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7184
diff
changeset
|
45 |
"XXX"); |
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
46 |
} |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
47 |
} |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
48 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
49 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
50 |
class OlsrMidTestCase : public TestCase { |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
51 |
public: |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
52 |
OlsrMidTestCase (); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
53 |
virtual void DoRun (void); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
54 |
}; |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
55 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
56 |
OlsrMidTestCase::OlsrMidTestCase () |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
57 |
: TestCase ("Check Mid olsr messages") |
7184
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
58 |
{ |
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
59 |
} |
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
60 |
void |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
61 |
OlsrMidTestCase::DoRun (void) |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
62 |
{ |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
63 |
Packet packet; |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
64 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
65 |
{ |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
66 |
olsr::PacketHeader hdr; |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
67 |
olsr::MessageHeader msg1; |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
68 |
olsr::MessageHeader::Mid &mid1 = msg1.GetMid (); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
69 |
olsr::MessageHeader msg2; |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
70 |
olsr::MessageHeader::Mid &mid2 = msg2.GetMid (); |
7184
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
71 |
|
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
72 |
// MID message #1 |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
73 |
{ |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
74 |
std::vector<Ipv4Address> &addresses = mid1.interfaceAddresses; |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
75 |
addresses.clear (); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
76 |
addresses.push_back (Ipv4Address ("1.2.3.4")); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
77 |
addresses.push_back (Ipv4Address ("1.2.3.5")); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
78 |
} |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
79 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
80 |
msg1.SetTimeToLive (255); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
81 |
msg1.SetOriginatorAddress (Ipv4Address ("11.22.33.44")); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
82 |
msg1.SetVTime (Seconds (9)); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
83 |
msg1.SetMessageSequenceNumber (7); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
84 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
85 |
// MID message #2 |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
86 |
{ |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
87 |
std::vector<Ipv4Address> &addresses = mid2.interfaceAddresses; |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
88 |
addresses.clear (); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
89 |
addresses.push_back (Ipv4Address ("2.2.3.4")); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
90 |
addresses.push_back (Ipv4Address ("2.2.3.5")); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
91 |
} |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
92 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
93 |
msg2.SetTimeToLive (254); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
94 |
msg2.SetOriginatorAddress (Ipv4Address ("12.22.33.44")); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
95 |
msg2.SetVTime (Seconds (10)); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
96 |
msg2.SetMessageType (olsr::MessageHeader::MID_MESSAGE); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
97 |
msg2.SetMessageSequenceNumber (7); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
98 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
99 |
// Build an OLSR packet header |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
100 |
hdr.SetPacketLength (hdr.GetSerializedSize () + msg1.GetSerializedSize () + msg2.GetSerializedSize ()); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
101 |
hdr.SetPacketSequenceNumber (123); |
7184
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
102 |
|
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
103 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
104 |
// Now add all the headers in the correct order |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
105 |
packet.AddHeader (msg2); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
106 |
packet.AddHeader (msg1); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
107 |
packet.AddHeader (hdr); |
7184
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
108 |
} |
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
109 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
110 |
{ |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
111 |
olsr::PacketHeader hdr; |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
112 |
packet.RemoveHeader (hdr); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
113 |
NS_TEST_ASSERT_MSG_EQ (hdr.GetPacketSequenceNumber (), 123, "XXX"); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
114 |
uint32_t sizeLeft = hdr.GetPacketLength () - hdr.GetSerializedSize (); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
115 |
{ |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
116 |
olsr::MessageHeader msg1; |
7184
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
117 |
|
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
118 |
packet.RemoveHeader (msg1); |
7184
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
119 |
|
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
120 |
NS_TEST_ASSERT_MSG_EQ (msg1.GetTimeToLive (), 255, "XXX"); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
121 |
NS_TEST_ASSERT_MSG_EQ (msg1.GetOriginatorAddress (), Ipv4Address ("11.22.33.44"), "XXX"); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
122 |
NS_TEST_ASSERT_MSG_EQ (msg1.GetVTime (), Seconds (9), "XXX"); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
123 |
NS_TEST_ASSERT_MSG_EQ (msg1.GetMessageType (), olsr::MessageHeader::MID_MESSAGE, "XXX"); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
124 |
NS_TEST_ASSERT_MSG_EQ (msg1.GetMessageSequenceNumber (), 7, "XXX"); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
125 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
126 |
olsr::MessageHeader::Mid &mid1 = msg1.GetMid (); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
127 |
NS_TEST_ASSERT_MSG_EQ (mid1.interfaceAddresses.size (), 2, "XXX"); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
128 |
NS_TEST_ASSERT_MSG_EQ (*mid1.interfaceAddresses.begin (), Ipv4Address ("1.2.3.4"), "XXX"); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
129 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
130 |
sizeLeft -= msg1.GetSerializedSize (); |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7184
diff
changeset
|
131 |
NS_TEST_ASSERT_MSG_EQ ((sizeLeft > 0), true, "XXX"); |
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
132 |
} |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
133 |
{ |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
134 |
// now read the second message |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
135 |
olsr::MessageHeader msg2; |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
136 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
137 |
packet.RemoveHeader (msg2); |
7184
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
138 |
|
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
139 |
NS_TEST_ASSERT_MSG_EQ (msg2.GetTimeToLive (), 254, "XXX"); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
140 |
NS_TEST_ASSERT_MSG_EQ (msg2.GetOriginatorAddress (), Ipv4Address ("12.22.33.44"), "XXX"); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
141 |
NS_TEST_ASSERT_MSG_EQ (msg2.GetVTime (), Seconds (10), "XXX"); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
142 |
NS_TEST_ASSERT_MSG_EQ (msg2.GetMessageType (), olsr::MessageHeader::MID_MESSAGE, "XXX"); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
143 |
NS_TEST_ASSERT_MSG_EQ (msg2.GetMessageSequenceNumber (), 7, "XXX"); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
144 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
145 |
olsr::MessageHeader::Mid mid2 = msg2.GetMid (); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
146 |
NS_TEST_ASSERT_MSG_EQ (mid2.interfaceAddresses.size (), 2, "XXX"); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
147 |
NS_TEST_ASSERT_MSG_EQ (*mid2.interfaceAddresses.begin (), Ipv4Address ("2.2.3.4"), "XXX"); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
148 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
149 |
sizeLeft -= msg2.GetSerializedSize (); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
150 |
NS_TEST_ASSERT_MSG_EQ (sizeLeft, 0, "XXX"); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
151 |
} |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
152 |
} |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
153 |
} |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
154 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
155 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
156 |
class OlsrHelloTestCase : public TestCase { |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
157 |
public: |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
158 |
OlsrHelloTestCase (); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
159 |
virtual void DoRun (void); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
160 |
}; |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
161 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
162 |
OlsrHelloTestCase::OlsrHelloTestCase () |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
163 |
: TestCase ("Check Hello olsr messages") |
7184
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
164 |
{ |
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
165 |
} |
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
166 |
void |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
167 |
OlsrHelloTestCase::DoRun (void) |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
168 |
{ |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
169 |
Packet packet; |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
170 |
olsr::MessageHeader msgIn; |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
171 |
olsr::MessageHeader::Hello &helloIn = msgIn.GetHello (); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
172 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
173 |
helloIn.SetHTime (Seconds (7)); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
174 |
helloIn.willingness = 66; |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
175 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
176 |
{ |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
177 |
olsr::MessageHeader::Hello::LinkMessage lm1; |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
178 |
lm1.linkCode = 2; |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
179 |
lm1.neighborInterfaceAddresses.push_back (Ipv4Address ("1.2.3.4")); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
180 |
lm1.neighborInterfaceAddresses.push_back (Ipv4Address ("1.2.3.5")); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
181 |
helloIn.linkMessages.push_back (lm1); |
7184
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
182 |
|
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
183 |
olsr::MessageHeader::Hello::LinkMessage lm2; |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
184 |
lm2.linkCode = 3; |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
185 |
lm2.neighborInterfaceAddresses.push_back (Ipv4Address ("2.2.3.4")); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
186 |
lm2.neighborInterfaceAddresses.push_back (Ipv4Address ("2.2.3.5")); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
187 |
helloIn.linkMessages.push_back (lm2); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
188 |
} |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
189 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
190 |
packet.AddHeader (msgIn); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
191 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
192 |
olsr::MessageHeader msgOut; |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
193 |
packet.RemoveHeader (msgOut); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
194 |
olsr::MessageHeader::Hello &helloOut = msgOut.GetHello (); |
7184
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
195 |
|
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
196 |
NS_TEST_ASSERT_MSG_EQ (helloOut.GetHTime (), Seconds (7), "XXX"); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
197 |
NS_TEST_ASSERT_MSG_EQ (helloOut.willingness, 66, "XXX"); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
198 |
NS_TEST_ASSERT_MSG_EQ (helloOut.linkMessages.size (), 2, "XXX"); |
7184
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
199 |
|
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
200 |
NS_TEST_ASSERT_MSG_EQ (helloOut.linkMessages[0].linkCode, 2, "XXX"); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
201 |
NS_TEST_ASSERT_MSG_EQ (helloOut.linkMessages[0].neighborInterfaceAddresses[0], |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
202 |
Ipv4Address ("1.2.3.4"), "XXX"); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
203 |
NS_TEST_ASSERT_MSG_EQ (helloOut.linkMessages[0].neighborInterfaceAddresses[1], |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
204 |
Ipv4Address ("1.2.3.5"), "XXX"); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
205 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
206 |
NS_TEST_ASSERT_MSG_EQ (helloOut.linkMessages[1].linkCode, 3, "XXX"); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
207 |
NS_TEST_ASSERT_MSG_EQ (helloOut.linkMessages[1].neighborInterfaceAddresses[0], |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
208 |
Ipv4Address ("2.2.3.4"), "XXX"); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
209 |
NS_TEST_ASSERT_MSG_EQ (helloOut.linkMessages[1].neighborInterfaceAddresses[1], |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
210 |
Ipv4Address ("2.2.3.5"), "XXX"); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
211 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
212 |
NS_TEST_ASSERT_MSG_EQ (packet.GetSize (), 0, "All bytes in packet were not read"); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
213 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
214 |
} |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
215 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
216 |
class OlsrTcTestCase : public TestCase { |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
217 |
public: |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
218 |
OlsrTcTestCase (); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
219 |
virtual void DoRun (void); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
220 |
}; |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
221 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
222 |
OlsrTcTestCase::OlsrTcTestCase () |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
223 |
: TestCase ("Check Tc olsr messages") |
7184
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
224 |
{ |
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
225 |
} |
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
226 |
void |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
227 |
OlsrTcTestCase::DoRun (void) |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
228 |
{ |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
229 |
Packet packet; |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
230 |
olsr::MessageHeader msgIn; |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
231 |
olsr::MessageHeader::Tc &tcIn = msgIn.GetTc (); |
7184
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
232 |
|
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
233 |
tcIn.ansn = 0x1234; |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
234 |
tcIn.neighborAddresses.push_back (Ipv4Address ("1.2.3.4")); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
235 |
tcIn.neighborAddresses.push_back (Ipv4Address ("1.2.3.5")); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
236 |
packet.AddHeader (msgIn); |
7184
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
237 |
|
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
238 |
olsr::MessageHeader msgOut; |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
239 |
packet.RemoveHeader (msgOut); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
240 |
olsr::MessageHeader::Tc &tcOut = msgOut.GetTc (); |
7184
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
241 |
|
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
242 |
NS_TEST_ASSERT_MSG_EQ (tcOut.ansn, 0x1234, "XXX"); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
243 |
NS_TEST_ASSERT_MSG_EQ (tcOut.neighborAddresses.size (), 2, "XXX"); |
7184
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
244 |
|
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
245 |
NS_TEST_ASSERT_MSG_EQ (tcOut.neighborAddresses[0], |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
246 |
Ipv4Address ("1.2.3.4"), "XXX"); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
247 |
NS_TEST_ASSERT_MSG_EQ (tcOut.neighborAddresses[1], |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
248 |
Ipv4Address ("1.2.3.5"), "XXX"); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
249 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
250 |
NS_TEST_ASSERT_MSG_EQ (packet.GetSize (), 0, "XXX"); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
251 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
252 |
} |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
253 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
254 |
class OlsrHnaTestCase : public TestCase { |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
255 |
public: |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
256 |
OlsrHnaTestCase (); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
257 |
virtual void DoRun (void); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
258 |
}; |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
259 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
260 |
OlsrHnaTestCase::OlsrHnaTestCase () |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
261 |
: TestCase ("Check Hna olsr messages") |
7184
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
262 |
{ |
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
263 |
} |
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
264 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
265 |
void |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
266 |
OlsrHnaTestCase::DoRun (void) |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
267 |
{ |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
268 |
Packet packet; |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
269 |
olsr::MessageHeader msgIn; |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
270 |
olsr::MessageHeader::Hna &hnaIn = msgIn.GetHna (); |
7184
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
271 |
|
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
272 |
hnaIn.associations.push_back ((olsr::MessageHeader::Hna::Association) |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
273 |
{ Ipv4Address ("1.2.3.4"), Ipv4Mask ("255.255.255.0")}); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
274 |
hnaIn.associations.push_back ((olsr::MessageHeader::Hna::Association) |
7184
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
275 |
{ Ipv4Address ("1.2.3.5"), Ipv4Mask ("255.255.0.0")}); |
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
276 |
packet.AddHeader (msgIn); |
7184
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
277 |
|
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
278 |
olsr::MessageHeader msgOut; |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
279 |
packet.RemoveHeader (msgOut); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
280 |
olsr::MessageHeader::Hna &hnaOut = msgOut.GetHna (); |
7184
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
281 |
|
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
282 |
NS_TEST_ASSERT_MSG_EQ (hnaOut.associations.size (), 2, "XXX"); |
7184
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
283 |
|
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
284 |
NS_TEST_ASSERT_MSG_EQ (hnaOut.associations[0].address, |
7184
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
285 |
Ipv4Address ("1.2.3.4"), "XXX"); |
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
286 |
NS_TEST_ASSERT_MSG_EQ (hnaOut.associations[0].mask, |
7184
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
287 |
Ipv4Mask ("255.255.255.0"), "XXX"); |
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
288 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
289 |
NS_TEST_ASSERT_MSG_EQ (hnaOut.associations[1].address, |
7184
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
290 |
Ipv4Address ("1.2.3.5"), "XXX"); |
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
291 |
NS_TEST_ASSERT_MSG_EQ (hnaOut.associations[1].mask, |
7184
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
292 |
Ipv4Mask ("255.255.0.0"), "XXX"); |
a15feb312428
olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6972
diff
changeset
|
293 |
|
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
294 |
NS_TEST_ASSERT_MSG_EQ (packet.GetSize (), 0, "All bytes in packet were not read"); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
295 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
296 |
} |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
297 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
298 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
299 |
static class OlsrTestSuite : public TestSuite |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
300 |
{ |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
301 |
public: |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
302 |
OlsrTestSuite (); |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
303 |
} g_olsrTestSuite; |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
304 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
305 |
OlsrTestSuite::OlsrTestSuite() |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7184
diff
changeset
|
306 |
: TestSuite ("routing-olsr-header", UNIT) |
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
307 |
{ |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7184
diff
changeset
|
308 |
AddTestCase (new OlsrHnaTestCase ()); |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7184
diff
changeset
|
309 |
AddTestCase (new OlsrTcTestCase ()); |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7184
diff
changeset
|
310 |
AddTestCase (new OlsrHelloTestCase ()); |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7184
diff
changeset
|
311 |
AddTestCase (new OlsrMidTestCase ()); |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7184
diff
changeset
|
312 |
AddTestCase (new OlsrEmfTestCase ()); |
6972
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
313 |
} |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
314 |
|
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
315 |
} // namespace ns3 |
01039b15c8eb
Move tests from some modules to their test libraries
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
316 |