mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-08-12 14:17:53 +00:00
Update so only config is shared. Everything else about the current job is passed.
This commit is contained in:
@@ -78,20 +78,26 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
||||
@config.expect :treat_inlines, :exclude
|
||||
@config.expect :exclude_setjmp_h, false
|
||||
@cmock_generator_strict = CMockGenerator.new(@config, @file_writer, @utils, @plugins)
|
||||
@cmock_generator_strict.module_name = @module_name
|
||||
@cmock_generator_strict.module_ext = '.h'
|
||||
@cmock_generator_strict.mock_name = "Mock#{@module_name}"
|
||||
@cmock_generator_strict.clean_mock_name = "Mock#{@module_name}"
|
||||
|
||||
@test_project = {
|
||||
:module_name => @module_name,
|
||||
:module_ext => '.h',
|
||||
:mock_name => "Mock#{@module_name}",
|
||||
:clean_name => "Mock#{@module_name}",
|
||||
:folder => nil,
|
||||
:parsed_stuff => {},
|
||||
:skeleton => false
|
||||
}
|
||||
end
|
||||
|
||||
after do
|
||||
end
|
||||
|
||||
def helper_create_header_top_with_opt_incldues_form_config_and_plugin(ext)
|
||||
def helper_create_header_top_with_opt_includes_form_config_and_plugin(ext)
|
||||
@config.expect :mock_prefix, "Mock"
|
||||
@config.expect :mock_suffix, ""
|
||||
@config.expect :weak, ""
|
||||
@cmock_generator.module_ext = ext
|
||||
|
||||
orig_filename = "PoutPoutFish#{ext}"
|
||||
define_name = "MOCKPOUTPOUTFISH_H"
|
||||
output = []
|
||||
@@ -122,41 +128,26 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
||||
@config.expect :orig_header_include_fmt, "#include \"%s\""
|
||||
@plugins.expect :run, "#include \"PluginRequiredHeader.h\"\n", [:include_files]
|
||||
|
||||
@cmock_generator.create_mock_header_header(output, "Mock#{orig_filename}")
|
||||
# Update the extention for this test
|
||||
test_project = @test_project.clone
|
||||
test_project[:module_ext] = ext
|
||||
|
||||
@cmock_generator.create_mock_header_header(output, "Mock#{orig_filename}", test_project)
|
||||
|
||||
assert_equal(expected, output)
|
||||
end
|
||||
|
||||
it "create the top of a header file with optional include files from config and include file from plugin" do
|
||||
['.h','.hh','.hpp'].each do |ext|
|
||||
helper_create_header_top_with_opt_incldues_form_config_and_plugin(ext)
|
||||
helper_create_header_top_with_opt_includes_form_config_and_plugin(ext)
|
||||
end
|
||||
end
|
||||
|
||||
it "handle dashes and spaces in the module name" do
|
||||
#no strict handling
|
||||
@config.expect :mock_prefix, "Mock"
|
||||
@config.expect :mock_suffix, ""
|
||||
@config.expect :weak, ""
|
||||
@config.expect :enforce_strict_ordering, nil
|
||||
@config.expect :framework, :unity
|
||||
@config.expect :includes, ["ConfigRequiredHeader1.h","ConfigRequiredHeader2.h"]
|
||||
@config.expect :includes_h_post_orig_header, nil
|
||||
@config.expect :includes_c_pre_header, nil
|
||||
@config.expect :includes_c_post_header, nil
|
||||
@config.expect :subdir, nil
|
||||
@config.expect :fail_on_unexpected_calls, true
|
||||
@config.expect :treat_inlines, :exclude
|
||||
@config.expect :exclude_setjmp_h, false
|
||||
@cmock_generator2 = CMockGenerator.new(@config, @file_writer, @utils, @plugins)
|
||||
@cmock_generator2.module_name = "Pout-Pout Fish"
|
||||
@cmock_generator2.module_ext = '.h'
|
||||
@cmock_generator2.mock_name = "MockPout-Pout Fish"
|
||||
@cmock_generator2.clean_mock_name = "MockPout_Pout_Fish"
|
||||
|
||||
@config.expect :mock_prefix, "Mock"
|
||||
@config.expect :mock_suffix, ""
|
||||
@config.expect :weak, ""
|
||||
|
||||
orig_filename = "Pout-Pout Fish.h"
|
||||
define_name = "MOCKPOUT_POUT_FISH_H"
|
||||
output = []
|
||||
@@ -187,7 +178,13 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
||||
@config.expect :orig_header_include_fmt, "#include \"%s\""
|
||||
@plugins.expect :run, "#include \"PluginRequiredHeader.h\"\n", [:include_files]
|
||||
|
||||
@cmock_generator2.create_mock_header_header(output, "MockPout-Pout Fish.h")
|
||||
# Create a project with some added challenges
|
||||
test_project = @test_project.clone
|
||||
test_project[:module_name] = "Pout-Pout Fish"
|
||||
test_project[:mock_name] = "MockPout-Pout Fish"
|
||||
test_project[:clean_name] = "MockPout_Pout_Fish"
|
||||
|
||||
@cmock_generator.create_mock_header_header(output, "MockPout-Pout Fish.h", test_project)
|
||||
|
||||
assert_equal(expected, output)
|
||||
end
|
||||
@@ -225,7 +222,7 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
||||
@config.expect :orig_header_include_fmt, "#include \"%s\""
|
||||
@plugins.expect :run, '', [:include_files]
|
||||
|
||||
@cmock_generator.create_mock_header_header(output, "MockPoutPoutFish.h")
|
||||
@cmock_generator.create_mock_header_header(output, "MockPoutPoutFish.h", @test_project)
|
||||
|
||||
assert_equal(expected, output)
|
||||
end
|
||||
@@ -264,7 +261,7 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
||||
@config.expect :orig_header_include_fmt, "#include \"%s\""
|
||||
@plugins.expect :run, "#include \"PluginRequiredHeader.h\"\n", [:include_files]
|
||||
|
||||
@cmock_generator.create_mock_header_header(output, "MockPoutPoutFish.h")
|
||||
@cmock_generator.create_mock_header_header(output, "MockPoutPoutFish.h", @test_project)
|
||||
|
||||
assert_equal(expected, output)
|
||||
end
|
||||
@@ -282,7 +279,8 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
||||
"\n\n"
|
||||
]
|
||||
|
||||
@cmock_generator.create_typedefs(output, typedefs)
|
||||
@test_project[:parsed_stuff][:typedefs] = typedefs
|
||||
@cmock_generator.create_typedefs(output, @test_project)
|
||||
|
||||
assert_equal(expected, output.flatten)
|
||||
end
|
||||
@@ -296,7 +294,7 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
||||
"void #{mock_name}_Verify(void);\n\n"
|
||||
]
|
||||
|
||||
@cmock_generator.create_mock_header_service_call_declarations(output)
|
||||
@cmock_generator.create_mock_header_service_call_declarations(output, @test_project)
|
||||
|
||||
assert_equal(expected, output)
|
||||
end
|
||||
@@ -340,7 +338,8 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
||||
"\n"
|
||||
]
|
||||
|
||||
@cmock_generator.create_source_header_section(output, "MockPoutPoutFish.c", functions)
|
||||
@test_project[:parsed_stuff][:functions] = functions
|
||||
@cmock_generator.create_source_header_section(output, "MockPoutPoutFish.c", @test_project)
|
||||
|
||||
assert_equal(expected, output)
|
||||
end
|
||||
@@ -354,7 +353,8 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
||||
"} Mock;\n\n"
|
||||
].join
|
||||
|
||||
@cmock_generator.create_instance_structure(output, functions)
|
||||
@test_project[:parsed_stuff][:functions] = functions
|
||||
@cmock_generator.create_instance_structure(output, @test_project)
|
||||
|
||||
assert_equal(expected, output.join)
|
||||
end
|
||||
@@ -384,7 +384,8 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
||||
@plugins.expect :run, [" d1"], [:instance_structure, functions[0]]
|
||||
@plugins.expect :run, [" e1"," e2"," e3"], [:instance_structure, functions[1]]
|
||||
|
||||
@cmock_generator.create_instance_structure(output, functions)
|
||||
@test_project[:parsed_stuff][:functions] = functions
|
||||
@cmock_generator.create_instance_structure(output, @test_project)
|
||||
|
||||
assert_equal(expected, output.join)
|
||||
end
|
||||
@@ -416,7 +417,8 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
||||
output = []
|
||||
expected = "void MockPoutPoutFish_Verify(void)\n{\n}\n\n"
|
||||
|
||||
@cmock_generator.create_mock_verify_function(output, functions)
|
||||
@test_project[:parsed_stuff][:functions] = functions
|
||||
@cmock_generator.create_mock_verify_function(output, @test_project)
|
||||
|
||||
assert_equal(expected, output.join)
|
||||
end
|
||||
@@ -441,7 +443,8 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
||||
@plugins.expect :run, [" Uno_Second"," Dos_Second"], [:mock_verify, functions[1]]
|
||||
|
||||
@cmock_generator.ordered = true
|
||||
@cmock_generator.create_mock_verify_function(output, functions)
|
||||
@test_project[:parsed_stuff][:functions] = functions
|
||||
@cmock_generator.create_mock_verify_function(output, @test_project)
|
||||
|
||||
assert_equal(expected, output.flatten)
|
||||
end
|
||||
@@ -453,7 +456,7 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
||||
"}\n\n"
|
||||
]
|
||||
|
||||
@cmock_generator.create_mock_init_function(output)
|
||||
@cmock_generator.create_mock_init_function(output, @test_project)
|
||||
|
||||
assert_equal(expected.join, output.join)
|
||||
end
|
||||
@@ -467,7 +470,8 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
||||
"}\n\n"
|
||||
]
|
||||
|
||||
@cmock_generator.create_mock_destroy_function(output, functions)
|
||||
@test_project[:parsed_stuff][:functions] = functions
|
||||
@cmock_generator.create_mock_destroy_function(output, @test_project)
|
||||
|
||||
assert_equal(expected.join, output.join)
|
||||
end
|
||||
@@ -488,7 +492,8 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
||||
@plugins.expect :run, [], [:mock_destroy, functions[0]]
|
||||
@plugins.expect :run, [" uno"], [:mock_destroy, functions[1]]
|
||||
|
||||
@cmock_generator_strict.create_mock_destroy_function(output, functions)
|
||||
@test_project[:parsed_stuff][:functions] = functions
|
||||
@cmock_generator_strict.create_mock_destroy_function(output, @test_project)
|
||||
|
||||
assert_equal(expected.join, output.join)
|
||||
end
|
||||
|
||||
@@ -13,7 +13,6 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
|
||||
before do
|
||||
create_mocks :config
|
||||
@test_name = 'test_file.h'
|
||||
@config.expect :strippables, ["STRIPPABLE"]
|
||||
@config.expect :attributes, ['__ramfunc', 'funky_attrib', 'SQLITE_API']
|
||||
@config.expect :c_calling_conventions, ['__stdcall']
|
||||
@@ -29,13 +28,20 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
@config.expect :array_size_name, 'size|len'
|
||||
|
||||
@parser = CMockHeaderParser.new(@config)
|
||||
|
||||
@test_project = {
|
||||
:module_name => 'test_file.h',
|
||||
:typedefs => [],
|
||||
:functions => [],
|
||||
:normalized_source => nil
|
||||
}
|
||||
end
|
||||
|
||||
after do
|
||||
end
|
||||
|
||||
it "create and initialize variables to defaults appropriately" do
|
||||
assert_equal([], @parser.funcs)
|
||||
assert_equal(nil, @parser.funcs)
|
||||
assert_equal(['const', '__ramfunc', 'funky_attrib', 'SQLITE_API'], @parser.c_attributes)
|
||||
assert_equal(['void','MY_FUNKY_VOID'], @parser.treat_as_void)
|
||||
end
|
||||
@@ -52,7 +58,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
"who"
|
||||
]
|
||||
|
||||
assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
|
||||
assert_equal(expected, @parser.import_source(source, @test_project).map!{|s|s.strip})
|
||||
end
|
||||
|
||||
it "remove block comments" do
|
||||
@@ -85,7 +91,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
"shown_because_line_above_ended_comment_this_time"
|
||||
]
|
||||
|
||||
assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
|
||||
assert_equal(expected, @parser.import_source(source, @test_project).map!{|s|s.strip})
|
||||
end
|
||||
|
||||
it "remove strippables from the beginning or end of function declarations" do
|
||||
@@ -105,7 +111,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
"void universal_handler()"
|
||||
]
|
||||
|
||||
assert_equal(expected, @parser.import_source(source))
|
||||
assert_equal(expected, @parser.import_source(source, @test_project))
|
||||
end
|
||||
|
||||
it "remove gcc's function __attribute__'s" do
|
||||
@@ -125,7 +131,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
"void universal_handler()"
|
||||
]
|
||||
|
||||
assert_equal(expected, @parser.import_source(source))
|
||||
assert_equal(expected, @parser.import_source(source, @test_project))
|
||||
end
|
||||
|
||||
it "remove preprocessor directives" do
|
||||
@@ -136,7 +142,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
|
||||
expected = []
|
||||
|
||||
assert_equal(expected, @parser.import_source(source))
|
||||
assert_equal(expected, @parser.import_source(source, @test_project))
|
||||
end
|
||||
|
||||
|
||||
@@ -151,7 +157,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
|
||||
expected = ["foo"]
|
||||
|
||||
assert_equal(expected, @parser.import_source(source))
|
||||
assert_equal(expected, @parser.import_source(source, @test_project))
|
||||
end
|
||||
|
||||
|
||||
@@ -165,7 +171,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
"hoo hah when"
|
||||
]
|
||||
|
||||
assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
|
||||
assert_equal(expected, @parser.import_source(source, @test_project).map!{|s|s.strip})
|
||||
end
|
||||
|
||||
|
||||
@@ -178,7 +184,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
|
||||
expected = ["but I'm here"]
|
||||
|
||||
assert_equal(expected, @parser.import_source(source))
|
||||
assert_equal(expected, @parser.import_source(source, @test_project))
|
||||
end
|
||||
|
||||
|
||||
@@ -212,7 +218,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
"this should remain!"
|
||||
]
|
||||
|
||||
assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
|
||||
assert_equal(expected, @parser.import_source(source, @test_project).map!{|s|s.strip})
|
||||
end
|
||||
|
||||
|
||||
@@ -230,7 +236,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
"} Thinger;\n" +
|
||||
"or me!!\n"
|
||||
|
||||
assert_equal(["don't delete me!! or me!!"], @parser.import_source(source).map!{|s|s.strip})
|
||||
assert_equal(["don't delete me!! or me!!"], @parser.import_source(source, @test_project).map!{|s|s.strip})
|
||||
end
|
||||
|
||||
|
||||
@@ -248,7 +254,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
"} Whatever;\n" +
|
||||
"me too!!\n"
|
||||
|
||||
assert_equal(["I want to live!! me too!!"], @parser.import_source(source).map!{|s|s.strip})
|
||||
assert_equal(["I want to live!! me too!!"], @parser.import_source(source, @test_project).map!{|s|s.strip})
|
||||
end
|
||||
|
||||
|
||||
@@ -271,7 +277,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
"I want to live!!\n"
|
||||
|
||||
assert_equal(["void foo(void)", "struct THINGER foo(void)", "I want to live!!"],
|
||||
@parser.import_source(source).map!{|s|s.strip})
|
||||
@parser.import_source(source, @test_project).map!{|s|s.strip})
|
||||
end
|
||||
|
||||
it "remove externed and inline functions" do
|
||||
@@ -290,7 +296,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
"uint32 funcinline(unsigned int)"
|
||||
]
|
||||
|
||||
assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
|
||||
assert_equal(expected, @parser.import_source(source, @test_project).map!{|s|s.strip})
|
||||
end
|
||||
|
||||
it "remove function definitions but keep function declarations" do
|
||||
@@ -312,7 +318,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
"uint32 func_with_decl_b", #okay. it's not going to be interpretted as another function
|
||||
]
|
||||
|
||||
assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
|
||||
assert_equal(expected, @parser.import_source(source, @test_project).map!{|s|s.strip})
|
||||
end
|
||||
|
||||
it "remove function definitions with nested braces but keep function declarations" do
|
||||
@@ -354,7 +360,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
"uint32 func_with_decl_c", #okay. it's not going to be interpretted as another function
|
||||
]
|
||||
|
||||
assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
|
||||
assert_equal(expected, @parser.import_source(source, @test_project).map!{|s|s.strip})
|
||||
end
|
||||
|
||||
it "remove a fully defined inline function" do
|
||||
@@ -371,7 +377,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
@parser.parse("module", source)
|
||||
end
|
||||
|
||||
assert_equal([], @parser.funcs)
|
||||
assert_equal(nil, @parser.funcs)
|
||||
|
||||
# verify exception message
|
||||
begin
|
||||
@@ -395,7 +401,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
@parser.parse("module", source)
|
||||
end
|
||||
|
||||
assert_equal([], @parser.funcs)
|
||||
assert_equal(nil, @parser.funcs)
|
||||
|
||||
# verify exception message
|
||||
begin
|
||||
@@ -423,7 +429,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
@parser.parse("module", source)
|
||||
end
|
||||
|
||||
assert_equal([], @parser.funcs)
|
||||
assert_equal(nil, @parser.funcs)
|
||||
|
||||
# verify exception message
|
||||
begin
|
||||
@@ -452,7 +458,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
]
|
||||
|
||||
@parser.treat_externs = :include
|
||||
assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
|
||||
assert_equal(expected, @parser.import_source(source, @test_project).map!{|s|s.strip})
|
||||
end
|
||||
|
||||
it "leave inline functions if inline to be included" do
|
||||
@@ -478,7 +484,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
]
|
||||
|
||||
@parser.treat_inlines = :include
|
||||
assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
|
||||
assert_equal(expected, @parser.import_source(source, @test_project).map!{|s|s.strip})
|
||||
end
|
||||
|
||||
it "leave inline and extern functions if inline and extern to be included" do
|
||||
@@ -507,7 +513,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
|
||||
@parser.treat_externs = :include
|
||||
@parser.treat_inlines = :include
|
||||
assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
|
||||
assert_equal(expected, @parser.import_source(source, @test_project).map!{|s|s.strip})
|
||||
end
|
||||
|
||||
it "Include inline functions that contain user defined inline function formats" do
|
||||
@@ -538,7 +544,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
|
||||
@parser.treat_inlines = :include
|
||||
@parser.inline_function_patterns = ['static __inline__ __attribute__ \(\(always_inline\)\)', 'static __inline__', '\binline\b']
|
||||
assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
|
||||
assert_equal(expected, @parser.import_source(source, @test_project).map!{|s|s.strip})
|
||||
end
|
||||
|
||||
it "remove defines" do
|
||||
@@ -554,7 +560,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
"void hello(void)",
|
||||
]
|
||||
|
||||
assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
|
||||
assert_equal(expected, @parser.import_source(source, @test_project).map!{|s|s.strip})
|
||||
end
|
||||
|
||||
|
||||
@@ -567,7 +573,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
"const int TheMatrix(int Trinity, unsigned int * Neo)",
|
||||
]
|
||||
|
||||
assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
|
||||
assert_equal(expected, @parser.import_source(source, @test_project).map!{|s|s.strip})
|
||||
end
|
||||
|
||||
|
||||
@@ -593,7 +599,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
:args=>[{:type=>"int", :name=>"a", :ptr? => false, :const? => false, :const_ptr? => false}],
|
||||
:args_string=>"int a",
|
||||
:args_call=>"a"}
|
||||
assert_equal(expected, @parser.parse_declaration(source))
|
||||
assert_equal(expected, @parser.parse_declaration(@test_project, source))
|
||||
end
|
||||
|
||||
it "handle odd case of typedef'd void as arg" do
|
||||
@@ -616,7 +622,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
:args=>[],
|
||||
:args_string=>"void",
|
||||
:args_call=>"" }
|
||||
assert_equal(expected, @parser.parse_declaration(source))
|
||||
assert_equal(expected, @parser.parse_declaration(@test_project, source))
|
||||
end
|
||||
|
||||
it "handle odd case of typedef'd void as arg pointer" do
|
||||
@@ -639,7 +645,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
:args=>[{:type=>"MY_FUNKY_VOID*", :name=>"bluh", :ptr? => true, :const? => false, :const_ptr? => false}],
|
||||
:args_string=>"MY_FUNKY_VOID* bluh",
|
||||
:args_call=>"bluh" }
|
||||
assert_equal(expected, @parser.parse_declaration(source))
|
||||
assert_equal(expected, @parser.parse_declaration(@test_project, source))
|
||||
end
|
||||
|
||||
|
||||
@@ -652,7 +658,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
"void Foo(int a, float b, char c, char* e)"
|
||||
]
|
||||
|
||||
assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
|
||||
assert_equal(expected, @parser.import_source(source, @test_project).map!{|s|s.strip})
|
||||
end
|
||||
|
||||
|
||||
@@ -664,7 +670,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
@parser.parse("module", source)
|
||||
end
|
||||
|
||||
assert_equal([], @parser.funcs)
|
||||
assert_equal(nil, @parser.funcs)
|
||||
|
||||
# verify exception message
|
||||
begin
|
||||
@@ -693,7 +699,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
@parser.parse("module", source)
|
||||
end
|
||||
|
||||
assert_equal([], @parser.funcs)
|
||||
assert_equal(nil, @parser.funcs)
|
||||
|
||||
# verify exception message
|
||||
begin
|
||||
@@ -743,7 +749,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
],
|
||||
:args_string=>"int a, unsigned int b",
|
||||
:args_call=>"a, b" }
|
||||
assert_equal(expected, @parser.parse_declaration(source))
|
||||
assert_equal(expected, @parser.parse_declaration(@test_project, source))
|
||||
end
|
||||
|
||||
it "extract and return function declarations with no retval" do
|
||||
@@ -770,7 +776,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
],
|
||||
:args_string=>"uint la, int de, bool da",
|
||||
:args_call=>"la, de, da" }
|
||||
assert_equal(expected, @parser.parse_declaration(source))
|
||||
assert_equal(expected, @parser.parse_declaration(@test_project, source))
|
||||
end
|
||||
|
||||
it "extract and return function declarations with implied voids" do
|
||||
@@ -794,7 +800,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
:args=>[ ],
|
||||
:args_string=>"void",
|
||||
:args_call=>"" }
|
||||
assert_equal(expected, @parser.parse_declaration(source))
|
||||
assert_equal(expected, @parser.parse_declaration(@test_project, source))
|
||||
end
|
||||
|
||||
it "extract modifiers properly" do
|
||||
@@ -820,7 +826,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
],
|
||||
:args_string=>"int Trinity, unsigned int* Neo",
|
||||
:args_call=>"Trinity, Neo" }
|
||||
assert_equal(expected, @parser.parse_declaration(source))
|
||||
assert_equal(expected, @parser.parse_declaration(@test_project, source))
|
||||
end
|
||||
|
||||
it "extract c calling conventions properly" do
|
||||
@@ -847,7 +853,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
],
|
||||
:args_string=>"int Trinity, unsigned int* Neo",
|
||||
:args_call=>"Trinity, Neo" }
|
||||
assert_equal(expected, @parser.parse_declaration(source))
|
||||
assert_equal(expected, @parser.parse_declaration(@test_project, source))
|
||||
end
|
||||
|
||||
it "extract and return function declarations inside namespace and class" do
|
||||
@@ -872,7 +878,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
],
|
||||
:args_string=>"int a, unsigned int b",
|
||||
:args_call=>"a, b" }
|
||||
assert_equal(expected, @parser.parse_declaration(source, ["ns1", "ns2"], "Bar"))
|
||||
assert_equal(expected, @parser.parse_declaration(@test_project, source, ["ns1", "ns2"], "Bar"))
|
||||
end
|
||||
|
||||
it "fully parse multiple prototypes" do
|
||||
@@ -2387,8 +2393,8 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
"} }"
|
||||
]
|
||||
|
||||
assert_equal(expected, @parser.import_source(source, cpp=true))
|
||||
refute_equal(expected, @parser.import_source(source))
|
||||
assert_equal(expected, @parser.import_source(source, @test_project, cpp=true))
|
||||
refute_equal(expected, @parser.import_source(source, @test_project))
|
||||
end
|
||||
|
||||
# only so parse_functions does not raise an error
|
||||
|
||||
Reference in New Issue
Block a user