| 1 | --- |
| 2 | :cmock: |
| 3 | :plugins: [] |
| 4 | :treat_as: |
| 5 | custom_type: INT |
| 6 | |
| 7 | :systest: |
| 8 | :types: | |
| 9 | typedef struct _BIG_FAT_STRUCT_T |
| 10 | { |
| 11 | char bytes[512]; |
| 12 | } BIG_FAT_STRUCT_T; |
| 13 | |
| 14 | :mockable: | |
| 15 | void foo(BIG_FAT_STRUCT_T a); |
| 16 | |
| 17 | :source: |
| 18 | :header: | |
| 19 | void function_a(void); |
| 20 | void function_b(void); |
| 21 | |
| 22 | :code: | |
| 23 | void function_a(void) |
| 24 | { |
| 25 | BIG_FAT_STRUCT_T stuff = { { 8, 0 } }; |
| 26 | foo(stuff); |
| 27 | } |
| 28 | |
| 29 | void function_b(void) |
| 30 | { |
| 31 | BIG_FAT_STRUCT_T stuff1 = { { 9, 1, 0 } }; |
| 32 | BIG_FAT_STRUCT_T stuff2 = { { 9, 2, 0 } }; |
| 33 | foo(stuff1); |
| 34 | foo(stuff2); |
| 35 | } |
| 36 | |
| 37 | :tests: |
| 38 | :common: | |
| 39 | void setUp(void) {} |
| 40 | void tearDown(void) {} |
| 41 | |
| 42 | :units: |
| 43 | - :pass: TRUE |
| 44 | :should: 'successfully should be able to run function a because it only takes half the memory' |
| 45 | :code: | |
| 46 | test() |
| 47 | { |
| 48 | BIG_FAT_STRUCT_T expected = { { 8, 0 } }; |
| 49 | foo_Expect(expected); |
| 50 | function_a(); |
| 51 | } |
| 52 | |
| 53 | - :pass: FALSE |
| 54 | :should: 'should error out because we do not have eough memory to handle two of these structures' |
| 55 | :code: | |
| 56 | test() |
| 57 | { |
| 58 | BIG_FAT_STRUCT_T expected1 = { { 9, 1, 0 } }; |
| 59 | BIG_FAT_STRUCT_T expected2 = { { 9, 2, 0 } }; |
| 60 | foo_Expect(expected1); |
| 61 | foo_Expect(expected2); |
| 62 | function_b(); |
| 63 | } |
| 64 | |
| 65 | ... |