| 1 |
--- |
| 2 |
:cmock: |
| 3 |
:plugins: |
| 4 |
- |
| 5 |
|
| 6 |
:systest: |
| 7 |
:types: | |
| 8 |
#define UINT32 unsigned int |
| 9 |
|
| 10 |
:mockable: | |
| 11 |
UINT32 foo(UINT32 a); |
| 12 |
void bar(void); |
| 13 |
|
| 14 |
:source: |
| 15 |
:header: | |
| 16 |
UINT32 function_a(int a); |
| 17 |
void function_b(void); |
| 18 |
|
| 19 |
:code: | |
| 20 |
UINT32 function_a(int a) |
| 21 |
{ |
| 22 |
bar(); |
| 23 |
return foo((UINT32)a); |
| 24 |
} |
| 25 |
|
| 26 |
void function_b(void) |
| 27 |
{ |
| 28 |
bar(); |
| 29 |
} |
| 30 |
|
| 31 |
:tests: |
| 32 |
:common: | |
| 33 |
void setUp(void) {} |
| 34 |
void tearDown(void) {} |
| 35 |
|
| 36 |
:units: |
| 37 |
- :pass: :ignore |
| 38 |
:should: 'ignore incorrect expects after the TEST_IGNORE call' |
| 39 |
:code: | |
| 40 |
test() |
| 41 |
{ |
| 42 |
TEST_IGNORE(); |
| 43 |
bar_Expect(); |
| 44 |
foo_ExpectAndReturn(10, 20); |
| 45 |
TEST_ASSERT_EQUAL(40, function_a(30)); |
| 46 |
} |
| 47 |
|
| 48 |
- :pass: :ignore |
| 49 |
:should: 'ignore missing expects after the TEST_IGNORE call' |
| 50 |
:code: | |
| 51 |
test() |
| 52 |
{ |
| 53 |
TEST_IGNORE(); |
| 54 |
foo_ExpectAndReturn(10, 20); |
| 55 |
TEST_ASSERT_EQUAL(20, function_a(10)); |
| 56 |
} |
| 57 |
|
| 58 |
- :pass: :ignore |
| 59 |
:should: 'ignore extra expects after the TEST_IGNORE call' |
| 60 |
:code: | |
| 61 |
test() |
| 62 |
{ |
| 63 |
TEST_IGNORE(); |
| 64 |
bar_Expect(); |
| 65 |
bar_Expect(); |
| 66 |
foo_ExpectAndReturn(10, 20); |
| 67 |
foo_ExpectAndReturn(10, 20); |
| 68 |
foo_ExpectAndReturn(10, 20); |
| 69 |
TEST_ASSERT_EQUAL(20, function_a(10)); |
| 70 |
} |
| 71 |
|
| 72 |
- :pass: :ignore |
| 73 |
:should: 'ignore no expects after the TEST_IGNORE call' |
| 74 |
:code: | |
| 75 |
test() |
| 76 |
{ |
| 77 |
TEST_IGNORE(); |
| 78 |
TEST_ASSERT_EQUAL(20, function_a(10)); |
| 79 |
} |
| 80 |
|
| 81 |
- :pass: :ignore |
| 82 |
:should: 'ignore extra expects after the TEST_IGNORE call even if it happens later' |
| 83 |
:code: | |
| 84 |
test() |
| 85 |
{ |
| 86 |
bar_Expect(); |
| 87 |
foo_ExpectAndReturn(10, 20); |
| 88 |
function_a(10); |
| 89 |
|
| 90 |
TEST_IGNORE(); |
| 91 |
bar_Expect(); |
| 92 |
foo_ExpectAndReturn(10, 20); |
| 93 |
TEST_ASSERT_EQUAL(40, function_a(30)); |
| 94 |
} |
| 95 |
|
| 96 |
- :pass: false |
| 97 |
:should: 'still fail if there are expect problems before the TEST_IGNORE' |
| 98 |
:code: | |
| 99 |
test() |
| 100 |
{ |
| 101 |
bar_Expect(); |
| 102 |
foo_ExpectAndReturn(10, 20); |
| 103 |
function_a(30); |
| 104 |
|
| 105 |
TEST_IGNORE(); |
| 106 |
bar_Expect(); |
| 107 |
foo_ExpectAndReturn(10, 20); |
| 108 |
TEST_ASSERT_EQUAL(40, function_a(30)); |
| 109 |
} |
| 110 |
|
| 111 |
- :pass: false |
| 112 |
:should: 'still fail if there are missing expect problems before the TEST_IGNORE' |
| 113 |
:code: | |
| 114 |
test() |
| 115 |
{ |
| 116 |
bar_Expect(); |
| 117 |
function_a(10); |
| 118 |
|
| 119 |
TEST_IGNORE(); |
| 120 |
bar_Expect(); |
| 121 |
foo_ExpectAndReturn(10, 20); |
| 122 |
TEST_ASSERT_EQUAL(40, function_a(30)); |
| 123 |
} |
| 124 |
|
| 125 |
- :pass: :ignore |
| 126 |
:should: 'ignore if extra expects before the TEST_IGNORE because it ignored the rest of the test that might have made calls to it' |
| 127 |
:code: | |
| 128 |
test() |
| 129 |
{ |
| 130 |
bar_Expect(); |
| 131 |
bar_Expect(); |
| 132 |
foo_ExpectAndReturn(10, 20); |
| 133 |
function_a(10); |
| 134 |
|
| 135 |
TEST_IGNORE(); |
| 136 |
foo_ExpectAndReturn(10, 20); |
| 137 |
TEST_ASSERT_EQUAL(40, function_a(30)); |
| 138 |
} |
| 139 |
... |