mirror of
https://github.com/meekrosoft/fff
synced 2026-01-23 00:15:59 +01:00
Add support for const parameters in fakes (C only)
This commit is contained in:
@@ -20,7 +20,6 @@ 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
|
||||
{
|
||||
@@ -30,7 +29,6 @@ public:
|
||||
RESET_FAKE(voidfunc1);
|
||||
RESET_FAKE(voidfunc2);
|
||||
RESET_FAKE(longfunc0);
|
||||
RESET_FAKE(strlcpy3);
|
||||
FFF_RESET_HISTORY();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -6,4 +6,6 @@ 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);
|
||||
#ifndef __cplusplus
|
||||
DEFINE_FAKE_VALUE_FUNC3(int, strlcpy3, char* const, const char* const, const size_t);
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#define GLOBAL_FAKES_H_
|
||||
|
||||
#include "../fff.h"
|
||||
#include "string.h"
|
||||
|
||||
|
||||
//// Imaginary production code header file ///
|
||||
@@ -24,6 +25,8 @@ 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);
|
||||
#ifndef __cplusplus
|
||||
DECLARE_FAKE_VALUE_FUNC3(int, strlcpy3, char* const, const char* const, const size_t);
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* GLOBAL_FAKES_H_ */
|
||||
|
||||
@@ -63,11 +63,13 @@ 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)
|
||||
|
||||
Reference in New Issue
Block a user