IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 7, 2007, 8:30:16 PM (19 years ago)
Author:
gusciora
Message:

Improved psVectorCountPixelMask() tests.

File:
1 edited

Legend:

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

    r13123 r13306  
    22#include <string.h>
    33#include <pslib.h>
    4 
    54#include "tap.h"
    65#include "pstap.h"
     
    109    psLogSetFormat("HLNM");
    1110    psLogSetLevel(PS_LOG_INFO);
    12     plan_tests(285);
     11    plan_tests(294);
    1312
    1413
     
    596595
    597596    // psVectorCountPixelMask() tests
     597    // Ensure -1 return for NULL psVector input
    598598    {
    599599        psMemId id = psMemGetId();
    600600        ok(psVectorCountPixelMask(NULL, 1) == -1,
    601            "psVectorCountPixelMask returned -1 for NULL Vector input");
    602         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    603     }
    604 
    605 
     601           "psVectorCountPixelMask() returned -1 for NULL psVector input");
     602        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     603    }
     604
     605
     606    // Ensure -1 return for incorrect TYPE psVector input
    606607    {
    607608        psMemId id = psMemGetId();
     
    613614        vec->data.S32[4] = 0;
    614615        ok(psVectorCountPixelMask(vec, 1) == -1,
    615            "returned -1 for wrong type of Vector input");
    616         psFree(vec);
    617         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    618     }
    619 
    620 
     616           "psVectorCountPixelMask() returned -1 for incorrect TYPE psVector input");
     617        psFree(vec);
     618        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     619    }
     620
     621
     622    // Use correct inputs
    621623    {
    622624        psMemId id = psMemGetId();
     
    628630        vec->data.U8[4] = 0;
    629631        long numPix = psVectorCountPixelMask(vec, 1);
    630         ok(numPix != -1, "did not return -1 for correct Vector input");
     632        ok(numPix != -1, "psVectorCountPixelMask() did return -1 for correct psVector input");
    631633        ok(numPix == 2, "returned pixel count %d", numPix);
     634        psFree(vec);
     635        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     636    }
     637
     638
     639    // Use correct inputs; psVector length of 0
     640    {
     641        psMemId id = psMemGetId();
     642        psVector *vec = psVectorAlloc(0, PS_TYPE_U8);
     643        long numPix = psVectorCountPixelMask(vec, 1);
     644        ok(numPix != -1, "psVectorCountPixelMask() did return -1 for correct psVector input (length 0)");
     645        ok(numPix == 0, "returned pixel count %d", numPix);
     646        psFree(vec);
     647        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     648    }
     649
     650
     651    // Use correct inputs; psVector length of 1
     652    {
     653        psMemId id = psMemGetId();
     654        psVector *vec = psVectorAlloc(1, PS_TYPE_U8);
     655        vec->data.U8[0] = 0;
     656        long numPix = psVectorCountPixelMask(vec, 1);
     657        ok(numPix != -1, "psVectorCountPixelMask() did return -1 for correct psVector input (length 1)");
     658        ok(numPix == 0, "returned pixel count %d", numPix);
     659        psFree(vec);
     660        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     661    }
     662
     663
     664    // Use correct inputs; large psVector
     665    {
     666        psMemId id = psMemGetId();
     667        #define N 10
     668        psVector *vec = psVectorAlloc(N, PS_TYPE_U8);
     669        for (int i = 0 ; i < N ; i++) {
     670            if (0 == i%2) {
     671                vec->data.U8[i] = 0;
     672            } else {
     673                vec->data.U8[i] = 1;
     674            }
     675        }
     676        long numPix = psVectorCountPixelMask(vec, 1);
     677        ok(numPix != -1, "psVectorCountPixelMask() did return -1 for correct psVector input (length: %d)", N);
     678        ok(numPix == N/2, "returned pixel count %d", numPix);
    632679        psFree(vec);
    633680        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
Note: See TracChangeset for help on using the changeset viewer.