forked from 3rd-party/fff
Add test with const parameters
This commit is contained in:
@@ -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_VALUE_FUNC(int, strlcpy3, char* const, const char* const, const size_t);
|
||||
|
||||
|
||||
void setup()
|
||||
@@ -36,6 +37,7 @@ void setup()
|
||||
RESET_FAKE(longfunc0);
|
||||
RESET_FAKE(enumfunc0);
|
||||
RESET_FAKE(structfunc0);
|
||||
RESET_FAKE(strlcpy3);
|
||||
FFF_RESET_HISTORY();
|
||||
}
|
||||
|
||||
@@ -68,6 +70,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);
|
||||
|
||||
@@ -20,6 +20,7 @@ DEFINE_FFF_GLOBALS
|
||||
FAKE_VOID_FUNC(voidfunc1, int);
|
||||
FAKE_VOID_FUNC(voidfunc2, char, char);
|
||||
FAKE_VALUE_FUNC(long, longfunc0);
|
||||
FAKE_VALUE_FUNC(int, strlcpy3, char* const, const char* const, const size_t);
|
||||
|
||||
class FFFTestSuite: public testing::Test
|
||||
{
|
||||
@@ -29,6 +30,7 @@ public:
|
||||
RESET_FAKE(voidfunc1);
|
||||
RESET_FAKE(voidfunc2);
|
||||
RESET_FAKE(longfunc0);
|
||||
RESET_FAKE(strlcpy3);
|
||||
FFF_RESET_HISTORY();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -13,6 +13,7 @@ void setup()
|
||||
RESET_FAKE(longfunc0);
|
||||
RESET_FAKE(enumfunc0);
|
||||
RESET_FAKE(structfunc0);
|
||||
RESET_FAKE(strlcpy3);
|
||||
|
||||
FFF_RESET_HISTORY();
|
||||
}
|
||||
@@ -39,6 +40,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);
|
||||
|
||||
@@ -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);
|
||||
DECLARE_FAKE_VALUE_FUNC3(int, strlcpy3, char* const, const char* const, const size_t);
|
||||
|
||||
@@ -24,5 +24,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_VALUE_FUNC3(int, strlcpy3, char* const, const char* const, const size_t);
|
||||
|
||||
#endif /* GLOBAL_FAKES_H_ */
|
||||
|
||||
@@ -63,6 +63,12 @@ TEST_F(FFFTestSuite, when_void_func_with_2_char_args_called_and_reset_then_captu
|
||||
ASSERT_EQ(voidfunc2_fake.arg1_val, 0);
|
||||
}
|
||||
|
||||
TEST_F(FFFTestSuite, when_fake_func_called_then_const_arguments_captured)
|
||||
{
|
||||
char dst[80];
|
||||
strlcpy3(dst, __FUNCTION__, sizeof(__FUNCTION__));
|
||||
}
|
||||
|
||||
// Argument history
|
||||
TEST_F(FFFTestSuite, when_fake_func_created_default_history_is_fifty_calls)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user