0
time_t now = time(NULL);
tm *currentTime = localtime(&now);
HelperClass helper({(uint8_t)currentTime->tm_mday,(uint8_t)(1+ currentTime->tm_mon),
                    (uint16_t)(currentTime->tm_year+1900),
                    (uint8_t)currentTime->tm_hour,
                    (uint8_t)currentTime->tm_min,(uint8_t)currentTime->tm_sec});

And output of this I need to test in gtest. Do anyone know how to mock it for gtest?

YSC
  • 38,212
  • 9
  • 96
  • 149
Homie
  • 1
  • You cannot mock free functions, you have to wrap them in class. – Jarod42 Dec 06 '21 at 15:26
  • 2
    What do you mean "mock" it? What are you actually trying to do? – Cubic Dec 06 '21 at 15:26
  • Everytime local time will change and hence, the testcase expectation should also change. For which I want to kind of create a mock method or stub. So localtime can take value I intended to send and not the system time. – Homie Dec 06 '21 at 17:14
  • @Jarod42 How to wrap them in class, can you briefly explain it? – Homie Dec 06 '21 at 17:15

0 Answers0