Skip to content

Commit

Permalink
tests/ansi: add tests for various new strftime modifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
no92 committed Jul 6, 2024
1 parent 4ea04b2 commit c824300
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions tests/ansi/strftime.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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"));
Expand Down

0 comments on commit c824300

Please sign in to comment.