shithub: opus

Download patch

ref: e84b96bbc16dca4d6fbdafbd6387b8ade26b1328
parent: 6238bc0ece31ca1a1b9378de71de32d405919d81
author: Jean-Marc Valin <[email protected]>
date: Mon Jan 28 17:41:55 EST 2008

testcase for 32-bit pulse encoding/decoding

--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,8 +1,12 @@
 INCLUDES = -I$(top_srcdir)/libcelt
 METASOURCES = AUTO
 
-TESTS = ectest
+TESTS = ectest cwrs32-test
 
-bin_PROGRAMS = ectest
+bin_PROGRAMS = ectest cwrs32-test
+
 ectest_SOURCES = ectest.c
 ectest_LDADD = $(top_builddir)/libcelt/libcelt.la
+
+cwrs32_test_SOURCES = cwrs32-test.c
+cwrs32_test_LDADD = $(top_builddir)/libcelt/libcelt.la
--- /dev/null
+++ b/tests/cwrs32-test.c
@@ -1,0 +1,46 @@
+#include <stdio.h>
+#include "cwrs.h"
+
+#define NMAX (10)
+#define MMAX (9)
+
+int main(int _argc,char **_argv){
+  int n;
+  for(n=0;n<=NMAX;n++){
+    int m;
+    for(m=0;m<=MMAX;m++){
+      unsigned nc;
+      unsigned i;
+      nc=ncwrs(n,m);
+      for(i=0;i<nc;i++){
+        int x[MMAX];
+        int s[MMAX];
+        int x2[MMAX];
+        int s2[MMAX];
+        int y[NMAX];
+        int j;
+        int k;
+        cwrsi(n,m,i,x,s);
+        /*printf("%6u of %u:",i,nc);*/
+        /*for(k=0;k<m;k++){
+          printf(" %c%i",k>0&&x[k]==x[k-1]?' ':s[k]?'-':'+',x[k]);
+        }
+        printf(" ->");*/
+        if(icwrs(n,m,x,s)!=i){
+          fprintf(stderr,"Combination-index mismatch.\n");
+          return 1;
+        }
+        comb2pulse(n,m,y,x,s);
+        /*for(j=0;j<n;j++)printf(" %c%i",y[j]?y[j]<0?'-':'+':' ',abs(y[j]));
+        printf("\n");*/
+        pulse2comb(n,m,x2,s2,y);
+        for(k=0;k<m;k++)if(x[k]!=x2[k]||s[k]!=s2[k]){
+          fprintf(stderr,"Pulse-combination mismatch.\n");
+          return 1;
+        }
+      }
+      /*printf("\n");*/
+    }
+  }
+  return 0;
+}
\ No newline at end of file