0

I have a mock for a c function

int Eeprom_WriteBuffer(uint32_t address, uint8_t *data, uint16_t data_len)
{
    return mock("eeprom").actualCall("Eeprom_WriteBuffer")
                            .withParameter("address", address)
                            .withParameter("data", data)
                            .withParameter("data_len", data_len)
                            .withOutputParameter("data", data)
                            .returnIntValueOrDefault(-1);
}

The function is that I provide it some byte array and it writes this to eeprom.

I want to be able to test that the data my man in the middle function passed down to the mock is what I expect.

eg

TEST (TestGroup, Test)
{
    uint8_t data[424];
    for (unsigned char & i : data)
        i = rand() % UINT8_MAX;

    uint8_t actual_data[sizeof(data)];
    
    mock("eeprom").expectOneCall("Eepriom_WriteBuffer")
                    .withParameter("address", 0)
                    .<GET THE DATA OUT TO TEST>("data", actual_data, sizeof(actual_data))
                   .andReturnValue(sizeof(data));

    ManInTheMiddle(data, sizeof(data));

    MEMCMP_EQUAL(data, actual_data, sizeof(data));
}

Is this possible with this framework or am I going to have to create some buffers to be able to pull the actual data from?

Grant Dare
  • 23
  • 5

0 Answers0