mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-08-10 21:27:52 +00:00
added more tests
git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@119 bf332499-1b4d-0410-844d-d2d48d5cc64c
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
|
||||
typedef unsigned short U16;
|
||||
|
||||
typedef struct _POINT_T
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
} POINT_T;
|
||||
|
||||
// typedef edge case
|
||||
typedef void VOID_TYPE_CRAZINESS;
|
||||
|
||||
struct _DUMMY_T { unsigned int a; float b; };
|
||||
|
||||
|
||||
/* fun parsing & mock generation cases */
|
||||
|
||||
void var_args1(int a, ...);
|
||||
void var_args2(int a, int b, ...);
|
||||
|
||||
VOID_TYPE_CRAZINESS void_type_craziness1(int, float, double, char, short, long, long int, long long, void*);
|
||||
int void_type_craziness2( VOID_TYPE_CRAZINESS );
|
||||
|
||||
void crazy_whitespace ( int lint, double shot , short stack ) ;
|
||||
|
||||
char
|
||||
crazy_multiline
|
||||
(
|
||||
int a,
|
||||
unsigned int b);
|
||||
|
||||
U16 *ptr_return1(int a);
|
||||
U16* ptr_return2(int a);
|
||||
U16 * ptr_return3(int a);
|
||||
|
||||
unsigned int** ptr_ptr_return1(unsigned int** a);
|
||||
unsigned int* *ptr_ptr_return2(unsigned int* *a);
|
||||
unsigned int **ptr_ptr_return3(unsigned int **a);
|
||||
unsigned int ** ptr_ptr_return4(unsigned int ** a);
|
||||
|
||||
extern unsigned long int incredible_descriptors(register const unsigned short a);
|
||||
|
||||
void const_variants1( const char* a, int const, unsigned short const * c );
|
||||
|
||||
// crazy const magic fairy dust
|
||||
void const_variants2(
|
||||
struct _DUMMY_T const * const param1,
|
||||
const unsigned long int const * const param2,
|
||||
const struct _DUMMY_T const * param3 );
|
||||
@@ -45,6 +45,7 @@ class CMockFunctionPrototypeParserTest < Test::Unit::TestCase
|
||||
assert_nil(@parser.parse("void foo-bar(void)")) # illegal function name
|
||||
assert_nil(@parser.parse("void foo_bar")) # no param list
|
||||
assert_nil(@parser.parse("foo_bar(void)")) # no return type
|
||||
assert_nil(@parser.parse("void ( (* const pointers[])(void) )")) # looks like function prototype but is actually array of function pointers
|
||||
assert_nil(@parser.parse("void foo_bar(int (func)(int a, char b), void (*)(void))")) # no asterisk in function pointer definition
|
||||
assert_nil(@parser.parse("unsigned int * (*(double foo, THING bar))(unsigned int a)")) # no function name
|
||||
assert_nil(@parser.parse("unsigned int * (* func(double foo, THING bar))")) # no parameter list for function pointer return
|
||||
@@ -198,15 +199,16 @@ class CMockFunctionPrototypeParserTest < Test::Unit::TestCase
|
||||
|
||||
|
||||
should "normalize pointer notation" do
|
||||
parsed = @parser.parse("void * foo(unsigned int * * * a, char * *b, int* c, int (* func)(void))")
|
||||
parsed = @parser.parse("void * foo(unsigned int * * * a, char * *b, int* c, int (* func)(void), CUSTOM_TYPE const* e)")
|
||||
|
||||
assert_equal('void*', parsed.get_return_type)
|
||||
assert_equal('unsigned int*** a, char** b, int* c, int (*func)(void)', parsed.get_argument_list)
|
||||
assert_equal('unsigned int*** a, char** b, int* c, int (*func)(void), CUSTOM_TYPE const * e', parsed.get_argument_list)
|
||||
assert_equal([
|
||||
{:type => 'unsigned int***', :name => 'a'},
|
||||
{:type => 'char**', :name => 'b'},
|
||||
{:type => 'int*', :name => 'c'},
|
||||
{:type => 'FUNC_PTR_FOO_PARAM_4_T', :name => 'func'}],
|
||||
{:type => 'FUNC_PTR_FOO_PARAM_4_T', :name => 'func'},
|
||||
{:type => 'CUSTOM_TYPE*', :name => 'e'}],
|
||||
parsed.get_arguments)
|
||||
assert_nil(parsed.get_var_arg)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user