| 1 |
--- |
| 2 |
|
| 3 |
:cmock: |
| 4 |
:plugins: |
| 5 |
- :array |
| 6 |
:treat_as_array: |
| 7 |
VOID_PTR: unsigned char |
| 8 |
|
| 9 |
:systest: |
| 10 |
:types: | |
| 11 |
#include "unity_internals.h" |
| 12 |
typedef void* VOID_PTR; |
| 13 |
|
| 14 |
:mockable: | |
| 15 |
void* ret_v_ptr(void); |
| 16 |
void get_v_ptr(void* ptr); |
| 17 |
void get_v_ptr_typedefed(VOID_PTR ptr); |
| 18 |
|
| 19 |
:source: |
| 20 |
:header: | |
| 21 |
void function_a(void); |
| 22 |
|
| 23 |
:code: | |
| 24 |
void function_a(void) { |
| 25 |
void* stuff = ret_v_ptr(); |
| 26 |
get_v_ptr(stuff); |
| 27 |
get_v_ptr_typedefed((VOID_PTR)stuff); |
| 28 |
} |
| 29 |
|
| 30 |
:tests: |
| 31 |
:common: | |
| 32 |
void setUp(void) {} |
| 33 |
void tearDown(void) {} |
| 34 |
|
| 35 |
:units: |
| 36 |
- :pass: TRUE |
| 37 |
:should: 'handle passing working expects' |
| 38 |
:code: | |
| 39 |
test() |
| 40 |
{ |
| 41 |
char* a = "Hello"; |
| 42 |
char* b = "Hello"; |
| 43 |
ret_v_ptr_ExpectAndReturn(a); |
| 44 |
get_v_ptr_Expect(b); |
| 45 |
get_v_ptr_typedefed_Expect((VOID_PTR)b); |
| 46 |
|
| 47 |
function_a(); |
| 48 |
} |
| 49 |
|
| 50 |
- :pass: TRUE |
| 51 |
:should: 'handle passing array expects' |
| 52 |
:code: | |
| 53 |
test() |
| 54 |
{ |
| 55 |
char* a = "Hello"; |
| 56 |
char* b = "Hello"; |
| 57 |
ret_v_ptr_ExpectAndReturn(a); |
| 58 |
get_v_ptr_ExpectWithArray(b,5); |
| 59 |
get_v_ptr_typedefed_ExpectWithArray((VOID_PTR)b,5); |
| 60 |
|
| 61 |
function_a(); |
| 62 |
} |
| 63 |
|
| 64 |
- :pass: FALSE |
| 65 |
:should: 'handle failing expects' |
| 66 |
:code: | |
| 67 |
test() |
| 68 |
{ |
| 69 |
char* a = "Hello"; |
| 70 |
char* b = "Jello"; |
| 71 |
ret_v_ptr_ExpectAndReturn(a); |
| 72 |
get_v_ptr_Expect(b); |
| 73 |
get_v_ptr_typedefed_Expect((VOID_PTR)b); |
| 74 |
|
| 75 |
function_a(); |
| 76 |
} |
| 77 |
|
| 78 |
- :pass: FALSE |
| 79 |
:should: 'handle failing array expects' |
| 80 |
:code: | |
| 81 |
test() |
| 82 |
{ |
| 83 |
char* a = "Hello"; |
| 84 |
char* b = "Hella"; |
| 85 |
ret_v_ptr_ExpectAndReturn(a); |
| 86 |
get_v_ptr_ExpectWithArray(b,5); |
| 87 |
get_v_ptr_typedefed_ExpectWithArray((VOID_PTR)b,5); |
| 88 |
|
| 89 |
function_a(); |
| 90 |
} |
| 91 |
... |