64-bit test for cwrs
authorJean-Marc Valin <jean-marc.valin@usherbrooke.ca>
Mon, 28 Jan 2008 12:01:58 +0000 (23:01 +1100)
committerJean-Marc Valin <jean-marc.valin@usherbrooke.ca>
Mon, 28 Jan 2008 12:01:58 +0000 (23:01 +1100)
tests/Makefile.am
tests/cwrs32-test.c
tests/cwrs64-test.c [new file with mode: 0644]

index 1d54857..d5fb043 100644 (file)
@@ -1,12 +1,15 @@
 INCLUDES = -I$(top_srcdir)/libcelt
 METASOURCES = AUTO
 
-TESTS = ectest cwrs32-test
+TESTS = ectest cwrs32-test cwrs64-test
 
-bin_PROGRAMS = ectest cwrs32-test
+bin_PROGRAMS = ectest cwrs32-test cwrs64-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
+
+cwrs64_test_SOURCES = cwrs64-test.c
+cwrs64_test_LDADD = $(top_builddir)/libcelt/libcelt.la
index af9042b..629c5c4 100644 (file)
@@ -9,10 +9,14 @@ int main(int _argc,char **_argv){
   for(n=0;n<=NMAX;n++){
     int m;
     for(m=0;m<=MMAX;m++){
+      unsigned inc;
       unsigned nc;
       unsigned i;
       nc=ncwrs(n,m);
-      for(i=0;i<nc;i++){
+      inc = nc/10000;
+      if (inc<1)
+        inc = 1;
+      for(i=0;i<nc;i+=inc){
         int x[MMAX];
         int s[MMAX];
         int x2[MMAX];
diff --git a/tests/cwrs64-test.c b/tests/cwrs64-test.c
new file mode 100644 (file)
index 0000000..eabf6e0
--- /dev/null
@@ -0,0 +1,51 @@
+#include <stdio.h>
+#include "cwrs.h"
+#define NMAX (32)
+#define MMAX (16)
+
+int main(int _argc,char **_argv){
+  int n;
+  for(n=0;n<=NMAX;n+=3){
+    int m;
+    for(m=0;m<=MMAX;m++){
+      celt_uint64_t inc;
+      celt_uint64_t nc;
+      celt_uint64_t i;
+      nc=ncwrs64(n,m);
+      /* Testing all cases just wouldn't work! */
+      inc = nc/1000;
+      if (inc<1)
+         inc = 1;
+      /*printf("%d/%d: %llu",n,m, nc);*/
+      for(i=0;i<nc;i+=inc){
+        int x[MMAX];
+        int s[MMAX];
+        int x2[MMAX];
+        int s2[MMAX];
+        int y[NMAX];
+        int j;
+        int k;
+        cwrsi64(n,m,i,x,s);
+        /*printf("%llu of %llu:",i,nc);
+        for(k=0;k<m;k++){
+          printf(" %c%i",k>0&&x[k]==x[k-1]?' ':s[k]?'-':'+',x[k]);
+        }
+        printf(" ->");*/
+        if(icwrs64(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