From e835ad9c9dee498e32c7f71cd4293a0cf3d6c520 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Wed, 21 May 2014 16:48:27 -0400 Subject: [PATCH] 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) --- lib/cmock_generator_plugin_ignore.rb | 2 +- .../test_interactions/ignore_and_return.yml | 39 ++++++++++++------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/lib/cmock_generator_plugin_ignore.rb b/lib/cmock_generator_plugin_ignore.rb index 4118e5e..5397393 100644 --- a/lib/cmock_generator_plugin_ignore.rb +++ b/lib/cmock_generator_plugin_ignore.rb @@ -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 diff --git a/test/system/test_interactions/ignore_and_return.yml b/test/system/test_interactions/ignore_and_return.yml index 281efd0..64e181e 100644 --- a/test/system/test_interactions/ignore_and_return.yml +++ b/test/system/test_interactions/ignore_and_return.yml @@ -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);