IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

Basically, added additional tests to increase overall coverage of these
psLib functions.

Location:
trunk/psLib/test/mathtypes
Files:
2 edited

Legend:

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

    r12918 r13305  
    1111 *  Sort vector with one element
    1212 *  Verify the sort for all supported types.
     13 *  Sort input vector into itself
    1314 *  Output vector is smaller than input vector
    1415 *  Output vector is different type from input vector
    15  *  Sort input float vector into itself
    16  *  Free float vectors
    1716 *
    1817 *  @author  Ross Harman, GLG, MHPCC
    1918 *
    20  *  @version $Revision: 1.1 $  $Name: not supported by cvs2svn $
    21  *  @date  $Date: 2007-04-19 03:50:44 $
     19 *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
     20 *  @date  $Date: 2007-05-08 06:21:16 $
    2221 *
    2322 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    2423 *
    2524 */
    26 
    2725#include <pslib.h>
    2826#include "tap.h"
    2927#include "pstap.h"
    30 
     28#define VERBOSE 0
    3129
    3230#define tstVectorSortByType(datatype, boolOutNull, value) \
     
    3432    psMemId id = psMemGetId(); \
    3533    psVector *out = NULL; \
    36     psVector *in = psVectorAlloc(7,PS_TYPE_##datatype); \
     34    psVector *in = psVectorAlloc(7, PS_TYPE_##datatype); \
    3735    if (boolOutNull) { \
    3836        out = NULL; \
     
    7472    psLogSetFormat("HLNM");
    7573    psLogSetLevel(PS_LOG_INFO);
    76     plan_tests(244);
     74    plan_tests(246);
    7775
    7876
     
    9088    {
    9189        psMemId id = psMemGetId();
    92         psVector *in = psVectorAlloc(7, PS_TYPE_F32);
    93         in->type.type = PS_TYPE_BOOL;
     90        psVector *in = psVectorAlloc(7, PS_TYPE_BOOL);
    9491        psVector *out = psVectorSort(NULL, in);
    9592        ok(out == NULL, "Did return NULL on error");
    9693        psFree(in);
     94        psFree(out);
    9795        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    9896    }
     
    236234        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    237235    }
     236
     237
     238    // Sort large input vector
     239    {
     240        #define N 1000000
     241        psMemId id = psMemGetId();
     242        psVector *in = psVectorAlloc(N, PS_TYPE_S32);
     243        for (int i = 0 ; i < N ; i++) {
     244            in->data.S32[N-i-1] = i;
     245        }
     246        psVector *out = psVectorSort(NULL, in);
     247        skip_start(out == NULL,  7, "Skipping tests because psVectorSort() returned NULL.");
     248        bool errorFlag = false;
     249        for (int i = 0 ; i < N ; i++) {
     250            if (out->data.S32[i] != i) {
     251                if (VERBOSE) {
     252                    diag("Test error: out[%d] is %d, should be %d\n", i, out->data.S32[i], i);
     253                }
     254                errorFlag = true;
     255            }
     256        }
     257        ok(!errorFlag, "psVectorSort() correctly sorted a large input vector");
     258        skip_end();
     259        psFree(in);
     260        psFree(out);
     261        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     262    }
    238263}
  • trunk/psLib/test/mathtypes/tap_psVectorSortIndex.c

    r12918 r13305  
    1414 *  @author  Ross Harman, GLG, MHPCC
    1515 *
    16  *  @version $Revision: 1.1 $  $Name: not supported by cvs2svn $
    17  *  @date  $Date: 2007-04-19 03:50:44 $
     16 *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
     17 *  @date  $Date: 2007-05-08 06:21:16 $
    1818 *
    1919 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2323#include "tap.h"
    2424#include "pstap.h"
     25#define VERBOSE 0
    2526
    2627#define tstVectorSortIndexByType(datatype, boolOutNull, value) \
     
    2829    psMemId id = psMemGetId(); \
    2930    psVector *out = NULL; \
    30     psVector *in = psVectorAlloc( 5, PS_TYPE_##datatype ); \
     31    psVector *in = psVectorAlloc(5, PS_TYPE_##datatype); \
    3132    in->data.datatype[0] = 7+value; \
    3233    in->data.datatype[1] = 9+value; \
     
    3738        out = NULL; \
    3839    } else { \
    39         out = psVectorAlloc(5,PS_TYPE_##datatype); \
     40        out = psVectorAlloc(5, PS_TYPE_##datatype); \
    4041    } \
    4142    psVector *tempVec = out; \
    42     out = psVectorSortIndex(out,in); \
     43    out = psVectorSortIndex(out, in); \
    4344    if (!boolOutNull) { \
    4445        ok(tempVec == out, "Return value equal to orignal output argument passed to function"); \
     
    7172        psVector *out = psVectorSortIndex(NULL, NULL);
    7273        ok(out == NULL, "psVectorSortIndex() return NULL with NULL input specified");
     74        psFree(out);
    7375        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    7476    }
     
    7880    {
    7981        psMemId id = psMemGetId();
    80         psVector *in = psVectorAlloc(5, PS_TYPE_U8);
    81         in->type.type = PS_TYPE_BOOL;
     82        psVector *in = psVectorAlloc(5, PS_TYPE_BOOL);
    8283        psVector *out = psVectorSortIndex(NULL, in);
    8384        ok(out == NULL, "psVectorSortIndex() returned NULL with unallowed input vector type");
    8485        psFree(in);
     86        psFree(out);
    8587        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    8688    }
     
    178180        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    179181    }
     182
     183
     184    // Sort large input vector
     185    {
     186        #define N 1000000
     187        psMemId id = psMemGetId();
     188        psVector *in = psVectorAlloc(N, PS_TYPE_S32);
     189        for (int i = 0 ; i < N ; i++) {
     190            in->data.S32[N-i-1] = i;
     191        }
     192        psVector *out = psVectorSortIndex(NULL, in);
     193        skip_start(out == NULL,  7, "Skipping tests because psVectorSort() returned NULL.");
     194        bool errorFlag = false;
     195        for (int i = 0 ; i < N ; i++) {
     196            if (out->data.U32[i] != N-i-1) {
     197                if (VERBOSE) {
     198                    diag("Test error: out[%d] is %d, should be %d\n", i, out->data.U32[i], i);
     199                }
     200                errorFlag = true;
     201            }
     202        }
     203        ok(!errorFlag, "psVectorSortIndex() correctly sorted a large input vector");
     204        skip_end();
     205        psFree(in);
     206        psFree(out);
     207        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     208    }
    180209}
Note: See TracChangeset for help on using the changeset viewer.