mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-08-07 11:47:50 +00:00
* added tests for single bracket arrays as pointers (need to think of desired way to handle mulitdimensional arrays)
* rolled unity float support in as default. user can still overload with :treat_as git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@153 bf332499-1b4d-0410-844d-d2d48d5cc64c
This commit is contained in:
@@ -94,6 +94,8 @@ class CMockConfig
|
||||
'pCHAR' => 'STRING',
|
||||
'cstring' => 'STRING',
|
||||
'CSTRING' => 'STRING',
|
||||
'float' => 'FLOAT',
|
||||
'double' => 'FLOAT',
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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?
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
...
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user