mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-07-30 07:47:50 +00:00
Merge pull request #186 from jlindgren90/master
mock_Verify functions should ideally not modify the state of the mock.
This commit is contained in:
@@ -188,9 +188,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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -412,8 +412,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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user