|
Bugzilla – Full Text Bug Listing |
| Summary: | NS_TEST_ASSERT_EQUAL | ||
|---|---|---|---|
| Product: | ns-3 | Reporter: | Gustavo J. A. M. Carneiro <gjcarneiro> |
| Component: | core | Assignee: | ns-bugs <ns-bugs> |
| Status: | RESOLVED FIXED | ||
| Severity: | blocker | ||
| Priority: | P1 | ||
| Version: | pre-release | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Attachments: | patch (adds line number, docs, adds NS_TEST_ASSERT macro) | ||
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. |
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...