diff --git a/tests/ansi/strftime.c b/tests/ansi/strftime.c index 69ec6427dc..e30df21cb6 100644 --- a/tests/ansi/strftime.c +++ b/tests/ansi/strftime.c @@ -11,8 +11,8 @@ int main() { fputs("strftime testcase could not set locale, errors may be expected!", stderr); } - char timebuf[16]; - char result[16] = " 8"; + char timebuf[32]; + char result[32] = " 8"; struct tm tm; tm.tm_sec = 0; tm.tm_min = 17; @@ -33,6 +33,24 @@ int main() { strftime(timebuf, sizeof(timebuf), "%X", &tm); assert(!strcmp(timebuf, "17:17:00")); + memset(timebuf, 0, sizeof(timebuf)); + strftime(timebuf, sizeof(timebuf), "%D", &tm); + assert(!strcmp(timebuf, "03/08/21")); + + memset(timebuf, 0, sizeof(timebuf)); + strftime(timebuf, sizeof(timebuf), "%OB %Ob", &tm); + assert(!strcmp(timebuf, "March Mar")); + + memset(timebuf, 0, sizeof(timebuf)); + strftime(timebuf, sizeof(timebuf), "%c", &tm); + memset(result, 0, sizeof(result)); + strftime(result, sizeof(result), "%a %b %e %H:%M:%S %Y", &tm); + assert(!strcmp(timebuf, result)); + + memset(timebuf, 0, sizeof(timebuf)); + strftime(timebuf, sizeof(timebuf), "%k %p %P%n", &tm); + assert(!strcmp(timebuf, "17 PM pm\n")); + memset(timebuf, 0, sizeof(timebuf)); strftime(timebuf, sizeof(timebuf), "%a %A", &tm); assert(!strcmp(timebuf, "Tue Tuesday"));