2
0

gmtime.c 1.3 KB

1234567891011121314151617181920212223242526272829
  1. #include <time.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include "test_helpers.h"
  6. int main(void) {
  7. time_t a = 0;
  8. struct tm expected = { .tm_sec = 0, .tm_min = 0, .tm_hour = 0, .tm_mday = 1, .tm_year = 70,
  9. .tm_wday = 4, .tm_yday = 0, .tm_isdst = 0, .tm_gmtoff = 0, .tm_zone = "UTC" };
  10. struct tm *info = gmtime(&a);
  11. if (info->tm_sec != expected.tm_sec || info->tm_min != expected.tm_min ||
  12. info->tm_hour != expected.tm_hour || info->tm_mday != expected.tm_mday ||
  13. info->tm_year != expected.tm_year || info->tm_wday != expected.tm_wday ||
  14. info->tm_yday != expected.tm_yday || info->tm_isdst != expected.tm_isdst ||
  15. info->tm_gmtoff != expected.tm_gmtoff || strcmp(info->tm_zone, expected.tm_zone) != 0) {
  16. exit(EXIT_FAILURE);
  17. }
  18. if (info->tm_sec != expected.tm_sec || info->tm_min != expected.tm_min ||
  19. info->tm_hour != expected.tm_hour || info->tm_mday != expected.tm_mday ||
  20. info->tm_year != expected.tm_year || info->tm_wday != expected.tm_wday ||
  21. info->tm_yday != expected.tm_yday || info->tm_isdst != expected.tm_isdst ||
  22. info->tm_gmtoff != expected.tm_gmtoff || strcmp(info->tm_zone, expected.tm_zone) != 0) {
  23. exit(EXIT_FAILURE);
  24. }
  25. }