IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 23, 2005, 2:19:51 PM (21 years ago)
Author:
desonia
Message:

changed psMatrix tests so that functions return NULL on error.

Location:
trunk/psLib/test/dataManip
Files:
4 edited

Legend:

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

    r3264 r3313  
    1212 *  @author  Ross Harman, MHPCC
    1313 *
    14  *  @version $Revision: 1.5 $  $Name: not supported by cvs2svn $
    15  *  @date  $Date: 2005-02-17 19:26:25 $
     14 *  @version $Revision: 1.6 $  $Name: not supported by cvs2svn $
     15 *  @date  $Date: 2005-02-24 00:19:51 $
    1616 *
    1717 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3232
    3333    // Test A - Input pointer same as output pointer
    34     printNegativeTestHeader(stdout,"psMatrix", "Input pointer same as output pointer",
    35                             "Invalid operation: Pointer to inImage is same as outImage.", 0);
    36     psMatrixTranspose(inImage, inImage);
     34    printPositiveTestHeader(stdout,"psMatrix", "Input pointer same as output pointer");
     35    psMemIncrRefCounter(inImage);
     36    if (psMatrixTranspose(inImage, inImage) != NULL) {
     37        psError(PS_ERR_UNKNOWN, true,
     38                "inImage = outImage didn't results in NULL return");
     39        return 1;
     40    }
     41    if (psMemGetRefCounter(inImage) != 1) {
     42        psError(PS_ERR_UNKNOWN, true,
     43                "the output image was not freed on an error.");
     44        return 2;
     45    }
    3746    printFooter(stdout, "psMatrix", "Input pointer same as output pointer", true);
    3847
    3948    // Test B - Null input psImage
    40     printNegativeTestHeader(stdout,"psMatrix", "Null input psImage",
    41                             "Invalid operation: inImage or its data is NULL.", 0);
    42     psMatrixTranspose(outImage, nullImage);
     49    printPositiveTestHeader(stdout,"psMatrix", "Null input psImage");
     50    psMemIncrRefCounter(outImage);
     51    if (psMatrixTranspose(outImage, nullImage) != NULL) {
     52        psError(PS_ERR_UNKNOWN, true,
     53                "inImage = outImage didn't results in NULL return");
     54        return 3;
     55    }
     56    if (psMemGetRefCounter(outImage) != 1) {
     57        psError(PS_ERR_UNKNOWN, true,
     58                "the output image was not freed on an error.");
     59        return 4;
     60    }
    4361    printFooter(stdout, "psMatrix", "Null input psImage", true);
    4462
    4563    // Test C - Incorrect type for input pointer
    46     printNegativeTestHeader(stdout,"psMatrix", "Incorrect type for input pointer",
    47                             "|Invalid operation: inImage not PS_TYPE_F64.", 0);
    48     psMatrixTranspose(outImage, badImage1);
     64    printPositiveTestHeader(stdout,"psMatrix", "Incorrect type for input pointer");
     65    psMemIncrRefCounter(outImage);
     66    if (psMatrixTranspose(outImage, badImage1) != NULL) {
     67        psError(PS_ERR_UNKNOWN, true,
     68                "inImage = outImage didn't results in NULL return");
     69        return 5;
     70    }
     71    if (psMemGetRefCounter(outImage) != 1) {
     72        psError(PS_ERR_UNKNOWN, true,
     73                "the output image was not freed on an error.");
     74        return 6;
     75    }
    4976    printFooter(stdout, "psMatrix", "Incorrect type for input pointer", true);
    5077
    5178    // Test D - Incorrect type for output pointer
    52     printNegativeTestHeader(stdout,"psMatrix", "Incorrect type for output pointer",
    53                             "Invalid operation: outImage not PS_TYPE_F64.", 0);
    54     psMatrixTranspose(badImage1, inImage);
     79    printPositiveTestHeader(stdout,"psMatrix", "Incorrect type for output pointer");
     80    badImage1 = psMatrixTranspose(badImage1, inImage);
     81    if (badImage1 == NULL) {
     82        psError(PS_ERR_UNKNOWN, true,
     83                "inImage = outImage didn't results in NULL return");
     84        return 7;
     85    }
     86    // check that the type was changed.
     87    if (badImage1->type.type != PS_TYPE_F64) {
     88        psError(PS_ERR_UNKNOWN, true,
     89                "the output image was not freed on an error.");
     90        return 8;
     91    }
    5592    printFooter(stdout, "psMatrix", "Incorrect type for output pointer", true);
    5693
    5794    // Test E - Matrix not square for output pointer
    58     printNegativeTestHeader(stdout,"psMatrix", "Matrix not square for output pointer",
    59                             "Invalid operation: outImage not square array.", 0);
     95    printPositiveTestHeader(stdout,"psMatrix", "Matrix not square for output pointer");
    6096    psMatrixTranspose(badImage2, inImage);
    6197    printFooter(stdout, "psMatrix", "Matrix not square for output pointer", true);
  • trunk/psLib/test/dataManip/tst_psMatrix03.c

    r3264 r3313  
    1414 *  @author  Ross Harman, MHPCC
    1515 *
    16  *  @version $Revision: 1.14 $  $Name: not supported by cvs2svn $
    17  *  @date  $Date: 2005-02-17 19:26:25 $
     16 *  @version $Revision: 1.15 $  $Name: not supported by cvs2svn $
     17 *  @date  $Date: 2005-02-24 00:19:51 $
    1818 *
    1919 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    148148    printFooter(stdout, "psMatrix", "Calculate LU matrix", true);
    149149
    150 
    151150    // Test C - Determine solution to matrix equation
    152151    printPositiveTestHeader(stdout, "psMatrix", "Determine solution to matrix equation");
     
    208207    psVector *vectorBadOut = (psVector*)psVectorAlloc(3, PS_TYPE_F64);
    209208    psVector *permBad = (psVector*)psVectorAlloc(3, PS_TYPE_F64);
     209    imageTest = (psImage*)psImageAlloc(3, 3, PS_TYPE_F64);
    210210    psMatrixLUSolve(vectorBadOut, imageTest, vectorBad, permBad);
    211211    printFooter(stdout, "psMatrix", "Attempt to use null input vector argument", true);
     
    215215    printNegativeTestHeader(stdout,"psMatrix", "Attempt to use null LU image argument",
    216216                            "Invalid operation: inImage or its data is NULL.", 0);
     217    vectorBadOut = (psVector*)psVectorAlloc(3, PS_TYPE_F64);
    217218    psMatrixLUSolve(vectorBadOut, NULL, vectorBad, permBad);
    218219    printFooter(stdout, "psMatrix", "Attempt to use null LU image argument", true);
    219220
     221    psFree(permBad);
     222    psFree(imageTest);
     223
     224    if( psMemCheckLeaks(0, NULL, stdout, false) ) {
     225        psError(PS_ERR_UNKNOWN,true,"Memory leaks detected");
     226        return 10;
     227    }
     228    nBad = psMemCheckCorruption(0);
     229    if(nBad) {
     230        printf("ERROR: Found %d bad memory blocks\n", nBad);
     231    }
     232
    220233    return 0;
    221234}
  • trunk/psLib/test/dataManip/tst_psMatrix07.c

    r3291 r3313  
    1616 *  @author  Ross Harman, MHPCC
    1717 *
    18  *  @version $Revision: 1.10 $  $Name: not supported by cvs2svn $
    19  *  @date  $Date: 2005-02-19 00:43:32 $
     18 *  @version $Revision: 1.11 $  $Name: not supported by cvs2svn $
     19 *  @date  $Date: 2005-02-24 00:19:51 $
    2020 *
    2121 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    245245                            "Invalid operation: inVector or its data is NULL.", 0);
    246246    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
    247     if(psVectorToMatrix(m2, NULL) != m2) {
     247    if(psVectorToMatrix(m2, NULL) != NULL) {
    248248        psError(PS_ERR_UNKNOWN,true,"Did not return output image");
    249249        return 12;
    250250    }
    251251    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
    252     if(psVectorToMatrix(m2_32, NULL) != m2_32) {
     252    if(psVectorToMatrix(m2_32, NULL) != NULL) {
    253253        psError(PS_ERR_UNKNOWN,true,"Did not return output image");
    254254        return 13;
     
    288288    psFree(m1);
    289289    psFree(v1);
    290     psFree(m2);
    291290    psFree(v2);
    292291    psFree(v3);
     
    295294    psFree(m1_32);
    296295    psFree(v1_32);
    297     psFree(m2_32);
    298296    psFree(v2_32);
    299297    psFree(v3_32);
  • trunk/psLib/test/dataManip/verified/tst_psMatrix02.stdout

    r2678 r3313  
    22*             TestFile: tst_psMatrix02.c                                           *
    33*            TestPoint: psMatrix{Input pointer same as output pointer}             *
    4 *             TestType: Negative                                                   *
    5 *    ExpectedErrorText: Invalid operation: Pointer to inImage is same as outImage. *
    6 *  ExpectedStatusValue: 0                                                          *
     4*             TestType: Positive                                                   *
    75\**********************************************************************************/
    86
     
    1311*             TestFile: tst_psMatrix02.c                                           *
    1412*            TestPoint: psMatrix{Null input psImage}                               *
    15 *             TestType: Negative                                                   *
    16 *    ExpectedErrorText: Invalid operation: inImage or its data is NULL.            *
    17 *  ExpectedStatusValue: 0                                                          *
     13*             TestType: Positive                                                   *
    1814\**********************************************************************************/
    1915
     
    2420*             TestFile: tst_psMatrix02.c                                           *
    2521*            TestPoint: psMatrix{Incorrect type for input pointer}                 *
    26 *             TestType: Negative                                                   *
    27 *    ExpectedErrorText: |Invalid operation: inImage not PS_TYPE_F64.               *
    28 *  ExpectedStatusValue: 0                                                          *
     22*             TestType: Positive                                                   *
    2923\**********************************************************************************/
    3024
     
    3529*             TestFile: tst_psMatrix02.c                                           *
    3630*            TestPoint: psMatrix{Incorrect type for output pointer}                *
    37 *             TestType: Negative                                                   *
    38 *    ExpectedErrorText: Invalid operation: outImage not PS_TYPE_F64.               *
    39 *  ExpectedStatusValue: 0                                                          *
     31*             TestType: Positive                                                   *
    4032\**********************************************************************************/
    4133
     
    4638*             TestFile: tst_psMatrix02.c                                           *
    4739*            TestPoint: psMatrix{Matrix not square for output pointer}             *
    48 *             TestType: Negative                                                   *
    49 *    ExpectedErrorText: Invalid operation: outImage not square array.              *
    50 *  ExpectedStatusValue: 0                                                          *
     40*             TestType: Positive                                                   *
    5141\**********************************************************************************/
    5242
Note: See TracChangeset for help on using the changeset viewer.