Merge "Fix the time unit tests for systems with 64-bit time_t."
This commit is contained in:
commit
25269b8874
1 changed files with 17 additions and 1 deletions
|
@ -55,7 +55,7 @@ TEST(time, gmtime) {
|
|||
ASSERT_EQ(1970, broken_down->tm_year + 1900);
|
||||
}
|
||||
|
||||
#ifdef __BIONIC__
|
||||
#if __BIONIC__
|
||||
TEST(time, mktime_10310929) {
|
||||
struct tm t;
|
||||
memset(&t, 0, sizeof(tm));
|
||||
|
@ -63,7 +63,23 @@ TEST(time, mktime_10310929) {
|
|||
t.tm_mon = 2;
|
||||
t.tm_mday = 10;
|
||||
|
||||
#if !defined(__LP64__)
|
||||
// 32-bit bionic stupidly had a signed 32-bit time_t.
|
||||
ASSERT_EQ(-1, mktime(&t));
|
||||
ASSERT_EQ(-1, mktime_tz(&t, "UTC"));
|
||||
#else
|
||||
// Everyone else should be using a signed 64-bit time_t.
|
||||
ASSERT_GE(sizeof(time_t) * 8, 64U);
|
||||
|
||||
setenv("TZ", "America/Los_Angeles", 1);
|
||||
tzset();
|
||||
ASSERT_EQ(static_cast<time_t>(4108348800U), mktime(&t));
|
||||
ASSERT_EQ(static_cast<time_t>(4108320000U), mktime_tz(&t, "UTC"));
|
||||
|
||||
setenv("TZ", "UTC", 1);
|
||||
tzset();
|
||||
ASSERT_EQ(static_cast<time_t>(4108320000U), mktime(&t));
|
||||
ASSERT_EQ(static_cast<time_t>(4108348800U), mktime_tz(&t, "America/Los_Angeles"));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue