mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-06-06 05:25:29 +00:00
Add an additional test for handling of pointer arguments.
This commit is contained in:
+7
-6
@@ -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
|
||||
|
||||
|
||||
@@ -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" }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user