Commit 9246896f authored by Nicolas George's avatar Nicolas George

parseutils: add FATE test.

parent 99f29108
...@@ -31,6 +31,13 @@ ...@@ -31,6 +31,13 @@
#include "random_seed.h" #include "random_seed.h"
#include "parseutils.h" #include "parseutils.h"
#ifdef TEST
#define av_get_random_seed av_get_random_seed_deterministic
static uint32_t av_get_random_seed_deterministic(void);
#endif
int av_parse_ratio(AVRational *q, const char *str, int max, int av_parse_ratio(AVRational *q, const char *str, int max,
int log_offset, void *log_ctx) int log_offset, void *log_ctx)
{ {
...@@ -677,6 +684,13 @@ int av_find_info_tag(char *arg, int arg_size, const char *tag1, const char *info ...@@ -677,6 +684,13 @@ int av_find_info_tag(char *arg, int arg_size, const char *tag1, const char *info
#ifdef TEST #ifdef TEST
static uint32_t random = MKTAG('L','A','V','U');
static uint32_t av_get_random_seed_deterministic(void)
{
return random = random * 1664525 + 1013904223;
}
#undef printf #undef printf
int main(void) int main(void)
......
...@@ -33,6 +33,10 @@ FATE_LIBAVUTIL += fate-md5 ...@@ -33,6 +33,10 @@ FATE_LIBAVUTIL += fate-md5
fate-md5: libavutil/md5-test$(EXESUF) fate-md5: libavutil/md5-test$(EXESUF)
fate-md5: CMD = run libavutil/md5-test fate-md5: CMD = run libavutil/md5-test
FATE_LIBAVUTIL += fate-parseutils
fate-parseutils: libavutil/parseutils-test$(EXESUF)
fate-parseutils: CMD = run libavutil/parseutils-test
FATE_LIBAVUTIL += fate-random_seed FATE_LIBAVUTIL += fate-random_seed
fate-random_seed: libavutil/random_seed-test$(EXESUF) fate-random_seed: libavutil/random_seed-test$(EXESUF)
fate-random_seed: CMD = run libavutil/random_seed-test fate-random_seed: CMD = run libavutil/random_seed-test
......
Testing av_parse_video_rate()
'-inf' -> -1/0 ret:-22
'inf' -> 1/0 ret:-22
'nan' -> 0/0 ret:-22
'123/0' -> 1/0 ret:-22
'-123 / 0' -> -1/0 ret:-22
'' -> 0/0 ret:-22
'/' -> 0/0 ret:-22
' 123 / 321' -> 41/107 ret:0
'foo/foo' -> 0/0 ret:-22
'foo/1' -> 0/0 ret:-22
'1/foo' -> 1/0 ret:-22
'0/0' -> 0/0 ret:-22
'/0' -> 0/0 ret:-22
'1/' -> 1/0 ret:-22
'1' -> 1/1 ret:0
'0' -> 0/1 ret:-22
'-123/123' -> -1/1 ret:-22
'-foo' -> 0/0 ret:-22
'123.23' -> 12323/100 ret:0
'.23' -> 23/100 ret:0
'-.23' -> -23/100 ret:-22
'-0.234' -> -117/500 ret:-22
'-0.0000001' -> 0/1 ret:-22
' 21332.2324 ' -> 917286/43 ret:0
' -21332.2324 ' -> -917286/43 ret:-22
Testing av_parse_color()
bikeshed -> R(80) G(64) B(140) A(59)
RaNdOm -> R(185) G(88) B(148) A(94)
foo -> error
red -> R(255) G(0) B(0) A(255)
Red -> error
RED -> R(255) G(0) B(0) A(255)
Violet -> R(238) G(130) B(238) A(255)
Yellow -> R(255) G(255) B(0) A(255)
Red -> R(255) G(0) B(0) A(255)
0x000000 -> R(0) G(0) B(0) A(255)
0x0000000 -> error
0xff000000 -> R(255) G(0) B(0) A(0)
0x3e34ff -> R(62) G(52) B(255) A(255)
0x3e34ffaa -> R(62) G(52) B(255) A(170)
0xffXXee -> error
0xfoobar -> error
0xffffeeeeeeee -> error
#ff0000 -> R(255) G(0) B(0) A(255)
#ffXX00 -> error
ff0000 -> R(255) G(0) B(0) A(255)
ffXX00 -> error
red@foo -> error
random@10 -> error
0xff0000@1.0 -> R(255) G(0) B(0) A(255)
red@ -> error
red@0xfff -> error
red@0xf -> R(255) G(0) B(0) A(15)
red@2 -> error
red@0.1 -> R(255) G(0) B(0) A(25)
red@-1 -> error
red@0.5 -> R(255) G(0) B(0) A(127)
red@1.0 -> R(255) G(0) B(0) A(255)
red@256 -> error
red@10foo -> error
red@-1.0 -> error
red@-0.0 -> R(255) G(0) B(0) A(0)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment