12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- #ifndef CORE_TEST_H
- #define CORE_TEST_H
- #include "core/Types.h"
- void finalizeTests(void);
- #define TEST_ARGS const char *file, int line
- #define TEST_FUNCTION(name, type) \
- bool test##name(TEST_ARGS, type wanted, type actual)
- TEST_FUNCTION(Int, int);
- TEST_FUNCTION(I64, i64);
- TEST_FUNCTION(U64, u64);
- TEST_FUNCTION(Size, size_t);
- TEST_FUNCTION(Bool, bool);
- TEST_FUNCTION(String, const char*);
- bool testFloat(TEST_ARGS, float wanted, float actual, float error);
- bool testNull(TEST_ARGS, const void* p);
- bool testNotNull(TEST_ARGS, const void* p);
- #define TEST(wanted, actual, name) \
- test##name(__FILE__, __LINE__, wanted, actual)
- #define TEST_FLOAT(wanted, actual, error) \
- testFloat(__FILE__, __LINE__, wanted, actual, error)
- #define TEST_BOOL(wanted, actual) TEST(wanted, actual, Bool)
- #define TEST_INT(wanted, actual) TEST(wanted, actual, Int)
- #define TEST_I64(wanted, actual) TEST(wanted, actual, I64)
- #define TEST_U64(wanted, actual) TEST(wanted, actual, U64)
- #define TEST_SIZE(wanted, actual) TEST(wanted, actual, Size)
- #define TEST_STRING(wanted, actual) TEST(wanted, actual, String)
- #define TEST_FALSE(actual) TEST(false, actual, Bool)
- #define TEST_TRUE(actual) TEST(true, actual, Bool)
- #define TEST_NULL(actual) testNull(__FILE__, __LINE__, actual)
- #define TEST_NOT_NULL(actual) testNotNull(__FILE__, __LINE__, actual)
- bool testVectorN(TEST_ARGS, const float* wanted, const float* actual, size_t n);
- #define TEST_VN(wanted, actual, n) \
- testVectorN(__FILE__, __LINE__, (wanted)->data, (actual)->data, n)
- #define TEST_V2(wanted, actual) \
- TEST_VN((Vector2*)(wanted), (Vector2*)(actual), 2)
- #define TEST_V3(wanted, actual) \
- TEST_VN((Vector3*)(wanted), (Vector3*)(actual), 3)
- #define TEST_V4(wanted, actual) \
- TEST_VN((Vector4*)(wanted), (Vector4*)(actual), 4)
- bool testIntVectorN(TEST_ARGS, const int* wanted, const int* actual, size_t n);
- #define TEST_IVN(wanted, actual, n) \
- testIntVectorN(__FILE__, __LINE__, (wanted)->data, (actual)->data, n)
- #define TEST_IV2(wanted, actual) \
- TEST_IVN((IntVector2*)(wanted), (IntVector2*)(actual), 2)
- #define TEST_IV3(wanted, actual) \
- TEST_IVN((IntVector3*)(wanted), (IntVector3*)(actual), 3)
- #define TEST_IV4(wanted, actual) \
- TEST_IVN((IntVector4*)(wanted), (IntVector4*)(actual), 4)
- #endif
|