Test.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #ifndef CORE_TEST_HPP
  2. #define CORE_TEST_HPP
  3. void Test_finalize(void);
  4. #define CORE_TEST_ARGS const char *file, int line
  5. #define CORE_TEST_NAMED_FUNCTION(name, type) \
  6. bool Test_compare_##name(CORE_TEST_ARGS, type wanted, type actual)
  7. #define CORE_TEST_FUNCTION(type) CORE_TEST_NAMED_FUNCTION(type, type)
  8. CORE_TEST_FUNCTION(int);
  9. CORE_TEST_NAMED_FUNCTION(bool, bool);
  10. CORE_TEST_NAMED_FUNCTION(string, const char*);
  11. bool Test_compare_float(CORE_TEST_ARGS, float wanted, float actual,
  12. float error);
  13. bool Test_isNull(CORE_TEST_ARGS, const void* p);
  14. bool Test_isNotNull(CORE_TEST_ARGS, const void* p);
  15. #define CORE_TEST(wanted, actual, type) \
  16. Test_compare_##type(__FILE__, __LINE__, wanted, actual)
  17. #define CORE_TEST_FLOAT(wanted, actual, error) \
  18. Test_compare_float(__FILE__, __LINE__, wanted, actual, error)
  19. #define CORE_TEST_BOOL(wanted, actual) CORE_TEST(wanted, actual, bool)
  20. #define CORE_TEST_INT(wanted, actual) CORE_TEST(wanted, actual, int)
  21. #define CORE_TEST_STRING(wanted, actual) CORE_TEST(wanted, actual, string)
  22. #define CORE_TEST_FALSE(actual) CORE_TEST(false, actual, bool)
  23. #define CORE_TEST_TRUE(actual) CORE_TEST(true, actual, bool)
  24. #define CORE_TEST_NULL(actual) Test_isNull(__FILE__, __LINE__, actual)
  25. #define CORE_TEST_NOT_NULL(actual) Test_isNotNull(__FILE__, __LINE__, actual)
  26. #endif