A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
drop-tail-queue-test-suite.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2007 University of Washington
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*/
18
19
#include "ns3/test.h"
20
#include "ns3/drop-tail-queue.h"
21
#include "ns3/uinteger.h"
22
23
namespace
ns3 {
24
25
class
DropTailQueueTestCase
:
public
TestCase
26
{
27
public
:
28
DropTailQueueTestCase
();
29
virtual
void
DoRun
(
void
);
30
};
31
32
DropTailQueueTestCase::DropTailQueueTestCase
()
33
:
TestCase
(
"Sanity check on the drop tail queue implementation"
)
34
{
35
}
36
void
37
DropTailQueueTestCase::DoRun
(
void
)
38
{
39
Ptr<DropTailQueue>
queue = CreateObject<DropTailQueue> ();
40
NS_TEST_EXPECT_MSG_EQ
(queue->SetAttributeFailSafe (
"MaxPackets"
,
UintegerValue
(3)),
true
,
41
"Verify that we can actually set the attribute"
);
42
43
Ptr<Packet>
p1, p2, p3, p4;
44
p1 = Create<Packet> ();
45
p2 = Create<Packet> ();
46
p3 = Create<Packet> ();
47
p4 = Create<Packet> ();
48
49
NS_TEST_EXPECT_MSG_EQ
(queue->GetNPackets (), 0,
"There should be no packets in there"
);
50
queue->Enqueue (p1);
51
NS_TEST_EXPECT_MSG_EQ
(queue->GetNPackets (), 1,
"There should be one packet in there"
);
52
queue->Enqueue (p2);
53
NS_TEST_EXPECT_MSG_EQ
(queue->GetNPackets (), 2,
"There should be two packets in there"
);
54
queue->Enqueue (p3);
55
NS_TEST_EXPECT_MSG_EQ
(queue->GetNPackets (), 3,
"There should be three packets in there"
);
56
queue->Enqueue (p4);
// will be dropped
57
NS_TEST_EXPECT_MSG_EQ
(queue->GetNPackets (), 3,
"There should be still three packets in there"
);
58
59
Ptr<Packet>
p;
60
61
p = queue->Dequeue ();
62
NS_TEST_EXPECT_MSG_EQ
((p != 0),
true
,
"I want to remove the first packet"
);
63
NS_TEST_EXPECT_MSG_EQ
(queue->GetNPackets (), 2,
"There should be two packets in there"
);
64
NS_TEST_EXPECT_MSG_EQ
(p->GetUid (), p1->GetUid (),
"was this the first packet ?"
);
65
66
p = queue->Dequeue ();
67
NS_TEST_EXPECT_MSG_EQ
((p != 0),
true
,
"I want to remove the second packet"
);
68
NS_TEST_EXPECT_MSG_EQ
(queue->GetNPackets (), 1,
"There should be one packet in there"
);
69
NS_TEST_EXPECT_MSG_EQ
(p->GetUid (), p2->GetUid (),
"Was this the second packet ?"
);
70
71
p = queue->Dequeue ();
72
NS_TEST_EXPECT_MSG_EQ
((p != 0),
true
,
"I want to remove the third packet"
);
73
NS_TEST_EXPECT_MSG_EQ
(queue->GetNPackets (), 0,
"There should be no packets in there"
);
74
NS_TEST_EXPECT_MSG_EQ
(p->GetUid (), p3->GetUid (),
"Was this the third packet ?"
);
75
76
p = queue->Dequeue ();
77
NS_TEST_EXPECT_MSG_EQ
((p == 0),
true
,
"There are really no packets in there"
);
78
}
79
80
static
class
DropTailQueueTestSuite
:
public
TestSuite
81
{
82
public
:
83
DropTailQueueTestSuite
()
84
:
TestSuite
(
"drop-tail-queue"
,
UNIT
)
85
{
86
AddTestCase
(
new
DropTailQueueTestCase
());
87
}
88
}
g_dropTailQueueTestSuite
;
89
90
}
// namespace ns3
src
network
test
drop-tail-queue-test-suite.cc
Generated on Tue Oct 9 2012 16:45:44 for ns-3 by
1.8.1.2