diff --git a/lib/cmock_generator.rb b/lib/cmock_generator.rb index 8cfe07b..d29658f 100644 --- a/lib/cmock_generator.rb +++ b/lib/cmock_generator.rb @@ -190,9 +190,15 @@ class CMockGenerator def create_mock_verify_function(file, functions) file << "void #{@clean_mock_name}_Verify(void)\n{\n" - verifications = functions.collect {|function| @plugins.run(:mock_verify, function)}.join - file << " UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM;\n" unless verifications.empty? - file << verifications + verifications = functions.collect do |function| + v = @plugins.run(:mock_verify, function) + v.empty? ? v : [" call_instance = Mock.#{function[:name]}_CallInstance;\n", v] + end.join + unless verifications.empty? + file << " UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM;\n" + file << " CMOCK_MEM_INDEX_TYPE call_instance;\n" + file << verifications + end file << "}\n\n" end diff --git a/lib/cmock_generator_plugin_callback.rb b/lib/cmock_generator_plugin_callback.rb index da55085..4e27443 100644 --- a/lib/cmock_generator_plugin_callback.rb +++ b/lib/cmock_generator_plugin_callback.rb @@ -92,7 +92,7 @@ class CMockGeneratorPluginCallback def mock_verify(function) func_name = function[:name] - " if (Mock.#{func_name}_CallbackFunctionPointer != NULL)\n Mock.#{func_name}_CallInstance = CMOCK_GUTS_NONE;\n" + " if (Mock.#{func_name}_CallbackFunctionPointer != NULL)\n call_instance = CMOCK_GUTS_NONE;\n" end end diff --git a/lib/cmock_generator_plugin_expect.rb b/lib/cmock_generator_plugin_expect.rb index 19fb41b..42c00bd 100644 --- a/lib/cmock_generator_plugin_expect.rb +++ b/lib/cmock_generator_plugin_expect.rb @@ -98,7 +98,7 @@ class CMockGeneratorPluginExpect def mock_verify(function) func_name = function[:name] " UNITY_SET_DETAIL(CMockString_#{function[:name]});\n" + - " UNITY_TEST_ASSERT(CMOCK_GUTS_NONE == Mock.#{func_name}_CallInstance, cmock_line, CMockStringCalledLess);\n" + " UNITY_TEST_ASSERT(CMOCK_GUTS_NONE == call_instance, cmock_line, CMockStringCalledLess);\n" end end diff --git a/lib/cmock_generator_plugin_ignore.rb b/lib/cmock_generator_plugin_ignore.rb index a291dd4..8f31967 100644 --- a/lib/cmock_generator_plugin_ignore.rb +++ b/lib/cmock_generator_plugin_ignore.rb @@ -70,6 +70,6 @@ class CMockGeneratorPluginIgnore def mock_verify(function) func_name = function[:name] - " if (Mock.#{func_name}_IgnoreBool)\n Mock.#{func_name}_CallInstance = CMOCK_GUTS_NONE;\n" + " if (Mock.#{func_name}_IgnoreBool)\n call_instance = CMOCK_GUTS_NONE;\n" end end diff --git a/test/unit/cmock_generator_main_test.rb b/test/unit/cmock_generator_main_test.rb index fbfe41c..47fad8d 100644 --- a/test/unit/cmock_generator_main_test.rb +++ b/test/unit/cmock_generator_main_test.rb @@ -409,8 +409,11 @@ describe CMockGenerator, "Verify CMockGenerator Module" do output = [] expected = [ "void MockPoutPoutFish_Verify(void)\n{\n", " UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM;\n", + " CMOCK_MEM_INDEX_TYPE call_instance;\n", + " call_instance = Mock.First_CallInstance;\n" + " Uno_First" + " Dos_First" + + " call_instance = Mock.Second_CallInstance;\n" + " Uno_Second" + " Dos_Second", "}\n\n" diff --git a/test/unit/cmock_generator_plugin_expect_a_test.rb b/test/unit/cmock_generator_plugin_expect_a_test.rb index c8e84c2..8a7ee65 100644 --- a/test/unit/cmock_generator_plugin_expect_a_test.rb +++ b/test/unit/cmock_generator_plugin_expect_a_test.rb @@ -179,7 +179,7 @@ describe CMockGeneratorPluginExpect, "Verify CMockGeneratorPluginExpect Module W it "add mock verify lines" do function = {:name => "Banana" } expected = " UNITY_SET_DETAIL(CMockString_Banana);\n" + - " UNITY_TEST_ASSERT(CMOCK_GUTS_NONE == Mock.Banana_CallInstance, cmock_line, CMockStringCalledLess);\n" + " UNITY_TEST_ASSERT(CMOCK_GUTS_NONE == call_instance, cmock_line, CMockStringCalledLess);\n" returned = @cmock_generator_plugin_expect.mock_verify(function) assert_equal(expected, returned) end diff --git a/test/unit/cmock_generator_plugin_expect_b_test.rb b/test/unit/cmock_generator_plugin_expect_b_test.rb index 031d246..ab2bd99 100644 --- a/test/unit/cmock_generator_plugin_expect_b_test.rb +++ b/test/unit/cmock_generator_plugin_expect_b_test.rb @@ -195,7 +195,7 @@ describe CMockGeneratorPluginExpect, "Verify CMockGeneratorPluginExpect Module w it "add mock verify lines" do function = {:name => "Banana" } expected = " UNITY_SET_DETAIL(CMockString_Banana);\n" + - " UNITY_TEST_ASSERT(CMOCK_GUTS_NONE == Mock.Banana_CallInstance, cmock_line, CMockStringCalledLess);\n" + " UNITY_TEST_ASSERT(CMOCK_GUTS_NONE == call_instance, cmock_line, CMockStringCalledLess);\n" returned = @cmock_generator_plugin_expect.mock_verify(function) assert_equal(expected, returned) end