* commit 'f7de5d57732d67f967243bea5e01f6da6be5f517': Fix the time unit tests for systems with 64-bit time_t.
This commit is contained in:
commit
7d0204b685
@ -55,7 +55,7 @@ TEST(time, gmtime) {
|
|||||||
ASSERT_EQ(1970, broken_down->tm_year + 1900);
|
ASSERT_EQ(1970, broken_down->tm_year + 1900);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __BIONIC__
|
#if __BIONIC__
|
||||||
TEST(time, mktime_10310929) {
|
TEST(time, mktime_10310929) {
|
||||||
struct tm t;
|
struct tm t;
|
||||||
memset(&t, 0, sizeof(tm));
|
memset(&t, 0, sizeof(tm));
|
||||||
@ -63,7 +63,23 @@ TEST(time, mktime_10310929) {
|
|||||||
t.tm_mon = 2;
|
t.tm_mon = 2;
|
||||||
t.tm_mday = 10;
|
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(&t));
|
||||||
ASSERT_EQ(-1, mktime_tz(&t, "UTC"));
|
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
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user