Changeset 7790
- Timestamp:
- Jul 1, 2006, 5:50:51 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/mathtypes/tap_psVector.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/mathtypes/tap_psVector.c
r7789 r7790 5 5 int main (void) 6 6 { 7 plan_tests(1 36);7 plan_tests(142); 8 8 9 9 diag("psVectorAlloc() tests"); … … 465 465 466 466 ok(psVectorLength((psVector*)array) == -1, 467 "returned -1 for an invalid input vector");467 "returned -1 for an invalid input vector"); 468 468 469 469 psFree(array); 470 } 471 472 473 diag("psVectorCopy() tests"); 474 475 { 476 477 ok(psVectorCopy(NULL, NULL, PS_TYPE_F32) == NULL, 478 "returned a NULL vector for NULL input"); 479 } 480 481 { 482 psVector *in = psVectorAlloc(5, PS_TYPE_F32); 483 in->n = 5; 484 485 for (int i = 0; i < 5; i++) { 486 in->data.F32[i] = i; 487 } 488 489 //Try copy of different type 490 psVector *copy = psVectorCopy(NULL, in, PS_TYPE_F64); 491 ok(copy != NULL, "returned a non NULL vector for correct input"); 492 ok(copy->data.F64[2] == 2.0, 493 "copy->data.f64[2] = %lf, in->data.f32[2] = %f", 494 copy->data.F64[2], in->data.F32[2]); 495 496 psFree(in); 497 psFree(copy); 498 } 499 500 // XXX psVectorRecycle needs it's own tests 501 // copy = psVectorRecycle(copy, in->n + 2, PS_TYPE_F64); 502 503 { 504 // Try copy of same type and non-NULL outVector of different type and 505 // size. 506 psVector *in = psVectorAlloc(5, PS_TYPE_F32); 507 in->n = 5; 508 for (int i = 0; i < 5; i++) 509 { 510 in->data.F32[i] = i; 511 } 512 psVector *copy = psVectorAlloc(5, PS_TYPE_F64); 513 copy = psVectorCopy(copy, in, in->type.type); 514 515 ok(copy != NULL, "returned a NULL vector for correct input"); 516 skip_start(copy == NULL, 2, 517 "Skipping 1 test because psVectorCopy() failed"); 518 ok(copy->type.type == PS_TYPE_F32, "copy has the correct data type"); 519 ok(copy->data.F32[2] == 2.0, "copy has the correct data value"); 520 skip_end(); 521 522 psFree(in); 523 psFree(copy); 470 524 } 471 525 472 526 return exit_status(); 473 527 } 474 475 # if 0476 477 psS32 testVectorCopy(void)478 {479 480 psVector *in = NULL;481 psVector *copy = NULL;482 483 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");484 copy = psVectorCopy(copy, in, PS_TYPE_F32);485 if (copy != NULL) {486 psError(PS_ERR_BAD_PARAMETER_NULL, true,487 "psVectorCopy failed to return a NULL vector for NULL input.\n");488 return 1;489 }490 491 in = psVectorAlloc(5, PS_TYPE_F32);492 in->n = 5;493 for (int i = 0; i < 5; i++) {494 in->data.F32[i] = i;495 }496 //Try copy of different type497 copy = psVectorCopy(copy, in, PS_TYPE_F64);498 if (copy == NULL) {499 psError(PS_ERR_BAD_PARAMETER_NULL, true,500 "psVectorCopy returned a NULL vector for correct input.\n");501 return 2;502 } else if (copy->data.F64[2] != 2.0) {503 psError(PS_ERR_BAD_PARAMETER_NULL, true,504 "psVectorCopy failed to return the correct data values.\n");505 printf("\n copy->data.f64[2] = %lf, in->data.f32[2] = %f\n", copy->data.F64[2],506 in->data.F32[2]);507 return 3;508 }509 510 copy = psVectorRecycle(copy, in->n + 2, PS_TYPE_F64);511 //Try copy of same type and non-NULL outVector of different type and size.512 copy = psVectorCopy(copy, in, in->type.type);513 if (copy == NULL) {514 psError(PS_ERR_BAD_PARAMETER_NULL, true,515 "psVectorCopy returned a NULL vector for correct input.\n");516 return 4;517 } else if (copy->type.type != PS_TYPE_F32 || copy->data.F32[2] != 2.0) {518 psError(PS_ERR_BAD_PARAMETER_NULL, true,519 "psVectorCopy failed to return the correct data values.\n");520 return 5;521 }522 523 524 psFree(in);525 psFree(copy);526 return 0;527 }528 529 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
