convert from old test API
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Tue, 03 May 2011 11:19:03 +0200
changeset 7115 fbd9480a0b7f
parent 7114 0e7da904832a
child 7116 5ef0b23a4c80
convert from old test API
src/network/test/packet-metadata-test.cc
--- a/src/network/test/packet-metadata-test.cc	Tue May 03 11:18:41 2011 +0200
+++ b/src/network/test/packet-metadata-test.cc	Tue May 03 11:19:03 2011 +0200
@@ -252,7 +252,7 @@
 public:
   PacketMetadataTest ();
   virtual ~PacketMetadataTest ();
-  bool CheckHistory (Ptr<Packet> p, const char *file, int line, uint32_t n, ...);
+  void CheckHistory (Ptr<Packet> p, const char *file, int line, uint32_t n, ...);
   virtual void DoRun (void);
 private:
   Ptr<Packet> DoAddHeader (Ptr<Packet> p);
@@ -265,7 +265,7 @@
 PacketMetadataTest::~PacketMetadataTest ()
 {}
 
-bool 
+void
 PacketMetadataTest::CheckHistory (Ptr<Packet> p, const char *file, int line, uint32_t n, ...)
 {
   std::list<int> expected;
@@ -333,7 +333,7 @@
           goto error;
         }
     }
-  return true;
+  return;
  error:
   std::ostringstream failure;
   failure << "PacketMetadata error. Got:\"";
@@ -349,8 +349,7 @@
       failure << *j << ", ";
     }
   failure << "\"" << std::endl;
-  ReportTestFailure ("", "", "", failure.str(), file, line);
-  return false;
+  NS_TEST_ASSERT_MSG_EQ_INTERNAL (false, true, failure.str(), file, line);
 }
 
 #define ADD_HEADER(p, n)                                           \
@@ -375,21 +374,13 @@
   }
 #define CHECK_HISTORY(p, ...)                                      \
   {                                                                \
-    if (!CheckHistory (p, __FILE__,                                \
-                      __LINE__, __VA_ARGS__))                      \
-      {                                                            \
-        result = false;                                            \
-      }                                                            \
+    CheckHistory (p, __FILE__, __LINE__, __VA_ARGS__);             \
     uint32_t size = p->GetSerializedSize ();                       \
     uint8_t* buffer = new uint8_t[size];                           \
     p->Serialize (buffer, size);                                   \
     Ptr<Packet> otherPacket = Create<Packet> (buffer, size, true); \
     delete [] buffer;                                              \
-    if (!CheckHistory (otherPacket, __FILE__,                      \
-                      __LINE__, __VA_ARGS__))                      \
-      {                                                            \
-        result = false;                                            \
-      }                                                            \
+    CheckHistory (otherPacket, __FILE__, __LINE__, __VA_ARGS__);   \
   }
 
 
@@ -403,8 +394,6 @@
 void
 PacketMetadataTest::DoRun (void)
 {
-  bool result = true;
-
   PacketMetadata::Enable ();
 
   Ptr<Packet> p = Create<Packet> (0);
@@ -825,9 +814,6 @@
                                  p3->GetSize ());
   delete [] buf;
   NS_TEST_EXPECT_MSG_EQ(msg, std::string("hello world"), "Could not find original data in received packet");
-
-
-  NS_TEST_EXPECT_MSG_EQ(result, true, "PacketMetadataTest failed");
 }
 //-----------------------------------------------------------------------------
 class PacketMetadataTestSuite : public TestSuite