IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7787


Ignore:
Timestamp:
Jul 1, 2006, 12:53:04 PM (20 years ago)
Author:
jhoblitt
Message:

add psVectorGet() & psVectorSet() tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/mathtypes/tap_psVector.c

    r7786 r7787  
    55int main (void)
    66{
    7     plan_tests(122);
     7    plan_tests(127);
    88
    99    diag("psVectorAlloc() tests");
     
    328328    }
    329329
     330
     331    diag("psVectorSet() tests");
     332
     333    {
     334        psVector *vec = psVectorAlloc(5, PS_TYPE_S32);
     335        vec->n = 0;
     336
     337        ok(psVectorSet(vec, 0, 10),
     338           "VectorSet set S32 at position 0");
     339
     340        psFree(vec);
     341    }
     342
     343    {
     344        psVector *vec = psVectorAlloc(5, PS_TYPE_S32);
     345        vec->n = 0;
     346
     347        ok(!psVectorSet(vec, 10, 10),
     348           "VectorSet failes to set S32 at out of range position");
     349
     350        psFree(vec);
     351    }
     352
     353    {
     354        psVector *vec = psVectorAlloc(5, PS_TYPE_S32);
     355        vec->n = 0;
     356
     357        ok(psVectorSet(vec, 1, 4),
     358           "VectorSet set S32 at position 1");
     359
     360        psFree(vec);
     361    }
     362
     363
     364    diag("psVectorGet() tests");
     365
     366    {
     367        psVector *vec = psVectorAlloc(10, PS_TYPE_S32);
     368        vec->n = 0;
     369        psVectorSet(vec, 0, 10);
     370
     371        ok((psS32)psVectorGet(vec, 0) == 10,
     372           "VectorGet returned the correct S32 from position 0");
     373
     374        psFree(vec);
     375    }
     376
     377    {
     378        psVector *vec = psVectorAlloc(5, PS_TYPE_S32);
     379        vec->n = 0;
     380        psVectorSet(vec, -1, 4);
     381
     382        ok((psS32)psVectorGet(vec, -1) == 4,
     383           "VectorGet returned the correct S32 from tail using -1");
     384
     385        psFree(vec);
     386    }
     387
    330388    return exit_status();
    331389}
    332390
    333391# if 0
    334 psS32 testVectorGetSet(void)
    335 {
    336     psVector *vec = NULL;
    337     vec = psVectorAlloc(5, PS_TYPE_S32);
    338     vec->n = 0;
    339 
    340     if ( !psVectorSet(vec, 0, 10) ) {
    341         fprintf(stderr, "VectorSet failed to set S32 at position 0\n");
    342     }
    343     psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
    344     if ( psVectorSet(vec, 10, 10) ) {
    345         fprintf(stderr, "VectorSet Improperly set S32 at out of range position\n");
    346     }
    347     if ( !psVectorSet(vec, 1, 4) ) {
    348         fprintf(stderr, "VectorSet Failed to set S32 at position 1\n");
    349     }
    350     if ( (psS32)psVectorGet(vec, 0) != 10 ) {
    351         fprintf(stderr,
    352                 "VectorGet Failed to return the correct S32 from position 0\n");
    353     }
    354     if ( (psS32)psVectorGet(vec, -1) != 4 ) {
    355         fprintf(stderr,
    356                 "VectorGet Failed to return the correct S32 from tail using -1\n");
    357     }
    358 
    359     psFree(vec);
    360     return 0;
    361 }
    362392
    363393psS32 testVectorCountPixelMask(void)
Note: See TracChangeset for help on using the changeset viewer.