summaryrefslogtreecommitdiff
path: root/libavutil
diff options
context:
space:
mode:
authorStefano Sabatini <stefasab@gmail.com>2012-09-17 00:49:31 +0200
committerStefano Sabatini <stefasab@gmail.com>2012-09-17 12:46:55 +0200
commit1ad63ff14adb652996c4604da59a330cef0d494e (patch)
tree37f3acf18016ca576c73ec6a63d09c4d9ed6bbcc /libavutil
parent85c93d90dfae17d2ccff21aec5a55ca3029be83c (diff)
fate: add av_small_strptime() test to fate-parseutils
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/parseutils.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c
index 8dc583c898..6e50d70657 100644
--- a/libavutil/parseutils.c
+++ b/libavutil/parseutils.c
@@ -781,6 +781,35 @@ int main(void)
}
}
+ printf("\nTesting av_small_strptime()\n");
+ {
+ int i;
+ struct tm tm = { 0 };
+ struct fmt_timespec_entry {
+ const char *fmt, *timespec;
+ } fmt_timespec_entries[] = {
+ { "%Y-%m-%d", "2012-12-21" },
+ { "%Y - %m - %d", "2012-12-21" },
+ { "%Y-%m-%d %H:%M:%S", "2012-12-21 20:12:21" },
+ { " %Y - %m - %d %H : %M : %S", " 2012 - 12 - 21 20 : 12 : 21" },
+ };
+
+ av_log_set_level(AV_LOG_DEBUG);
+ for (i = 0; i < FF_ARRAY_ELEMS(fmt_timespec_entries); i++) {
+ char *p;
+ struct fmt_timespec_entry *e = &fmt_timespec_entries[i];
+ printf("fmt:'%s' spec:'%s' -> ", e->fmt, e->timespec);
+ p = av_small_strptime(e->timespec, e->fmt, &tm);
+ if (p) {
+ printf("%04d-%02d-%2d %02d:%02d:%02d\n",
+ 1900+tm.tm_year, tm.tm_mon+1, tm.tm_mday,
+ tm.tm_hour, tm.tm_min, tm.tm_sec);
+ } else {
+ printf("error\n");
+ }
+ }
+ }
+
printf("\nTesting av_parse_time()\n");
{
int i;