Changeset 13305 for trunk/psLib/test/mathtypes
- Timestamp:
- May 7, 2007, 8:21:16 PM (19 years ago)
- Location:
- trunk/psLib/test/mathtypes
- Files:
-
- 2 edited
-
tap_psVectorSort.c (modified) (5 diffs)
-
tap_psVectorSortIndex.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/mathtypes/tap_psVectorSort.c
r12918 r13305 11 11 * Sort vector with one element 12 12 * Verify the sort for all supported types. 13 * Sort input vector into itself 13 14 * Output vector is smaller than input vector 14 15 * Output vector is different type from input vector 15 * Sort input float vector into itself16 * Free float vectors17 16 * 18 17 * @author Ross Harman, GLG, MHPCC 19 18 * 20 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $21 * @date $Date: 2007-0 4-19 03:50:44$19 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 20 * @date $Date: 2007-05-08 06:21:16 $ 22 21 * 23 22 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 24 23 * 25 24 */ 26 27 25 #include <pslib.h> 28 26 #include "tap.h" 29 27 #include "pstap.h" 30 28 #define VERBOSE 0 31 29 32 30 #define tstVectorSortByType(datatype, boolOutNull, value) \ … … 34 32 psMemId id = psMemGetId(); \ 35 33 psVector *out = NULL; \ 36 psVector *in = psVectorAlloc(7, PS_TYPE_##datatype); \34 psVector *in = psVectorAlloc(7, PS_TYPE_##datatype); \ 37 35 if (boolOutNull) { \ 38 36 out = NULL; \ … … 74 72 psLogSetFormat("HLNM"); 75 73 psLogSetLevel(PS_LOG_INFO); 76 plan_tests(24 4);74 plan_tests(246); 77 75 78 76 … … 90 88 { 91 89 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); 94 91 psVector *out = psVectorSort(NULL, in); 95 92 ok(out == NULL, "Did return NULL on error"); 96 93 psFree(in); 94 psFree(out); 97 95 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 98 96 } … … 236 234 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 237 235 } 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 } 238 263 } -
trunk/psLib/test/mathtypes/tap_psVectorSortIndex.c
r12918 r13305 14 14 * @author Ross Harman, GLG, MHPCC 15 15 * 16 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $17 * @date $Date: 2007-0 4-19 03:50:44$16 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 17 * @date $Date: 2007-05-08 06:21:16 $ 18 18 * 19 19 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 23 23 #include "tap.h" 24 24 #include "pstap.h" 25 #define VERBOSE 0 25 26 26 27 #define tstVectorSortIndexByType(datatype, boolOutNull, value) \ … … 28 29 psMemId id = psMemGetId(); \ 29 30 psVector *out = NULL; \ 30 psVector *in = psVectorAlloc( 5, PS_TYPE_##datatype); \31 psVector *in = psVectorAlloc(5, PS_TYPE_##datatype); \ 31 32 in->data.datatype[0] = 7+value; \ 32 33 in->data.datatype[1] = 9+value; \ … … 37 38 out = NULL; \ 38 39 } else { \ 39 out = psVectorAlloc(5, PS_TYPE_##datatype); \40 out = psVectorAlloc(5, PS_TYPE_##datatype); \ 40 41 } \ 41 42 psVector *tempVec = out; \ 42 out = psVectorSortIndex(out, in); \43 out = psVectorSortIndex(out, in); \ 43 44 if (!boolOutNull) { \ 44 45 ok(tempVec == out, "Return value equal to orignal output argument passed to function"); \ … … 71 72 psVector *out = psVectorSortIndex(NULL, NULL); 72 73 ok(out == NULL, "psVectorSortIndex() return NULL with NULL input specified"); 74 psFree(out); 73 75 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 74 76 } … … 78 80 { 79 81 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); 82 83 psVector *out = psVectorSortIndex(NULL, in); 83 84 ok(out == NULL, "psVectorSortIndex() returned NULL with unallowed input vector type"); 84 85 psFree(in); 86 psFree(out); 85 87 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 86 88 } … … 178 180 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 179 181 } 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 } 180 209 }
Note:
See TracChangeset
for help on using the changeset viewer.
