| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
require 'minitest/autorun' |
| 9 |
|
| 10 |
def create_mocks(*mocks) |
| 11 |
mocks.each do |mock| |
| 12 |
eval "@#{mock} = Minitest::Mock.new" |
| 13 |
end |
| 14 |
end |
| 15 |
|
| 16 |
def create_stub(funcs) |
| 17 |
stub = Class.new |
| 18 |
blob = "class << stub\n" |
| 19 |
funcs.each_pair {|k,v| blob += "def #{k.to_s}(unused=nil)\n #{v.inspect}\nend\n" } |
| 20 |
blob += "end" |
| 21 |
eval blob |
| 22 |
stub |
| 23 |
end |
| 24 |
|
| 25 |
def test_return |
| 26 |
{ |
| 27 |
:int => {:type => "int", :name => 'cmock_to_return', :ptr? => false, :const? => false, :void? => false, :str => 'int cmock_to_return'}, |
| 28 |
:int_ptr => {:type => "int*", :name => 'cmock_to_return', :ptr? => true, :const? => false, :void? => false, :str => 'int* cmock_to_return'}, |
| 29 |
:void => {:type => "void", :name => 'cmock_to_return', :ptr? => false, :const? => false, :void? => true, :str => 'void cmock_to_return'}, |
| 30 |
:string => {:type => "const char*", :name => 'cmock_to_return', :ptr? => false, :const? => true, :void? => false, :str => 'const char* cmock_to_return'}, |
| 31 |
} |
| 32 |
end |
| 33 |
|
| 34 |
def test_arg |
| 35 |
{ |
| 36 |
:int => {:type => "int", :name => 'MyInt', :ptr? => false, :const? => false, :const_ptr? => false}, |
| 37 |
:int_ptr => {:type => "int*", :name => 'MyIntPtr', :ptr? => true, :const? => false, :const_ptr? => false}, |
| 38 |
:const_ptr => {:type => "int*", :name => 'MyConstPtr', :ptr? => true, :const? => false, :const_ptr? => true}, |
| 39 |
:double_ptr => {:type => "int const**", :name => 'MyDoublePtr', :ptr? => true, :const? => true, :const_ptr? => false}, |
| 40 |
:mytype => {:type => "MY_TYPE", :name => 'MyMyType', :ptr? => false, :const? => true, :const_ptr? => false}, |
| 41 |
:mytype_ptr => {:type => "MY_TYPE*", :name => 'MyMyTypePtr', :ptr? => true, :const? => false, :const_ptr? => false}, |
| 42 |
:string => {:type => "const char*", :name => 'MyStr', :ptr? => false, :const? => true, :const_ptr? => false}, |
| 43 |
} |
| 44 |
end |