OpenVPN
assert_module_test.c
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #include <stdarg.h>
17 #include <stddef.h>
18 #include <setjmp.h>
19 #include <cmocka.h>
20 
21 #include "assert_module.h"
22 
23 extern void increment_value(int * const value);
24 
25 /* This test case will fail but the assert is caught by run_tests() and the
26  * next test is executed. */
27 static void increment_value_fail(void **state) {
28  (void) state;
29 
30  increment_value(NULL);
31 }
32 
33 /* This test case succeeds since increment_value() asserts on the NULL
34  * pointer. */
35 static void increment_value_assert(void **state) {
36  (void) state;
37 
39 }
40 
41 /* This test case fails since decrement_value() doesn't assert on a NULL
42  * pointer. */
43 static void decrement_value_fail(void **state) {
44  (void) state;
45 
47 }
48 
49 int main(void) {
50  const struct CMUnitTest tests[] = {
54  };
55  return cmocka_run_group_tests(tests, NULL, NULL);
56 }
#define cmocka_unit_test(f)
Initializes a CMUnitTest structure.
Definition: cmocka.h:1653
void increment_value(int *const value)
Definition: assert_module.c:29
int main(void)
static void increment_value_assert(void **state)
static void increment_value_fail(void **state)
static void decrement_value_fail(void **state)
void decrement_value(int *const value)
Definition: assert_module.c:34
#define cmocka_run_group_tests(group_tests, group_setup, group_teardown)
Definition: cmocka.h:1749
#define expect_assert_failure(function_call)
Definition: cmocka.h:2012