Skip to content

Commit bb0b0e0

Browse files
authored
Fix confusing output when failing within a callback
Unset argument detail before calling callback
2 parents 204117c + 2bb9086 commit bb0b0e0

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/cmock_generator_plugin_callback.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ def generate_call(function)
4343
end
4444

4545
def mock_implementation(function)
46-
" if (Mock.#{function[:name]}_CallbackFunctionPointer != NULL)\n {\n" +
46+
" if (Mock.#{function[:name]}_CallbackFunctionPointer != NULL)\n {\n" \
47+
" UNITY_SET_DETAIL(CMockString_#{function[:name]});\n" +
4748
if function[:return][:void?]
4849
" #{generate_call(function)};\n }\n"
4950
else

test/unit/cmock_generator_plugin_callback_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
function = {:name => "Apple", :args => [], :args_string => "void", :return => test_return[:void]}
9797
expected = [" if (Mock.Apple_CallbackFunctionPointer != NULL)\n",
9898
" {\n",
99+
" UNITY_SET_DETAIL(CMockString_#{function[:name]});\n",
99100
" Mock.Apple_CallbackFunctionPointer(Mock.Apple_CallbackCalls++);\n",
100101
" }\n"
101102
].join
@@ -107,6 +108,7 @@
107108
function = {:name => "Apple", :args => [], :args_string => "void", :return => test_return[:void]}
108109
expected = [" if (Mock.Apple_CallbackFunctionPointer != NULL)\n",
109110
" {\n",
111+
" UNITY_SET_DETAIL(CMockString_#{function[:name]});\n",
110112
" Mock.Apple_CallbackFunctionPointer();\n",
111113
" }\n"
112114
].join
@@ -119,6 +121,7 @@
119121
function = {:name => "Apple", :args => [], :args_string => "void", :return => test_return[:int]}
120122
expected = [" if (Mock.Apple_CallbackFunctionPointer != NULL)\n",
121123
" {\n",
124+
" UNITY_SET_DETAIL(CMockString_#{function[:name]});\n",
122125
" cmock_call_instance->ReturnVal = Mock.Apple_CallbackFunctionPointer(Mock.Apple_CallbackCalls++);\n",
123126
" }\n"
124127
].join
@@ -134,6 +137,7 @@
134137
:return=> test_return[:void]}
135138
expected = [" if (Mock.Apple_CallbackFunctionPointer != NULL)\n",
136139
" {\n",
140+
" UNITY_SET_DETAIL(CMockString_#{function[:name]});\n",
137141
" Mock.Apple_CallbackFunctionPointer(steak, flag, Mock.Apple_CallbackCalls++);\n",
138142
" }\n"
139143
].join
@@ -149,6 +153,7 @@
149153
:return=> test_return[:void]}
150154
expected = [" if (Mock.Apple_CallbackFunctionPointer != NULL)\n",
151155
" {\n",
156+
" UNITY_SET_DETAIL(CMockString_#{function[:name]});\n",
152157
" Mock.Apple_CallbackFunctionPointer(steak, flag);\n",
153158
" }\n"
154159
].join
@@ -165,6 +170,7 @@
165170
:return => test_return[:int]}
166171
expected = [" if (Mock.Apple_CallbackFunctionPointer != NULL)\n",
167172
" {\n",
173+
" UNITY_SET_DETAIL(CMockString_#{function[:name]});\n",
168174
" cmock_call_instance->ReturnVal = Mock.Apple_CallbackFunctionPointer(steak, flag, Mock.Apple_CallbackCalls++);\n",
169175
" }\n"
170176
].join

0 commit comments

Comments
 (0)