Test.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef CORE_TEST_H
  2. #define CORE_TEST_H
  3. #include "core/Types.h"
  4. void coreFinalizeTests(void);
  5. #define CORE_TEST_ARGS const char *file, int line
  6. #define CORE_TEST_FUNCTION(name, type) \
  7. bool coreTest##name(CORE_TEST_ARGS, type wanted, type actual)
  8. CORE_TEST_FUNCTION(Int, int);
  9. CORE_TEST_FUNCTION(I64, i64);
  10. CORE_TEST_FUNCTION(U64, u64);
  11. CORE_TEST_FUNCTION(Size, size_t);
  12. CORE_TEST_FUNCTION(Bool, bool);
  13. CORE_TEST_FUNCTION(String, const char*);
  14. bool coreTestFloat(CORE_TEST_ARGS, float wanted, float actual, float error);
  15. bool coreTestNull(CORE_TEST_ARGS, const void* p);
  16. bool coreTestNotNull(CORE_TEST_ARGS, const void* p);
  17. #define CORE_TEST(wanted, actual, name) \
  18. coreTest##name(__FILE__, __LINE__, wanted, actual)
  19. #define CORE_TEST_FLOAT(wanted, actual, error) \
  20. coreTestFloat(__FILE__, __LINE__, wanted, actual, error)
  21. #define CORE_TEST_BOOL(wanted, actual) CORE_TEST(wanted, actual, Bool)
  22. #define CORE_TEST_INT(wanted, actual) CORE_TEST(wanted, actual, Int)
  23. #define CORE_TEST_I64(wanted, actual) CORE_TEST(wanted, actual, I64)
  24. #define CORE_TEST_U64(wanted, actual) CORE_TEST(wanted, actual, U64)
  25. #define CORE_TEST_SIZE(wanted, actual) CORE_TEST(wanted, actual, Size)
  26. #define CORE_TEST_STRING(wanted, actual) CORE_TEST(wanted, actual, String)
  27. #define CORE_TEST_FALSE(actual) CORE_TEST(false, actual, Bool)
  28. #define CORE_TEST_TRUE(actual) CORE_TEST(true, actual, Bool)
  29. #define CORE_TEST_NULL(actual) coreTestNull(__FILE__, __LINE__, actual)
  30. #define CORE_TEST_NOT_NULL(actual) coreTestNotNull(__FILE__, __LINE__, actual)
  31. bool coreTestVectorN(CORE_TEST_ARGS, const float* wanted, const float* actual,
  32. size_t n);
  33. #define CORE_TEST_VN(wanted, actual, n) \
  34. coreTestVectorN(__FILE__, __LINE__, (wanted)->data, (actual)->data, n)
  35. #define CORE_TEST_V2(wanted, actual) \
  36. CORE_TEST_VN((CoreVector2*)(wanted), (CoreVector2*)(actual), 2)
  37. #define CORE_TEST_V3(wanted, actual) \
  38. CORE_TEST_VN((CoreVector3*)(wanted), (CoreVector3*)(actual), 3)
  39. #define CORE_TEST_V4(wanted, actual) \
  40. CORE_TEST_VN((CoreVector4*)(wanted), (CoreVector4*)(actual), 4)
  41. bool coreTestIntVectorN(CORE_TEST_ARGS, const int* wanted, const int* actual,
  42. size_t n);
  43. #define CORE_TEST_IVN(wanted, actual, n) \
  44. coreTestIntVectorN(__FILE__, __LINE__, (wanted)->data, (actual)->data, n)
  45. #define CORE_TEST_IV2(wanted, actual) \
  46. CORE_TEST_IVN((CoreIntVector2*)(wanted), (CoreIntVector2*)(actual), 2)
  47. #define CORE_TEST_IV3(wanted, actual) \
  48. CORE_TEST_IVN((CoreIntVector3*)(wanted), (CoreIntVector3*)(actual), 3)
  49. #define CORE_TEST_IV4(wanted, actual) \
  50. CORE_TEST_IVN((CoreIntVector4*)(wanted), (CoreIntVector4*)(actual), 4)
  51. #endif