Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
9b84f8a9
Commit
9b84f8a9
authored
Apr 16, 2012
by
Nicolas George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parseutils: add av_parse_time() test.
parent
43b70680
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
1 deletion
+62
-1
parseutils.c
libavutil/parseutils.c
+50
-1
parseutils
tests/ref/fate/parseutils
+12
-0
No files found.
libavutil/parseutils.c
View file @
9b84f8a9
...
...
@@ -31,11 +31,15 @@
#include "random_seed.h"
#include "parseutils.h"
#undef time
#ifdef TEST
#define av_get_random_seed av_get_random_seed_deterministic
static
uint32_t
av_get_random_seed_deterministic
(
void
);
#define time(t) 1331972053
#endif
int
av_parse_ratio
(
AVRational
*
q
,
const
char
*
str
,
int
max
,
...
...
@@ -541,7 +545,6 @@ int av_parse_time(int64_t *timeval, const char *timestr, int duration)
q
=
NULL
;
*
timeval
=
INT64_MIN
;
if
(
!
duration
)
{
#undef time
now
=
time
(
0
);
if
(
!
av_strcasecmp
(
timestr
,
"now"
))
{
...
...
@@ -776,6 +779,52 @@ int main(void)
}
}
printf
(
"
\n
Testing av_parse_time()
\n
"
);
{
int
i
;
int64_t
tv
;
time_t
tvi
;
struct
tm
*
tm
;
const
char
*
time_string
[]
=
{
"now"
,
"12:35:46"
,
"2000-12-20 0:02:47.5z"
,
"2000-12-20T010247.6"
,
};
const
char
*
duration_string
[]
=
{
"2:34:56.79"
,
"-1:23:45.67"
,
"42.1729"
,
"-1729.42"
,
"12:34"
,
};
av_log_set_level
(
AV_LOG_DEBUG
);
setenv
(
"TZ"
,
"CET-1"
,
1
);
printf
(
"(now is 2012-03-17 09:14:13 +0100, local time is UTC+1)
\n
"
);
for
(
i
=
0
;
i
<
FF_ARRAY_ELEMS
(
time_string
);
i
++
)
{
printf
(
"%-24s -> "
,
time_string
[
i
]);
if
(
av_parse_time
(
&
tv
,
time_string
[
i
],
0
))
{
printf
(
"error
\n
"
);
}
else
{
tvi
=
tv
/
1000000
;
tm
=
gmtime
(
&
tvi
);
printf
(
"%14"
PRIi64
".%06d = %04d-%02d-%02dT%02d:%02d:%02dZ
\n
"
,
tv
/
1000000
,
(
int
)(
tv
%
1000000
),
tm
->
tm_year
+
1900
,
tm
->
tm_mon
+
1
,
tm
->
tm_mday
,
tm
->
tm_hour
,
tm
->
tm_min
,
tm
->
tm_sec
);
}
}
for
(
i
=
0
;
i
<
FF_ARRAY_ELEMS
(
duration_string
);
i
++
)
{
printf
(
"%-24s -> "
,
duration_string
[
i
]);
if
(
av_parse_time
(
&
tv
,
duration_string
[
i
],
1
))
{
printf
(
"error
\n
"
);
}
else
{
printf
(
"%+21"
PRIi64
"
\n
"
,
tv
);
}
}
}
return
0
;
}
...
...
tests/ref/fate/parseutils
View file @
9b84f8a9
...
...
@@ -62,3 +62,15 @@ red@256 -> error
red@10foo -> error
red@-1.0 -> error
red@-0.0 -> R(255) G(0) B(0) A(0)
Testing av_parse_time()
(now is 2012-03-17 09:14:13 +0100, local time is UTC+1)
now -> 1331972053.000000 = 2012-03-17T08:14:13Z
12:35:46 -> 1331984146.000000 = 2012-03-17T11:35:46Z
2000-12-20 0:02:47.5z -> 977270567.500000 = 2000-12-20T00:02:47Z
2000-12-20T010247.6 -> 977270567.600000 = 2000-12-20T00:02:47Z
2:34:56.79 -> +9296790000
-1:23:45.67 -> -5025670000
42.1729 -> +42172900
-1729.42 -> -1729420000
12:34 -> error
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment