-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtests.h
42 lines (33 loc) · 822 Bytes
/
tests.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#pragma once
/**
* @file tests.c
* @brief Utilities for tests
*
* @author Valérian Rousset
*/
#include <stdlib.h> // EXIT_FAILURE
#include <check.h>
#include "error.h"
#define ck_assert_bad_param(value) \
ck_assert_int_eq(value, ERR_BAD_PARAMETER)
#define ck_assert_err_none(value) \
ck_assert_int_eq(value, ERR_NONE)
#ifndef ck_assert_ptr_nonnull
#define ck_assert_ptr_nonnull(ptr) \
ck_assert_ptr_ne(ptr, NULL)
#endif
#ifndef ck_assert_ptr_null
#define ck_assert_ptr_null(ptr) \
ck_assert_ptr_eq(ptr, NULL)
#endif
#define TEST_SUITE(get_suite) \
int main() \
{ \
SRunner *sr = srunner_create(get_suite()); \
srunner_run_all(sr, CK_VERBOSE); \
\
int number_failed = srunner_ntests_failed(sr); \
srunner_free(sr); \
\
return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; \
}