OSDN Git Service

fr32_vector_add_svv() passed test.
[libbfin32/algorithm_vector.git] / algorithm_vector / fx_vector_test.c
index cde0a24..a9fd931 100644 (file)
@@ -16,7 +16,7 @@ void clearBuffer ( fract32 buf[], int count)
 }
 
 /*
- * Basic test to see the continuity of HH and HL&LH product.
+ * Basic test to see vector + vector addition.
  */
 #define NUMSAMPLE_01 4
 
@@ -68,3 +68,51 @@ void test_01_fr32_vector_add()
 
 #undef TAPS_01
 #undef NUMSAMPLE_01
+
+/*
+ * Basic test to see vector + vector addition.
+ */
+#define NUMSAMPLE_02 4
+
+fract32 buf_a_02[NUMSAMPLE_02]=
+    {
+        0x08000000,     //
+        0x7FFFFFFF,     //
+        0x02000000,
+        0x20000000
+    };
+
+
+fract32 desired_02[NUMSAMPLE_02] =
+    {
+        0x09000000,         // Simple addition
+        0x7FFFFFFF,         // Saturated
+        0x03000000,         // dummy
+        0x00000000,         // 0 for count test
+    };
+
+void test_02_fr32_vector_add_svv()
+{
+    fract32 output[NUMSAMPLE_02];
+    int i;
+
+
+        // clear output buffer
+    clearBuffer( output, NUMSAMPLE_02);
+        // test addition. Sample is less than NUMSAMPLE_02 to test the count parameter
+    fr32_vector_add_svv( 0x01000000, buf_a_02, output, NUMSAMPLE_02-1);
+
+    for ( i=0; i<NUMSAMPLE_02; i++)
+    {
+        if ( output[i] != desired_02[i] )
+        {
+            printf( "test02 NG :output[%2d] = 0x%08X but should be 0x%08X\n", i, output[i], desired_02[i] );
+            return;
+        }
+    }
+    printf ("test02 OK\n");
+}
+
+#undef TAPS_02
+#undef NUMSAMPLE_02
+