IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 2677


Ignore:
Timestamp:
Dec 9, 2004, 11:33:04 AM (22 years ago)
Author:
evanalst
Message:

Updated test cases and added additional ones to provide more coverage.

Location:
trunk/psLib/test/collections
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/collections/tst_psVectorSort_02.c

    r2392 r2677  
    66 *     A)  Create vectors
    77 *     B)  Sort integer vector of indices based on pre-sort order of floating point vector
    8  *     C)  Free vectors
     8 *     C)  Attempt to sort with null input vector
     9 *     D)  Sort with output vector which needs to be resized
     10 *     E)  Sort input vector with zero elements
     11 *     F)  Attempt to sort input vector with invalid type
     12 *     G)  Free vectors
    913 *
    1014 *  @author  Ross Harman, MHPCC
    1115 *
    12  *  @version $Revision: 1.5 $  $Name: not supported by cvs2svn $
    13  *  @date  $Date: 2004-11-22 21:07:42 $
     16 *  @version $Revision: 1.6 $  $Name: not supported by cvs2svn $
     17 *  @date  $Date: 2004-12-09 21:33:04 $
    1418 *
    1519 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2024#include "psTest.h"
    2125
     26#define tstVectorSortIndexByType(datatype,value) \
     27in = psVectorAlloc( 5, PS_TYPE_##datatype ); \
     28in->n = 5; \
     29in->data.datatype[0] = 7+value; \
     30in->data.datatype[1] = 9+value; \
     31in->data.datatype[2] = 5+value; \
     32in->data.datatype[3] = 1+value; \
     33in->data.datatype[4] = 5+value; \
     34out = psVectorSortIndex(out,in); \
     35if(out->type.type != PS_TYPE_U32) { \
     36    psError(PS_ERR_UNKNOWN,true,"Output vector is not of type PS_TYPE_U32"); \
     37    return 10; \
     38} \
     39if(out->data.U32[0] != 3 ) { \
     40    psError(PS_ERR_UNKNOWN,true,"Improper index sort out[0] = %ld",out->data.U32[0]); \
     41    return 20; \
     42} \
     43if(out->data.U32[1] != 2 ) { \
     44    psError(PS_ERR_UNKNOWN,true,"Improper index sort out[1] = %ld",out->data.U32[1]); \
     45    return 30; \
     46} \
     47if(out->data.U32[2] != 4 ) { \
     48    psError(PS_ERR_UNKNOWN,true,"Improper index sort out[2] = %ld",out->data.U32[2]); \
     49    return 40; \
     50} \
     51if(out->data.U32[3] != 0 ) { \
     52    psError(PS_ERR_UNKNOWN,true,"Improper index sort out[3] = %ld",out->data.U32[3]); \
     53    return 50; \
     54} \
     55if(out->data.U32[4] != 1 ) { \
     56    psError(PS_ERR_UNKNOWN,true,"Improper index sort out[4] = %ld",out->data.U32[4]); \
     57    return 60; \
     58} \
     59psFree(in);
     60
    2261psS32 main(psS32 argc,
    2362           char* argv[])
     
    2564    psVector *in = NULL;
    2665    psVector *out = NULL;
     66    psVector *tempVect = NULL;
    2767
     68    // Test A - Sort vectors by index for all types
     69    printPositiveTestHeader(stdout,"psVectorSortIndex","Sort by index for all types");
     70    tstVectorSortIndexByType(S8,0)
     71    tstVectorSortIndexByType(U8,1)
     72    tstVectorSortIndexByType(S16,2)
     73    tstVectorSortIndexByType(U16,3)
     74    tstVectorSortIndexByType(S32,4)
     75    tstVectorSortIndexByType(U32,5)
     76    tstVectorSortIndexByType(S64,6)
     77    tstVectorSortIndexByType(U64,7)
     78    tstVectorSortIndexByType(F32,8)
     79    tstVectorSortIndexByType(F64,9)
     80    psFree(out);
     81    printFooter(stdout,"psVectorSortIndex","Sort by index for all types",true);
    2882
    29     // Test A - Create float vectors
    30     printPositiveTestHeader(stdout,"psVectorSortIndex", "Create vectors");
    31     in = psVectorAlloc(5, PS_TYPE_F32);
    32     in->n = 5;
    33     in->data.F32[0] = 7.0f;
    34     in->data.F32[1] = 9.0f;
    35     in->data.F32[2] = 3.0f;
    36     in->data.F32[3] = 1.0f;
    37     in->data.F32[4] = 5.0f;
    38     for(psS32 i=0; i<5; i++) {
    39         printf("arr[%d] = %f\n", i, in->data.F32[i]);
     83    // Test  C  Attempt to sort with null input vector
     84    printPositiveTestHeader(stdout,"psVectorSortIndex","Attempt to sort with NULL input");
     85    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
     86    in = NULL;
     87    out = psVectorAlloc(5,PS_TYPE_U32);
     88    out = psVectorSortIndex(out,in);
     89    if(out != NULL) {
     90        psError(PS_ERR_UNKNOWN,true,"Did not return NULL with NULL input specified");
     91        return 111;
    4092    }
    41     printFooter(stdout, "psVectorSortIndex", "Create vectors", true);
     93    printFooter(stdout,"psVectorSortIndex","Attempt to sort with NULL input",true);
    4294
    43 
    44     // Test B - Sort integer vector of indices based on pre-sort order of floating point vector
    45     printPositiveTestHeader(stdout,"psVectorSortIndex", "Create sorted index vector");
    46     out = psVectorSortIndex(out, in);
    47     for(psS32 i=0; i<5; i++) {
    48         printf("arr[%d] = %d\n", i, out->data.U32[i]);
     95    // Test  D  Sort with output vector which needs to be resized
     96    printPositiveTestHeader(stdout,"psVectorSortIndex","Sort with resize output vector");
     97    in = psVectorAlloc(5,PS_TYPE_U8);
     98    for(psS32 m=0; m<5; m++) {
     99        in->data.U8[m]= 20-m;
    49100    }
    50     printFooter(stdout, "psVectorSortIndex", "Create sorted index vector", true);
    51 
    52     // Test D - Verify the output vector is of type psU32
    53     printPositiveTestHeader(stdout,"psVectorSortIndex", "Verify output vector type");
    54     if(out->type.type != PS_TYPE_U32) {
    55         printf("ERROR: output vector is of type %d\n", out->type.type);
     101    out = psVectorAlloc(3,PS_TYPE_U32);
     102    out = psVectorSortIndex(out,in);
     103    if(out->n != 5) {
     104        psError(PS_ERR_UNKNOWN,true,"Did not properly resize output vector");
     105        return 112;
    56106    }
    57     printFooter(stdout, "psVectorSortIndex", "Verify output vector type", true);
    58 
    59     // Test C - Free vectors
    60     printPositiveTestHeader(stdout,"psVectorSortIndex", "Free vectors");
     107    if(out->data.U32[0] != 4) {
     108        psError(PS_ERR_UNKNOWN,true,"Did not properly sort index out[0] = %d",out->data.U32[0]);
     109        return 113;
     110    }
     111    if(out->data.U32[1] != 3) {
     112        psError(PS_ERR_UNKNOWN,true,"Did not properly sort index out[1] = %d",out->data.U32[1]);
     113        return 114;
     114    }
     115    if(out->data.U32[2] != 2) {
     116        psError(PS_ERR_UNKNOWN,true,"Did not properly sort index out[2] = %d",out->data.U32[2]);
     117        return 115;
     118    }
     119    if(out->data.U32[3] != 1) {
     120        psError(PS_ERR_UNKNOWN,true,"Did not properly sort index out[3] = %d",out->data.U32[3]);
     121        return 116;
     122    }
     123    if(out->data.U32[4] != 0) {
     124        psError(PS_ERR_UNKNOWN,true,"Did not properly sort index out[4] = %d",out->data.U32[4]);
     125        return 117;
     126    }
    61127    psFree(in);
    62128    psFree(out);
     129    printFooter(stdout,"psVectorSortIndex","Sort with resize output vector",true);
     130
     131    // Test E - Sort input vector with zero elements
     132    printPositiveTestHeader(stdout,"psVectorSortIndex","Sort with input vector with zero elements");
     133    in = psVectorAlloc(5,PS_TYPE_U8);
     134    out = psVectorAlloc(5,PS_TYPE_U32);
     135    in->n = 0;
     136    out->n = 0;
     137    tempVect = out;
     138    out = psVectorSortIndex(out,in);
     139    if ( out != tempVect ) {
     140        psError(PS_ERR_UNKNOWN,true,"Did not return the same output vector");
     141        return 118;
     142    }
     143    in->n=5;
     144    out->n=5;
     145    psFree(out);
     146    psFree(in);
     147    printFooter(stdout,"psVectorSortIndex","Sort with input vector with zero elements",true);
     148
     149    // Test F - Attempt to sort input vector with invalid type
     150    printPositiveTestHeader(stdout,"psVectorSortIndex","Attempt to sort with invalid type");
     151    in = psVectorAlloc(5,PS_TYPE_U8);
     152    out = psVectorAlloc(5,PS_TYPE_U32);
     153    tempVect = out;
     154    in->type.type = PS_TYPE_BOOL;
     155    psLogMsg(__func__,PS_LOG_INFO,"Following should generate two error messages(psVectorSort,psVectorSortIndex)");
     156    out = psVectorSortIndex(out,in);
     157    if( out != tempVect) {
     158        psError(PS_ERR_UNKNOWN,true,"Did not return the same output vector");
     159        return 119;
     160    }
     161    in->type.type = PS_TYPE_U8;
     162    psFree(in);
     163    psFree(out);
     164    printFooter(stdout,"psVectorSortIndex","Attempt to sort with invalid type",true);
     165
     166    // Test G - Free vectors
     167    printPositiveTestHeader(stdout,"psVectorSortIndex", "Free vectors");
    63168    psS32 nLeaks = psMemCheckLeaks(0, NULL, stdout, false);
    64169    if(nLeaks) {
    65170        printf("ERROR: Found %d memory leaks\n", nLeaks);
     171        return 222;
    66172    }
    67173    psS32 nBad = psMemCheckCorruption(0);
    68174    if(nBad) {
    69175        printf("ERROR: Found %d bad memory blocks\n", nBad);
     176        return 333;
    70177    }
    71178    printFooter(stdout, "psVectorSort", "Free vectors", true);
  • trunk/psLib/test/collections/verified/tst_psVectorSort_02.stderr

    r2281 r2677  
     1<DATE><TIME>|<HOST>|I|main
     2    Following should generate an error message
    13<DATE><TIME>|<HOST>|E|psVectorSortIndex (psVector.c:<LINENO>)
    2     Input psVector is an unsupported type (0).
     4    psVectorSort can not sort a NULL psVector.
     5<DATE><TIME>|<HOST>|I|main
     6    Following should generate two error messages(psVectorSort,psVectorSortIndex)
     7<DATE><TIME>|<HOST>|E|psVectorSort (psVector.c:<LINENO>)
     8    Input psVector is an unsupported type (4865).
     9<DATE><TIME>|<HOST>|E|psVectorSortIndex (psVector.c:<LINENO>)
     10    Input psVector is an unsupported type (4865).
  • trunk/psLib/test/collections/verified/tst_psVectorSort_02.stdout

    r1912 r2677  
    11/***************************** TESTPOINT ******************************************\
    22*             TestFile: tst_psVectorSort_02.c                                      *
    3 *            TestPoint: psVectorSortIndex{Create vectors}                          *
    4 *             TestType: Positive                                                   *
    5 \**********************************************************************************/
    6 
    7 arr[0] = 7.000000
    8 arr[1] = 9.000000
    9 arr[2] = 3.000000
    10 arr[3] = 1.000000
    11 arr[4] = 5.000000
    12 
    13 ---> TESTPOINT PASSED (psVectorSortIndex{Create vectors} | tst_psVectorSort_02.c)
    14 
    15 /***************************** TESTPOINT ******************************************\
    16 *             TestFile: tst_psVectorSort_02.c                                      *
    17 *            TestPoint: psVectorSortIndex{Create sorted index vector}              *
    18 *             TestType: Positive                                                   *
    19 \**********************************************************************************/
    20 
    21 arr[0] = 0
    22 arr[1] = 0
    23 arr[2] = 0
    24 arr[3] = 0
    25 arr[4] = 0
    26 
    27 ---> TESTPOINT PASSED (psVectorSortIndex{Create sorted index vector} | tst_psVectorSort_02.c)
    28 
    29 /***************************** TESTPOINT ******************************************\
    30 *             TestFile: tst_psVectorSort_02.c                                      *
    31 *            TestPoint: psVectorSortIndex{Verify output vector type}               *
     3*            TestPoint: psVectorSortIndex{Sort by index for all types}             *
    324*             TestType: Positive                                                   *
    335\**********************************************************************************/
    346
    357
    36 ---> TESTPOINT PASSED (psVectorSortIndex{Verify output vector type} | tst_psVectorSort_02.c)
     8---> TESTPOINT PASSED (psVectorSortIndex{Sort by index for all types} | tst_psVectorSort_02.c)
     9
     10/***************************** TESTPOINT ******************************************\
     11*             TestFile: tst_psVectorSort_02.c                                      *
     12*            TestPoint: psVectorSortIndex{Attempt to sort with NULL input}         *
     13*             TestType: Positive                                                   *
     14\**********************************************************************************/
     15
     16
     17---> TESTPOINT PASSED (psVectorSortIndex{Attempt to sort with NULL input} | tst_psVectorSort_02.c)
     18
     19/***************************** TESTPOINT ******************************************\
     20*             TestFile: tst_psVectorSort_02.c                                      *
     21*            TestPoint: psVectorSortIndex{Sort with resize output vector}          *
     22*             TestType: Positive                                                   *
     23\**********************************************************************************/
     24
     25
     26---> TESTPOINT PASSED (psVectorSortIndex{Sort with resize output vector} | tst_psVectorSort_02.c)
     27
     28/***************************** TESTPOINT ******************************************\
     29*             TestFile: tst_psVectorSort_02.c                                      *
     30*            TestPoint: psVectorSortIndex{Sort with input vector with zero elements} *
     31*             TestType: Positive                                                   *
     32\**********************************************************************************/
     33
     34
     35---> TESTPOINT PASSED (psVectorSortIndex{Sort with input vector with zero elements} | tst_psVectorSort_02.c)
     36
     37/***************************** TESTPOINT ******************************************\
     38*             TestFile: tst_psVectorSort_02.c                                      *
     39*            TestPoint: psVectorSortIndex{Attempt to sort with invalid type}       *
     40*             TestType: Positive                                                   *
     41\**********************************************************************************/
     42
     43
     44---> TESTPOINT PASSED (psVectorSortIndex{Attempt to sort with invalid type} | tst_psVectorSort_02.c)
    3745
    3846/***************************** TESTPOINT ******************************************\
Note: See TracChangeset for help on using the changeset viewer.