Test.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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(U64, u64);
  10. CORE_TEST_FUNCTION(Size, size_t);
  11. CORE_TEST_FUNCTION(Bool, bool);
  12. CORE_TEST_FUNCTION(String, const char*);
  13. bool coreTestFloat(CORE_TEST_ARGS, float wanted, float actual, float error);
  14. bool coreTestNull(CORE_TEST_ARGS, const void* p);
  15. bool coreTestNotNull(CORE_TEST_ARGS, const void* p);
  16. #define CORE_TEST(wanted, actual, name) \
  17. coreTest##name(__FILE__, __LINE__, wanted, actual)
  18. #define CORE_TEST_FLOAT(wanted, actual, error) \
  19. coreTestFloat(__FILE__, __LINE__, wanted, actual, error)
  20. #define CORE_TEST_BOOL(wanted, actual) CORE_TEST(wanted, actual, Bool)
  21. #define CORE_TEST_INT(wanted, actual) CORE_TEST(wanted, actual, Int)
  22. #define CORE_TEST_U64(wanted, actual) CORE_TEST(wanted, actual, U64)
  23. #define CORE_TEST_SIZE(wanted, actual) CORE_TEST(wanted, actual, Size)
  24. #define CORE_TEST_STRING(wanted, actual) CORE_TEST(wanted, actual, String)
  25. #define CORE_TEST_FALSE(actual) CORE_TEST(false, actual, Bool)
  26. #define CORE_TEST_TRUE(actual) CORE_TEST(true, actual, Bool)
  27. #define CORE_TEST_NULL(actual) coreTestNull(__FILE__, __LINE__, actual)
  28. #define CORE_TEST_NOT_NULL(actual) coreTestNotNull(__FILE__, __LINE__, actual)
  29. #endif