summaryrefslogtreecommitdiff
path: root/core/fxcrt/fx_system_unittest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcrt/fx_system_unittest.cpp')
-rw-r--r--core/fxcrt/fx_system_unittest.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/core/fxcrt/fx_system_unittest.cpp b/core/fxcrt/fx_system_unittest.cpp
index 5a7660d256..a83b275111 100644
--- a/core/fxcrt/fx_system_unittest.cpp
+++ b/core/fxcrt/fx_system_unittest.cpp
@@ -173,7 +173,21 @@ TEST(fxcrt, FXSYS_wcsftime) {
wchar_t buf[100] = {};
EXPECT_EQ(19u, FXSYS_wcsftime(buf, FX_ArraySize(buf), L"%Y-%m-%dT%H:%M:%S",
&good_time));
- EXPECT_EQ(std::wstring(L"1974-08-09T11:59:59"), buf);
+ EXPECT_STREQ(L"1974-08-09T11:59:59", buf);
+
+ // Ensure wcsftime handles a wide range of years without crashing.
+ struct tm year_time = {};
+ year_time.tm_mon = 7; // 0-based.
+ year_time.tm_mday = 9; // 1-based.
+ year_time.tm_hour = 11;
+ year_time.tm_min = 59;
+ year_time.tm_sec = 59;
+
+ for (int year = -2500; year <= 2500; ++year) {
+ year_time.tm_year = year;
+ wchar_t buf[100] = {};
+ FXSYS_wcsftime(buf, FX_ArraySize(buf), L"%Y-%m-%dT%H:%M:%S", &year_time);
+ }
// Ensure wcsftime handles bad years, etc. without crashing.
struct tm bad_time = {};