Changeset 13337 for trunk/psLib/test/math/tap_psPolyFit2D.c
- Timestamp:
- May 10, 2007, 10:17:52 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/math/tap_psPolyFit2D.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/math/tap_psPolyFit2D.c
r13124 r13337 364 364 psLogSetFormat("HLNM"); 365 365 psLogSetLevel(PS_LOG_INFO); 366 plan_tests(44); 366 plan_tests(88); 367 368 369 // psVectorFitPolynomial2D() 370 // Test various erroneous input paramater configurations 371 { 372 psMemId id = psMemGetId(); 373 psPolynomial2D *myPoly = psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, POLY_ORDER_X, POLY_ORDER_Y); 374 psVector *x = psVectorAlloc(NUM_DATA, PS_TYPE_F32); 375 psVector *xS32 = psVectorAlloc(NUM_DATA, PS_TYPE_S32); 376 psVector *y = psVectorAlloc(NUM_DATA, PS_TYPE_F32); 377 psVector *yS32 = psVectorAlloc(NUM_DATA, PS_TYPE_S32); 378 psVector *f = psVectorAlloc(NUM_DATA, PS_TYPE_F32); 379 psVector *fS32 = psVectorAlloc(NUM_DATA, PS_TYPE_S32); 380 psVector *mask = psVectorAlloc(NUM_DATA, PS_TYPE_U8); 381 psVector *maskS8 = psVectorAlloc(NUM_DATA, PS_TYPE_S8); 382 psVector *fErr = psVectorAlloc(NUM_DATA, PS_TYPE_F32); 383 psVector *fErrS32 = psVectorAlloc(NUM_DATA, PS_TYPE_S32); 384 385 386 // Set psPolynomial2D to NULL, should cause error 387 { 388 psMemId id = psMemGetId(); 389 bool rc = psVectorFitPolynomial2D(NULL, mask, MASK_VALUE, f, fErr, x, y); 390 ok(rc == false, "psVectorFitPolynomial2D() returned FALSE with NULL psPolynomial2D"); 391 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 392 } 393 394 395 // Set mask to incorrect type, should cause error 396 { 397 psMemId id = psMemGetId(); 398 bool rc = psVectorFitPolynomial2D(myPoly, maskS8, MASK_VALUE, f, fErr, x, y); 399 ok(rc == false, "psVectorFitPolynomial2D() returned FALSE with mask set to incorrect type"); 400 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 401 } 402 403 404 // Set f psVector to incorrect type, should cause error 405 { 406 psMemId id = psMemGetId(); 407 bool rc = psVectorFitPolynomial2D(myPoly, mask, MASK_VALUE, fS32, fErr, x, y); 408 ok(rc == false, "psVectorFitPolynomial2D() returned FALSE: Set f psVector to incorrect type"); 409 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 410 } 411 412 413 // Set fError vector to incorrect type, should cause error 414 { 415 psMemId id = psMemGetId(); 416 bool rc = psVectorFitPolynomial2D(myPoly, mask, MASK_VALUE, f, fErrS32, x, y); 417 ok(rc == false, "psVectorFitPolynomial2D() returned FALSE: Set fError vector to incorrect type"); 418 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 419 } 420 421 422 // Set x vector to incorrect type, should cause error 423 { 424 psMemId id = psMemGetId(); 425 bool rc = psVectorFitPolynomial2D(myPoly, mask, MASK_VALUE, f, fErr, xS32, y); 426 ok(rc == false, "psVectorFitPolynomial2D() returned FALSE: Set x vector to incorrect type"); 427 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 428 } 429 430 431 // Set y vector to incorrect type, should cause error 432 { 433 psMemId id = psMemGetId(); 434 bool rc = psVectorFitPolynomial2D(myPoly, mask, MASK_VALUE, f, fErr, x, yS32); 435 ok(rc == false, "psVectorFitPolynomial2D() returned FALSE: Set y vector to incorrect type"); 436 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 437 } 438 439 440 // Incorrect mask psVector size, should cause error 441 { 442 psMemId id = psMemGetId(); 443 mask->n++; 444 bool rc = psVectorFitPolynomial2D(myPoly, mask, MASK_VALUE, f, fErr, x, y); 445 mask->n--; 446 ok(rc == false, "psVectorFitPolynomial2D() returned FALSE: Incorrect mask psVector size"); 447 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 448 } 449 450 451 // Incorrect f psVector size, should cause error 452 { 453 psMemId id = psMemGetId(); 454 f->n++; 455 bool rc = psVectorFitPolynomial2D(myPoly, mask, MASK_VALUE, f, fErr, x, y); 456 f->n--; 457 ok(rc == false, "psVectorFitPolynomial2D() returned FALSE: Incorrect f psVector size"); 458 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 459 } 460 461 462 // Incorrect fErr psVector size, should cause error 463 { 464 psMemId id = psMemGetId(); 465 fErr->n++; 466 bool rc = psVectorFitPolynomial2D(myPoly, mask, MASK_VALUE, f, fErr, x, y); 467 fErr->n--; 468 ok(rc == false, "psVectorFitPolynomial2D() returned FALSE: Incorrect fErr psVector size"); 469 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 470 } 471 472 473 // Incorrect x psVector size, should cause error 474 { 475 psMemId id = psMemGetId(); 476 x->n++; 477 bool rc = psVectorFitPolynomial2D(myPoly, mask, MASK_VALUE, f, fErr, x, y); 478 x->n--; 479 ok(rc == false, "psVectorFitPolynomial2D() returned FALSE: Incorrect x psVector size"); 480 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 481 } 482 483 psFree(myPoly); 484 psFree(x); 485 psFree(xS32); 486 psFree(y); 487 psFree(yS32); 488 psFree(f); 489 psFree(fS32); 490 psFree(mask); 491 psFree(maskS8); 492 psFree(fErr); 493 psFree(fErrS32); 494 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 495 } 496 497 498 // psVectorClipFitPolynomial2D() 499 // Test various erroneous input paramater configurations 500 { 501 psMemId id = psMemGetId(); 502 psPolynomial2D *myPoly = psPolynomial2DAlloc(PS_POLYNOMIAL_ORD, POLY_ORDER_X, POLY_ORDER_Y); 503 psVector *x = psVectorAlloc(NUM_DATA, PS_TYPE_F32); 504 psVector *xS32 = psVectorAlloc(NUM_DATA, PS_TYPE_S32); 505 psVector *y = psVectorAlloc(NUM_DATA, PS_TYPE_F32); 506 psVector *yS32 = psVectorAlloc(NUM_DATA, PS_TYPE_S32); 507 psVector *f = psVectorAlloc(NUM_DATA, PS_TYPE_F32); 508 psVector *fS32 = psVectorAlloc(NUM_DATA, PS_TYPE_S32); 509 psVector *mask = psVectorAlloc(NUM_DATA, PS_TYPE_U8); 510 psVector *maskS8 = psVectorAlloc(NUM_DATA, PS_TYPE_S8); 511 psVector *fErr = psVectorAlloc(NUM_DATA, PS_TYPE_F32); 512 psVector *fErrS32 = psVectorAlloc(NUM_DATA, PS_TYPE_S32); 513 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); 514 515 516 // Set psPolynomial2D to NULL, should cause error 517 { 518 psMemId id = psMemGetId(); 519 bool rc = psVectorClipFitPolynomial2D(NULL, stats, mask, MASK_VALUE, f, fErr, x, y); 520 ok(rc == false, "psVectorClipFitPolynomial2D() returned FALSE with NULL psPolynomial2D"); 521 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 522 } 523 524 525 // Set psStats to NULL, should cause error 526 { 527 psMemId id = psMemGetId(); 528 bool rc = psVectorClipFitPolynomial2D(myPoly, NULL, mask, MASK_VALUE, f, fErr, x, y); 529 ok(rc == false, "psVectorClipFitPolynomial2D() returned FALSE with NULL psStats"); 530 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 531 } 532 533 534 // Set mask to incorrect type, should cause error 535 { 536 psMemId id = psMemGetId(); 537 bool rc = psVectorClipFitPolynomial2D(myPoly, stats, maskS8, MASK_VALUE, f, fErr, x, y); 538 ok(rc == false, "psVectorClipFitPolynomial2D() returned FALSE with mask set to incorrect type"); 539 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 540 } 541 542 543 // Set f psVector to incorrect type, should cause error 544 { 545 psMemId id = psMemGetId(); 546 bool rc = psVectorClipFitPolynomial2D(myPoly, stats, mask, MASK_VALUE, fS32, fErr, x, y); 547 ok(rc == false, "psVectorClipFitPolynomial2D() returned FALSE: Set f psVector to incorrect type"); 548 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 549 } 550 551 552 // Set fError vector to incorrect type, should cause error 553 { 554 psMemId id = psMemGetId(); 555 bool rc = psVectorClipFitPolynomial2D(myPoly, stats, mask, MASK_VALUE, f, fErrS32, x, y); 556 ok(rc == false, "psVectorClipFitPolynomial2D() returned FALSE: Set fError vector to incorrect type"); 557 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 558 } 559 560 561 // Set x vector to incorrect type, should cause error 562 { 563 psMemId id = psMemGetId(); 564 bool rc = psVectorClipFitPolynomial2D(myPoly, stats, mask, MASK_VALUE, f, fErr, xS32, y); 565 ok(rc == false, "psVectorClipFitPolynomial2D() returned FALSE: Set x vector to incorrect type"); 566 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 567 } 568 569 570 // Set y vector to incorrect type, should cause error 571 { 572 psMemId id = psMemGetId(); 573 bool rc = psVectorClipFitPolynomial2D(myPoly, stats, mask, MASK_VALUE, f, fErr, x, yS32); 574 ok(rc == false, "psVectorClipFitPolynomial2D() returned FALSE: Set y vector to incorrect type"); 575 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 576 } 577 578 579 // Incorrect mask psVector size, should cause error 580 { 581 psMemId id = psMemGetId(); 582 mask->n++; 583 bool rc = psVectorClipFitPolynomial2D(myPoly, stats, mask, MASK_VALUE, f, fErr, x, y); 584 mask->n--; 585 ok(rc == false, "psVectorClipFitPolynomial2D() returned FALSE: Incorrect mask psVector size"); 586 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 587 } 588 589 590 // Incorrect f psVector size, should cause error 591 { 592 psMemId id = psMemGetId(); 593 f->n++; 594 bool rc = psVectorClipFitPolynomial2D(myPoly, stats, mask, MASK_VALUE, f, fErr, x, y); 595 f->n--; 596 ok(rc == false, "psVectorClipFitPolynomial2D() returned FALSE: Incorrect f psVector size"); 597 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 598 } 599 600 601 // Incorrect fErr psVector size, should cause error 602 { 603 psMemId id = psMemGetId(); 604 fErr->n++; 605 bool rc = psVectorClipFitPolynomial2D(myPoly, stats, mask, MASK_VALUE, f, fErr, x, y); 606 fErr->n--; 607 ok(rc == false, "psVectorClipFitPolynomial2D() returned FALSE: Incorrect fErr psVector size"); 608 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 609 } 610 611 612 // Incorrect x psVector size, should cause error 613 { 614 psMemId id = psMemGetId(); 615 x->n++; 616 bool rc = psVectorClipFitPolynomial2D(myPoly, stats, mask, MASK_VALUE, f, fErr, x, y); 617 x->n--; 618 ok(rc == false, "psVectorClipFitPolynomial2D() returned FALSE: Incorrect x psVector size"); 619 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 620 } 621 622 psFree(myPoly); 623 psFree(x); 624 psFree(xS32); 625 psFree(y); 626 psFree(yS32); 627 psFree(f); 628 psFree(fS32); 629 psFree(mask); 630 psFree(maskS8); 631 psFree(fErr); 632 psFree(fErrS32); 633 psFree(stats); 634 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 635 } 636 367 637 368 638 //
Note:
See TracChangeset
for help on using the changeset viewer.
