mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-08-03 01:37:51 +00:00
Merge pull request #140 from jlindgren90/master
Remove dead code (unity_msg is not used since 647876644b). (Thanks @jlindgren90 )
This commit is contained in:
@@ -68,7 +68,7 @@ class CMockGeneratorPluginExpect
|
||||
function[:args].each do |arg|
|
||||
lines << @utils.code_verify_an_arg_expectation(function, arg)
|
||||
end
|
||||
lines << "\n }\n"
|
||||
lines << " }\n"
|
||||
lines
|
||||
end
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ class CMockGeneratorPluginExpectAnyArgs
|
||||
end
|
||||
|
||||
def mock_function_declarations(function)
|
||||
|
||||
if (function[:return][:void?])
|
||||
return "#define #{function[:name]}_ExpectAnyArgs() #{function[:name]}_CMockExpectAnyArgs(__LINE__)\n" +
|
||||
"void #{function[:name]}_CMockExpectAnyArgs(UNITY_LINE_TYPE cmock_line);\n"
|
||||
@@ -38,19 +37,6 @@ class CMockGeneratorPluginExpectAnyArgs
|
||||
end
|
||||
end
|
||||
|
||||
# def mock_implementation(function)
|
||||
# lines = " if (cmock_call_instance->IgnoreMode == CMOCK_ARG_NONE)\n {\n"
|
||||
# if (function[:return][:void?])
|
||||
# lines << " return;\n }\n"
|
||||
# else
|
||||
# retval = function[:return].merge( { :name => "cmock_call_instance->ReturnVal"} )
|
||||
# lines << " " + @utils.code_assign_argument_quickly("Mock.#{function[:name]}_FinalReturn", retval) unless (retval[:void?])
|
||||
# return_type = function[:return][:const?] ? "(const #{function[:return][:type]})" : ((function[:return][:type] =~ /cmock/) ? "(#{function[:return][:type]})" : '')
|
||||
# lines << " return #{return_type}cmock_call_instance->ReturnVal;\n }\n"
|
||||
# end
|
||||
# lines
|
||||
# end
|
||||
|
||||
def mock_interfaces(function)
|
||||
lines = ""
|
||||
if (function[:return][:void?])
|
||||
|
||||
@@ -112,12 +112,11 @@ class CMockGeneratorUtils
|
||||
else
|
||||
(@helpers.nil? or @helpers[:unity_helper].nil?) ? ["UNITY_TEST_ASSERT_EQUAL",''] : @helpers[:unity_helper].get_helper(c_type)
|
||||
end
|
||||
unity_msg = "Function '#{function[:name]}' called with unexpected value for argument '#{arg_name}'."
|
||||
return c_type, arg_name, expected, ignore, unity_func[0], unity_func[1], unity_msg
|
||||
return c_type, arg_name, expected, ignore, unity_func[0], unity_func[1]
|
||||
end
|
||||
|
||||
def code_verify_an_arg_expectation_with_no_arrays(function, arg)
|
||||
c_type, arg_name, expected, ignore, unity_func, pre, unity_msg = lookup_expect_type(function, arg)
|
||||
c_type, arg_name, expected, ignore, unity_func, pre = lookup_expect_type(function, arg)
|
||||
lines = ""
|
||||
lines << " if (!#{ignore})\n" if @ignore_arg
|
||||
lines << " {\n"
|
||||
@@ -152,7 +151,7 @@ class CMockGeneratorUtils
|
||||
end
|
||||
|
||||
def code_verify_an_arg_expectation_with_normal_arrays(function, arg)
|
||||
c_type, arg_name, expected, ignore, unity_func, pre, unity_msg = lookup_expect_type(function, arg)
|
||||
c_type, arg_name, expected, ignore, unity_func, pre = lookup_expect_type(function, arg)
|
||||
depth_name = (arg[:ptr?]) ? "cmock_call_instance->Expected_#{arg_name}_Depth" : 1
|
||||
lines = ""
|
||||
lines << " if (!#{ignore})\n" if @ignore_arg
|
||||
@@ -188,7 +187,7 @@ class CMockGeneratorUtils
|
||||
end
|
||||
|
||||
def code_verify_an_arg_expectation_with_smart_arrays(function, arg)
|
||||
c_type, arg_name, expected, ignore, unity_func, pre, unity_msg = lookup_expect_type(function, arg)
|
||||
c_type, arg_name, expected, ignore, unity_func, pre = lookup_expect_type(function, arg)
|
||||
depth_name = (arg[:ptr?]) ? "cmock_call_instance->Expected_#{arg_name}_Depth" : 1
|
||||
lines = ""
|
||||
lines << " if (!#{ignore})\n" if @ignore_arg
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
# CMock Project - Automatic Mock Generation for C
|
||||
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
|
||||
# [Released under MIT License. Please refer to license.txt for details]
|
||||
# ==========================================
|
||||
# ==========================================
|
||||
|
||||
class CMockPluginManager
|
||||
|
||||
attr_accessor :plugins
|
||||
|
||||
|
||||
def initialize(config, utils)
|
||||
@plugins = []
|
||||
plugins_to_load = [:expect, config.plugins].flatten.uniq.compact
|
||||
@@ -25,7 +25,7 @@ class CMockPluginManager
|
||||
end
|
||||
@plugins.sort! {|a,b| a.priority <=> b.priority }
|
||||
end
|
||||
|
||||
|
||||
def run(method, args=nil)
|
||||
if args.nil?
|
||||
return @plugins.collect{ |plugin| plugin.send(method) if plugin.respond_to?(method) }.flatten.join
|
||||
@@ -33,7 +33,7 @@ class CMockPluginManager
|
||||
return @plugins.collect{ |plugin| plugin.send(method, args) if plugin.respond_to?(method) }.flatten.join
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def camelize(lower_case_and_underscored_word)
|
||||
lower_case_and_underscored_word.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
|
||||
end
|
||||
|
||||
@@ -96,11 +96,12 @@ describe CMockGeneratorPluginExpect, "Verify CMockGeneratorPluginExpect Module w
|
||||
it "add mock function implementation for functions of style 'int func(int veal, unsigned int sushi)'" do
|
||||
function = {:name => "Cherry", :args => [ { :type => "int", :name => "veal" }, { :type => "unsigned int", :name => "sushi" } ], :return => test_return[:int]}
|
||||
|
||||
@utils.expect :code_verify_an_arg_expectation, " mocked_retval_1", [function, function[:args][0]]
|
||||
@utils.expect :code_verify_an_arg_expectation, " mocked_retval_2", [function, function[:args][1]]
|
||||
@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]]
|
||||
expected = " if (cmock_call_instance->IgnoreMode != CMOCK_ARG_NONE)\n" +
|
||||
" {\n" +
|
||||
" mocked_retval_1 mocked_retval_2\n" +
|
||||
"mocked_retval_1\n" +
|
||||
"mocked_retval_2\n" +
|
||||
" }\n"
|
||||
returned = @cmock_generator_plugin_expect.mock_implementation(function)
|
||||
assert_equal(expected, returned)
|
||||
@@ -116,7 +117,7 @@ describe CMockGeneratorPluginExpect, "Verify CMockGeneratorPluginExpect Module w
|
||||
|
||||
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]}
|
||||
@utils.expect :code_verify_an_arg_expectation, "mocked_retval_0", [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" +
|
||||
" {\n" +
|
||||
"mocked_retval_0\n" +
|
||||
@@ -128,12 +129,12 @@ describe CMockGeneratorPluginExpect, "Verify CMockGeneratorPluginExpect Module w
|
||||
|
||||
it "add mock interfaces for functions of style 'void func(void)'" do
|
||||
function = {:name => "Pear", :args => [], :args_string => "void", :return => test_return[:void]}
|
||||
@utils.expect :code_add_base_expectation, "mock_retval_0 ", ["Pear"]
|
||||
@utils.expect :code_call_argument_loader, "mock_retval_1 ", [function]
|
||||
@utils.expect :code_add_base_expectation, "mock_retval_0\n", ["Pear"]
|
||||
@utils.expect :code_call_argument_loader, "mock_retval_1\n", [function]
|
||||
expected = ["void Pear_CMockExpect(UNITY_LINE_TYPE cmock_line)\n",
|
||||
"{\n",
|
||||
"mock_retval_0 ",
|
||||
"mock_retval_1 ",
|
||||
"mock_retval_0\n",
|
||||
"mock_retval_1\n",
|
||||
" UNITY_CLR_DETAILS();\n",
|
||||
"}\n\n"
|
||||
].join
|
||||
@@ -143,14 +144,14 @@ describe CMockGeneratorPluginExpect, "Verify CMockGeneratorPluginExpect Module w
|
||||
|
||||
it "add mock interfaces for functions of style 'int func(void)'" do
|
||||
function = {:name => "Orange", :args => [], :args_string => "void", :return => test_return[:int]}
|
||||
@utils.expect :code_add_base_expectation, "mock_retval_0 ", ["Orange"]
|
||||
@utils.expect :code_call_argument_loader, "mock_retval_1 ", [function]
|
||||
@utils.expect :code_assign_argument_quickly, "mock_retval_2", ["cmock_call_instance->ReturnVal", function[:return]]
|
||||
@utils.expect :code_add_base_expectation, "mock_retval_0\n", ["Orange"]
|
||||
@utils.expect :code_call_argument_loader, "mock_retval_1\n", [function]
|
||||
@utils.expect :code_assign_argument_quickly, "mock_retval_2\n", ["cmock_call_instance->ReturnVal", function[:return]]
|
||||
expected = ["void Orange_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, int cmock_to_return)\n",
|
||||
"{\n",
|
||||
"mock_retval_0 ",
|
||||
"mock_retval_1 ",
|
||||
"mock_retval_2",
|
||||
"mock_retval_0\n",
|
||||
"mock_retval_1\n",
|
||||
"mock_retval_2\n",
|
||||
" UNITY_CLR_DETAILS();\n",
|
||||
"}\n\n"
|
||||
].join
|
||||
@@ -160,14 +161,14 @@ describe CMockGeneratorPluginExpect, "Verify CMockGeneratorPluginExpect Module w
|
||||
|
||||
it "add mock interfaces for functions of style 'int func(char* pescado)'" do
|
||||
function = {:name => "Lemon", :args => [{ :type => "char*", :name => "pescado"}], :args_string => "char* pescado", :return => test_return[:int]}
|
||||
@utils.expect :code_add_base_expectation, "mock_retval_0 ", ["Lemon"]
|
||||
@utils.expect :code_call_argument_loader, "mock_retval_1 ", [function]
|
||||
@utils.expect :code_assign_argument_quickly, "mock_retval_2", ["cmock_call_instance->ReturnVal", function[:return]]
|
||||
@utils.expect :code_add_base_expectation, "mock_retval_0\n", ["Lemon"]
|
||||
@utils.expect :code_call_argument_loader, "mock_retval_1\n", [function]
|
||||
@utils.expect :code_assign_argument_quickly, "mock_retval_2\n", ["cmock_call_instance->ReturnVal", function[:return]]
|
||||
expected = ["void Lemon_CMockExpectAndReturn(UNITY_LINE_TYPE cmock_line, char* pescado, int cmock_to_return)\n",
|
||||
"{\n",
|
||||
"mock_retval_0 ",
|
||||
"mock_retval_1 ",
|
||||
"mock_retval_2",
|
||||
"mock_retval_0\n",
|
||||
"mock_retval_1\n",
|
||||
"mock_retval_2\n",
|
||||
" UNITY_CLR_DETAILS();\n",
|
||||
"}\n\n"
|
||||
].join
|
||||
@@ -177,12 +178,12 @@ describe CMockGeneratorPluginExpect, "Verify CMockGeneratorPluginExpect Module w
|
||||
|
||||
it "add mock interfaces for functions when using ordering" do
|
||||
function = {:name => "Pear", :args => [], :args_string => "void", :return => test_return[:void]}
|
||||
@utils.expect :code_add_base_expectation, "mock_retval_0 ", ["Pear"]
|
||||
@utils.expect :code_call_argument_loader, "mock_retval_1 ", [function]
|
||||
@utils.expect :code_add_base_expectation, "mock_retval_0\n", ["Pear"]
|
||||
@utils.expect :code_call_argument_loader, "mock_retval_1\n", [function]
|
||||
expected = ["void Pear_CMockExpect(UNITY_LINE_TYPE cmock_line)\n",
|
||||
"{\n",
|
||||
"mock_retval_0 ",
|
||||
"mock_retval_1 ",
|
||||
"mock_retval_0\n",
|
||||
"mock_retval_1\n",
|
||||
" UNITY_CLR_DETAILS();\n",
|
||||
"}\n\n"
|
||||
].join
|
||||
|
||||
Reference in New Issue
Block a user