Changeset 7786
- Timestamp:
- Jul 1, 2006, 12:10:49 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/mathtypes/tap_psVector.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/mathtypes/tap_psVector.c
r7785 r7786 5 5 int main (void) 6 6 { 7 plan_tests( 62);7 plan_tests(122); 8 8 9 9 diag("psVectorAlloc() tests"); … … 44 44 psFree(vecBogus); 45 45 } 46 46 47 47 48 diag("psVectorRealloc() tests"); … … 120 121 } 121 122 123 122 124 diag("psVectorExtend() tests"); 123 125 … … 174 176 } 175 177 178 176 179 diag("psVectorInit() tests"); 177 180 … … 251 254 } 252 255 256 257 diag("psVectorCreate() tests"); 258 259 { 260 psVector *test = psVectorCreate(NULL, 0.0, 10.0, 1.0, PS_TYPE_S32); 261 for (int i = 0; i < 10; i++) { 262 ok(test->data.S32[i] == i, "Vector data matches. i = %d, data=%d", 263 i, test->data.S32[i]); 264 } 265 psFree(test); 266 } 267 268 { 269 psVector *input = psVectorAlloc(5, PS_TYPE_F32); 270 psVector *test = psVectorCreate(input, 0.0, 5.0, 0.5, PS_TYPE_F32); 271 272 for (int i = 0; i < 10; i++) { 273 ok(test->data.F32[i] == i * 0.5, 274 "Vector data matches. i = %d, data=%f", i, test->data.F32[i]); 275 } 276 277 psFree(input); 278 } 279 280 // Test PS_TYPE_F64 281 // PS_TYPE_S64 282 { 283 psVector *test = psVectorCreate(NULL, 0.0, 10.0, 1.0, PS_TYPE_S64); 284 for (int i = 0; i < 10; i++) 285 { 286 ok(test->data.S64[i] == i, 287 "Vector data does not match. i = %d, data=%ld", 288 i, (long)test->data.S64[i]); 289 } 290 psFree(test); 291 } 292 293 { 294 psVector *input = psVectorAlloc(5, PS_TYPE_F64); 295 psVector *test = psVectorCreate(input, 0.0, 5.0, 0.5, PS_TYPE_F64); 296 297 for (int i = 0; i < 10; i++) 298 { 299 ok(test->data.F64[i] == i * 0.5, 300 "Vector data does not match. i = %d, data=%f", 301 i, test->data.F64[i]); 302 } 303 psFree(input); 304 } 305 306 // Test PS_TYPE_U16 307 // PS_TYPE_S16 308 { 309 psVector *test = psVectorCreate(NULL, 0.0, 10.0, 1.0, PS_TYPE_S16); 310 for (int i = 0; i < 10; i++) 311 { 312 ok(test->data.S16[i] == i, "Vector data matches. i = %d, data=%d", 313 i, test->data.S16[i]); 314 } 315 psFree(test); 316 } 317 318 { 319 psVector *input = psVectorAlloc(5, PS_TYPE_U16); 320 psVector *test = psVectorCreate(input, 0.0, 20.0, 2.0, PS_TYPE_U16); 321 322 for (int i = 0; i < 10; i++) 323 { 324 ok(test->data.U16[i] == i * 2.0, 325 "Vector data matches. i = %d, data=%d", i, test->data.U16[i]); 326 } 327 psFree(input); 328 } 329 253 330 return exit_status(); 254 331 } 255 332 256 333 # if 0 257 258 psS32 testVectorCreate(void)259 {260 psVector *test = NULL;261 psVector *test2 = NULL;262 psVector *input = NULL;263 psVector *input2 = psVectorAlloc(5, PS_TYPE_F32);264 265 test = psVectorCreate(input, 0.0, 10.0, 1.0, PS_TYPE_S32);266 test2 = psVectorCreate(input2, 0.0, 5.0, 0.5, PS_TYPE_F32);267 268 for (int i = 0; i < 10; i++) {269 if (test->data.S32[i] != i) {270 fprintf(stderr, "Vector data does not match. i = %d, data=%d\n",271 i, test->data.S32[i]);272 return 1;273 }274 if (test2->data.F32[i] != i*0.5) {275 fprintf(stderr, "Vector data does not match. i = %d, data=%f\n",276 i, test->data.F32[i]);277 return 1;278 }279 }280 psFree(test);281 psFree(test2);282 return 0;283 }284 psS32 testVectorCreateA(void)285 {286 //287 // Test PS_TYPE_F64288 // PS_TYPE_S64289 //290 psVector *test = NULL;291 psVector *test2 = NULL;292 psVector *input = NULL;293 psVector *input2 = psVectorAlloc(5, PS_TYPE_F64);294 295 test = psVectorCreate(input, 0.0, 10.0, 1.0, PS_TYPE_S64);296 test2 = psVectorCreate(input2, 0.0, 5.0, 0.5, PS_TYPE_F64);297 298 for (int i = 0; i < 10; i++) {299 if (test->data.S64[i] != i) {300 fprintf(stderr, "Vector data does not match. i = %d, data=%ld\n",301 i, (long)test->data.S64[i]);302 return 1;303 }304 if (test2->data.F64[i] != i*0.5) {305 fprintf(stderr, "Vector data does not match. i = %d, data=%f\n",306 i, test->data.F64[i]);307 return 1;308 }309 }310 psFree(test);311 psFree(test2);312 return 0;313 }314 psS32 testVectorCreateB(void)315 {316 //317 // Test PS_TYPE_U16318 // PS_TYPE_S16319 //320 psVector *test = NULL;321 psVector *test2 = NULL;322 psVector *input = NULL;323 psVector *input2 = psVectorAlloc(5, PS_TYPE_U16);324 325 test = psVectorCreate(input, 0.0, 10.0, 1.0, PS_TYPE_S16);326 test2 = psVectorCreate(input2, 0.0, 20.0, 2.0, PS_TYPE_U16);327 328 for (int i = 0; i < 10; i++) {329 if (test->data.S16[i] != i) {330 fprintf(stderr, "Vector data does not match. i = %d, data=%d\n",331 i, test->data.S16[i]);332 return 1;333 }334 if (test2->data.U16[i] != i*2.0) {335 fprintf(stderr, "Vector data does not match. i = %d, data=%d\n",336 i, test->data.U16[i]);337 return 1;338 }339 }340 psFree(test);341 psFree(test2);342 return 0;343 }344 334 psS32 testVectorGetSet(void) 345 335 {
Note:
See TracChangeset
for help on using the changeset viewer.
