I replaced the MOCK() macro and its function pointers with plain functions in my fork for better error messags from the compiler when the wrong arguments are given. See below for compiler error messages with MOCK() and plain functions.
MOCK()
poetry run make -C tests
make: Entering directory '/home/erik/workspace/narmock/tests'
cc -E dummy_functions.c main.c narwhal.c | narmock -g
cc -Wall -Wextra -Wconversion -std=c11 -g -Og -fsanitize=address -fno-omit-frame-pointer $(narmock -f) *.c -o run_tests
In file included from main.c:7:
main.c: In function ‘_narwhal_test_function_pipe_function’:
__mocks__.h:19:25: error: too many arguments to function ‘_narmock_get_mock_for_pipe((const void *)&pipe)->mock_once’
#define MOCK(function) (_narmock_get_mock_for_##function((void *)&function))
~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:95:5: note: in expansion of macro ‘MOCK’
MOCK(pipe)
^~~~
make: *** [Makefile:22: run_tests] Error 1
make: Leaving directory '/home/erik/workspace/narmock/tests'
Plain function
poetry run make -C tests
make: Entering directory '/home/erik/workspace/narmock/tests'
cc -E dummy_functions.c main.c narwhal.c | narmock -g
cc -Wall -Wextra -Wconversion -std=c11 -g -Og -fsanitize=address -fno-omit-frame-pointer $(narmock -f) *.c -o run_tests
main.c: In function ‘_narwhal_test_function_pipe_function_set_out’:
main.c:93:5: error: too many arguments to function ‘pipe_mock_once’
pipe_mock_once(42, 1);
^~~~~~~~~~~~~~
In file included from main.c:7:
__mocks__.h:123:6: note: declared here
void pipe_mock_once(int return_value);
^~~~~~~~~~~~~~
make: *** [Makefile:22: run_tests] Error 1
make: Leaving directory '/home/erik/workspace/narmock/tests'
Hello!
I replaced the
MOCK()
macro and its function pointers with plain functions in my fork for better error messags from the compiler when the wrong arguments are given. See below for compiler error messages withMOCK()
and plain functions.MOCK()
Plain function