1
0
mirror of https://github.com/meekrosoft/fff synced 2026-01-28 18:54:28 +01:00

Implement minimal support for varargs

This commit is contained in:
Micha Hoiting
2012-11-09 01:33:10 +01:00
parent cacd5f5459
commit ef62856fc3
7 changed files with 895 additions and 25 deletions

View File

@@ -27,6 +27,7 @@ FAKE_VOID_FUNC(voidfunc2, char, char);
FAKE_VALUE_FUNC(long, longfunc0);
FAKE_VALUE_FUNC(enum MYBOOL, enumfunc0);
FAKE_VALUE_FUNC(struct MyStruct, structfunc0);
FAKE_VOID_FUNC3_VARARG(voidfunc3var, char *, int, ...);
void setup()
@@ -36,6 +37,7 @@ void setup()
RESET_FAKE(longfunc0);
RESET_FAKE(enumfunc0);
RESET_FAKE(structfunc0);
RESET_FAKE(voidfunc3var);
FFF_RESET_HISTORY();
}
@@ -91,6 +93,8 @@ int main()
RUN_TEST(FFFTestSuite, can_register_custom_fake);
RUN_TEST(FFFTestSuite, when_value_custom_fake_called_THEN_it_returns_custom_return_value);
RUN_TEST(FFFTestSuite, use_vararg_fake_with_different_number_of_arguments);
printf("\n-------------\n");
printf("Complete\n");
printf("-------------\n\n");

View File

@@ -13,6 +13,7 @@ void setup()
RESET_FAKE(longfunc0);
RESET_FAKE(enumfunc0);
RESET_FAKE(structfunc0);
RESET_FAKE(voidfunc3var);
FFF_RESET_HISTORY();
}
@@ -61,6 +62,8 @@ int main()
RUN_TEST(FFFTestSuite, can_register_custom_fake);
RUN_TEST(FFFTestSuite, when_value_custom_fake_called_THEN_it_returns_custom_return_value);
RUN_TEST(FFFTestSuite, use_vararg_fake_with_different_number_of_arguments);
printf("\n-------------\n");
printf("Complete\n");
printf("-------------\n\n");

View File

@@ -6,3 +6,4 @@ DEFINE_FAKE_VOID_FUNC2(voidfunc2, char, char);
DEFINE_FAKE_VALUE_FUNC0(long, longfunc0);
DEFINE_FAKE_VALUE_FUNC0(enum MYBOOL, enumfunc0);
DEFINE_FAKE_VALUE_FUNC0(struct MyStruct, structfunc0);
DEFINE_FAKE_VOID_FUNC3_VARARG(voidfunc3var, const char *, int, ...);

View File

@@ -9,6 +9,7 @@
void voidfunc1(int);
void voidfunc2(char, char);
long longfunc0();
void voidfunc3var(const char *fmt, int argc, ...);
enum MYBOOL { FALSE = 899, TRUE };
struct MyStruct {
@@ -24,5 +25,6 @@ DECLARE_FAKE_VOID_FUNC2(voidfunc2, char, char);
DECLARE_FAKE_VALUE_FUNC0(long, longfunc0);
DECLARE_FAKE_VALUE_FUNC0(enum MYBOOL, enumfunc0);
DECLARE_FAKE_VALUE_FUNC0(struct MyStruct, structfunc0);
DECLARE_FAKE_VOID_FUNC3_VARARG(voidfunc3var, const char *, int, ...);
#endif /* GLOBAL_FAKES_H_ */

View File

@@ -229,3 +229,13 @@ TEST_F(FFFTestSuite, when_value_custom_fake_called_THEN_it_returns_custom_return
long retval = longfunc0();
ASSERT_EQ(MEANING_OF_LIFE, retval);
}
#ifndef __cplusplus
TEST_F(FFFTestSuite, use_vararg_fake_with_different_number_of_arguments)
{
voidfunc3var("0 parameters", 0);
voidfunc3var("1 parameter", 1, 10);
voidfunc3var("2 parameters", 2, 10, 20);
voidfunc3var("3 parameters", 3, 10, 20, 30);
}
#endif /* __cplusplus */