From 526668961afcda97594c32c63ac242cf36cd8583 Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Tue, 12 Sep 2017 17:24:35 -0400 Subject: [PATCH] Add an additional test for handling of pointer arguments. --- test/test_helper.rb | 13 +++++++------ test/unit/cmock_generator_utils_test.rb | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/test/test_helper.rb b/test/test_helper.rb index f369895..486196c 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -33,11 +33,12 @@ end def test_arg { - :int => {:type => "int", :name => 'MyInt', :ptr? => false, :const? => false}, - :int_ptr => {:type => "int*", :name => 'MyIntPtr', :ptr? => true, :const? => false}, - :mytype => {:type => "MY_TYPE", :name => 'MyMyType', :ptr? => false, :const? => true}, - :mytype_ptr => {:type => "MY_TYPE*", :name => 'MyMyTypePtr', :ptr? => true, :const? => false}, - :string => {:type => "const char*", :name => 'MyStr', :ptr? => false, :const? => true}, + :int => {:type => "int", :name => 'MyInt', :ptr? => false, :const? => false, :const_ptr? => false}, + :int_ptr => {:type => "int*", :name => 'MyIntPtr', :ptr? => true, :const? => false, :const_ptr? => false}, + :const_ptr => {:type => "int*", :name => 'MyConstPtr', :ptr? => true, :const? => false, :const_ptr? => true}, + :double_ptr => {:type => "int const**", :name => 'MyDoublePtr', :ptr? => true, :const? => true, :const_ptr? => false}, + :mytype => {:type => "MY_TYPE", :name => 'MyMyType', :ptr? => false, :const? => true, :const_ptr? => false}, + :mytype_ptr => {:type => "MY_TYPE*", :name => 'MyMyTypePtr', :ptr? => true, :const? => false, :const_ptr? => false}, + :string => {:type => "const char*", :name => 'MyStr', :ptr? => false, :const? => true, :const_ptr? => false}, } end - diff --git a/test/unit/cmock_generator_utils_test.rb b/test/unit/cmock_generator_utils_test.rb index f2066f8..bd59749 100644 --- a/test/unit/cmock_generator_utils_test.rb +++ b/test/unit/cmock_generator_utils_test.rb @@ -177,6 +177,23 @@ describe CMockGeneratorUtils, "Verify CMockGeneratorUtils Module" do assert_equal(expected, @cmock_generator_utils_complex.code_add_argument_loader(function)) end + it 'create an argument loader when the function has pointer arguments supporting arrays' do + function = { :name => "Melon", + :args_string => "stuff", + :args => [test_arg[:const_ptr], test_arg[:double_ptr]] + } + expected = "void CMockExpectParameters_Melon(CMOCK_Melon_CALL_INSTANCE* cmock_call_instance, int* const MyConstPtr, int MyConstPtr_Depth, int const** MyDoublePtr, int MyDoublePtr_Depth)\n{\n" + + " cmock_call_instance->Expected_MyConstPtr = MyConstPtr;\n" + + " cmock_call_instance->Expected_MyConstPtr_Depth = MyConstPtr_Depth;\n" + + " cmock_call_instance->IgnoreArg_MyConstPtr = 0;\n" + + " cmock_call_instance->ReturnThruPtr_MyConstPtr_Used = 0;\n" + + " cmock_call_instance->Expected_MyDoublePtr = MyDoublePtr;\n" + + " cmock_call_instance->Expected_MyDoublePtr_Depth = MyDoublePtr_Depth;\n" + + " cmock_call_instance->IgnoreArg_MyDoublePtr = 0;\n" + + "}\n\n" + assert_equal(expected, @cmock_generator_utils_complex.code_add_argument_loader(function)) + end + it "not call argument loader if there are no arguments to actually use for this function" do function = { :name => "Pineapple", :args_string => "void" }