Closed michahoiting closed 11 years ago
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 ? Many thanks for that microframework, has been incredibly helpful !
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, I have merged Micha's const parameter support. Many thanks to Micha for sharing! Cheers, Mike
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-memberstrlcpy3_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 1SAVE_ARG
andSAVE_ARG_HISTORY
in fff.h will need to be changed.