mctest.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef MC__TEST
  2. #define MC__TEST
  3. #include <config.h>
  4. #include <check.h>
  5. #include "lib/global.h"
  6. /*** typedefs(not structures) and defined constants **********************************************/
  7. #define mctest_add_parameterized_test(tc_core, test_func, test_data_source) {\
  8. tcase_add_loop_test (tc_core, test_func, 0, G_N_ELEMENTS (test_data_source)); \
  9. }
  10. #define mctest_assert_str_eq(actual_result, etalon_result) { \
  11. g_assert_cmpstr (actual_result, ==, etalon_result); \
  12. }
  13. #define mctest_assert_int_eq(actual_result, etalon_result) { \
  14. ck_assert_int_eq (actual_result, etalon_result); \
  15. }
  16. #define mctest_assert_int_ne(actual_result, etalon_result) { \
  17. ck_assert_int_ne (actual_result, etalon_result); \
  18. }
  19. #define mctest_assert_ptr_eq(actual_pointer, etalon_pointer) { \
  20. fail_unless ( actual_pointer == etalon_pointer, \
  21. "%s(%p) pointer should be equal to %s(%p)\n", \
  22. #actual_pointer, actual_pointer, #etalon_pointer , etalon_pointer \
  23. );\
  24. }
  25. #define mctest_assert_ptr_ne(actual_pointer, etalon_pointer) { \
  26. fail_unless ( actual_pointer != etalon_pointer, \
  27. "%s(%p) pointer should not be equal to %s(%p)\n", \
  28. #actual_pointer, actual_pointer, #etalon_pointer , etalon_pointer \
  29. );\
  30. }
  31. #define mctest_assert_null(actual_pointer) { \
  32. fail_unless( \
  33. (void *) actual_pointer == NULL, \
  34. "%s(%p) variable should be NULL", #actual_pointer, actual_pointer \
  35. ); \
  36. }
  37. #define mctest_assert_not_null(actual_pointer) { \
  38. fail_if( \
  39. (void *) actual_pointer == NULL, \
  40. "%s(nil) variable should not be NULL", #actual_pointer \
  41. ); \
  42. }
  43. /**
  44. * Define header for a parameterized test.
  45. * Declare 'data' variable for access to the parameters in current iteration
  46. */
  47. #define START_PARAMETRIZED_TEST(name_test, struct_name) START_TEST (name_test) { const struct struct_name *data = &struct_name[_i];
  48. /**
  49. * Define footer for a parameterized test.
  50. */
  51. #define END_PARAMETRIZED_TEST } END_TEST
  52. /*** enums ***************************************************************************************/
  53. /*** structures declarations (and typedefs of structures)*****************************************/
  54. /*** global variables defined in .c file *********************************************************/
  55. /*** declarations of public functions ************************************************************/
  56. /*** inline functions ****************************************************************************/
  57. #endif /* MC__TEST */