#include <time.h>
#include <cyg/infra/testcase.h>
-
+#include <string.h> // strlen()
// HOW TO START TESTS
# define START_TEST( test ) test(0)
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");
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()