mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-06-05 21:15:20 +00:00
Add unit test for inline_function_patterns (failing now)
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
class CMockHeaderParser
|
||||
|
||||
attr_accessor :funcs, :c_attr_noconst, :c_attributes, :treat_as_void, :treat_externs, :treat_inlines
|
||||
attr_accessor :funcs, :c_attr_noconst, :c_attributes, :treat_as_void, :treat_externs, :treat_inlines, :inline_function_patterns
|
||||
|
||||
def initialize(cfg)
|
||||
@funcs = []
|
||||
@@ -25,6 +25,7 @@ class CMockHeaderParser
|
||||
@verbosity = cfg.verbosity
|
||||
@treat_externs = cfg.treat_externs
|
||||
@treat_inlines = cfg.treat_inlines
|
||||
@inline_function_patterns = cfg.inline_function_patterns
|
||||
@c_strippables += ['extern'] if (@treat_externs == :include) #we'll need to remove the attribute if we're allowing externs
|
||||
@c_strippables += ['inline'] if (@treat_inlines == :include) #we'll need to remove the attribute if we're allowing inlines
|
||||
end
|
||||
|
||||
@@ -55,6 +55,7 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
||||
@config.expect :subdir, nil
|
||||
@config.expect :fail_on_unexpected_calls, true
|
||||
@config.expect :treat_inlines, :exclude
|
||||
@config.expect :inline_function_patterns, []
|
||||
@cmock_generator = CMockGenerator.new(@config, @file_writer, @utils, @plugins)
|
||||
@cmock_generator.module_name = @module_name
|
||||
@cmock_generator.mock_name = "Mock#{@module_name}"
|
||||
@@ -74,6 +75,7 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
||||
@config.expect :subdir, nil
|
||||
@config.expect :fail_on_unexpected_calls, true
|
||||
@config.expect :treat_inlines, :exclude
|
||||
@config.expect :inline_function_patterns, []
|
||||
@cmock_generator_strict = CMockGenerator.new(@config, @file_writer, @utils, @plugins)
|
||||
@cmock_generator_strict.module_name = @module_name
|
||||
@cmock_generator_strict.mock_name = "Mock#{@module_name}"
|
||||
@@ -136,6 +138,7 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
||||
@config.expect :subdir, nil
|
||||
@config.expect :fail_on_unexpected_calls, true
|
||||
@config.expect :treat_inlines, :exclude
|
||||
@config.expect :inline_function_patterns, []
|
||||
@cmock_generator2 = CMockGenerator.new(@config, @file_writer, @utils, @plugins)
|
||||
@cmock_generator2.module_name = "Pout-Pout Fish"
|
||||
@cmock_generator2.mock_name = "MockPout-Pout Fish"
|
||||
|
||||
@@ -1998,4 +1998,29 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
assert_equal(0, @parser.count_number_of_pairs_of_braces_in_function(bad_source_2))
|
||||
end
|
||||
|
||||
it "Transform inline functions takes user provided patterns into account" do
|
||||
source =
|
||||
"static inline int staticinlinefunc(struct my_struct *s)\n" + # 'normal' inline pattern
|
||||
"{\n" +
|
||||
" return s->a;\n" +
|
||||
"}\n" +
|
||||
"static __inline__ int dummy_func_2(int a, char b, float c) {\n" + # First user pattern
|
||||
" c += 3.14;\n" +
|
||||
" b -= 32;\n" +
|
||||
" return a + (int)(b) + (int)c;\n" +
|
||||
"}\n" +
|
||||
"static __inline__ __attribute__ ((always_inline)) uint16_t attributealwaysinlinefuncname(void) {\n" + # Second user pattern
|
||||
" return (uint16_t)(42);\n" +
|
||||
"}\n" +
|
||||
"\n"
|
||||
|
||||
expected =
|
||||
"int staticinlinefunc(struct my_struct *s);\n" +
|
||||
"int dummy_func_2(int a, char b, float c);\n" +
|
||||
"uint16_t attributealwaysinlinefuncname(void);\n" +
|
||||
"\n"
|
||||
|
||||
assert_equal(expected, @parser.transform_inline_functions(source))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user