diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2010-10-05 01:43:34 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2010-10-05 01:43:34 +0000 |
commit | 59a3bf0e51c5bbb38adbc883c25daff11bb1b4a8 (patch) | |
tree | 04c51c13acec92d00824ef5fc5284209a1903677 /libavutil/rational.c | |
parent | dec112691561bddaea07e0ad455a71bf29ade60d (diff) | |
download | ffmpeg-59a3bf0e51c5bbb38adbc883c25daff11bb1b4a8.tar.gz |
Add selftest code for av_cmp_q().
Originally committed as revision 25339 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavutil/rational.c')
-rw-r--r-- | libavutil/rational.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libavutil/rational.c b/libavutil/rational.c index a82bc84ad4..701f06717e 100644 --- a/libavutil/rational.c +++ b/libavutil/rational.c @@ -133,3 +133,23 @@ int av_find_nearest_q_idx(AVRational q, const AVRational* q_list) return nearest_q_idx; } + +#ifdef TEST +main(){ + AVRational a,b; + for(a.num=-2; a.num<=2; a.num++){ + for(a.den=-2; a.den<=2; a.den++){ + for(b.num=-2; b.num<=2; b.num++){ + for(b.den=-2; b.den<=2; b.den++){ + int c= av_cmp_q(a,b); + double d= av_q2d(a) == av_q2d(b) ? 0 : (av_q2d(a) - av_q2d(b)); + if(d>0) d=1; + else if(d<0) d=-1; + else if(d != d) d= INT_MIN; + if(c!=d) av_log(0, AV_LOG_ERROR, "%d/%d %d/%d, %d %f\n", a.num, a.den, b.num, b.den, c,d); + } + } + } + } +} +#endif |