diff --git a/lib/cmock_config.rb b/lib/cmock_config.rb index 1c68e91..471d7f1 100644 --- a/lib/cmock_config.rb +++ b/lib/cmock_config.rb @@ -94,6 +94,8 @@ class CMockConfig 'pCHAR' => 'STRING', 'cstring' => 'STRING', 'CSTRING' => 'STRING', + 'float' => 'FLOAT', + 'double' => 'FLOAT', } end end diff --git a/lib/cmock_header_parser.rb b/lib/cmock_header_parser.rb index 48b7d34..236e959 100644 --- a/lib/cmock_header_parser.rb +++ b/lib/cmock_header_parser.rb @@ -126,9 +126,9 @@ class CMockHeaderParser return 'void' else c=0 - arg_list.gsub!(/(\w)\s*\[[\s\d]*\]/,'*\1') # magically turn brackets into asterisks - arg_list.gsub!(/\s+\*/,'*') # remove space to place asterisks with type (where they belong) - arg_list.gsub!(/\*(\w)/,'* \1') # pull asterisks away from arg to place asterisks with type (where they belong) + arg_list.gsub!(/(\w+)(?:\s*\[[\s\d]*\])+/,'*\1') # magically turn brackets into asterisks + arg_list.gsub!(/\s+\*/,'*') # remove space to place asterisks with type (where they belong) + arg_list.gsub!(/\*(\w)/,'* \1') # pull asterisks away from arg to place asterisks with type (where they belong) #scan argument list for function pointers and replace them with custom types arg_list.gsub!(/([\w\s]+)\(*\(\s*\*([\w\s]+)\)\s*\(([\w\s,]+)\)\)*/) do |m| @@ -160,7 +160,7 @@ class CMockHeaderParser def parse_declaration(declaration) decl = {} - + regex_match = @declaration_parse_matcher.match(declaration) raise "Failed parsing function declaration: '#{declaration}'" if regex_match.nil? diff --git a/test/system/test_interactions/expect_and_return_treat_as.yml b/test/system/test_interactions/expect_and_return_treat_as.yml index 7108b2e..e48c960 100644 --- a/test/system/test_interactions/expect_and_return_treat_as.yml +++ b/test/system/test_interactions/expect_and_return_treat_as.yml @@ -17,11 +17,13 @@ MY_INT foo(MY_HEX a); MY_INT bar(MY_HEX b); MY_STRING foo_char_strings(MY_STRING a, MY_STRING b); + float float_adder(float a, float b); :source: :header: | MY_INT function_a(MY_INT a, MY_INT b); MY_STRING function_b(MY_STRING a, MY_STRING b); + float function_c(float a, float b); :code: | MY_INT function_a(MY_INT a, MY_INT b) @@ -34,6 +36,11 @@ return foo_char_strings(a, b); } + float function_c(float a, float b) + { + return float_adder(b, a); + } + :tests: :common: | void setUp(void) {} @@ -77,4 +84,22 @@ TEST_ASSERT_EQUAL_STRING("boing!", function_b((MY_STRING)"jello", (MY_STRING)"jiggle")); } + - :pass: TRUE + :should: 'handle floating point numbers with Unity support: pass' + :code: | + test() + { + float_adder_ExpectAndReturn(1.2345, 6.7890, 8.0235); + TEST_ASSERT_EQUAL_FLOAT(8.0235, function_c(6.7890, 1.2345)); + } + + - :pass: FALSE + :should: 'handle floating point numbers with Unity support: fail' + :code: | + test() + { + float_adder_ExpectAndReturn(1.2345, 6.7892, 8.0235); + TEST_ASSERT_EQUAL_FLOAT(8.0235, function_c(6.7890, 1.2345)); + } + ... diff --git a/test/system/test_interactions/parsing_challenges.yml b/test/system/test_interactions/parsing_challenges.yml index 07b55dd..16682ee 100644 --- a/test/system/test_interactions/parsing_challenges.yml +++ b/test/system/test_interactions/parsing_challenges.yml @@ -58,6 +58,9 @@ TypeDefInt uses_typedef_like_names(TypeDefInt typedefvar); + void oh_brackets1(int fudge[5]); + void oh_brackets2(int caramel[]); + :source: :header: | U16* exercise_return_pointers(int a); @@ -66,7 +69,7 @@ char exercise_multiline_declarations(int a, unsigned int b); void exercise_double_pointers(unsigned int a); int exercise_many_descriptors(int a); - TypeDefInt exercise_typedef_like_names(TypeDefInt a); + TypeDefInt exercise_typedef_like_names(TypeDefInt a); :code: | int A, B, C;