IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 14, 2005, 10:35:04 AM (22 years ago)
Author:
evanalst
Message:

Add additional test case for psRandomAlloc.

File:
1 edited

Legend:

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

    r2780 r2995  
    4646                            "psRandomAlloc()");
    4747
    48     myRNG = psRandomAlloc(PS_RANDOM_TAUS, SEED);
    49     if (myRNG == NULL) {
    50         printf("ERROR: Could not allocate psRandom structure\n");
    51         testStatus = false;
    52     }
    53 
    54     psMemCheckCorruption(1);
    55     psFree(myRNG);
    56     psMemCheckCorruption(1);
    57     memLeaks = psMemCheckLeaks(currentId,NULL,stderr,false);
    58     if (0 != memLeaks) {
    59         psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
     48    // Valid type allocation
     49    myRNG = psRandomAlloc(PS_RANDOM_TAUS, SEED);
     50    if (myRNG == NULL) {
     51        printf("ERROR: Could not allocate psRandom structure\n");
     52        testStatus = false;
     53    }
     54
     55    if (myRNG->type != PS_RANDOM_TAUS) {
     56        psError(PS_ERR_UNKNOWN,true,"Did not have the expected type");
     57        testStatus = false;
     58    }
     59    psFree(myRNG);
     60
     61    // Invalid type allocation
     62    psLogMsg(__func__,PS_LOG_INFO,"Invalid type, should generate error message");
     63    myRNG = psRandomAlloc(100,SEED);
     64    if (myRNG != NULL) {
     65        psError(PS_ERR_UNKNOWN,true,"Did not return NULL for invalid type");
     66        testStatus = false;
     67    }
     68
     69    // Negative seed value
     70    myRNG = psRandomAlloc(PS_RANDOM_TAUS,-5);
     71    if(myRNG == NULL) {
     72        psError(PS_ERR_UNKNOWN,true,"Did not return allocated psRandom");
     73        testStatus = false;
     74    }
     75    psFree(myRNG);
     76
     77    psMemCheckCorruption(1);
     78    memLeaks = psMemCheckLeaks(currentId,NULL,stderr,false);
     79    if (0 != memLeaks) {
     80        printf("ERROR: Memory Leaks! (%d leaks)", memLeaks);
     81        testStatus = false;
    6082    }
    6183
Note: See TracChangeset for help on using the changeset viewer.