Debian Codegraph @

test/system/test_interactions/function_pointer_handling.yml

raw symbols SCIP
1 ---
2 :cmock:
3 :plugins:
4 - # none
5 :treat_as:
6 FUNCTION_T: PTR
7
8 :systest:
9 :types: |
10 typedef void (*FUNCTION_T)(void);
11
12 :mockable: |
13 void takes_function_type( FUNCTION_T myfunc );
14 void takes_function_ptr( unsigned int (*func_ptr)(int, char) );
15 void takes_function_ptr_shorthand( unsigned int func_ptr(int, char*) );
16 void takes_const_function_ptr( unsigned int (* const)(int, char) );
17 unsigned short (*returns_function_ptr( const char op_code ))( int, long int );
18
19 :source:
20 :header: |
21 void exercise_function_pointer_param(void);
22 unsigned short (*exercise_function_pointer_return( const char op_code ))( int, long int );
23
24 // functions for function pointer tests
25 unsigned int dummy_function1(int a, char b);
26 unsigned short dummy_function2(int a, long int b);
27
28 :code: |
29 /*
30 * functions used in tests
31 */
32
33 unsigned int dummy_function1(int a, char b)
34 {
35 // prevent compiler warnings by using everything
36 return (unsigned int)a + (unsigned int)b;
37 }
38
39 unsigned short dummy_function2(int a, long int b)
40 {
41 // prevent compiler warnings by using everything
42 return (unsigned short)a + (unsigned short)b;
43 }
44
45 /*
46 * functions executed by tests
47 */
48
49 void exercise_function_pointer_param(void)
50 {
51 takes_function_ptr(dummy_function1);
52 }
53
54 unsigned short (*exercise_function_pointer_return( const char op_code ))( int, long int )
55 {
56 return returns_function_ptr(op_code);
57 }
58
59 :tests:
60 :common: |
61 void setUp(void) {}
62 void tearDown(void) {}
63 :units:
64 - :pass: TRUE
65 :should: 'expect a function pointer param'
66 :code: |
67 test()
68 {
69 takes_function_ptr_Expect(dummy_function1);
70 exercise_function_pointer_param();
71 }
72
73 - :pass: TRUE
74 :should: 'return a function pointer'
75 :code: |
76 test()
77 {
78 returns_function_ptr_ExpectAndReturn('z', dummy_function2);
79 TEST_ASSERT_EQUAL_PTR(dummy_function2, exercise_function_pointer_return('z'));
80 }
81
82
83 ...