mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-06-05 21:15:20 +00:00
Merge pull request #305 from pwatt01/master
add <function>_StopIgnore() function
This commit is contained in:
@@ -161,6 +161,18 @@ care how many times it was called, right?
|
||||
* `retval func(void)` => `void func_IgnoreAndReturn(retval_to_return)`
|
||||
* `retval func(params)` => `void func_IgnoreAndReturn(retval_to_return)`
|
||||
|
||||
StopIgnore:
|
||||
-------
|
||||
|
||||
Maybe you want to ignore a particular function for part of a test but dont want to
|
||||
ignore it later on. In that case, you want to use StopIgnore which will cancel the
|
||||
previously called Ignore or IgnoreAndReturn requiring you to Expect or otherwise
|
||||
handle the call to a function.
|
||||
|
||||
* `void func(void)` => `void func_StopIgnore(void)`
|
||||
* `void func(params)` => `void func_StopIgnore(void)`
|
||||
* `retval func(void)` => `void func_StopIgnore(void)`
|
||||
* `retval func(params)` => `void func_StopIgnore(void)`
|
||||
|
||||
Ignore Arg:
|
||||
------------
|
||||
|
||||
@@ -24,12 +24,17 @@ class CMockGeneratorPluginIgnore
|
||||
|
||||
def mock_function_declarations(function)
|
||||
if function[:return][:void?]
|
||||
"#define #{function[:name]}_Ignore() #{function[:name]}_CMockIgnore()\n" \
|
||||
lines = "#define #{function[:name]}_Ignore() #{function[:name]}_CMockIgnore()\n" \
|
||||
"void #{function[:name]}_CMockIgnore(void);\n"
|
||||
else
|
||||
"#define #{function[:name]}_IgnoreAndReturn(cmock_retval) #{function[:name]}_CMockIgnoreAndReturn(__LINE__, cmock_retval)\n" \
|
||||
lines = "#define #{function[:name]}_IgnoreAndReturn(cmock_retval) #{function[:name]}_CMockIgnoreAndReturn(__LINE__, cmock_retval)\n" \
|
||||
"void #{function[:name]}_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, #{function[:return][:str]});\n"
|
||||
end
|
||||
|
||||
#add stop ignore function. it does not matter if there are any args
|
||||
lines << "#define #{function[:name]}_StopIgnore() #{function[:name]}_CMockStopIgnore()\n" \
|
||||
"void #{function[:name]}_CMockStopIgnore(void);\n"void #{function[:name]}_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, #{function[:return][:str]});\n
|
||||
lines
|
||||
end
|
||||
|
||||
def mock_implementation_precheck(function)
|
||||
@@ -61,6 +66,15 @@ class CMockGeneratorPluginIgnore
|
||||
end
|
||||
lines << " Mock.#{function[:name]}_IgnoreBool = (char)1;\n"
|
||||
lines << "}\n\n"
|
||||
|
||||
#add stop ignore function. it does not matter if there are any args
|
||||
lines << "void #{function[:name]}_CMockStopIgnore(void)\n{\n"
|
||||
unless function[:return][:void?]
|
||||
lines << " if(Mock.#{function[:name]}_IgnoreBool)\n"
|
||||
lines << " Mock.#{function[:name]}_CallInstance = CMock_Guts_MemNext(Mock.#{function[:name]}_CallInstance);\n"
|
||||
end
|
||||
lines << " Mock.#{function[:name]}_IgnoreBool = (char)0;\n"
|
||||
lines << "}\n\n"
|
||||
end
|
||||
|
||||
def mock_ignore(function)
|
||||
|
||||
Reference in New Issue
Block a user