simgear/misc/test_macros.hxx: add missing <iostream> header + minor changes
- The header is needed for std::cerr. - Also improve the messages when tests fail (spacing, and in some cases an argument was missing). - Reorder the macros a tiny bit.
This commit is contained in:
parent
6b16f96c8a
commit
ab4814c916
@ -1,42 +1,43 @@
|
|||||||
|
|
||||||
#ifndef SG_MISC_TEST_MACROS_HXX
|
#ifndef SG_MISC_TEST_MACROS_HXX
|
||||||
#define SG_MISC_TEST_MACROS_HXX
|
#define SG_MISC_TEST_MACROS_HXX
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include <cmath> // for std::fabs()
|
#include <cmath> // for std::fabs()
|
||||||
|
|
||||||
#define SG_CHECK_EQUAL(a, b) \
|
|
||||||
if ((a) != (b)) { \
|
|
||||||
std::cerr << "failed:" << #a << " != " << #b << std::endl; \
|
|
||||||
std::cerr << "\tgot:'" << a << "'" << std::endl; \
|
|
||||||
std::cerr << "\tat:" << __FILE__ << ":" << __LINE__ << std::endl; \
|
|
||||||
exit(1); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define SG_VERIFY(a) \
|
#define SG_VERIFY(a) \
|
||||||
if (!(a)) { \
|
if (!(a)) { \
|
||||||
std::cerr << "failed:" << #a << std::endl; \
|
std::cerr << "failed: " << #a << std::endl; \
|
||||||
std::cerr << "\tat:" << __FILE__ << ":" << __LINE__ << std::endl; \
|
std::cerr << "\tat " << __FILE__ << ":" << __LINE__ << std::endl; \
|
||||||
|
exit(1); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define SG_CHECK_EQUAL(a, b) \
|
||||||
|
if ((a) != (b)) { \
|
||||||
|
std::cerr << "failed: " << #a << " != " << #b << std::endl; \
|
||||||
|
std::cerr << "\tgot '" << a << "' and '" << b << "'" << std::endl; \
|
||||||
|
std::cerr << "\tat " << __FILE__ << ":" << __LINE__ << std::endl; \
|
||||||
exit(1); \
|
exit(1); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SG_CHECK_EQUAL_EP(a, b) \
|
#define SG_CHECK_EQUAL_EP(a, b) \
|
||||||
if (std::fabs((a) - (b)) > SG_EPSILON) { \
|
if (std::fabs((a) - (b)) > SG_EPSILON) { \
|
||||||
std::cerr << "failed with epsilon:" << #a << " != " << #b << std::endl; \
|
std::cerr << "failed with epsilon: " << #a << " != " << #b << std::endl; \
|
||||||
std::cerr << "\tgot:'" << a << "'" << std::endl; \
|
std::cerr << "\tgot '" << a << "' and '" << b << "'" << std::endl; \
|
||||||
std::cerr << "\tat:" << __FILE__ << ":" << __LINE__ << std::endl; \
|
std::cerr << "\tat " << __FILE__ << ":" << __LINE__ << std::endl; \
|
||||||
exit(1); \
|
exit(1); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SG_CHECK_EQUAL_EP2(a, b, ep) \
|
#define SG_CHECK_EQUAL_EP2(a, b, ep) \
|
||||||
if (std::fabs((a) - (b)) > ep) { \
|
if (std::fabs((a) - (b)) > ep) { \
|
||||||
std::cerr << "failed with epsilon:" << #a << " != " << #b << std::endl; \
|
std::cerr << "failed with epsilon: " << #a << " != " << #b << std::endl; \
|
||||||
std::cerr << "\tgot:'" << a << "'" << std::endl; \
|
std::cerr << "\tgot '" << a << "' and '" << b << "'" << std::endl; \
|
||||||
std::cerr << "\tat:" << __FILE__ << ":" << __LINE__ << std::endl; \
|
std::cerr << "\tat " << __FILE__ << ":" << __LINE__ << std::endl; \
|
||||||
exit(1); \
|
exit(1); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SG_TEST_FAIL(msg) \
|
#define SG_TEST_FAIL(msg) \
|
||||||
std::cerr << "failure:" << msg; \
|
std::cerr << "failure: " << msg; \
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user