[FFmpeg-devel] [PATCH] avutil/integer: move the test to the corresponding subdirectory

James Almer jamrial at gmail.com
Tue Mar 20 20:43:19 EET 2018


And actually enable it.

Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavutil/Makefile        |  1 +
 libavutil/integer.c       | 38 ------------------------------------
 libavutil/tests/integer.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/fate/libavutil.mak  |  5 +++++
 4 files changed, 55 insertions(+), 38 deletions(-)
 create mode 100644 libavutil/tests/integer.c

diff --git a/libavutil/Makefile b/libavutil/Makefile
index d7474f59e4..17ec1f1aa9 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -204,6 +204,7 @@ TESTPROGS = adler32                                                     \
             fifo                                                        \
             hash                                                        \
             hmac                                                        \
+            integer                                                     \
             imgutils                                                    \
             lfg                                                         \
             lls                                                         \
diff --git a/libavutil/integer.c b/libavutil/integer.c
index 6d6855fa1b..890e314dce 100644
--- a/libavutil/integer.c
+++ b/libavutil/integer.c
@@ -164,41 +164,3 @@ int64_t av_i2int(AVInteger a){
     }
     return out;
 }
-
-#ifdef TEST
-
-const uint8_t ff_log2_tab[256]={
-        0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
-        5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
-        6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
-        6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
-        7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
-        7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
-        7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
-        7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
-};
-
-int main(void){
-    int64_t a,b;
-
-    for(a=7; a<256*256*256; a+=13215){
-        for(b=3; b<256*256*256; b+=27118){
-            AVInteger ai= av_int2i(a);
-            AVInteger bi= av_int2i(b);
-
-            av_assert0(av_i2int(ai) == a);
-            av_assert0(av_i2int(bi) == b);
-            av_assert0(av_i2int(av_add_i(ai,bi)) == a+b);
-            av_assert0(av_i2int(av_sub_i(ai,bi)) == a-b);
-            av_assert0(av_i2int(av_mul_i(ai,bi)) == a*b);
-            av_assert0(av_i2int(av_shr_i(ai, 9)) == a>>9);
-            av_assert0(av_i2int(av_shr_i(ai,-9)) == a<<9);
-            av_assert0(av_i2int(av_shr_i(ai, 17)) == a>>17);
-            av_assert0(av_i2int(av_shr_i(ai,-17)) == a<<17);
-            av_assert0(av_log2_i(ai) == av_log2(a));
-            av_assert0(av_i2int(av_div_i(ai,bi)) == a/b);
-        }
-    }
-    return 0;
-}
-#endif
diff --git a/libavutil/tests/integer.c b/libavutil/tests/integer.c
new file mode 100644
index 0000000000..d2c8f2a903
--- /dev/null
+++ b/libavutil/tests/integer.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2004 Michael Niedermayer <michaelni at gmx.at>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdint.h>
+
+#include "libavutil/avassert.h"
+#include "libavutil/integer.h"
+#include "libavutil/intmath.h"
+
+int main(void){
+    int64_t a,b;
+
+    for(a=7; a<256*256*256; a+=13215){
+        for(b=3; b<256*256*256; b+=27118){
+            AVInteger ai= av_int2i(a);
+            AVInteger bi= av_int2i(b);
+
+            av_assert0(av_i2int(ai) == a);
+            av_assert0(av_i2int(bi) == b);
+            av_assert0(av_i2int(av_add_i(ai,bi)) == a+b);
+            av_assert0(av_i2int(av_sub_i(ai,bi)) == a-b);
+            av_assert0(av_i2int(av_mul_i(ai,bi)) == a*b);
+            av_assert0(av_i2int(av_shr_i(ai, 9)) == a>>9);
+            av_assert0(av_i2int(av_shr_i(ai,-9)) == a<<9);
+            av_assert0(av_i2int(av_shr_i(ai, 17)) == a>>17);
+            av_assert0(av_i2int(av_shr_i(ai,-17)) == a<<17);
+            av_assert0(av_log2_i(ai) == av_log2(a));
+            av_assert0(av_i2int(av_div_i(ai,bi)) == a/b);
+        }
+    }
+    return 0;
+}
diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak
index 2ec5650c0f..9b32d880f5 100644
--- a/tests/fate/libavutil.mak
+++ b/tests/fate/libavutil.mak
@@ -90,6 +90,11 @@ FATE_LIBAVUTIL += fate-imgutils
 fate-imgutils: libavutil/tests/imgutils$(EXESUF)
 fate-imgutils: CMD = run libavutil/tests/imgutils
 
+FATE_LIBAVUTIL += fate-integer
+fate-integer: libavutil/tests/integer$(EXESUF)
+fate-integer: CMD = run libavutil/tests/integer
+fate-integer: CMP = null
+
 FATE_LIBAVUTIL += fate-lfg
 fate-lfg: libavutil/tests/lfg$(EXESUF)
 fate-lfg: CMD = run libavutil/tests/lfg
-- 
2.16.2



More information about the ffmpeg-devel mailing list