mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-10-18 14:47:57 +00:00
Merge pull request #243 from jlindgren90/expect-any-args-cleanup
Replace IgnoreMode with ExpectAnyArgsBool (no functional change).
This commit is contained in:
@@ -64,7 +64,7 @@ class CMockGeneratorPluginExpect
|
|||||||
|
|
||||||
def mock_implementation_might_check_args(function)
|
def mock_implementation_might_check_args(function)
|
||||||
return "" if (function[:args].empty?)
|
return "" if (function[:args].empty?)
|
||||||
lines = " if (cmock_call_instance->IgnoreMode != CMOCK_ARG_NONE)\n {\n"
|
lines = " if (!cmock_call_instance->ExpectAnyArgsBool)\n {\n"
|
||||||
function[:args].each do |arg|
|
function[:args].each do |arg|
|
||||||
lines << @utils.code_verify_an_arg_expectation(function, arg)
|
lines << @utils.code_verify_an_arg_expectation(function, arg)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,16 +15,8 @@ class CMockGeneratorPluginExpectAnyArgs
|
|||||||
@priority = 3
|
@priority = 3
|
||||||
end
|
end
|
||||||
|
|
||||||
def instance_structure(function)
|
|
||||||
if (function[:return][:void?]) || (@config.plugins.include? :ignore)
|
|
||||||
""
|
|
||||||
else
|
|
||||||
" #{function[:return][:type]} #{function[:name]}_FinalReturn;\n"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def instance_typedefs(function)
|
def instance_typedefs(function)
|
||||||
" CMOCK_ARG_MODE IgnoreMode;\n"
|
" int ExpectAnyArgsBool;\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
def mock_function_declarations(function)
|
def mock_function_declarations(function)
|
||||||
@@ -48,7 +40,7 @@ class CMockGeneratorPluginExpectAnyArgs
|
|||||||
unless (function[:return][:void?])
|
unless (function[:return][:void?])
|
||||||
lines << " cmock_call_instance->ReturnVal = cmock_to_return;\n"
|
lines << " cmock_call_instance->ReturnVal = cmock_to_return;\n"
|
||||||
end
|
end
|
||||||
lines << " cmock_call_instance->IgnoreMode = CMOCK_ARG_NONE;\n"
|
lines << " cmock_call_instance->ExpectAnyArgsBool = (int)1;\n"
|
||||||
lines << "}\n\n"
|
lines << "}\n\n"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class CMockGeneratorUtils
|
|||||||
lines << " cmock_call_instance->LineNumber = cmock_line;\n"
|
lines << " cmock_call_instance->LineNumber = cmock_line;\n"
|
||||||
lines << " cmock_call_instance->CallOrder = ++GlobalExpectCount;\n" if (@ordered and global_ordering_supported)
|
lines << " cmock_call_instance->CallOrder = ++GlobalExpectCount;\n" if (@ordered and global_ordering_supported)
|
||||||
lines << " cmock_call_instance->ExceptionToThrow = CEXCEPTION_NONE;\n" if (@cexception)
|
lines << " cmock_call_instance->ExceptionToThrow = CEXCEPTION_NONE;\n" if (@cexception)
|
||||||
lines << " cmock_call_instance->IgnoreMode = CMOCK_ARG_ALL;\n" if (@expect_any)
|
lines << " cmock_call_instance->ExpectAnyArgsBool = (int)0;\n" if (@expect_any)
|
||||||
lines
|
lines
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -16,10 +16,6 @@
|
|||||||
|
|
||||||
#define CMOCK_GUTS_NONE (0)
|
#define CMOCK_GUTS_NONE (0)
|
||||||
|
|
||||||
#define CMOCK_ARG_MODE CMOCK_MEM_INDEX_TYPE
|
|
||||||
#define CMOCK_ARG_ALL 0
|
|
||||||
#define CMOCK_ARG_NONE ((CMOCK_MEM_INDEX_TYPE)(~0U))
|
|
||||||
|
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
// Memory API
|
// Memory API
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ describe CMockGeneratorPluginExpectAnyArgs, "Verify CMockGeneratorPluginExpectAn
|
|||||||
expected = ["void Slime_CMockExpectAnyArgs(UNITY_LINE_TYPE cmock_line)\n",
|
expected = ["void Slime_CMockExpectAnyArgs(UNITY_LINE_TYPE cmock_line)\n",
|
||||||
"{\n",
|
"{\n",
|
||||||
"mock_return_1",
|
"mock_return_1",
|
||||||
" cmock_call_instance->IgnoreMode = CMOCK_ARG_NONE;\n",
|
" cmock_call_instance->ExpectAnyArgsBool = (int)1;\n",
|
||||||
"}\n\n"
|
"}\n\n"
|
||||||
].join
|
].join
|
||||||
@utils.expect :code_add_base_expectation, "mock_return_1", ["Slime", true]
|
@utils.expect :code_add_base_expectation, "mock_return_1", ["Slime", true]
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ describe CMockGeneratorPluginExpect, "Verify CMockGeneratorPluginExpect Module w
|
|||||||
|
|
||||||
@utils.expect :code_verify_an_arg_expectation, "mocked_retval_1\n", [function, function[:args][0]]
|
@utils.expect :code_verify_an_arg_expectation, "mocked_retval_1\n", [function, function[:args][0]]
|
||||||
@utils.expect :code_verify_an_arg_expectation, "mocked_retval_2\n", [function, function[:args][1]]
|
@utils.expect :code_verify_an_arg_expectation, "mocked_retval_2\n", [function, function[:args][1]]
|
||||||
expected = " if (cmock_call_instance->IgnoreMode != CMOCK_ARG_NONE)\n" +
|
expected = " if (!cmock_call_instance->ExpectAnyArgsBool)\n" +
|
||||||
" {\n" +
|
" {\n" +
|
||||||
"mocked_retval_1\n" +
|
"mocked_retval_1\n" +
|
||||||
"mocked_retval_2\n" +
|
"mocked_retval_2\n" +
|
||||||
@@ -118,7 +118,7 @@ describe CMockGeneratorPluginExpect, "Verify CMockGeneratorPluginExpect Module w
|
|||||||
it "add mock function implementation for functions of style 'void func(int worm)' and strict ordering" do
|
it "add mock function implementation for functions of style 'void func(int worm)' and strict ordering" do
|
||||||
function = {:name => "Apple", :args => [{ :type => "int", :name => "worm" }], :return => test_return[:void]}
|
function = {:name => "Apple", :args => [{ :type => "int", :name => "worm" }], :return => test_return[:void]}
|
||||||
@utils.expect :code_verify_an_arg_expectation, "mocked_retval_0\n", [function, function[:args][0]]
|
@utils.expect :code_verify_an_arg_expectation, "mocked_retval_0\n", [function, function[:args][0]]
|
||||||
expected = " if (cmock_call_instance->IgnoreMode != CMOCK_ARG_NONE)\n" +
|
expected = " if (!cmock_call_instance->ExpectAnyArgsBool)\n" +
|
||||||
" {\n" +
|
" {\n" +
|
||||||
"mocked_retval_0\n" +
|
"mocked_retval_0\n" +
|
||||||
" }\n"
|
" }\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user