static const char *const datemsk[] = {
/* ISO format */
"%Y-%m-%d %H:%M:%S",
+ /* Generic time, same day */
+ "%H:%M:%S",
+ "%H:%M",
/* "%Y-%m-%d %H:%M:%S %Z" - no, not sensibly supported anywhere */
/* Locale-specific date + time */
"%c",
/* Locale-specific time, same day */
"%X",
"%EX",
- /* Generic time, same day */
- "%H:%M",
- "%H:%M:%S",
NULL,
};
check_date(now, "%H:%M:%S", localtime);
/* This one needs a bodge: */
check_date(now - now % 60, "%H:%M", localtime);
+#if __FreeBSD__
+ fprintf(stderr, "strptime() is broken on FreeBSD - skipping further tests\n");
+ ++skipped;
+#else
/* Reject invalid formats */
check_fatal(dateparse("12"));
check_fatal(dateparse("12:34:56:23"));
check_fatal(dateparse("25:34"));
check_fatal(dateparse("23:61"));
check_fatal(dateparse("23:23:62"));
+#endif
}
TEST(dateparse);
long long tests, errors;
int fail_first;
int verbose;
+int skipped;
void count_error(void) {
++errors;
extern long long tests, errors;
extern int fail_first;
extern int verbose;
+extern int skipped;
/** @brief Checks that @p expr is nonzero */
#define insist(expr) do { \
if(errors || verbose) \
fprintf(stderr, "test_"#name": %lld errors out of %lld tests\n", \
errors, tests); \
- return !!errors; \
+ if(errors) \
+ return 1; \
+ if(skipped) \
+ return 77; \
+ return 0; \
} \
\
struct swallow_semicolon