I am using Ceedling under Ubuntu 16.04 and Eclipse 4.7.2. So far everything works fine with the exception that I can't make _ExpectWithArray mocking functions to work.
For example I have the following function that I need to mock void TestFunc(uint8_t * data);
. In my test file I have the following call
uint8_t TEST_DATA[5] = { 0xFF, 0x00, 0xA0, 0x00, 0x09 };
TestFunc_ExpectWithArray(TEST_DATA, 5)
I also tried giving different values for param_depth
but with no luck.
When I try to run the test it always fails with
implicit declaration of function ‘TestFunc_ExpectWithArray’ [-Wimplicit-function-declaration]
In my experience that always happens when the function to mock is not called with the right parameters and CMock fails to generate a mocked version. What am I doing wrong? Can someone give an example how to use _ExpectWithArray properly?
Add this line - :array for plugins in .yml -file
:cmock:
:mock_prefix: mock_
:when_no_prototypes: :warn
:enforce_strict_ordering: TRUE
:plugins:
- :array
- :ignore
- :callback
example use _ExpectWithArray
/test/test_example.c
#include "unity.h"
#include "temp.h"
#include "mock_example.h"
void setUp(void)
{
}
void tearDown(void)
{
}
void test_sendMesFirst(void)
{
uint8_t message[] = {"Hello"}, answerMessage[] = {"Hello"}, answerNum = 4;
sendBytes_ExpectWithArray(answerMessage, sizeof(message), answerNum);
sendMes(message, sizeof(message), answerNum);
}
/src/example.h
#ifndef example_H
#define example_H
#include "stdint.h"
void sendBytes(uint8_t *bytes, int size);
#endif //
/src/temp.c
#include "temp.h"
#include "example.h"
void sendMes(uint8_t *mes, int size, int num)
{
if(num < size)
sendBytes(mes, num);
else
sendBytes(mes, size);
}
/src/temp.h
#ifndef temp_H
#define temp_H
#include "stdint.h"
void sendMes(uint8_t *mes, int size, int num);
#endif