< prev index next >
test/native/logging/test_logDecorations.cpp
Print this page
rev 12265 : 8169003: LogDecorations.iso8601_utctime_test fails if numeric locale uses "," as separator between integer and fraction part
Reviewed-by: duke
*** 129,142 ****
const char *timestr = decorations.decoration(LogDecorators::time_decorator);
time_t expected_ts = time(NULL);
// Verify format
! int y, M, d, h, m;
! double s;
! int read = sscanf(timestr, "%d-%d-%dT%d:%d:%lf", &y, &M, &d, &h, &m, &s);
! ASSERT_EQ(6, read) << "Invalid format: " << timestr;
// Verify reported time & date
struct tm reported_time = {0};
reported_time.tm_year = y - 1900;
reported_time.tm_mon = M - 1;
--- 129,141 ----
const char *timestr = decorations.decoration(LogDecorators::time_decorator);
time_t expected_ts = time(NULL);
// Verify format
! int y, M, d, h, m, s, ms;
! int read = sscanf(timestr, "%d-%d-%dT%d:%d:%d.%d", &y, &M, &d, &h, &m, &s, &ms);
! ASSERT_EQ(7, read) << "Invalid format: " << timestr;
// Verify reported time & date
struct tm reported_time = {0};
reported_time.tm_year = y - 1900;
reported_time.tm_mon = M - 1;
*** 165,178 ****
const char *timestr = decorations.decoration(LogDecorators::utctime_decorator);
time_t expected_ts = time(NULL);
// Verify format
char trailing_character;
! int y, M, d, h, m, offset;
! double s;
! int read = sscanf(timestr, "%d-%d-%dT%d:%d:%lf%c%d", &y, &M, &d, &h, &m, &s, &trailing_character, &offset);
! ASSERT_GT(read, 7) << "Invalid format: " << timestr;
// Ensure time is UTC (no offset)
if (trailing_character == '+') {
ASSERT_EQ(0, offset) << "Invalid offset: " << timestr;
} else {
--- 164,178 ----
const char *timestr = decorations.decoration(LogDecorators::utctime_decorator);
time_t expected_ts = time(NULL);
// Verify format
char trailing_character;
! int y, M, d, h, m, s, ms, offset;
!
! int read = sscanf(timestr, "%d-%d-%dT%d:%d:%d.%d%c%d", &y, &M, &d, &h, &m, &s, &ms, &trailing_character, &offset);
!
! ASSERT_EQ(9, read) << "Invalid format: " << timestr;
// Ensure time is UTC (no offset)
if (trailing_character == '+') {
ASSERT_EQ(0, offset) << "Invalid offset: " << timestr;
} else {
< prev index next >