IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 3007


Ignore:
Timestamp:
Jan 14, 2005, 2:55:15 PM (22 years ago)
Author:
evanalst
Message:

Add addition test cases.

File:
1 edited

Legend:

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

    r2995 r3007  
    5252        testStatus = false;
    5353    }
    54 
     54    if (myRNG->type != PS_RANDOM_TAUS) {
     55        psError(PS_ERR_UNKNOWN,true,"Did not have the expected type");
     56        testStatus = false;
     57    }
     58    psFree(myRNG);
     59
     60    // Valid type allocation with seed equal to zero
     61    myRNG = psRandomAlloc(PS_RANDOM_TAUS, 0);
     62    if (myRNG == NULL) {
     63        printf("ERROR: Could not allocate psRandom structure\n");
     64        testStatus = false;
     65    }
    5566    if (myRNG->type != PS_RANDOM_TAUS) {
    5667        psError(PS_ERR_UNKNOWN,true,"Did not have the expected type");
     
    130141    psFree(rans);
    131142    psFree(stats);
     143
     144    psLogMsg(__func__,PS_LOG_INFO,"NULL psRandom variable, should generate error message");
     145    if(psRandomUniform(NULL) != 0) {
     146        psError(PS_ERR_UNKNOWN,true,"Did not return zero for null psRandom");
     147        testStatus = false;
     148    }
     149
    132150    psMemCheckCorruption(1);
    133151    memLeaks = psMemCheckLeaks(currentId,NULL,stderr,false);
     
    184202    psFree(rans);
    185203    psFree(stats);
     204
     205    psLogMsg(__func__,PS_LOG_INFO,"NULL psRandom variable, should generate error message");
     206    if(psRandomGaussian(NULL) != 0) {
     207        psError(PS_ERR_UNKNOWN,true,"Did not return zero for null psRandom");
     208        testStatus = false;
     209    }
     210
    186211    psMemCheckCorruption(1);
    187212    memLeaks = psMemCheckLeaks(currentId,NULL,stderr,false);
     
    239264    psFree(rans);
    240265    psFree(stats);
     266
     267    psLogMsg(__func__,PS_LOG_INFO,"NULL psRandom variable, should generate error message");
     268    if(psRandomPoisson(NULL, POISSON_MEAN) != 0) {
     269        psError(PS_ERR_UNKNOWN,true,"Did not return zero for null psRandom");
     270        testStatus = false;
     271    }
     272
    241273    psMemCheckCorruption(1);
    242274    memLeaks = psMemCheckLeaks(currentId,NULL,stderr,false);
     
    294326    psFree(rans01);
    295327    psFree(rans02);
     328
     329    psRandom *myRNG1 = NULL;
     330    myRNG1 = psRandomAlloc(PS_RANDOM_TAUS, SEED);
     331    psRandomReset(myRNG1,0);
     332    psFree(myRNG1);
     333
     334    psLogMsg(__func__,PS_LOG_INFO,"Reset a NULL psRandom variable, should generate an error message");
     335    psRandomReset(NULL,SEED);
     336
    296337    psMemCheckCorruption(1);
    297338    memLeaks = psMemCheckLeaks(currentId,NULL,stderr,false);
Note: See TracChangeset for help on using the changeset viewer.