Changeset 13305
- Timestamp:
- May 7, 2007, 8:21:16 PM (19 years ago)
- Location:
- trunk/psLib/test
- Files:
-
- 6 edited
-
TABLE-SDRS-CH06-DataManip (modified) (2 diffs)
-
math/tap_psPolynomial.c (modified) (6 diffs)
-
math/tap_psPolynomialEval1D.c (modified) (3 diffs)
-
math/tap_psStats00.c (modified) (2 diffs)
-
mathtypes/tap_psVectorSort.c (modified) (5 diffs)
-
mathtypes/tap_psVectorSortIndex.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/TABLE-SDRS-CH06-DataManip
r13126 r13305 5 5 ------------------------------------------------------------------------------- 6 6 psVectorSort() 7 10 10 2108 We only test with NULL, size 1, and size 7 vectors.9 Add a test with NULL input, non-NULL output.7 10 10 10 10 8 in mathtypes/tap_psVectorSort.c 9 Many more types are tested successfully than required in the SDRS. 10 10 psVectorSortIndex() 11 10 10 21012 We only test with NULL, size 1, and size 7 vectors.13 Add a test with NULL input, non-NULL output.11 10 10 10 10 12 in mathtypes/tap_psVectorSortIndex.c 13 Many more typres are tested successfully than required in the SDRS. 14 14 psVectorStats() 5 10 5 5 15 files: math/tap_psStats00.c - math/tap_psStats09.c 15 16 Must review these files more. 16 17 More extensie robust stats? 18 Preset answers 19 Unclear what types should be supported from SDRS: 20 psS8, psU16, psF32, psF64 17 21 psStatsAlloc() 18 22 na na na 10 … … 38 42 8 na 10 8 39 43 psPolynomial1DAlloc() 40 8 na na 5 41 Can we test with negative polynomial order? 42 How about verifying the data is allocated, and initialized? 44 10 10 10 10 na 45 math/tap_psPolynomial.c 43 46 psPolynomial2DAlloc() 44 8 na na 545 Can we test with negative polynomial order?47 10 10 10 10 na 48 math/tap_psPolynomial.c 46 49 psPolynomial3DAlloc() 47 8 na na 548 Can we test with negative polynomial order?50 10 10 10 10 na 51 math/tap_psPolynomial.c 49 52 psPolynomial4DAlloc() 50 8 na na 551 Can we test with negative polynomial order?53 10 10 10 10 na 54 math/tap_psPolynomial.c 52 55 psPolynomial1DEval() 53 56 10 10 1 8 54 57 We only allocate polynomials with 4 terms 55 We should ensure that asking for negatiev number of terms fails nicely. 58 We should ensure that asking for negative number of terms fails nicely. 59 The test uses precomputed results. 56 60 psPolynomial2DEval() 57 61 10 10 1 5 58 62 We only allocate polynomials with 4 terms 59 63 Must vary x,y number of terms. 64 The test uses precomputed results. 60 65 psPolynomial3DEval() 61 66 10 10 1 5 62 67 We only allocate polynomials with 4 terms 63 68 Must vary x,y,z number of terms. 69 The test uses precomputed results. 64 70 psPolynomial4DEval() 65 71 10 10 1 5 66 72 We only allocate polynomials with 4 terms 67 73 Must vary w,x,y,z number of terms. 74 The test uses precomputed results. 68 75 psPolynomial1DEvalVector() 69 76 10 10 5 9 -
trunk/psLib/test/math/tap_psPolynomial.c
r13084 r13305 16 16 * XXX: Compare to FLT_EPSILON 17 17 * 18 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $19 * @date $Date: 2007-05-0 1 00:08:52$18 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 19 * @date $Date: 2007-05-08 06:21:16 $ 20 20 * 21 21 * Copyright 2004-2005 Maui High Performance Computing Center, Univ. of Hawaii … … 35 35 psLogSetFormat("HLNM"); 36 36 psLogSetLevel(PS_LOG_INFO); 37 38 plan_tests(26); 37 plan_tests(51); 39 38 40 39 // This test will allocate a 1D polynomial and verify the structure allocated … … 75 74 76 75 77 if (0) { 78 // Attempt to allocate with negative order 79 // Following should generate error msg for negative terms 80 if (psPolynomial1DAlloc(PS_POLYNOMIAL_ORD, -1) != NULL) { 81 diag("psPolynomial1DAlloc() Returned structure but expected NULL"); 82 } 83 } 76 // This test will allocate a Chebyshev 1D polynomial and verify the structure allocated 77 { 78 psMemId id = psMemGetId(); 79 psPolynomial1D* my1DPoly = NULL; 80 my1DPoly = psPolynomial1DAlloc(PS_POLYNOMIAL_CHEB, ORDER); 81 ok(my1DPoly != NULL, "Chebyshev 1D polynomial allocated successfully"); 82 skip_start(my1DPoly == NULL, 1, "Skipping tests because psPolynomial1DAlloc() failed"); 83 ok(my1DPoly->type == PS_POLYNOMIAL_CHEB, "psPolynomial1DAlloc(): Chebyshev type set correctly"); 84 skip_end(); 85 psFree(my1DPoly); 86 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 87 } 88 89 90 // Attempt to allocate with negative order 91 // Following should generate error msg for negative terms 92 if (1) { 93 psMemId id = psMemGetId(); 94 ok(psPolynomial1DAlloc(PS_POLYNOMIAL_ORD, -1) == NULL, 95 "psPolynomial1DAlloc() returned NULL with negative polynomial order"); 96 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 97 } 98 84 99 85 100 // This test will allocate a 2D polynomial and verify the structure allocated … … 122 137 } 123 138 124 if (0) { 125 // Attempt to allocate with negative order 126 // Following should generate error msg for negative terms 127 if (psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, -1, 1) != NULL) { 128 diag("psPolynomial2DAlloc() returned structure but expected NULL"); 129 } 130 // Attempt to allocate with negative order 131 // Following should generate error msg for negative terms 132 if (psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, 1, -1) != NULL) { 133 diag("psPolynomial2DAlloc() returned structure but expected NULL"); 134 } 135 } 139 140 // This test will allocate a Chebyshev 2D polynomial and verify the structure allocated 141 { 142 psMemId id = psMemGetId(); 143 psPolynomial2D* my2DPoly = NULL; 144 my2DPoly = psPolynomial2DAlloc(PS_POLYNOMIAL_CHEB, ORDER,ORDER+1); 145 ok(my2DPoly != NULL, "Chebyshev 2D polynomial allocated successfully"); 146 skip_start(my2DPoly == NULL, 1, "Skipping tests because psPolynomial2DAlloc() failed"); 147 skip_end(); 148 psFree(my2DPoly); 149 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 150 } 151 152 153 // Attempt to allocate with negative order 154 // Following should generate error msg for negative terms 155 if (1) { 156 psMemId id = psMemGetId(); 157 ok(psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, -1, 1) == NULL, 158 "psPolynomial2DAlloc() returned NULL with negative polynomial order"); 159 ok(psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, 1, -1) == NULL, 160 "psPolynomial2DAlloc() returned NULL with negative polynomial order"); 161 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 162 } 163 136 164 137 165 // This test will allocate a 3D polynomial and verify the structure allocated … … 179 207 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 180 208 } 181 if (0) { 182 // Attempt to allocate with negative order 183 // Following should generate error msg for negative terms 184 if (psPolynomial3DAlloc(PS_POLYNOMIAL_ORD, -1, 1, 1) != NULL) { 185 diag("psPolynomial3DAlloc(): returned structure but expected NULL"); 186 } 187 // Attempt to allocate with negative order 188 // Following should generate error msg for negative terms 189 if (psPolynomial3DAlloc(PS_POLYNOMIAL_ORD, 1, -1, 1) != NULL) { 190 diag("psPolynomial3DAlloc() returned structure but expected NULL"); 191 } 192 // Attempt to allocate with negative order 193 // Following should generate error msg for negative terms 194 if (psPolynomial3DAlloc(PS_POLYNOMIAL_ORD, 1, 1, -1) != NULL) { 195 diag("psPolynomial3DAlloc(): returned structure but expected NULL"); 196 } 197 } 209 210 211 // This test will allocate a Chebyshev 3D polynomial and verify the structure allocated 212 { 213 psMemId id = psMemGetId(); 214 psPolynomial3D* my3DPoly = NULL; 215 my3DPoly = psPolynomial3DAlloc(PS_POLYNOMIAL_CHEB, ORDER, ORDER+1, ORDER+2); 216 ok(my3DPoly != NULL, "Chebyshev 3D polynomial allocated successfully"); 217 skip_start(my3DPoly == NULL, 1, "Skipping tests because psPolynomial2DAlloc() failed"); 218 ok(my3DPoly->type == PS_POLYNOMIAL_CHEB, "psPolynomial3DAlloc(): Chebyshev type set correctly"); 219 skip_end(); 220 psFree(my3DPoly); 221 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 222 } 223 224 225 // Attempt to allocate with negative order 226 // Following should generate error msg for negative terms 227 if (1) { 228 psMemId id = psMemGetId(); 229 ok(psPolynomial3DAlloc(PS_POLYNOMIAL_ORD, -1, 1, 1) == NULL, 230 "psPolynomial3DAlloc() returned NULL with negative polynomial order"); 231 ok(psPolynomial3DAlloc(PS_POLYNOMIAL_ORD, 1, -1, 1) == NULL, 232 "psPolynomial3DAlloc() returned NULL with negative polynomial order"); 233 ok(psPolynomial3DAlloc(PS_POLYNOMIAL_ORD, 1, 1, -1) == NULL, 234 "psPolynomial3DAlloc() returned NULL with negative polynomial order"); 235 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 236 } 237 198 238 199 239 // This test will allocate a 4D polynomial and verify the structure allocated … … 245 285 } 246 286 247 if (0) { 248 // Attempt to allocate with negative order 249 // Following should generate error msg for negative terms 250 if (psPolynomial4DAlloc(PS_POLYNOMIAL_ORD, -1, 1, 1, 1) != NULL) { 251 diag("psPolynomial4DAlloc(): returned structure but expected NULL"); 252 } 253 // Attempt to allocate with negative order 254 // Following should generate error msg for negative terms 255 if (psPolynomial4DAlloc(PS_POLYNOMIAL_ORD, 1, -1, 1, 1) != NULL) { 256 diag("psPolynomial4DAlloc(): returned structure but expected NULL"); 257 psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL"); 258 } 259 // Attempt to allocate with negative order 260 // Following should generate error msg for negative terms 261 if (psPolynomial4DAlloc(PS_POLYNOMIAL_ORD, 1, 1, -1, 1) != NULL) { 262 diag("psPolynomial4DAlloc(): returned structure but expected NULL"); 263 psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL"); 264 } 265 // Attempt to allocate with negative order 266 // Following should generate error msg for negative terms 267 if (psPolynomial4DAlloc(PS_POLYNOMIAL_ORD, 1, 1, 1, -1) != NULL) { 268 diag("psPolynomial4DAlloc(): returned structure but expected NULL"); 269 } 270 } 287 288 // This test will allocate a Chebyshev 4D polynomial and verify the structure allocated 289 { 290 psMemId id = psMemGetId(); 291 psPolynomial4D* my4DPoly = NULL; 292 my4DPoly = psPolynomial4DAlloc(PS_POLYNOMIAL_CHEB, ORDER,ORDER+1,ORDER+2,ORDER+3); 293 ok(my4DPoly != NULL, "Chebyshev 4D polynomial allocated successfully"); 294 skip_start(my4DPoly == NULL, 1, "Skipping tests because psPolynomial4DAlloc() failed"); 295 ok(my4DPoly->type == PS_POLYNOMIAL_CHEB, "psPolynomial4DAlloc(): Chebyshev type set correctly"); 296 skip_end(); 297 psFree(my4DPoly); 298 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 299 } 300 301 302 // Attempt to allocate with negative order 303 // Following should generate error msg for negative terms 304 if (1) { 305 psMemId id = psMemGetId(); 306 ok(psPolynomial4DAlloc(PS_POLYNOMIAL_ORD, -1, 1, 1, 1) == NULL, 307 "psPolynomial4DAlloc() returned NULL with negative polynomial order"); 308 ok(psPolynomial4DAlloc(PS_POLYNOMIAL_ORD, 1, -1, 1, 1) == NULL, 309 "psPolynomial4DAlloc() returned NULL with negative polynomial order"); 310 ok(psPolynomial4DAlloc(PS_POLYNOMIAL_ORD, 1, 1, -1, 1) == NULL, 311 "psPolynomial4DAlloc() returned NULL with negative polynomial order"); 312 ok(psPolynomial4DAlloc(PS_POLYNOMIAL_ORD, 1, 1, 1, -1) == NULL, 313 "psPolynomial4DAlloc() returned NULL with negative polynomial order"); 314 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 315 } 316 317 271 318 } 272 319 -
trunk/psLib/test/math/tap_psPolynomialEval1D.c
r13124 r13305 4 4 * ORD and CHEB type polynomials. 5 5 * 6 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $7 * @date $Date: 2007-05-0 2 04:20:06 $6 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2007-05-08 06:21:16 $ 8 8 * 9 9 * XXX: Probably should test single- and multi-dimensional polynomials in … … 76 76 77 77 // Set polynomial members 78 for(psS32 i = 0; i < TERMS; i++) 79 { 78 for(psS32 i = 0; i < TERMS; i++) { 80 79 polyOrd->coeff[i] = poly1DCoeff[i]; 81 80 polyOrd->mask[i] = poly1DMask[i]; … … 84 83 // Evaluate test points and verify results 85 84 bool errorFlag = false; 86 for(psS32 i = 0; i < TESTPOINTS; i++) 87 { 85 for(psS32 i = 0; i < TESTPOINTS; i++) { 88 86 psF64 result = psPolynomial1DEval(polyOrd,poly1DXValue[i]); 89 87 if (fabs(poly1DXResult[i]-result) > ERROR_TOL ) { -
trunk/psLib/test/math/tap_psStats00.c
r12781 r13305 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $12 * @date $Date: 2007-0 4-10 21:09:30$11 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2007-05-08 06:21:16 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, Univ. of Hawaii … … 82 82 } 83 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 84 // Call psVectorStats() with no vector mask. 117 85 { -
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.
