Test.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef CORE_TEST_HPP
  2. #define CORE_TEST_HPP
  3. void coreFinalizeTests(void);
  4. #define CORE_TEST_ARGS const char *file, int line
  5. #define CORE_TEST_FUNCTION(name, type) \
  6. bool coreTest##name(CORE_TEST_ARGS, type wanted, type actual)
  7. CORE_TEST_FUNCTION(Int, int);
  8. CORE_TEST_FUNCTION(Bool, bool);
  9. CORE_TEST_FUNCTION(String, const char*);
  10. bool coreTestFloat(CORE_TEST_ARGS, float wanted, float actual, float error);
  11. bool coreTestNull(CORE_TEST_ARGS, const void* p);
  12. bool coreTestNotNull(CORE_TEST_ARGS, const void* p);
  13. #define CORE_TEST(wanted, actual, name, type) \
  14. coreTest##name(__FILE__, __LINE__, wanted, actual)
  15. #define CORE_TEST_FLOAT(wanted, actual, error) \
  16. coreTestFloat(__FILE__, __LINE__, wanted, actual, error)
  17. #define CORE_TEST_BOOL(wanted, actual) CORE_TEST(wanted, actual, Bool, bool)
  18. #define CORE_TEST_INT(wanted, actual) CORE_TEST(wanted, actual, Int, int)
  19. #define CORE_TEST_STRING(wanted, actual) \
  20. CORE_TEST(wanted, actual, String, string)
  21. #define CORE_TEST_FALSE(actual) CORE_TEST(false, actual, Bool, bool)
  22. #define CORE_TEST_TRUE(actual) CORE_TEST(true, actual, Bool, bool)
  23. #define CORE_TEST_NULL(actual) coreTestNull(__FILE__, __LINE__, actual)
  24. #define CORE_TEST_NOT_NULL(actual) coreTestNotNull(__FILE__, __LINE__, actual)
  25. #endif