Bugzilla – Bug 37
NS_TEST_ASSERT_EQUAL
Last modified: 2008-07-01 13:32:14 UTC
I have found this macro useful in unit tests: #define NS_TEST_ASSERT_EQUAL(got, expected) \ if (got != expected) \ { \ Failure () << __FILE__ << ": expected " << expected \ << ", but got " << got << std::endl; \ result = false; \ } E.g.: [...] packet.RemoveHeader (hdr); NS_TEST_ASSERT_EQUAL (hdr.m_packetSequenceNumber, 123); A similar NS_TEST_ASSERT(expression_that_must_be_true) macro could easily be derived...
Looks good. Are you willing to add this to test.h ? It would be nice to add the line number to the output too.
Created attachment 23 [details] patch (adds line number, docs, adds NS_TEST_ASSERT macro)
+1
Committed to ns-3-dev.