File: test_assert_ptr_msg.c

package info (click to toggle)
cmocka 2.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,372 kB
  • sloc: ansic: 13,134; xml: 226; makefile: 23
file content (42 lines) | stat: -rw-r--r-- 1,136 bytes parent folder | download
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
#include "config.h"

#include <cmocka.h>

static void test_ptr_equal_msg(void **state)
{
    (void)state; /* unused */
    const char *my_pointer = "wurst";
    assert_ptr_equal_msg(my_pointer, my_pointer, "my_pointer should be equal to itself");
}

static void test_ptr_not_equal_msg(void **state)
{
    (void)state; /* unused */
    assert_ptr_not_equal_msg("wurst", "brot", "\"wurst\" should be a different pointer then \"brot\"");
}

static void test_null_msg(void **state)
{
    (void)state; /* unused */
    void *my_pointer = NULL;
    assert_null_msg(my_pointer, "my_pointer should be a NULL pointer");
}

static void test_non_null_msg(void **state)
{
    (void)state; /* unused */
    const char *my_pointer = "hello world";
    assert_non_null_msg(my_pointer, "my_pointer should not be a NULL pointer");
}

int main(void)
{
    const struct CMUnitTest ptr_msg_tests[] = {
        cmocka_unit_test(test_ptr_equal_msg),
        cmocka_unit_test(test_ptr_not_equal_msg),
        cmocka_unit_test(test_null_msg),
        cmocka_unit_test(test_non_null_msg),
    };

    return cmocka_run_group_tests(ptr_msg_tests, NULL, NULL);
}