IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 7, 2004, 10:25:03 AM (22 years ago)
Author:
harman
Message:

Added more tests

File:
1 edited

Legend:

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

    r798 r897  
    88 *     C)  Calculate determinant only
    99 *     D)  Free input and output images
    10  *
     10 *     E)  Attempt to use null input image argument
     11 *     F)  Attempt to use null input float argument
     12 * 
    1113 *  @author  Ross Harman, MHPCC
    1214 *
    13  *  @version $Revision: 1.1 $  $Name: not supported by cvs2svn $
    14  *  @date  $Date: 2004-05-28 02:52:23 $
     15 *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
     16 *  @date  $Date: 2004-06-07 20:25:03 $
    1517 *
    1618 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2224
    2325#define PRINT_MATRIX(IMAGE)                         \
    24 for(int i=IMAGE->numRows-1; i>-1; i--) {        \
    25     for(int j=0; j<IMAGE->numCols; j++) {       \
    26         printf("%f ", IMAGE->data.F64[i][j]);   \
    27     }                                          \
    28     printf("\n");                              \
     26for(int i=IMAGE->numRows-1; i>-1; i--) {            \
     27    for(int j=0; j<IMAGE->numCols; j++) {           \
     28        printf("%f ", IMAGE->data.F64[i][j]);       \
     29    }                                               \
     30    printf("\n");                                   \
    2931}
    3032
     
    3436{
    3537    float det = 0.0f;
     38    float *det2 = NULL;
    3639    psImage *outImage = NULL;
    3740    psImage *inImage = NULL;
     41    psImage *tempImage = NULL;
    3842
    3943
     
    5761    // Test B - Invert matrix and calculate determinant
    5862    printPositiveTestHeader(stdout, "psMatrix", "Invert matrix and calculate determinant");
    59     psMatrixInvert(outImage, inImage, &det);
     63    tempImage = outImage;
     64    outImage = psMatrixInvert(outImage, inImage, &det);
    6065    PRINT_MATRIX(outImage);
    6166    printf("\ndet = %f\n", det);
     67    if(outImage->type.dimen != PS_DIMEN_IMAGE) {
     68        printf("Error: Resulting image is not PS_DIMEN_IMAGE\n");
     69    } else if(outImage != tempImage) {
     70        printf("Error: Return pointer not equal to output argument pointer\n");
     71    }
    6272    printFooter(stdout, "psMatrix", "Invert matrix and calculate determinant", true);
    6373
     
    6575    // Test C - Calculate determinant only
    6676    printPositiveTestHeader(stdout, "psMatrix", "Calculate determinant only");
    67     det = 0.0f;
    68     det = psMatrixDeterminant(inImage);
    69     printf("det = %f\n", det);
     77    det2 = psMatrixDeterminant(inImage);
     78    printf("det = %f\n", *det2);
    7079    printFooter(stdout, "psMatrix", "Calculate determinant only", true);
    7180
     
    7584    psImageFree(outImage);
    7685    psImageFree(inImage);
     86    psFree(det2);
    7787    psMemCheckLeaks(0, NULL, stdout);
    7888    int nBad = psMemCheckCorruption(0);
     
    8292    printFooter(stdout, "psMatrix" ,"Free input and output images", true);
    8393
     94
     95    // Test E - Attempt to use null input image argument
     96    printNegativeTestHeader(stdout,"psMatrix", "Attempt to use null input image argument",
     97                            "Invalid operation: inImage or its data is NULL.", 0);
     98    psImage *badOutImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_F64);
     99    psMatrixInvert(badOutImage, NULL, &det);
     100    printFooter(stdout, "psMatrix", "Attempt to use null input image argument", true);
     101
     102
     103    // Test F - Attempt to use null input float argument
     104    printNegativeTestHeader(stdout,"psMatrix", "Attempt to use null input float argument",
     105                            "Invalid operation: determinant argument is NULL.", 0);
     106    psImage *badInImage = (psImage*)psImageAlloc(3, 3, PS_TYPE_F64);
     107    psMatrixInvert(badOutImage, badInImage, NULL);
     108    printFooter(stdout, "psMatrix", "Attempt to use null input float argument", true);
     109
    84110    return 0;
    85111}
Note: See TracChangeset for help on using the changeset viewer.