Skip to content

Commit

Permalink
Merge pull request #148 from jlindgren90/master
Browse files Browse the repository at this point in the history
Fix warnings when running "rake test" -- Thanks @jlindgren90 !
  • Loading branch information
mvandervoord authored Nov 1, 2017
2 parents 2a2f19d + 6d1c0f9 commit 2b4f9b4
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 21 deletions.
1 change: 0 additions & 1 deletion lib/cmock_generator_plugin_cexception.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def mock_implementation(function)

def mock_interfaces(function)
arg_insert = (function[:args_string] == "void") ? "" : "#{function[:args_string]}, "
call_string = function[:args].map{|m| m[:name]}.join(', ')
[ "void #{function[:name]}_CMockExpectAndThrow(UNITY_LINE_TYPE cmock_line, #{arg_insert}CEXCEPTION_T cmock_to_throw)\n{\n",
@utils.code_add_base_expectation(function[:name]),
@utils.code_call_argument_loader(function),
Expand Down
6 changes: 2 additions & 4 deletions lib/cmock_generator_plugin_ignore_arg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@ def mock_interfaces(function)
lines = []
func_name = function[:name]
function[:args].each do |arg|
arg_name = arg[:name]
arg_type = arg[:type]
lines << "void #{function[:name]}_CMockIgnoreArg_#{arg[:name]}(UNITY_LINE_TYPE cmock_line)\n"
lines << "void #{func_name}_CMockIgnoreArg_#{arg[:name]}(UNITY_LINE_TYPE cmock_line)\n"
lines << "{\n"
lines << " CMOCK_#{func_name}_CALL_INSTANCE* cmock_call_instance = " +
"(CMOCK_#{func_name}_CALL_INSTANCE*)CMock_Guts_GetAddressFor(CMock_Guts_MemEndOfChain(Mock.#{func_name}_CallInstance));\n"
lines << " UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, CMockStringIgnPreExp);\n"
lines << " cmock_call_instance->IgnoreArg_#{arg_name} = 1;\n"
lines << " cmock_call_instance->IgnoreArg_#{arg[:name]} = 1;\n"
lines << "}\n\n"
end
lines
Expand Down
2 changes: 0 additions & 2 deletions lib/cmock_generator_plugin_return_thru_ptr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def mock_interfaces(function)
func_name = function[:name]
function[:args].each do |arg|
arg_name = arg[:name]
arg_type = arg[:type]
if (@utils.ptr_or_str?(arg[:type]) and not arg[:const?])
lines << "void #{func_name}_CMockReturnMemThruPtr_#{arg_name}(UNITY_LINE_TYPE cmock_line, #{arg[:type]} #{arg_name}, int cmock_size)\n"
lines << "{\n"
Expand All @@ -60,7 +59,6 @@ def mock_implementation(function)
lines = []
function[:args].each do |arg|
arg_name = arg[:name]
arg_type = arg[:type]
if (@utils.ptr_or_str?(arg[:type]) and not arg[:const?])
lines << " if (cmock_call_instance->ReturnThruPtr_#{arg_name}_Used)\n"
lines << " {\n"
Expand Down
6 changes: 4 additions & 2 deletions test/unit/cmock_config_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
it "use default settings when no parameters are specified" do
config = CMockConfig.new
assert_equal(CMockConfig::CMockDefaultOptions[:mock_path], config.mock_path)
assert_equal(CMockConfig::CMockDefaultOptions[:includes], config.includes)
assert_nil(CMockConfig::CMockDefaultOptions[:includes])
assert_nil(config.includes)
assert_equal(CMockConfig::CMockDefaultOptions[:attributes], config.attributes)
assert_equal(CMockConfig::CMockDefaultOptions[:plugins], config.plugins)
assert_equal(CMockConfig::CMockDefaultOptions[:treat_externs], config.treat_externs)
Expand All @@ -35,7 +36,8 @@
test_plugins = [:soda, :pizza]
config = CMockConfig.new("#{File.expand_path(File.dirname(__FILE__))}/cmock_config_test.yml")
assert_equal(CMockConfig::CMockDefaultOptions[:mock_path], config.mock_path)
assert_equal(CMockConfig::CMockDefaultOptions[:includes], config.includes)
assert_nil(CMockConfig::CMockDefaultOptions[:includes])
assert_nil(config.includes)
assert_equal(test_plugins, config.plugins)
assert_equal(:include, config.treat_externs)
end
Expand Down
4 changes: 0 additions & 4 deletions test/unit/cmock_generator_main_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ def mock_implementation(name, args)
@config.expect :weak, ""
orig_filename = "PoutPoutFish.h"
define_name = "MOCKPOUTPOUTFISH_H"
mock_name = "MockPoutPoutFish"
output = []
expected = [
"/* AUTOGENERATED FILE. DO NOT EDIT. */\n",
Expand Down Expand Up @@ -143,7 +142,6 @@ def mock_implementation(name, args)
@config.expect :weak, ""
orig_filename = "Pout-Pout Fish.h"
define_name = "MOCKPOUT_POUT_FISH_H"
mock_name = "MockPout_Pout_Fish"
output = []
expected = [
"/* AUTOGENERATED FILE. DO NOT EDIT. */\n",
Expand Down Expand Up @@ -182,7 +180,6 @@ def mock_implementation(name, args)
@config.expect :weak, ""
orig_filename = "PoutPoutFish.h"
define_name = "MOCKPOUTPOUTFISH_H"
mock_name = "MockPoutPoutFish"
output = []
expected = [
"/* AUTOGENERATED FILE. DO NOT EDIT. */\n",
Expand Down Expand Up @@ -220,7 +217,6 @@ def mock_implementation(name, args)
@config.expect :weak, ""
orig_filename = "PoutPoutFish.h"
define_name = "MOCKPOUTPOUTFISH_H"
mock_name = "MockPoutPoutFish"
output = []
expected = [
"/* AUTOGENERATED FILE. DO NOT EDIT. */\n",
Expand Down
4 changes: 2 additions & 2 deletions test/unit/cmock_generator_plugin_array_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def code_add_base_expectation(func)
end

it "have set up internal priority" do
assert_equal(nil, @cmock_generator_plugin_array.unity_helper)
assert_equal(8, @cmock_generator_plugin_array.priority)
assert_nil(@cmock_generator_plugin_array.unity_helper)
assert_equal(8, @cmock_generator_plugin_array.priority)
end

it "not include any additional include files" do
Expand Down
4 changes: 2 additions & 2 deletions test/unit/cmock_generator_plugin_expect_a_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
end

it "have set up internal priority on init" do
assert_equal(nil, @cmock_generator_plugin_expect.unity_helper)
assert_equal(5, @cmock_generator_plugin_expect.priority)
assert_nil(@cmock_generator_plugin_expect.unity_helper)
assert_equal(5, @cmock_generator_plugin_expect.priority)
end

it "not include any additional include files" do
Expand Down
4 changes: 2 additions & 2 deletions test/unit/cmock_generator_plugin_expect_b_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
end

it "have set up internal priority on init" do
assert_equal(nil, @cmock_generator_plugin_expect.unity_helper)
assert_equal(5, @cmock_generator_plugin_expect.priority)
assert_nil(@cmock_generator_plugin_expect.unity_helper)
assert_equal(5, @cmock_generator_plugin_expect.priority)
end

it "not include any additional include files" do
Expand Down
6 changes: 4 additions & 2 deletions test/unit/cmock_generator_plugin_return_thru_ptr_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,13 @@ def complex_func_expect
expected =
" if (cmock_call_instance->ReturnThruPtr_tofu_Used)\n" +
" {\n" +
" memcpy(tofu, cmock_call_instance->ReturnThruPtr_tofu_Val,\n" +
" UNITY_TEST_ASSERT_NOT_NULL(tofu, cmock_line, CMockStringPtrIsNULL);\n" +
" memcpy((void*)tofu, (void*)cmock_call_instance->ReturnThruPtr_tofu_Val,\n" +
" cmock_call_instance->ReturnThruPtr_tofu_Size);\n" +
" }\n" +
" }\n"

returned = @cmock_generator_plugin_return_thru_ptr.mock_implementation(@complex_func).join("")
assert_equal(expected, returned)
end

end

0 comments on commit 2b4f9b4

Please sign in to comment.