Skip to content
Snippets Groups Projects
Commit b15c90ee authored by Peter Limkilde Svendsen's avatar Peter Limkilde Svendsen
Browse files

Add test for ctime_r()

parent b2338968
No related branches found
No related tags found
No related merge requests found
Pipeline #7570 failed
...@@ -6,3 +6,4 @@ Year 70, Day of year: 0, Month 0, Day of month: 1, Day of week: 4, 0:0:0 ...@@ -6,3 +6,4 @@ Year 70, Day of year: 0, Month 0, Day of month: 1, Day of week: 4, 0:0:0
Year 70, Day of year: 0, Month 0, Day of month: 1, Day of week: 4, 0:0:1 Year 70, Day of year: 0, Month 0, Day of month: 1, Day of week: 4, 0:0:1
Year 118, Day of year: 193, Month 6, Day of month: 13, Day of week: 5, 4:9:10 Year 118, Day of year: 193, Month 6, Day of month: 13, Day of week: 5, 4:9:10
Fri Jul 13 06:03:43 2018 Fri Jul 13 06:03:43 2018
Fri Jul 13 06:03:43 2018
...@@ -17,4 +17,15 @@ int main(void) { ...@@ -17,4 +17,15 @@ int main(void) {
time_t input = 1531461823; time_t input = 1531461823;
fputs(ctime(&input), stdout); // Omit newline fputs(ctime(&input), stdout); // Omit newline
char ctime_r_buffer[26];
/* ctime_r() generally returns the address of the provided buffer,
* but may return NULL upon error according to the spec. */
char *ctime_r_result = ctime_r(&input, ctime_r_buffer);
if (ctime_r_result == ctime_r_buffer) {
fputs(ctime_r_result, stdout);
}
else {
printf("Unexpected pointer from ctime_r: %p\n", ctime_r_result);
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment