Improved the quality of codes in unit test.
authorXianyi Zhang <xianyi@iscas.ac.cn>
Sun, 20 Feb 2011 16:42:46 +0000 (00:42 +0800)
committerXianyi Zhang <xianyi@iscas.ac.cn>
Sun, 20 Feb 2011 16:43:15 +0000 (00:43 +0800)
Thanks José Luis García Pallero

common_reference.h
utest/common_utest.h
utest/main.c
utest/test_rot.c
utest/test_swap.c

index 4bc46bc..27a27a6 100644 (file)
@@ -43,16 +43,16 @@ void  BLASFUNC_REF(csrot) (blasint *, float  *, blasint *, float  *, blasint *,
 void  BLASFUNC_REF(zdrot) (blasint *, double *, blasint *, double *, blasint *, double *, double *);
 void  BLASFUNC_REF(xqrot) (blasint *, xdouble *, blasint *, xdouble *, blasint *, xdouble *, xdouble *);
 
-void    BLASFUNC_REF(sswap) (blasint *, float  *, blasint *, float  *, blasint *);
-void    BLASFUNC_REF(dswap) (blasint *, double *, blasint *, double *, blasint *);
-void    BLASFUNC_REF(qswap) (blasint *, xdouble *, blasint *, xdouble *, blasint *);
-void    BLASFUNC_REF(cswap) (blasint *, float  *, blasint *, float  *, blasint *);
-void    BLASFUNC_REF(zswap) (blasint *, double *, blasint *, double *, blasint *);
-void    BLASFUNC_REF(xswap) (blasint *, xdouble *, blasint *, xdouble *, blasint *);
-
-void    BLASFUNC_REF(saxpy) (blasint *, float  *, float  *, blasint *, float  *, blasint *);
-void    BLASFUNC_REF(daxpy) (blasint *, double *, double *, blasint *, double *, blasint *);
-void    BLASFUNC_REF(caxpy) (blasint *, float  *, float  *, blasint *, float  *, blasint *);
-void    BLASFUNC_REF(zaxpy) (blasint *, double *, double *, blasint *, double *, blasint *);
+void BLASFUNC_REF(sswap) (blasint *, float  *, blasint *, float  *, blasint *);
+void BLASFUNC_REF(dswap) (blasint *, double *, blasint *, double *, blasint *);
+void BLASFUNC_REF(qswap) (blasint *, xdouble *, blasint *, xdouble *, blasint *);
+void BLASFUNC_REF(cswap) (blasint *, float  *, blasint *, float  *, blasint *);
+void BLASFUNC_REF(zswap) (blasint *, double *, blasint *, double *, blasint *);
+void BLASFUNC_REF(xswap) (blasint *, xdouble *, blasint *, xdouble *, blasint *);
+
+void BLASFUNC_REF(saxpy) (blasint *, float  *, float  *, blasint *, float  *, blasint *);
+void BLASFUNC_REF(daxpy) (blasint *, double *, double *, blasint *, double *, blasint *);
+void BLASFUNC_REF(caxpy) (blasint *, float  *, float  *, blasint *, float  *, blasint *);
+void BLASFUNC_REF(zaxpy) (blasint *, double *, double *, blasint *, double *, blasint *);
 
 #endif
index f4fc728..43c7f7f 100644 (file)
@@ -39,10 +39,10 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #define CHECK_EPS 0.00002
 
 //Testcase list
-void test_drot_incx_0(void);
-void test_srot_incx_0(void);
-void test_zdrot_incx_0(void);
-void test_csrot_incx_0(void);
+void test_drot_inc_0(void);
+void test_srot_inc_0(void);
+void test_zdrot_inc_0(void);
+void test_csrot_inc_0(void);
 
 void test_dswap_inc_0(void);
 void test_zswap_inc_0(void);
index eddf1ce..ef4232d 100644 (file)
@@ -37,20 +37,20 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <CUnit/Basic.h>
 
 CU_TestInfo test_level1[]={
-       {"Testing srot when incx & incy == 0",test_srot_incx_0},
-       {"Testing drot when incx & incy == 0",test_drot_incx_0},
-       {"Testing csrot when incx & incy == 0",test_csrot_incx_0},
-       {"Testing zdrot when incx & incy == 0",test_zdrot_incx_0},
+       {"Testing srot when incx || incy == 0",test_srot_inc_0},
+       {"Testing drot when incx || incy == 0",test_drot_inc_0},
+       {"Testing csrot when incx || incy == 0",test_csrot_inc_0},
+       {"Testing zdrot when incx || incy == 0",test_zdrot_inc_0},
 
-       {"Testing sswap with incx & incy == 0",test_sswap_inc_0},
-       {"Testing dswap with incx & incy == 0",test_dswap_inc_0},
-       {"Testing cswap with incx & incy == 0",test_cswap_inc_0},
-       {"Testing zswap with incx & incy == 0",test_zswap_inc_0},
+       {"Testing sswap with incx || incy == 0",test_sswap_inc_0},
+       {"Testing dswap with incx || incy == 0",test_dswap_inc_0},
+       {"Testing cswap with incx || incy == 0",test_cswap_inc_0},
+       {"Testing zswap with incx || incy == 0",test_zswap_inc_0},
 
-       {"Testing saxpy with incx & incy == 0",test_saxpy_inc_0},
-       {"Testing daxpy with incx & incy == 0",test_daxpy_inc_0},
-       {"Testing caxpy with incx & incy == 0",test_caxpy_inc_0},
-       {"Testing zaxpy with incx & incy == 0",test_zaxpy_inc_0},
+       {"Testing saxpy with incx || incy == 0",test_saxpy_inc_0},
+       {"Testing daxpy with incx || incy == 0",test_daxpy_inc_0},
+       {"Testing caxpy with incx || incy == 0",test_caxpy_inc_0},
+       {"Testing zaxpy with incx || incy == 0",test_zaxpy_inc_0},
 
        CU_TEST_INFO_NULL,
 };
index 18a2bbd..f5332d4 100644 (file)
@@ -32,9 +32,9 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include "common_utest.h"
 
-void test_drot_incx_0(void)
+void test_drot_inc_0(void)
 {
-       int i;
+       int i=0;
        int N=4,incX=0,incY=0;
        double c=0.25,s=0.5;
        double x1[]={1.0,3.0,5.0,7.0};
@@ -53,9 +53,9 @@ void test_drot_incx_0(void)
        }
 }
 
-void test_zdrot_incx_0(void)
+void test_zdrot_inc_0(void)
 {
-       int i;
+       int i=0;
        int N=4,incX=0,incY=0;
        double c=0.25,s=0.5;
        double x1[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
@@ -68,15 +68,15 @@ void test_zdrot_incx_0(void)
        //reference
        BLASFUNC_REF(zdrot)(&N,x2,&incX,y2,&incY,&c,&s);
 
-       for(i=0; i<N; i++){
+       for(i=0; i<2*N; i++){
                CU_ASSERT_DOUBLE_EQUAL(x1[i], x2[i], CHECK_EPS);
                CU_ASSERT_DOUBLE_EQUAL(y1[i], y2[i], CHECK_EPS);
        }
 }
 
-void test_srot_incx_0(void)
+void test_srot_inc_0(void)
 {
-       int i;
+       int i=0;
        int N=4,incX=0,incY=0;
        float c=0.25,s=0.5;
        float x1[]={1.0,3.0,5.0,7.0};
@@ -95,9 +95,9 @@ void test_srot_incx_0(void)
        }
 }
 
-void test_csrot_incx_0(void)
+void test_csrot_inc_0(void)
 {
-       int i;
+       int i=0;
        int N=4,incX=0,incY=0;
        float c=0.25,s=0.5;
        float x1[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
@@ -110,7 +110,7 @@ void test_csrot_incx_0(void)
        //reference
        BLASFUNC_REF(csrot)(&N,x2,&incX,y2,&incY,&c,&s);
 
-       for(i=0; i<N; i++){
+       for(i=0; i<2*N; i++){
                CU_ASSERT_DOUBLE_EQUAL(x1[i], x2[i], CHECK_EPS);
                CU_ASSERT_DOUBLE_EQUAL(y1[i], y2[i], CHECK_EPS);
        }
index 5218a71..30c2e77 100644 (file)
@@ -13,19 +13,19 @@ met:
       notice, this list of conditions and the following disclaimer in
       the documentation and/or other materials provided with the
       distribution.
-   3. Neither the name of the ISCAS nor the names of its contributors may 
-      be used to endorse or promote products derived from this software 
+   3. Neither the name of the ISCAS nor the names of its contributors may
+      be used to endorse or promote products derived from this software
       without specific prior written permission.
 
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
-SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
-OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
 USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 **********************************************************************************/
@@ -34,7 +34,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 void test_dswap_inc_0(void)
 {
-       int i;
+       int i=0;
        int N=4,incX=0,incY=0;
        double x1[]={1.0,3.0,5.0,7.0};
        double y1[]={2.0,4.0,6.0,8.0};
@@ -54,9 +54,8 @@ void test_dswap_inc_0(void)
 
 void test_zswap_inc_0(void)
 {
-       int i;
+       int i=0;
        int N=4,incX=0,incY=0;
-       double c=0.25,s=0.5;
        double x1[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
        double y1[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
        double x2[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
@@ -67,7 +66,7 @@ void test_zswap_inc_0(void)
        //reference
        BLASFUNC_REF(zswap)(&N,x2,&incX,y2,&incY);
 
-       for(i=0; i<N; i++){
+       for(i=0; i<2*N; i++){
                CU_ASSERT_DOUBLE_EQUAL(x1[i], x2[i], CHECK_EPS);
                CU_ASSERT_DOUBLE_EQUAL(y1[i], y2[i], CHECK_EPS);
        }
@@ -75,9 +74,8 @@ void test_zswap_inc_0(void)
 
 void test_sswap_inc_0(void)
 {
-       int i;
+       int i=0;
        int N=4,incX=0,incY=0;
-
        float x1[]={1.0,3.0,5.0,7.0};
        float y1[]={2.0,4.0,6.0,8.0};
        float x2[]={1.0,3.0,5.0,7.0};
@@ -96,9 +94,8 @@ void test_sswap_inc_0(void)
 
 void test_cswap_inc_0(void)
 {
-       int i;
+       int i=0;
        int N=4,incX=0,incY=0;
-       float c=0.25,s=0.5;
        float x1[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
        float y1[]={2.0,4.0,6.0,8.0,2.0,4.0,6.0,8.0};
        float x2[]={1.0,3.0,5.0,7.0,1.0,3.0,5.0,7.0};
@@ -109,7 +106,7 @@ void test_cswap_inc_0(void)
        //reference
        BLASFUNC_REF(cswap)(&N,x2,&incX,y2,&incY);
 
-       for(i=0; i<N; i++){
+       for(i=0; i<2*N; i++){
                CU_ASSERT_DOUBLE_EQUAL(x1[i], x2[i], CHECK_EPS);
                CU_ASSERT_DOUBLE_EQUAL(y1[i], y2[i], CHECK_EPS);
        }