mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-10-14 12:57:26 +00:00
Fix error where we would get errors if we IgnoredAndReturned a function and then never called it. stupid eh? ( thanks for bringing this up, smaankers)
This commit is contained in:
@@ -64,7 +64,7 @@ class CMockGeneratorPluginIgnore
|
||||
lines << "}\n\n"
|
||||
end
|
||||
|
||||
def mock_conditionally_verify(function)
|
||||
def mock_verify(function)
|
||||
func_name = function[:name]
|
||||
" if (Mock.#{func_name}_IgnoreBool)\n Mock.#{func_name}_CallInstance = CMOCK_GUTS_NONE;\n"
|
||||
end
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
int foo(int a);
|
||||
void bar(int b);
|
||||
|
||||
:source:
|
||||
:source:
|
||||
:header: |
|
||||
int function(int a, int b, int c);
|
||||
:code: |
|
||||
@@ -18,7 +18,7 @@
|
||||
{
|
||||
bar(b);
|
||||
return foo(a) + foo(b) + foo(c);
|
||||
}
|
||||
}
|
||||
|
||||
:tests:
|
||||
:common: |
|
||||
@@ -36,7 +36,7 @@
|
||||
foo_ExpectAndReturn(3, 30);
|
||||
TEST_ASSERT_EQUAL(60, function(1, 2, 3));
|
||||
}
|
||||
|
||||
|
||||
- :pass: TRUE
|
||||
:should: 'ignore foo() calls'
|
||||
:code: |
|
||||
@@ -48,7 +48,16 @@
|
||||
foo_IgnoreAndReturn(80);
|
||||
TEST_ASSERT_EQUAL(130, function(3, 4, 3));
|
||||
}
|
||||
|
||||
|
||||
- :pass: TRUE
|
||||
:should: 'ignore the situation where foo() is not called even though we explicitly ignored it'
|
||||
:code: |
|
||||
test()
|
||||
{
|
||||
foo_IgnoreAndReturn(20);
|
||||
//notice we do not call foo
|
||||
}
|
||||
|
||||
- :pass: TRUE
|
||||
:should: 'ignore foo() calls and always return last item if we run out'
|
||||
:code: |
|
||||
@@ -59,7 +68,7 @@
|
||||
foo_IgnoreAndReturn(30);
|
||||
TEST_ASSERT_EQUAL(80, function(3, 4, 9));
|
||||
}
|
||||
|
||||
|
||||
- :pass: TRUE
|
||||
:should: 'ignore foo() calls and always return only item if only one specified'
|
||||
:code: |
|
||||
@@ -69,7 +78,7 @@
|
||||
foo_IgnoreAndReturn(20);
|
||||
TEST_ASSERT_EQUAL(60, function(3, 4, 9));
|
||||
}
|
||||
|
||||
|
||||
- :pass: TRUE
|
||||
:should: 'ignore bar() and foo() calls'
|
||||
:code: |
|
||||
@@ -79,7 +88,7 @@
|
||||
foo_IgnoreAndReturn(50);
|
||||
TEST_ASSERT_EQUAL(150, function(0, 0, 0));
|
||||
}
|
||||
|
||||
|
||||
- :pass: TRUE
|
||||
:should: 'ignore foo() calls over multiple mock calls'
|
||||
:code: |
|
||||
@@ -90,18 +99,18 @@
|
||||
foo_IgnoreAndReturn(60);
|
||||
foo_IgnoreAndReturn(70);
|
||||
TEST_ASSERT_EQUAL(180, function(0, 0, 0));
|
||||
|
||||
|
||||
bar_Ignore();
|
||||
foo_IgnoreAndReturn(30);
|
||||
foo_IgnoreAndReturn(80);
|
||||
foo_IgnoreAndReturn(10);
|
||||
TEST_ASSERT_EQUAL(120, function(0, 0, 0));
|
||||
|
||||
|
||||
foo_IgnoreAndReturn(70);
|
||||
foo_IgnoreAndReturn(20);
|
||||
TEST_ASSERT_EQUAL(110, function(0, 0, 0));
|
||||
}
|
||||
|
||||
|
||||
- :pass: TRUE
|
||||
:should: 'multiple cycles of expects still pass when ignores enabled'
|
||||
:code: |
|
||||
@@ -112,20 +121,20 @@
|
||||
foo_ExpectAndReturn(2, 60);
|
||||
foo_ExpectAndReturn(3, 70);
|
||||
TEST_ASSERT_EQUAL(180, function(1, 2, 3));
|
||||
|
||||
|
||||
bar_Expect(5);
|
||||
foo_ExpectAndReturn(4, 30);
|
||||
foo_ExpectAndReturn(5, 80);
|
||||
foo_ExpectAndReturn(6, 10);
|
||||
TEST_ASSERT_EQUAL(120, function(4, 5, 6));
|
||||
|
||||
|
||||
bar_Expect(8);
|
||||
foo_ExpectAndReturn(7, 70);
|
||||
foo_ExpectAndReturn(8, 20);
|
||||
foo_ExpectAndReturn(9, 20);
|
||||
TEST_ASSERT_EQUAL(110, function(7, 8, 9));
|
||||
}
|
||||
|
||||
|
||||
- :pass: FALSE
|
||||
:should: 'multiple cycles of expects still fail when ignores enabled'
|
||||
:code: |
|
||||
@@ -136,13 +145,13 @@
|
||||
foo_ExpectAndReturn(2, 60);
|
||||
foo_ExpectAndReturn(3, 70);
|
||||
TEST_ASSERT_EQUAL(180, function(1, 2, 3));
|
||||
|
||||
|
||||
bar_Expect(5);
|
||||
foo_ExpectAndReturn(4, 30);
|
||||
foo_ExpectAndReturn(5, 80);
|
||||
foo_ExpectAndReturn(6, 10);
|
||||
TEST_ASSERT_EQUAL(120, function(4, 5, 6));
|
||||
|
||||
|
||||
bar_Expect(8);
|
||||
foo_ExpectAndReturn(7, 70);
|
||||
foo_ExpectAndReturn(8, 20);
|
||||
|
||||
Reference in New Issue
Block a user