diff --git a/libc/test/src/time/TmMatcher.h b/libc/test/src/time/TmMatcher.h --- a/libc/test/src/time/TmMatcher.h +++ b/libc/test/src/time/TmMatcher.h @@ -26,14 +26,14 @@ bool match(::tm actualValue) { actual = actualValue; - return (actual.tm_sec == expected.tm_sec || - actual.tm_min == expected.tm_min || - actual.tm_hour == expected.tm_hour || - actual.tm_mday == expected.tm_mday || - actual.tm_mon == expected.tm_mon || - actual.tm_year == expected.tm_year || - actual.tm_wday == expected.tm_wday || - actual.tm_yday == expected.tm_yday || + return (actual.tm_sec == expected.tm_sec && + actual.tm_min == expected.tm_min && + actual.tm_hour == expected.tm_hour && + actual.tm_mday == expected.tm_mday && + actual.tm_mon == expected.tm_mon && + actual.tm_year == expected.tm_year && + actual.tm_wday == expected.tm_wday && + actual.tm_yday == expected.tm_yday && actual.tm_isdst == expected.tm_isdst); } diff --git a/libc/test/src/time/gmtime_r_test.cpp b/libc/test/src/time/gmtime_r_test.cpp --- a/libc/test/src/time/gmtime_r_test.cpp +++ b/libc/test/src/time/gmtime_r_test.cpp @@ -22,6 +22,7 @@ struct tm tm_data; struct tm *tm_data_ptr; tm_data_ptr = __llvm_libc::gmtime_r(&seconds, &tm_data); + ASSERT_NE(tm_data_ptr, nullptr); EXPECT_TM_EQ((tm{7, // sec 14, // min 3, // hr @@ -29,7 +30,7 @@ 0, // tm_mon starts with 0 for Jan 2038 - TimeConstants::TIME_YEAR_BASE, // year 2, // wday - 7, // yday + 18, // yday 0}), *tm_data_ptr); EXPECT_TM_EQ(*tm_data_ptr, tm_data); @@ -43,6 +44,7 @@ struct tm tm_data; struct tm *tm_data_ptr; tm_data_ptr = __llvm_libc::gmtime_r(&seconds, &tm_data); + ASSERT_NE(tm_data_ptr, nullptr); EXPECT_TM_EQ((tm{50, // sec 50, // min 12, // hr diff --git a/libc/test/src/time/gmtime_test.cpp b/libc/test/src/time/gmtime_test.cpp --- a/libc/test/src/time/gmtime_test.cpp +++ b/libc/test/src/time/gmtime_test.cpp @@ -43,6 +43,7 @@ // -1 second from 1970-01-01 00:00:00 returns 1969-12-31 23:59:59. seconds = -1; tm_data = __llvm_libc::gmtime(&seconds); + ASSERT_NE(tm_data, nullptr); EXPECT_TM_EQ((tm{59, // sec 59, // min 23, // hr @@ -56,6 +57,7 @@ // 60 seconds from 1970-01-01 00:00:00 returns 1970-01-01 00:01:00. seconds = 60; tm_data = __llvm_libc::gmtime(&seconds); + ASSERT_NE(tm_data, nullptr); EXPECT_TM_EQ((tm{0, // sec 1, // min 0, // hr @@ -74,6 +76,7 @@ // -1 minute from 1970-01-01 00:00:00 returns 1969-12-31 23:59:00. seconds = -TimeConstants::SECONDS_PER_MIN; tm_data = __llvm_libc::gmtime(&seconds); + ASSERT_NE(tm_data, nullptr); EXPECT_TM_EQ((tm{0, // sec 59, // min 23, // hr @@ -87,6 +90,7 @@ // 60 minutes from 1970-01-01 00:00:00 returns 1970-01-01 01:00:00. seconds = 60 * TimeConstants::SECONDS_PER_MIN; tm_data = __llvm_libc::gmtime(&seconds); + ASSERT_NE(tm_data, nullptr); EXPECT_TM_EQ((tm{0, // sec 0, // min 1, // hr @@ -105,6 +109,7 @@ // -1 hour from 1970-01-01 00:00:00 returns 1969-12-31 23:00:00. seconds = -TimeConstants::SECONDS_PER_HOUR; tm_data = __llvm_libc::gmtime(&seconds); + ASSERT_NE(tm_data, nullptr); EXPECT_TM_EQ((tm{0, // sec 0, // min 23, // hr @@ -118,6 +123,7 @@ // 24 hours from 1970-01-01 00:00:00 returns 1970-01-02 00:00:00. seconds = 24 * TimeConstants::SECONDS_PER_HOUR; tm_data = __llvm_libc::gmtime(&seconds); + ASSERT_NE(tm_data, nullptr); EXPECT_TM_EQ((tm{0, // sec 0, // min 0, // hr @@ -135,6 +141,7 @@ time_t seconds = -TimeConstants::DAYS_PER_NON_LEAP_YEAR * TimeConstants::SECONDS_PER_DAY; struct tm *tm_data = __llvm_libc::gmtime(&seconds); + ASSERT_NE(tm_data, nullptr); EXPECT_TM_EQ((tm{0, // sec 0, // min 0, // hr @@ -153,6 +160,7 @@ // -1 month from 1970-01-01 00:00:00 returns 1969-12-01 00:00:00. seconds = -31 * TimeConstants::SECONDS_PER_DAY; tm_data = __llvm_libc::gmtime(&seconds); + ASSERT_NE(tm_data, nullptr); EXPECT_TM_EQ((tm{0, // sec 0, // min 0, // hr @@ -167,6 +175,7 @@ seconds = TimeConstants::DAYS_PER_NON_LEAP_YEAR * TimeConstants::SECONDS_PER_DAY; tm_data = __llvm_libc::gmtime(&seconds); + ASSERT_NE(tm_data, nullptr); EXPECT_TM_EQ((tm{0, // sec 0, // min 0, // hr @@ -185,6 +194,7 @@ // -1 day from 1970-01-01 00:00:00 returns 1969-12-31 00:00:00. seconds = -1 * TimeConstants::SECONDS_PER_DAY; tm_data = __llvm_libc::gmtime(&seconds); + ASSERT_NE(tm_data, nullptr); EXPECT_TM_EQ((tm{0, // sec 0, // min 0, // hr @@ -199,6 +209,7 @@ // 1970-01-32 00:00:00 returns 1970-02-01 00:00:00. seconds = 31 * TimeConstants::SECONDS_PER_DAY; tm_data = __llvm_libc::gmtime(&seconds); + ASSERT_NE(tm_data, nullptr); EXPECT_TM_EQ((tm{0, // sec 0, // min 0, // hr @@ -213,6 +224,7 @@ // 1970-02-29 00:00:00 returns 1970-03-01 00:00:00. seconds = 59 * TimeConstants::SECONDS_PER_DAY; tm_data = __llvm_libc::gmtime(&seconds); + ASSERT_NE(tm_data, nullptr); EXPECT_TM_EQ((tm{0, // sec 0, // min 0, // hr @@ -228,6 +240,7 @@ seconds = ((2 * TimeConstants::DAYS_PER_NON_LEAP_YEAR) + 60) * TimeConstants::SECONDS_PER_DAY; tm_data = __llvm_libc::gmtime(&seconds); + ASSERT_NE(tm_data, nullptr); EXPECT_TM_EQ((tm{0, // sec 0, // min 0, // hr @@ -245,6 +258,7 @@ // Test implementation can encode time for Tue 19 January 2038 03:14:07 UTC. time_t seconds = 0x7FFFFFFF; struct tm *tm_data = __llvm_libc::gmtime(&seconds); + ASSERT_NE(tm_data, nullptr); EXPECT_TM_EQ((tm{7, // sec 14, // min 3, // hr @@ -252,7 +266,7 @@ 0, // tm_mon starts with 0 for Jan 2038 - TimeConstants::TIME_YEAR_BASE, // year 2, // wday - 7, // yday + 18, // yday 0}), *tm_data); } @@ -263,6 +277,7 @@ // Mon Jan 1 12:50:50 2170 (200 years from 1970), time_t seconds = 6311479850; struct tm *tm_data = __llvm_libc::gmtime(&seconds); + ASSERT_NE(tm_data, nullptr); EXPECT_TM_EQ((tm{50, // sec 50, // min 12, // hr @@ -277,6 +292,7 @@ // Test for Tue Jan 1 12:50:50 in 2,147,483,647th year. seconds = 67767976202043050; tm_data = __llvm_libc::gmtime(&seconds); + ASSERT_NE(tm_data, nullptr); EXPECT_TM_EQ((tm{50, // sec 50, // min 12, // hr