IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7788


Ignore:
Timestamp:
Jul 1, 2006, 4:54:20 PM (20 years ago)
Author:
jhoblitt
Message:

add psVectorCountPixelMask() tests

File:
1 edited

Legend:

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

    r7787 r7788  
    55int main (void)
    66{
    7     plan_tests(127);
     7    plan_tests(131);
    88
    99    diag("psVectorAlloc() tests");
     
    386386    }
    387387
     388
     389    diag("psVectorCountPixelMask() tests");
     390
     391    {
     392        ok(psVectorCountPixelMask(NULL, 1) == -1,
     393           "psVectorCountPixelMask returned -1 for NULL Vector input.");
     394    }
     395
     396    {
     397        psVector *vec = psVectorAlloc(5, PS_TYPE_S32);
     398        vec->data.S32[0] = 0;
     399        vec->data.S32[1] = 1;
     400        vec->data.S32[2] = 0;
     401        vec->data.S32[3] = 1;
     402        vec->data.S32[4] = 0;
     403        vec->n = 5;
     404
     405        ok(psVectorCountPixelMask(vec, 1) == -1,
     406           "returned -1 for wrong type of Vector input.");
     407
     408        psFree(vec);
     409    }
     410
     411    {
     412        psVector *vec = vec = psVectorAlloc(5, PS_TYPE_U8);
     413        vec->data.U8[0] = 0;
     414        vec->data.U8[1] = 1;
     415        vec->data.U8[2] = 0;
     416        vec->data.U8[3] = 1;
     417        vec->data.U8[4] = 0;
     418        vec->n = 5;
     419        long numPix = psVectorCountPixelMask(vec, 1);
     420
     421        ok(numPix != -1, "returned -1 for correct Vector input\n");
     422        ok(numPix == 2, "returned pixel count %d\n", numPix);
     423
     424        psFree(vec);
     425    }
     426
    388427    return exit_status();
    389428}
    390429
    391430# if 0
    392 
    393 psS32 testVectorCountPixelMask(void)
    394 {
    395     long numPix = 0;
    396     long numPix2 = 0;
    397     psVector *vec = NULL;
    398 
    399     psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
    400     numPix = psVectorCountPixelMask(vec, 1);
    401     if (numPix != -1) {
    402         psError(PS_ERR_BAD_PARAMETER_VALUE, false,
    403                 "psVectorCountPixelMask failed to return -1 for NULL Vector input.\n");
    404         return 1;
    405     }
    406 
    407     numPix = 0;
    408     vec = psVectorAlloc(5, PS_TYPE_S32);
    409     psVector *vec2 = NULL;
    410     vec2 = psVectorAlloc(5, PS_TYPE_U8);
    411     vec->data.S32[0] = 0;
    412     vec->data.S32[1] = 1;
    413     vec->data.S32[2] = 0;
    414     vec->data.S32[3] = 1;
    415     vec->data.S32[4] = 0;
    416     vec2->data.U8[0] = 0;
    417     vec2->data.U8[1] = 1;
    418     vec2->data.U8[2] = 0;
    419     vec2->data.U8[3] = 1;
    420     vec2->data.U8[4] = 0;
    421     vec->n = 5;
    422     vec2->n = 5;
    423 
    424     psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
    425     numPix = psVectorCountPixelMask(vec, 1);
    426     numPix2 = psVectorCountPixelMask(vec2, 1);
    427 
    428     if (numPix != -1) {
    429         psError(PS_ERR_BAD_PARAMETER_VALUE, false,
    430                 "psVectorCountPixelMask failed to return -1 for wrong type of Vector input.\n");
    431         return 2;
    432     }
    433     if (numPix2 == -1) {
    434         psError(PS_ERR_BAD_PARAMETER_VALUE, false,
    435                 "psVectorCountPixelMask returned -1 for correct Vector input\n");
    436         return 3;
    437     }
    438     if (numPix2 != 2) {
    439         psError(PS_ERR_BAD_PARAMETER_VALUE, false,
    440                 "psVectorCountPixelMask returned incorrect pixel count %d\n", numPix2);
    441         return 4;
    442     }
    443 
    444     psFree(vec);
    445     psFree(vec2);
    446     return 0;
    447 }
    448431
    449432psS32 testVectorLength( void )
Note: See TracChangeset for help on using the changeset viewer.