-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for fakes with const parameters #3
Comments
Agreed, this feature would significantly increase the utility of fff for me. |
Have been using @michahoiting 's fork with no issues for my (strongly) const parameterized code. Maybe it'd be time considering pulling that request ? |
I'd love to include this feature but I haven't received a pull request so far. Let me take a look at how to get his changes in here. |
Hi folks, |
Using a fake function that has a const parameter leads to compiler errors.
For instance using a fake for the function ‘strlcpy’ see below.
FAKE_VALUE_FUNC(int, strlcpy3, char* const, const char* const, const size_t);
TEST_F(FFFTestSuite, when_fake_func_called_then_const_arguments_captured) { char dst[80]; strlcpy3(dst, __FUNCTION__, sizeof(__FUNCTION__)); }
Building file: fff_test_cpp.cpp
Invoking: GCC C++ Compiler
g++ -I../ -O0 -g3 -Wall -c -o "../build/fff_test_cpp.o" "fff_test_cpp.cpp"
fff_test_cpp.cpp:23: error: structure
strlcpy3_fake' with uninitialized const members fff_test_cpp.cpp: In function
int strlcpy3(char_, const char_, size_t)':fff_test_cpp.cpp:23: error: assignment of read-only data-member
strlcpy3_Fake::arg0_val' fff_test_cpp.cpp:23: error: assignment of read-only data-member
strlcpy3_Fake::arg1_val'fff_test_cpp.cpp:23: error: assignment of read-only data-member `strlcpy3_Fake::arg2_val'
fff_test_cpp.cpp:23: error: assignment of read-only location
fff_test_cpp.cpp:23: error: assignment of read-only location
fff_test_cpp.cpp:23: error: assignment of read-only location
gmake[1]: *** [../build/fff_test_cpp.o] Error 1
The macros
SAVE_ARG
andSAVE_ARG_HISTORY
in fff.h will need to be changed.The text was updated successfully, but these errors were encountered: