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

(-)a/src/core/test.h (+35 lines)
 Lines 101-106   private: Link Here 
101
};
101
};
102
}; // namespace ns3 
102
}; // namespace ns3 
103
103
104
/**
105
 * Convenience macro to check that a value returned by a test is what
106
 * is expected.  Note: this macro assumes a 'bool result = true'
107
 * declaration exists in the test function body, and that the function
108
 * returns that value.
109
 *
110
 * \param got value obtained from the test
111
 * \param expected value that the test is expected to return
112
 */
113
#define NS_TEST_ASSERT_EQUAL(got, expected)             \
114
    if ((got) != (expected))                            \
115
      {                                                 \
116
        Failure () << __FILE__ << ":" <<__LINE__        \
117
                   << ": expected " << (expected)       \
118
                   << ", got " << (got) << std::endl;   \
119
        result = false;                                 \
120
      }
121
/**
122
 * Convenience macro to check an assertion is held during an unit
123
 * test.  Note: this macro assumes a 'bool result = true' declaration
124
 * exists in the test function body, and that the function returns
125
 * that value.
126
 *
127
 * \param assertion expression that must be true if the test did not fail
128
 */
129
#define NS_TEST_ASSERT(assertion)                       \
130
    if (!(assertion))                                   \
131
      {                                                 \
132
        Failure () << __FILE__ << ":" <<__LINE__        \
133
                   << ": assertion `" << (assertion)    \
134
                   << "'failed." << std::endl;          \
135
        result = false;                                 \
136
      }
137
138
104
#endif /* RUN_SELF_TESTS */
139
#endif /* RUN_SELF_TESTS */
105
140
106
#endif /* TEST_H */
141
#endif /* TEST_H */

Return to bug 37