View | Details | Raw Unified | Return to bug 2268
Collapse All | Expand All

(-)a/src/network/test/drop-tail-queue-test-suite.cc (-8 / +32 lines)
 Lines 19-24    Link Here 
19
#include "ns3/test.h"
19
#include "ns3/test.h"
20
#include "ns3/drop-tail-queue.h"
20
#include "ns3/drop-tail-queue.h"
21
#include "ns3/uinteger.h"
21
#include "ns3/uinteger.h"
22
#include "ns3/string.h"
23
#include "ns3/simulator.h"
22
24
23
using namespace ns3;
25
using namespace ns3;
24
26
 Lines 27-50   class DropTailQueueTestCase : public TestCase Link Here 
27
public:
29
public:
28
  DropTailQueueTestCase ();
30
  DropTailQueueTestCase ();
29
  virtual void DoRun (void);
31
  virtual void DoRun (void);
32
private:
33
  void RunDropTailTest (StringValue mode);
30
};
34
};
31
35
32
DropTailQueueTestCase::DropTailQueueTestCase ()
36
DropTailQueueTestCase::DropTailQueueTestCase ()
33
  : TestCase ("Sanity check on the drop tail queue implementation")
37
  : TestCase ("Sanity check on the drop tail queue implementation")
34
{
38
{
35
}
39
}
40
36
void
41
void
37
DropTailQueueTestCase::DoRun (void)
42
DropTailQueueTestCase::RunDropTailTest (StringValue mode)
38
{
43
{
44
  uint32_t pktSize = 100;
39
  Ptr<DropTailQueue> queue = CreateObject<DropTailQueue> ();
45
  Ptr<DropTailQueue> queue = CreateObject<DropTailQueue> ();
40
  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxPackets", UintegerValue (3)), true,
46
41
                         "Verify that we can actually set the attribute");
47
  if (mode.Get().compare ("QUEUE_MODE_PACKETS") == 0)
48
    {
49
      NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxPackets", UintegerValue (3)), true,
50
                             "Verify that we can actually set the attribute");
51
    }
52
  else
53
    {
54
      NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", StringValue ("QUEUE_MODE_BYTES")), true,
55
                             "Verify that we can actually set the attribute");
56
      NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxBytes", UintegerValue (3 * pktSize)), true,
57
                             "Verify that we can actually set the attribute");
58
    }
42
59
43
  Ptr<Packet> p1, p2, p3, p4;
60
  Ptr<Packet> p1, p2, p3, p4;
44
  p1 = Create<Packet> ();
61
  p1 = Create<Packet> (pktSize);
45
  p2 = Create<Packet> ();
62
  p2 = Create<Packet> (pktSize);
46
  p3 = Create<Packet> ();
63
  p3 = Create<Packet> (pktSize);
47
  p4 = Create<Packet> ();
64
  p4 = Create<Packet> (pktSize);
48
65
49
  NS_TEST_EXPECT_MSG_EQ (queue->GetNPackets (), 0, "There should be no packets in there");
66
  NS_TEST_EXPECT_MSG_EQ (queue->GetNPackets (), 0, "There should be no packets in there");
50
  queue->Enqueue (p1);
67
  queue->Enqueue (p1);
 Lines 77-82   DropTailQueueTestCase::DoRun (void) Link Here 
77
  NS_TEST_EXPECT_MSG_EQ ((p == 0), true, "There are really no packets in there");
94
  NS_TEST_EXPECT_MSG_EQ ((p == 0), true, "There are really no packets in there");
78
}
95
}
79
96
97
void
98
DropTailQueueTestCase::DoRun (void)
99
{
100
  RunDropTailTest (StringValue ("QUEUE_MODE_PACKETS"));
101
  RunDropTailTest (StringValue ("QUEUE_MODE_BYTES"));
102
  Simulator::Destroy ();
103
}
104
80
static class DropTailQueueTestSuite : public TestSuite
105
static class DropTailQueueTestSuite : public TestSuite
81
{
106
{
82
public:
107
public:
83
- 

Return to bug 2268