c-template
array_test.c
Go to the documentation of this file.
1
#include <stdio.h>
2
#include <stdarg.h>
3
#include <stddef.h>
4
#include <setjmp.h>
5
#include <cmocka.h>
6
#include <assert.h>
7
#include "../../include/utils/array_len.h"
8
9
#pragma GCC diagnostic ignored "-Wunused-parameter"
10
#pragma GCC diagnostic ignored "-Wunused-variable"
11
#pragma GCC diagnostic ignored "-Wpedantic"
12
void
test_array_len
(
void
**state) {
13
int
one[1] = {0};
14
int
two[2] = {0, 1};
15
assert(
array_len
(one) == 1);
16
assert(
array_len
(two) == 2);
17
}
18
19
#pragma GCC diagnostic ignored "-Wunused-parameter"
20
#pragma GCC diagnostic ignored "-Wunused-variable"
21
#pragma GCC diagnostic ignored "-Wpedantic"
22
void
test_array_size
(
void
**state) {
23
int
one[1] = {0};
24
int
two[2] = {0, 1};
25
assert(
array_size
(one) ==
sizeof
(
int
));
26
assert(
array_size
(two) ==
sizeof
(
int
)*2);
27
}
28
29
int
main
(
void
) {
30
const
struct
CMUnitTest tests[] = {
31
cmocka_unit_test(
test_array_len
),
32
cmocka_unit_test(
test_array_size
),
33
};
34
return
cmocka_run_group_tests(tests, NULL, NULL);
35
}
main
int main(void)
Definition:
array_test.c:29
test_array_len
void test_array_len(void **state)
Definition:
array_test.c:12
array_size
#define array_size(x)
Definition:
array_len.h:4
test_array_size
void test_array_size(void **state)
Definition:
array_test.c:22
array_len
#define array_len(x)
Definition:
array_len.h:2
src
utils
array_test.c
Generated by
1.8.17