1
0
mirror of https://github.com/meekrosoft/fff synced 2026-01-23 00:15:59 +01:00

Merged varargs support with const support

This commit is contained in:
Mike Long
2013-06-23 22:22:34 +08:00
7 changed files with 24 additions and 4 deletions

View File

@@ -28,6 +28,7 @@ FAKE_VALUE_FUNC(long, longfunc0);
FAKE_VALUE_FUNC(enum MYBOOL, enumfunc0);
FAKE_VALUE_FUNC(struct MyStruct, structfunc0);
FAKE_VOID_FUNC3_VARARG(voidfunc3var, char *, int, ...);
FAKE_VALUE_FUNC(int, strlcpy3, char* const, const char* const, const size_t);
void setup()
@@ -38,6 +39,7 @@ void setup()
RESET_FAKE(enumfunc0);
RESET_FAKE(structfunc0);
RESET_FAKE(voidfunc3var);
RESET_FAKE(strlcpy3);
FFF_RESET_HISTORY();
}
@@ -70,6 +72,7 @@ int main()
RUN_TEST(FFFTestSuite, when_void_func_with_2_char_args_called_then_last_args_captured);
RUN_TEST(FFFTestSuite, when_void_func_with_2_char_args_called_twice_then_last_args_captured);
RUN_TEST(FFFTestSuite, when_void_func_with_2_char_args_called_and_reset_then_captured_arg_is_zero);
RUN_TEST(FFFTestSuite, when_fake_func_called_then_const_arguments_captured);
RUN_TEST(FFFTestSuite, when_fake_func_created_default_history_is_fifty_calls);
RUN_TEST(FFFTestSuite, when_fake_func_called_then_arguments_captured_in_history);

View File

@@ -14,6 +14,7 @@ void setup()
RESET_FAKE(enumfunc0);
RESET_FAKE(structfunc0);
RESET_FAKE(voidfunc3var);
RESET_FAKE(strlcpy3);
FFF_RESET_HISTORY();
}
@@ -40,6 +41,7 @@ int main()
RUN_TEST(FFFTestSuite, when_void_func_with_2_char_args_called_then_last_args_captured);
RUN_TEST(FFFTestSuite, when_void_func_with_2_char_args_called_twice_then_last_args_captured);
RUN_TEST(FFFTestSuite, when_void_func_with_2_char_args_called_and_reset_then_captured_arg_is_zero);
RUN_TEST(FFFTestSuite, when_fake_func_called_then_const_arguments_captured);
RUN_TEST(FFFTestSuite, when_fake_func_created_default_history_is_fifty_calls);
RUN_TEST(FFFTestSuite, when_fake_func_called_then_arguments_captured_in_history);

View File

@@ -7,3 +7,6 @@ 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, ...);
#ifndef __cplusplus
DEFINE_FAKE_VALUE_FUNC3(int, strlcpy3, char* const, const char* const, const size_t);
#endif /* __cplusplus */

View File

@@ -3,6 +3,7 @@
#define GLOBAL_FAKES_H_
#include "../fff.h"
#include "string.h"
//// Imaginary production code header file ///
@@ -26,5 +27,8 @@ 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, ...);
#ifndef __cplusplus
DECLARE_FAKE_VALUE_FUNC3(int, strlcpy3, char* const, const char* const, const size_t);
#endif /* __cplusplus */
#endif /* GLOBAL_FAKES_H_ */

View File

@@ -63,6 +63,14 @@ TEST_F(FFFTestSuite, when_void_func_with_2_char_args_called_and_reset_then_captu
ASSERT_EQ(voidfunc2_fake.arg1_val, 0);
}
#ifndef __cplusplus
TEST_F(FFFTestSuite, when_fake_func_called_then_const_arguments_captured)
{
char dst[80];
strlcpy3(dst, __FUNCTION__, sizeof(__FUNCTION__));
}
#endif /* __cplusplus */
// Argument history
TEST_F(FFFTestSuite, when_fake_func_created_default_history_is_fifty_calls)
{