mirror of
https://github.com/ThrowTheSwitch/CMock
synced 2025-06-08 05:09:34 -04:00
Trying to reproduce bug pull request
This commit is contained in:
parent
bd5fbc30eb
commit
f291ed217c
@ -2083,4 +2083,53 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|||||||
assert_equal(expected, @parser.parse("module", source)[:functions])
|
assert_equal(expected, @parser.parse("module", source)[:functions])
|
||||||
end
|
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"
|
||||||
|
|
||||||
|
@parser.treat_inlines = :include
|
||||||
|
@parser.inline_function_patterns = ['static __inline__ __attribute__ \(\(always_inline\)\)', 'static __inline__', 'static inline']
|
||||||
|
assert_equal(expected, @parser.transform_inline_functions(source))
|
||||||
|
end
|
||||||
|
|
||||||
|
it "Transform inline functions takes user provided patterns into account" do
|
||||||
|
source =
|
||||||
|
"static __inline__ __attribute__ ((always_inline)) uint16_t _somefunc (uint32_t a)\n" +
|
||||||
|
"{\n" +
|
||||||
|
" return _someotherfunc (a);\n" +
|
||||||
|
"}\n" +
|
||||||
|
"static __inline__ uint16_t _somefunc_0 (uint32_t a)\n" +
|
||||||
|
"{\n" +
|
||||||
|
" return (uint16_t) a;\n" +
|
||||||
|
"}\n" +
|
||||||
|
"\n"
|
||||||
|
|
||||||
|
expected =
|
||||||
|
"uint16_t _somefunc (uint32_t a);\n" +
|
||||||
|
"uint16_t _somefunc_0 (uint32_t a);\n" +
|
||||||
|
"\n"
|
||||||
|
|
||||||
|
@parser.treat_inlines = :include
|
||||||
|
@parser.inline_function_patterns = ['static __inline__ __attribute__ \(\(always_inline\)\)', 'static __inline__']
|
||||||
|
assert_equal(expected, @parser.transform_inline_functions(source))
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user