From 788c3a1ec58087ce2e6425e30ac89771a0350741 Mon Sep 17 00:00:00 2001 From: Alexander Afanasyev Date: Tue, 10 Apr 2012 11:45:22 -0700 Subject: network: Correcting test cases for new PacketTag API diff --git a/src/internet/test/ipv4-packet-info-tag-test-suite.cc b/src/internet/test/ipv4-packet-info-tag-test-suite.cc index ca7808f..e08673b 100644 --- a/src/internet/test/ipv4-packet-info-tag-test-suite.cc +++ b/src/internet/test/ipv4-packet-info-tag-test-suite.cc @@ -97,10 +97,8 @@ Ipv4PacketInfoTagTest::RxCb (Ptr socket) m_receivedPacket = socket->Recv (std::numeric_limits::max (), 0); NS_TEST_ASSERT_MSG_EQ (availableData, m_receivedPacket->GetSize (), "Did not read expected data"); - Ipv4PacketInfoTag tag; - bool found; - found = m_receivedPacket->RemovePacketTag (tag); - NS_TEST_ASSERT_MSG_EQ (found, true, "Could not find tag"); + Ptr tag = m_receivedPacket->RemovePacketTag (); + NS_TEST_ASSERT_MSG_NE (tag, 0, "Could not find tag"); } void diff --git a/src/internet/test/ipv6-packet-info-tag-test-suite.cc b/src/internet/test/ipv6-packet-info-tag-test-suite.cc index e52985e..0d4e55e 100644 --- a/src/internet/test/ipv6-packet-info-tag-test-suite.cc +++ b/src/internet/test/ipv6-packet-info-tag-test-suite.cc @@ -93,10 +93,8 @@ Ipv6PacketInfoTagTest::RxCb (Ptr socket) m_receivedPacket = socket->Recv (std::numeric_limits::max (), 0); NS_TEST_ASSERT_MSG_EQ (availableData, m_receivedPacket->GetSize (), "Did not read expected data"); - Ipv6PacketInfoTag tag; - bool found; - found = m_receivedPacket->RemovePacketTag (tag); - NS_TEST_ASSERT_MSG_EQ (found, true, "Could not find tag"); + Ptr tag = m_receivedPacket->RemovePacketTag (); + NS_TEST_ASSERT_MSG_NE (tag, 0, "Could not find tag"); } void diff --git a/src/network/test/packet-test-suite.cc b/src/network/test/packet-test-suite.cc index 7a65e5e..a152701 100644 --- a/src/network/test/packet-test-suite.cc +++ b/src/network/test/packet-test-suite.cc @@ -391,33 +391,33 @@ PacketTest::DoRun (void) { Packet p; - ATestTag<10> a; + Ptr< ATestTag<10> > a = CreateObject< ATestTag<10> > (); p.AddPacketTag (a); - NS_TEST_EXPECT_MSG_EQ (p.PeekPacketTag (a), true, "trivial"); - ATestTag<11> b; + NS_TEST_EXPECT_MSG_NE (p.PeekPacketTag< ATestTag<10> > (), 0, "trivial"); + Ptr< ATestTag<11> > b = CreateObject< ATestTag<11> > (); p.AddPacketTag (b); - NS_TEST_EXPECT_MSG_EQ (p.PeekPacketTag (b), true, "trivial"); - NS_TEST_EXPECT_MSG_EQ (p.PeekPacketTag (a), true, "trivial"); + NS_TEST_EXPECT_MSG_NE (p.PeekPacketTag< ATestTag<11> > (), 0, "trivial"); + NS_TEST_EXPECT_MSG_NE (p.PeekPacketTag< ATestTag<10> > (), 0, "trivial"); Packet copy = p; - NS_TEST_EXPECT_MSG_EQ (copy.PeekPacketTag (b), true, "trivial"); - NS_TEST_EXPECT_MSG_EQ (copy.PeekPacketTag (a), true, "trivial"); - ATestTag<12> c; - NS_TEST_EXPECT_MSG_EQ (copy.PeekPacketTag (c), false, "trivial"); + NS_TEST_EXPECT_MSG_NE (copy.PeekPacketTag< ATestTag<11> > (), 0, "trivial"); + NS_TEST_EXPECT_MSG_NE (copy.PeekPacketTag< ATestTag<10> > (), 0, "trivial"); + Ptr< ATestTag<12> > c = CreateObject< ATestTag<12> > (); + NS_TEST_EXPECT_MSG_EQ (copy.PeekPacketTag< ATestTag<12> > (), 0, "trivial"); copy.AddPacketTag (c); - NS_TEST_EXPECT_MSG_EQ (copy.PeekPacketTag (c), true, "trivial"); - NS_TEST_EXPECT_MSG_EQ (copy.PeekPacketTag (b), true, "trivial"); - NS_TEST_EXPECT_MSG_EQ (copy.PeekPacketTag (a), true, "trivial"); - NS_TEST_EXPECT_MSG_EQ (p.PeekPacketTag (c), false, "trivial"); - copy.RemovePacketTag (b); - NS_TEST_EXPECT_MSG_EQ (copy.PeekPacketTag (b), false, "trivial"); - NS_TEST_EXPECT_MSG_EQ (p.PeekPacketTag (b), true, "trivial"); - p.RemovePacketTag (a); - NS_TEST_EXPECT_MSG_EQ (p.PeekPacketTag (a), false, "trivial"); - NS_TEST_EXPECT_MSG_EQ (copy.PeekPacketTag (a), true, "trivial"); - NS_TEST_EXPECT_MSG_EQ (p.PeekPacketTag (c), false, "trivial"); - NS_TEST_EXPECT_MSG_EQ (copy.PeekPacketTag (c), true, "trivial"); + NS_TEST_EXPECT_MSG_NE (copy.PeekPacketTag< ATestTag<12> > (), 0, "trivial"); + NS_TEST_EXPECT_MSG_NE (copy.PeekPacketTag< ATestTag<11> > (), 0, "trivial"); + NS_TEST_EXPECT_MSG_NE (copy.PeekPacketTag< ATestTag<10> > (), 0, "trivial"); + NS_TEST_EXPECT_MSG_EQ (p.PeekPacketTag< ATestTag<12> > (), 0, "trivial"); + copy.RemovePacketTag< ATestTag<11> > (); + NS_TEST_EXPECT_MSG_EQ (copy.PeekPacketTag< ATestTag<11> > (), 0, "trivial"); + NS_TEST_EXPECT_MSG_NE (p.PeekPacketTag< ATestTag<11> > (), 0, "trivial"); + p.RemovePacketTag< ATestTag<10> > (); + NS_TEST_EXPECT_MSG_EQ (p.PeekPacketTag< ATestTag<10> > (), 0, "trivial"); + NS_TEST_EXPECT_MSG_NE (copy.PeekPacketTag< ATestTag<10> > (), 0, "trivial"); + NS_TEST_EXPECT_MSG_EQ (p.PeekPacketTag< ATestTag<12> > (), 0, "trivial"); + NS_TEST_EXPECT_MSG_NE (copy.PeekPacketTag< ATestTag<12> > (), 0, "trivial"); p.RemoveAllPacketTags (); - NS_TEST_EXPECT_MSG_EQ (p.PeekPacketTag (b), false, "trivial"); + NS_TEST_EXPECT_MSG_EQ (p.PeekPacketTag< ATestTag<11> > (), 0, "trivial"); } { diff --git a/src/test/global-routing-test-suite.cc b/src/test/global-routing-test-suite.cc index c1e88a4..1811e8f 100644 --- a/src/test/global-routing-test-suite.cc +++ b/src/test/global-routing-test-suite.cc @@ -76,11 +76,9 @@ DynamicGlobalRoutingTestCase::~DynamicGlobalRoutingTestCase () void DynamicGlobalRoutingTestCase::SinkRx (std::string path, Ptr p, const Address& address) { - Ipv4PacketInfoTag tag; - bool found; - found = p->PeekPacketTag (tag); + Ptr tag = p->PeekPacketTag (); uint8_t now = static_cast (Simulator::Now ().GetSeconds ()); - if (found) + if (tag != 0) { ; } @@ -99,17 +97,15 @@ DynamicGlobalRoutingTestCase::HandleRead (Ptr socket) { //EOF break; } - Ipv4PacketInfoTag tag; - bool found; - found = packet->PeekPacketTag (tag); + Ptr tag = packet->PeekPacketTag (); uint8_t now = static_cast (Simulator::Now ().GetSeconds ()); - if (found) + if (tag != 0) { - if (tag.GetRecvIf () == 1) + if (tag->GetRecvIf () == 1) { m_firstInterface[now]++; } - if (tag.GetRecvIf () == 2) + if (tag->GetRecvIf () == 2) { m_secondInterface[now]++; } diff --git a/src/topology-read/test/rocketfuel-topology-reader-test-suite.cc b/src/topology-read/test/rocketfuel-topology-reader-test-suite.cc index c0a960d..997b870 100644 --- a/src/topology-read/test/rocketfuel-topology-reader-test-suite.cc +++ b/src/topology-read/test/rocketfuel-topology-reader-test-suite.cc @@ -55,7 +55,7 @@ RocketfuelTopologyReaderTest::DoRun (void) std::string input ("./src/topology-read/examples/RocketFuel_toposample_1239_weights.txt"); - inFile = CreateObject (); + inFile = Create (); inFile->SetFileName (input); if (inFile != 0) -- 1.7.9.5