IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 10, 2004, 11:38:48 AM (22 years ago)
Author:
evanalst
Message:

Update for test failures.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/dataManip/tst_psMatrixVectorArithmetic03.c

    r2273 r2693  
    1515 *  @author  Ross Harman, MHPCC
    1616 *
    17  *  @version $Revision: 1.7 $  $Name: not supported by cvs2svn $
    18  *  @date  $Date: 2004-11-04 01:05:00 $
     17 *  @version $Revision: 1.8 $  $Name: not supported by cvs2svn $
     18 *  @date  $Date: 2004-12-10 21:38:47 $
    1919 *
    2020 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2525#include "psTest.h"
    2626
    27 
    28 #define PRINT_VECTOR(VECTOR,TYPE)                                                                            \
    29 for(psS32 i=0; i<VECTOR->n; i++) {                                                                         \
    30     if(PS_IS_PSELEMTYPE_COMPLEX(VECTOR->type.type)) {                                                    \
    31         printf("%f+%fi ", creal(VECTOR->data.TYPE[i]), cimag(VECTOR->data.TYPE[i]));                     \
    32     } else if(PS_IS_PSELEMTYPE_INT(VECTOR->type.type)) {                                                 \
    33         printf("%d ", (psS32)VECTOR->data.TYPE[i]);                                                        \
    34     } else {                                                                                             \
    35         printf("%f ", (double)VECTOR->data.TYPE[i]);                                                     \
    36     }                                                                                                    \
    37 }                                                                                                        \
     27#define PRINT_VECTOR(VECTOR,TYPE) \
     28for(psS32 i=0; i<VECTOR->n; i++) { \
     29    if(PS_IS_PSELEMTYPE_COMPLEX(VECTOR->type.type)) { \
     30        printf("%f+%fi ", creal(VECTOR->data.TYPE[i]), cimag(VECTOR->data.TYPE[i])); \
     31    } else if(PS_IS_PSELEMTYPE_INT(VECTOR->type.type)) { \
     32        printf("%d ", (psS32)VECTOR->data.TYPE[i]); \
     33    } else { \
     34        printf("%f ", (double)VECTOR->data.TYPE[i]); \
     35    } \
     36} \
    3837printf("\n\n");
    3938
    40 
    41 #define PRINT_MATRIX(IMAGE,TYPE)                                                                             \
    42 for(psS32 i=IMAGE->numRows-1; i>-1; i--) {                                                                 \
    43     for(psS32 j=0; j<IMAGE->numCols; j++) {                                                                \
    44         if(PS_IS_PSELEMTYPE_COMPLEX(IMAGE->type.type)) {                                                 \
    45             printf("%f+%fi ", creal(IMAGE->data.TYPE[i][j]), cimag(IMAGE->data.TYPE[i][j]));             \
    46         } else if(PS_IS_PSELEMTYPE_INT(IMAGE->type.type)) {                                              \
    47             printf("%d ", (psS32)IMAGE->data.TYPE[i][j]);                                                  \
    48         } else {                                                                                         \
    49             printf("%f ", (double)IMAGE->data.TYPE[i][j]);                                               \
    50         }                                                                                                \
    51     }                                                                                                    \
    52     printf("\n");                                                                                        \
    53 }                                                                                                        \
     39#define PRINT_MATRIX(IMAGE,TYPE) \
     40for(psS32 i=IMAGE->numRows-1; i>-1; i--) { \
     41    for(psS32 j=0; j<IMAGE->numCols; j++) { \
     42        if(PS_IS_PSELEMTYPE_COMPLEX(IMAGE->type.type)) { \
     43            printf("%f+%fi ", creal(IMAGE->data.TYPE[i][j]), cimag(IMAGE->data.TYPE[i][j])); \
     44        } else if(PS_IS_PSELEMTYPE_INT(IMAGE->type.type)) { \
     45            printf("%d ", (psS32)IMAGE->data.TYPE[i][j]); \
     46        } else { \
     47            printf("%f ", (double)IMAGE->data.TYPE[i][j]); \
     48        } \
     49    } \
     50    printf("\n"); \
     51} \
    5452printf("\n");
    5553
    5654
    57 #define CREATE_AND_SET_VECTOR(NAME,TYPE,VALUE,SIZE)                                                          \
    58 psVector *NAME = (psVector*)psVectorAlloc(SIZE, PS_TYPE_##TYPE);                                         \
    59 for(psS32 i=0; i<SIZE; i++) {                                                                              \
    60     NAME->data.TYPE[i] = VALUE;                                                                          \
    61 }                                                                                                        \
     55#define CREATE_AND_SET_VECTOR(NAME,TYPE,VALUE,SIZE) \
     56psVector *NAME = (psVector*)psVectorAlloc(SIZE, PS_TYPE_##TYPE); \
     57for(psS32 i=0; i<SIZE; i++) { \
     58    NAME->data.TYPE[i] = VALUE; \
     59} \
    6260NAME->n = SIZE;
    6361
    6462
    65 #define CREATE_AND_SET_IMAGE(NAME,TYPE,VALUE,NROWS,NCOLS)                                                    \
    66 psImage *NAME = (psImage*)psImageAlloc(NCOLS,NROWS,PS_TYPE_##TYPE);                                      \
    67 for(psS32 i=0; i<NAME->numRows; i++) {                                                                     \
    68     for(psS32 j=0; j<NAME->numCols; j++) {                                                                 \
    69         NAME->data.TYPE[i][j] = VALUE;                                                                   \
    70     }                                                                                                    \
     63#define CREATE_AND_SET_IMAGE(NAME,TYPE,VALUE,NROWS,NCOLS) \
     64psImage *NAME = (psImage*)psImageAlloc(NCOLS,NROWS,PS_TYPE_##TYPE); \
     65for(psS32 i=0; i<NAME->numRows; i++) { \
     66    for(psS32 j=0; j<NAME->numCols; j++) { \
     67        NAME->data.TYPE[i][j] = VALUE; \
     68    } \
    7169}
    7270
     
    8280    CREATE_AND_SET_VECTOR(vector2,F64,0,3);
    8381
    84 
    85     // Check for NULL arguments
    86     printNegativeTestHeader(stdout,"psMatrixVectorArithmetic", "Check for NULL arguments",
    87                             "Null XXX argument", 0);
     82    // Check for NULL output argument
     83    printPositiveTestHeader(stdout,"psBinaryOp", "Check for output generated");
    8884    psImage* image6 = (psImage*)psBinaryOp(NULL, image1, "+", image2);
    8985    if (image6 == NULL) {
     
    9187        return 1;
    9288    }
    93 
     89    printFooter(stdout,"psBinaryOp","Check for output generated",true);
     90
     91    // Check for NULL input argument #1
     92    printPositiveTestHeader(stdout,"psBinaryOp","Check for null input arg 1");
     93    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
    9494    image6 = (psImage*)psBinaryOp(image6, NULL, "+", image2);
    9595    if (image6 != NULL) {
     
    9797        return 2;
    9898    }
    99 
     99    printFooter(stdout,"psBinaryOp","Check for null input arg 1",true);
     100
     101    // Check for NULL input argument #2
     102    printPositiveTestHeader(stdout,"psBinaryOp","Check for null input arg 2");
     103    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
    100104    image6 = (psImage*)psBinaryOp(image6, image1, "+", NULL);
    101105    if (image6 != NULL) {
     
    103107        return 3;
    104108    }
     109    printFooter(stdout,"psBinaryOp","Check for null input arg 2",true);
     110
     111    // Check for NULL operand
     112    printPositiveTestHeader(stdout,"psBinaryOp","Check for null operand");
     113    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
    105114    image6 = (psImage*)psBinaryOp(image6, image1, NULL, image2);
    106115    if (image6 != NULL) {
     
    108117        return 4;
    109118    }
    110 
     119    printFooter(stdout,"psBinaryOp","Check for null operand",true);
     120
     121    // Check for null output
     122    printPositiveTestHeader(stdout,"psUnaryOp","Check for null output");
    111123    image6 = (psImage*)psUnaryOp(NULL, image1, "sin");
    112124    if (image6 == NULL) {
     
    114126        return 5;
    115127    }
    116 
     128    printFooter(stdout,"psUnaryOp","Check for null output",true);
     129
     130    // Check for NULL input arg
     131    printPositiveTestHeader(stdout,"psUnaryOp","Check for null input");
     132    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
    117133    image6 = (psImage*)psUnaryOp(image6, NULL, "sin");
    118134    if (image6 != NULL) {
     
    120136        return 6;
    121137    }
    122 
     138    printFooter(stdout,"psUnaryOp","Check for null input",true);
     139
     140    // Check for NULL operand
     141    printPositiveTestHeader(stdout,"psUnaryOp","Check for null operator");
     142    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
    123143    image6 = (psImage*)psUnaryOp(image6, image1, NULL);
    124144    if (image6 != NULL) {
     
    126146        return 7;
    127147    }
    128 
    129     printFooter(stdout, "psMatrixVectorArithmetic", "Check for NULL arguments", true);
     148    printFooter(stdout,"psUnaryOp","Check for null operator",true);
    130149
    131150    // Inconsistent element types
    132     printNegativeTestHeader(stdout,"psMatrixVectorArithmetic", "Inconsistent element types",
    133                             "Element types for arguments inconsistent", 0);
     151    printPositiveTestHeader(stdout,"psBinaryOp", "Inconsistent element types");
     152    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
    134153    image6 = (psImage*)psBinaryOp(image6, image3, "+", image2);
    135154    if (image6 != NULL) {
     
    137156        return 8;
    138157    }
    139 
     158    printFooter(stdout,"psBinaryOp","Inconsistent element types",true);
     159
     160    // Check unary op to convert to correct type
     161    printPositiveTestHeader(stdout,"psUnaryOp","Check output type conversion");
    140162    image6 = psImageCopy(image6,image2,PS_TYPE_F64);
    141163    image6 = (psImage*)psUnaryOp(image6, image3, "sin");
     
    144166        return 9;
    145167    }
    146 
    147     printFooter(stdout, "psMatrixVectorArithmetic", "Inconsistent element types", true);
    148 
     168    printFooter(stdout,"psUnaryOp","Check output type conversion",true);
    149169
    150170    // Inconsistent element count
    151     printNegativeTestHeader(stdout,"psMatrixVectorArithmetic", "Inconsistent element count",
    152                             "Inconsistent element count", 0);
     171    printPositiveTestHeader(stdout,"psBinaryOp","Check for inconsistent elements");
     172    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
    153173    image6 = (psImage*)psBinaryOp(image6, image4, "+", image2);
    154174    if (image6 != NULL) {
     
    156176        return 10;
    157177    }
    158 
     178    printFooter(stdout,"psBinaryOp","Check for inconsistent elements",true);
     179
     180    // Inconsistent element in input and output
     181    printPositiveTestHeader(stdout,"psUnaryOp","Check inconsistent elements in input and output");
    159182    image6 = psImageCopy(image6,image2,PS_TYPE_F64);
    160183    image6 = (psImage*)psUnaryOp(image6, image4, "sin");
     
    165188        return 11;
    166189    }
    167 
     190    printFooter(stdout,"psUnaryOp","Check inconsistent elements in input and output",true);
     191
     192    // Inconsistent size of input 1 and input 2
     193    printPositiveTestHeader(stdout,"psBinaryOp","Check inconsistent size");
     194    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
    168195    image6 = (psImage*)psBinaryOp(image6, vector1, "+", image2);
    169196    if (image6 != NULL) {
     
    171198        return 12;
    172199    }
    173 
     200    printFooter(stdout,"psBinaryOp","Check inconsistent size",true);
     201
     202    // Inconsistent size of input 1 and input 2
     203    printPositiveTestHeader(stdout,"psBinaryOp","Check inconsistent size");
     204    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
    174205    vector1->type.dimen = PS_DIMEN_TRANSV;
    175206    image6 = (psImage*)psBinaryOp(image6, vector1, "+", image2);
     
    178209        return 13;
    179210    }
    180     printFooter(stdout, "psMatrixVectorArithmetic", "Inconsistent element count", true);
     211    printFooter(stdout, "psBinaryOp", "Check inconsistent size", true);
    181212
    182213
    183214    // Inconsistent dimensionality
    184     printNegativeTestHeader(stdout,"psMatrixVectorArithmetic", "Inconsistent dimensionality",
    185                             "Dimensionality for arguments inconsistent", 0);
     215    printPositiveTestHeader(stdout,"psUnaryOp","Check inconsistent dimensionality");
    186216    image6 = psImageCopy(image6,image2,PS_TYPE_F64);
     217    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an two error messages");
    187218    image6 = (psImage*)psUnaryOp(image6, vector2, "sin");
    188219    if (image6 != NULL) {
     
    190221        return 14;
    191222    }
    192 
    193     printFooter(stdout, "psMatrixVectorArithmetic", "Inconsistent dimensionality", true);
     223    printFooter(stdout,"psUnaryOp","Check inconsistent dimensionality",true);
    194224
    195225    // Attempt to use min with complex numbers
    196     printNegativeTestHeader(stdout,"psMatrixVectorArithmetic", "Use min with complex numbers",
    197                             "Minimum operation not supported for complex numbers", 0);
     226    printPositiveTestHeader(stdout,"psBinaryOp","Attempt to use min with complex numbers");
     227    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
    198228    image6 = (psImage*)psBinaryOp(image6, image5, "min", image5);
    199     printFooter(stdout, "psMatrixVectorArithmetic", "Use min with complex numbers", true);
     229    if(image6 != NULL) {
     230        psLogMsg(__func__,PS_LOG_ERROR,"psUnaryOp returned result with min of complex numbers");
     231        return 15;
     232    }
     233    printFooter(stdout, "psBinaryOp", "Attempt to use  min with complex numbers", true);
    200234
    201235
    202236    // Attempt to use max with complex numbers
    203     printNegativeTestHeader(stdout,"psMatrixVectorArithmetic", "Use max with complex numbers",
    204                             "Maximum operation not supported for complex numbers", 0);
     237    printPositiveTestHeader(stdout,"psBinaryOp","Attempt to use max with complex numbers");
     238    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
    205239    image6 = (psImage*)psBinaryOp(image6, image5, "max", image5);
    206     printFooter(stdout, "psMatrixVectorArithmetic", "Use max with complex numbers", true);
     240    if(image6 != NULL) {
     241        psLogMsg(__func__,PS_LOG_ERROR,"psUnaryOp returned result with max of complex numbers");
     242        return 16;
     243    }
     244    printFooter(stdout, "psBinaryOp", "Attempt to use max with complex numbers", true);
    207245
    208246
    209247    // Invalid operation
    210     printNegativeTestHeader(stdout,"psMatrixVectorArithmetic", "Invalid operation",
    211                             "Invalid operation", 0);
     248    printPositiveTestHeader(stdout,"psBinary","Attempt to use invalid operator");
     249    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error messgae");
    212250    image6 = (psImage*)psBinaryOp(image6, image1, "yarg", image2);
     251    if(image6 != NULL) {
     252        psLogMsg(__func__,PS_LOG_ERROR,"psBinaryOp returned result with invalid operator");
     253        return 17;
     254    }
     255    printFooter(stdout,"psBinaryOp","Attempt to use invalid operator",true);
     256
     257    printPositiveTestHeader(stdout,"psUnaryOp","Attempt to use invalid operator");
     258    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
    213259    image6 = (psImage*)psUnaryOp(image6, image1, "yarg");
    214     printFooter(stdout, "psMatrixVectorArithmetic", "Invalid operation", true);
    215 
    216     // Invalid parameter in2
    217     printNegativeTestHeader(stdout,"psMatrixVectorArithmetic","Invalid input",
    218                             "Invalid operation", 0);
     260    if(image6 != NULL) {
     261        psLogMsg(__func__,PS_LOG_ERROR,"psUnaryOp returned result with invalid operator");
     262        return 18;
     263    }
     264    printFooter(stdout, "psUnaryOp", "Attempt to use invalid operator", true);
     265
    219266    CREATE_AND_SET_VECTOR(vector4,F64,0,3);
    220267    CREATE_AND_SET_VECTOR(vector5,F64,0,3);
    221     CREATE_AND_SET_VECTOR(vector6,F64,0,3);
    222     if ( psBinaryOp(vector6,vector4,"+",NULL) != NULL ) {
    223         psError(PS_ERR_UNKNOWN, true,"psBinaryOp should return null when out and in1 valid but in2 null.");
    224         return 10;
    225     }
    226     printFooter(stdout, "psMatrixVectorArithmetic", "Invalid input", true);
    227 
     268
     269    // Input parameter with dimension of PS_DIMEN_OTHER
     270    printPositiveTestHeader(stdout,"psBinaryOp","Attempt to use input with PS_DIMEN_OTHER");
     271    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
    228272    vector4->type.dimen = PS_DIMEN_OTHER;
    229273    if ( psBinaryOp(NULL,vector4,"+",vector5) != NULL) {
    230274        psError(PS_ERR_UNKNOWN, true,"psBinaryOp should return null when input dimen PS_DIMEN_OTHER.");
    231         return 11;
     275        return 19;
    232276    }
    233277    vector4->type.dimen = PS_DIMEN_VECTOR;
    234 
    235     psScalar* inScalar = psScalarAlloc(0,PS_TYPE_F64);
    236     CREATE_AND_SET_IMAGE(image10,F64,0,3,3);
    237     if ( psBinaryOp(image10,inScalar,"+",vector4) == NULL ) {
    238         psError(PS_ERR_UNKNOWN, true,"psBinaryOp should not return null when input/out dimension don't match.");
    239         return 12;
    240     }
     278    printFooter(stdout,"psBinaryOp","Attempt to use input with PS_DIMEN_OTHER",true);
     279
     280    // Input parameter with dimension of PS_DIMEN_OTHER
     281    printPositiveTestHeader(stdout,"psUnaryOp","Attempt to use input with PS_DIMEN_OTHER");
     282    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
     283    vector4->type.dimen = PS_DIMEN_OTHER;
     284    if ( psUnaryOp(NULL,vector4,"sin") != NULL ) {
     285        psError(PS_ERR_UNKNOWN,true,"psUnaryOp should return null when input dimen PS_DIMEN_OTHER");
     286        return 20;
     287    }
     288    vector4->type.dimen = PS_DIMEN_VECTOR;
     289    printFooter(stdout,"psUnaryOp","Attempt to use input with PS_DIMEN_OTHER",true);
    241290
    242291    psFree(vector4);
    243292    psFree(vector5);
     293    psFree(image1);
     294    psFree(image2);
     295    psFree(image3);
     296    psFree(image4);
     297    psFree(image5);
     298    psFree(vector1);
     299    psFree(vector2);
     300
     301    psS32 nLeaks = psMemCheckLeaks(0,NULL,stdout,false);
     302    if(nLeaks != 0) {
     303        psError(PS_ERR_UNKNOWN,true,"Memory leaks detected");
     304        return 50;
     305    }
     306    psS32 nBad = psMemCheckCorruption(0);
     307    if(nBad) {
     308        psError(PS_ERR_UNKNOWN,true,"Memory corruption detected");
     309        return 51;
     310    }
    244311
    245312    return 0;
Note: See TracChangeset for help on using the changeset viewer.