V
V
Vasily Melnikov2019-02-12 17:53:30
Google
Vasily Melnikov, 2019-02-12 17:53:30

How to check for compile-time dependent things?

Once again we are trying to start writing tests for legacy projects. At least for potentially buggy pieces.
We use GoogleTests
There is a piece of code that parses the compilation date, takes out various elements from it, such as the string writing of the month and translates it into some convenient and uniform number.
Of course, all this depends on the locale compiler and God knows what else.
Simple tests check small pieces, such as converting a month to a number.

EXPECT_EQ(rc_guisrv::utils::MonthByName("Feb"), 2);
  EXPECT_EQ(rc_guisrv::utils::MonthByName("Фев"), 2);

But there is a problem with checking the full function call.
Because they didn’t think of anything better than taking the current date and using it for verification. Therefore, if the tests are rebuilt, they pass, with an incremental build they break as expected
. How to overcome this, for example, mark the file so that it is always rebuilt.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question