meekrosoft / fff

A testing micro framework for creating function test doubles
Other
761 stars 167 forks source link

error: overloaded function with no contextual type information #73

Open ZaneV opened 5 years ago

ZaneV commented 5 years ago

When trying to run make on a unit test using fff.h to fake a function initSerialCommDevice i get the following error:

In file included from /home/zanev/mbed/AFDAU_0_01/UNITTESTS/app/drivers/test_rockair.cpp:6:0:
/home/zanev/mbed/AFDAU_0_01/UNITTESTS/app/drivers/test_rockair.cpp: In function ‘int initSerialCommDevice(uint8_t, uint32_t, uint8_t, serialParity_e, uint8_t)’:
/home/zanev/mbed/AFDAU_0_01/UNITTESTS/app/drivers/test_rockair.cpp:10:22: error: overloaded function with no contextual type information
 FAKE_VALUE_FUNC(int, initSerialCommDevice, uint8_t, uint32_t, uint8_t, serialParity_e, uint8_t);

my test file is as follows (initSerialCommDevice is prototyped in _hal_serial.h):

#include <stdint.h>
#include "../../app/drivers/rockair.h"
#include "../../app/peripherals/_hal_serial.h"
#include <gtest/gtest.h>
#include "fff.h"

DEFINE_FFF_GLOBALS;

FAKE_VALUE_FUNC(int, initSerialCommDevice, uint8_t, uint32_t, uint8_t, serialParity_e, uint8_t);
class RockairDriverTest : public ::testing::Test
{
public:
  void SetUp()
  {
    //RESET_FAKE(initSerialCommDevice);
    FFF_RESET_HISTORY();
  }
};

TEST_F(RockairDriverTest, initializes_rockair_driver_successfully) {
  uint8_t port_id = 1;
  uint32_t baud = 9600;
  uint8_t data_bits = 8;
  serialParity_e parity = NONE;
  uint8_t stop_bits = 1;

  rockair_initDriver(port_id, baud, data_bits, parity, stop_bits);
  //ASSERT_EQ(initSerialCommDevice_fake.call_count, 1);
}

From the digging I have done on the issue it appears that the compiler is seeing the function in the _hal_serial.h file and also seeing the function that the macro is creating and is having an issue. I have looked over the example code and tried to see where I have gone wrong but everything seems to be as it should. Can anybody point me in the right direction here?

ZaneV commented 5 years ago

I have fixed my issue... very basic rookie mistake! This issue can be closed. FYI, an argument in the prototype was supposed to be a uint8_t and I had an int.