]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
(main): Add new tests.
authorUlrich Drepper <drepper@redhat.com>
Mon, 15 Apr 2002 06:24:49 +0000 (06:24 +0000)
committerUlrich Drepper <drepper@redhat.com>
Mon, 15 Apr 2002 06:24:49 +0000 (06:24 +0000)
time/tst-mktime.c

index 70c123c3f93bdc7dee8479159552cbc050c74656..7ce1d45dd55d5e29d6a09bb0015eb35a7c9b5235 100644 (file)
@@ -5,7 +5,8 @@
 int
 main (void)
 {
-  struct tm time_str;
+  struct tm time_str, *tm;
+  time_t t;
   char daybuf[20];
   int result;
 
@@ -29,5 +30,38 @@ main (void)
       result = strcmp (daybuf, "Wednesday") != 0;
     }
 
+  setenv ("TZ", "EST", 1);
+#define EVENING69 1 * 60 * 60 + 2 * 60 + 29
+  t = EVENING69;
+  tm = localtime (&t);
+  if (tm == NULL)
+    {
+      (void) puts ("localtime returned NULL");
+      result = 1;
+    }
+  else
+    {
+      time_str = *tm;
+      t = mktime (&time_str);
+      if (t != EVENING69)
+        {
+          printf ("mktime returned %ld, expected %ld\n",
+                 (long) t, EVENING69);
+         result = 1;
+        }
+      else
+        (void) puts ("Dec 31 1969 EST test passed");
+
+      setenv ("TZ", "CET", 1);
+      t = mktime (&time_str);
+      if (t != (time_t) -1)
+        {
+         printf ("mktime returned %ld, expected -1\n", (long) t);
+         result = 1;
+        }
+      else
+        (void) puts ("Dec 31 1969 CET test passed");
+    }
+
   return result;
 }