MCPcopy Create free account
hub / github.com/catboost/catboost / TestGmTimeR

Function TestGmTimeR

util/datetime/base_ut.cpp:313–336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

311 }
312
313 void TestGmTimeR(time_t starttime, time_t finishtime, int steps) {
314 time_t step = (finishtime - starttime) / steps;
315 struct tm tms0, tms1;
316 struct tm* ptm0 = nullptr;
317 struct tm* ptm1 = nullptr;
318 for (time_t t = starttime; t < finishtime; t += step) {
319 ptm0 = GmTimeR(&t, &tms0);
320 UNIT_ASSERT_EQUAL(ptm0, &tms0);
321
322#ifdef _win_
323 if (tms0.tm_year + 1900 > 3000) {
324 // Windows: _MAX__TIME64_T == 23:59:59. 12/31/3000 UTC
325 continue;
326 }
327#endif
328
329 ptm1 = gmtime_r(&t, &tms1);
330 if (!ptm1) {
331 continue;
332 }
333 UNIT_ASSERT_EQUAL(ptm1, &tms1);
334 UNIT_ASSERT(CompareTMFull(ptm0, ptm1));
335 }
336 }
337
338 Y_UNIT_TEST(TestGmTimeRLongRange) {
339 time_t starttime = static_cast<time_t>(-86397839500LL); // 29-Jan-2668 B.C.

Callers 1

Y_UNIT_TESTFunction · 0.85

Calls 3

GmTimeRFunction · 0.85
gmtime_rFunction · 0.85
CompareTMFullFunction · 0.85

Tested by

no test coverage detected