]> git.kernelconcepts.de Git - karo-tx-redboot.git/blobdiff - packages/language/c/libc/time/v2_0/tests/strptime.c
unified MX27, MX25, MX37 trees
[karo-tx-redboot.git] / packages / language / c / libc / time / v2_0 / tests / strptime.c
index 3bb547da4ec90ab5a0e3802568cbcf5dcaff2b1d..a39b4455d1382a703ef23b560936596be0950cc2 100644 (file)
@@ -57,7 +57,7 @@
 
 #include <time.h>
 #include <cyg/infra/testcase.h>
-
+#include <string.h>                     // strlen()
 // HOW TO START TESTS
 
 # define START_TEST( test ) test(0)
@@ -84,7 +84,12 @@ test( CYG_ADDRWORD data )
     
     dp = "Fri Jan 24 08:33:14 2003";
     fp = "%a %b %d %H:%M:%S %Y";
-    sp = strptime(dp, fp, &tm1);    
+    sp = strptime(dp, fp, &tm1);
+    
+    // Set an invalid year day. The following converters don't use
+    // this, so it should not cause a problem.
+    tm1.tm_yday = 1000;
+
     CYG_TEST_PASS_FAIL(((sp!=NULL) && (*sp=='\0')), "strptime test #1");
     size = strftime(s, sizeof(s), fp, &tm1);
     CYG_TEST_PASS_FAIL(((size==strlen(dp)) && (my_strcmp(s, dp) == 0)), "strptime test #2");
@@ -96,6 +101,17 @@ test( CYG_ADDRWORD data )
     size = strftime(s, sizeof(s), fp, &tm1);
     CYG_TEST_PASS_FAIL(((size==strlen(dp)) && (my_strcmp(s, dp) == 0)), "strptime test #4");
 
+    dp = "2006:06:13 12:22:01";
+    fp = "%x %X";
+    sp = strptime(dp, fp, &tm1);    
+    CYG_TEST_PASS_FAIL(((sp!=NULL) && (*sp=='\0')), "strptime test #5");
+    CYG_TEST_PASS_FAIL((tm1.tm_sec == 01) &&
+                       (tm1.tm_min == 22) &&
+                       (tm1.tm_hour == 12) &&
+                       (tm1.tm_mday == 13) &&
+                       (tm1.tm_mon ==  (06 - 1)) &&
+                       (tm1.tm_year == (2006 - 1900)), "strptime test #6");
+    size = strftime(s, sizeof(s), fp, &tm1);
     CYG_TEST_FINISH("Finished tests from testcase " __FILE__ " for C library "
                     "strptime() function");
 } // test()