Changeset 3382 for trunk/psLib/test/dataManip/tst_psFunc00.c
- Timestamp:
- Mar 7, 2005, 11:00:03 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/dataManip/tst_psFunc00.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/dataManip/tst_psFunc00.c
r3377 r3382 1 /***************************************************************************** 2 This routine must ensure that the psPolynomial structures are 3 allocated and deallocated by the psPolynomialXXXlloc() procedures. 4 It also calls the various psPolynomialXXXEval() procedures. 5 6 The F32 and F64 polynomials are tested for all orders (1 - 4) and for 7 both ordinary and chebyshev polynomials. 8 9 NOTE: This test code requries the stdout file to verify that the results 10 are good. 11 *****************************************************************************/ 1 /** tst_Func00.c 2 * 3 * This routine must ensure that the psPolynomial structures are 4 * allocated and deallocated by the psPolynomialXXXlloc() procedures. 5 * It also calls the various psPolynomialXXXEval() procedures. 6 * 7 * The F32 and F64 polynomials are tested for all orders (1 - 4) and for 8 * both ordinary and chebyshev polynomials. 9 * 10 * NOTE: This test code requries the stdout file to verify that the results 11 * are good. 12 * 13 * @version $Revision: 1.18 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2005-03-07 21:00:03 $ 15 * 16 * Copyright 2004-2005 Maui High Performance Computing Center, Univ. of Hawaii 17 * 18 *****************************************************************************/ 12 19 #include <stdio.h> 13 20 #include "pslib.h" … … 15 22 #include "psMemory.h" 16 23 #include "psFunctions.h" 24 25 // Defines 26 #define ORDER 3 27 28 17 29 #define MISC_FLOAT_NUMBER 345.0 18 30 #define MISC_X_VALUE 5.0 19 31 #define MISC_X_CHEB_VALUE 0.5 20 32 #define MISC_INT_NUMBER 35 21 //#define AN 2 22 #define AN 1 33 #define AN 2 23 34 #define BN 4 24 35 #define CN 6 25 36 #define DN 8 26 37 38 static psS32 t01(void); 39 40 static psS32 testPolynomial1DAlloc(void); 41 static psS32 testPolynomial2DAlloc(void); 42 static psS32 testPolynomial3DAlloc(void); 43 static psS32 testPolynomial4DAlloc(void); 44 static psS32 testDPolynomial1DAlloc(void); 45 static psS32 testDPolynomial2DAlloc(void); 46 static psS32 testDPolynomial3DAlloc(void); 47 static psS32 testDPolynomial4DAlloc(void); 48 49 testDescription tests[] = { 50 {testPolynomial1DAlloc,578,"psPolynomial1DAlloc",0,false}, 51 {testPolynomial2DAlloc,578,"psPolynomial2DAlloc",0,false}, 52 {testPolynomial3DAlloc,578,"psPolynomial3DAlloc",0,false}, 53 {testPolynomial4DAlloc,578,"psPolynomial4DAlloc",0,false}, 54 {testDPolynomial1DAlloc,579,"psDPolynomial1DAlloc",0,false}, 55 {testDPolynomial2DAlloc,579,"psDPolynomial2DAlloc",0,false}, 56 {testDPolynomial3DAlloc,579,"psDPolynomial3DAlloc",0,false}, 57 {testDPolynomial4DAlloc,579,"psDPolynomial4DAlloc",0,false}, 58 {t01,0000,"psPolynomial1DAlloc",0,false}, 59 {NULL} 60 }; 61 62 63 psS32 main(psS32 argc, char* argv[]) 64 { 65 psLogSetLevel(PS_LOG_INFO); 66 67 return !runTestSuite(stderr,"psPolynomialXD", tests, argc, argv); 68 } 69 70 71 // This test will allocate a 1D polynomial and verify the structure allocated 72 psS32 testPolynomial1DAlloc(void) 73 { 74 psPolynomial1D* my1DPoly = NULL; 75 76 // Allocate polynomial 77 my1DPoly = psPolynomial1DAlloc(ORDER,PS_POLYNOMIAL_ORD); 78 // Verify structure allocated 79 if(my1DPoly == NULL) { 80 psError(PS_ERR_UNKNOWN,true,"Returned NULL not expected"); 81 return 1; 82 } 83 // Verify polynomial structure members set properly 84 if(my1DPoly->n != ORDER) { 85 psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d", 86 my1DPoly->n, ORDER); 87 return 2; 88 } 89 if(my1DPoly->type != PS_POLYNOMIAL_ORD) { 90 psError(PS_ERR_UNKNOWN,true,"Type %d not as expected %d", 91 my1DPoly->type, PS_POLYNOMIAL_ORD); 92 return 3; 93 } 94 for(psS32 i = 0; i < ORDER; i++) { 95 if(my1DPoly->coeff[i] != 0.0) { 96 psError(PS_ERR_UNKNOWN,true,"Coeff[%d] %lg not as expected %lg", 97 i, my1DPoly->coeff[i], 0.0); 98 return 4; 99 } 100 if(my1DPoly->coeffErr[i] != 0.0) { 101 psError(PS_ERR_UNKNOWN,true,"CoeffErr[%d] %lg not as expected %lg", 102 i, my1DPoly->coeffErr[i], 0.0); 103 return 5; 104 } 105 if(my1DPoly->mask[i] != 0) { 106 psError(PS_ERR_UNKNOWN,true,"Mask[%d] %d not as expected %d", 107 i, my1DPoly->mask[i], 0); 108 return 6; 109 } 110 } 111 psFree(my1DPoly); 112 113 // Attempt to allocate with negative order 114 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms"); 115 if(psPolynomial1DAlloc(-1,PS_POLYNOMIAL_ORD) != NULL) { 116 psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL"); 117 return 7; 118 } 119 120 return 0; 121 } 122 123 // This test will allocate a 1D polynomial and verify the structure allocated 124 psS32 testDPolynomial1DAlloc(void) 125 { 126 psDPolynomial1D* my1DDPoly = NULL; 127 128 // Allocate polynomial 129 my1DDPoly = psDPolynomial1DAlloc(ORDER,PS_POLYNOMIAL_CHEB); 130 // Verify structure allocated 131 if(my1DDPoly == NULL) { 132 psError(PS_ERR_UNKNOWN,true,"Returned NULL not expected"); 133 return 1; 134 } 135 // Verify polynomial structure members set properly 136 if(my1DDPoly->n != ORDER) { 137 psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d", 138 my1DDPoly->n, ORDER); 139 return 2; 140 } 141 if(my1DDPoly->type != PS_POLYNOMIAL_CHEB) { 142 psError(PS_ERR_UNKNOWN,true,"Type %d not as expected %d", 143 my1DDPoly->type, PS_POLYNOMIAL_CHEB); 144 return 3; 145 } 146 for(psS32 i = 0; i < ORDER; i++) { 147 if(my1DDPoly->coeff[i] != 0.0) { 148 psError(PS_ERR_UNKNOWN,true,"Coeff[%d] %lg not as expected %lg", 149 i, my1DDPoly->coeff[i], 0.0); 150 return 4; 151 } 152 if(my1DDPoly->coeffErr[i] != 0.0) { 153 psError(PS_ERR_UNKNOWN,true,"CoeffErr[%d] %lg not as expected %lg", 154 i, my1DDPoly->coeffErr[i], 0.0); 155 return 5; 156 } 157 if(my1DDPoly->mask[i] != 0) { 158 psError(PS_ERR_UNKNOWN,true,"Mask[%d] %d not as expected %d", 159 i, my1DDPoly->mask[i], 0); 160 return 6; 161 } 162 } 163 psFree(my1DDPoly); 164 165 // Attempt to allocate with negative order 166 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms"); 167 if(psDPolynomial1DAlloc(-1,PS_POLYNOMIAL_ORD) != NULL) { 168 psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL"); 169 return 7; 170 } 171 172 return 0; 173 } 174 175 // This test will allocate a 2D polynomial and verify the structure allocated 176 psS32 testPolynomial2DAlloc(void) 177 { 178 psPolynomial2D* my2DPoly = NULL; 179 180 // Allocate polynomial 181 my2DPoly = psPolynomial2DAlloc(ORDER,ORDER+1,PS_POLYNOMIAL_ORD); 182 // Verify structure allocated 183 if(my2DPoly == NULL) { 184 psError(PS_ERR_UNKNOWN,true,"Returned NULL not expected"); 185 return 1; 186 } 187 // Verify polynomial structure members set properly 188 if(my2DPoly->nX != ORDER) { 189 psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d", 190 my2DPoly->nX, ORDER); 191 return 2; 192 } 193 // Verify polynomial structure members set properly 194 if(my2DPoly->nY != ORDER+1) { 195 psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d", 196 my2DPoly->nY, ORDER+1); 197 return 3; 198 } 199 if(my2DPoly->type != PS_POLYNOMIAL_ORD) { 200 psError(PS_ERR_UNKNOWN,true,"Type %d not as expected %d", 201 my2DPoly->type, PS_POLYNOMIAL_ORD); 202 return 4; 203 } 204 for(psS32 i = 0; i < ORDER; i++) { 205 for(psS32 j = 0; j < ORDER+1; j++) { 206 if(my2DPoly->coeff[i][j] != 0.0) { 207 psError(PS_ERR_UNKNOWN,true,"Coeff[%d][%d] %lg not as expected %lg", 208 i, j, my2DPoly->coeff[i][j], 0.0); 209 return 5; 210 } 211 if(my2DPoly->coeffErr[i][j] != 0.0) { 212 psError(PS_ERR_UNKNOWN,true,"CoeffErr[%d][%d] %lg not as expected %lg", 213 i, j, my2DPoly->coeffErr[i][j], 0.0); 214 return 6; 215 } 216 if(my2DPoly->mask[i][j] != 0) { 217 psError(PS_ERR_UNKNOWN,true,"Mask[%d][%d] %d not as expected %d", 218 i, j, my2DPoly->mask[i][j], 0); 219 return 7; 220 } 221 } 222 } 223 psFree(my2DPoly); 224 225 // Attempt to allocate with negative order 226 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms"); 227 if(psPolynomial2DAlloc(-1,1,PS_POLYNOMIAL_ORD) != NULL) { 228 psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL"); 229 return 8; 230 } 231 // Attempt to allocate with negative order 232 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms"); 233 if(psPolynomial2DAlloc(1,-1,PS_POLYNOMIAL_ORD) != NULL) { 234 psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL"); 235 return 9; 236 } 237 238 return 0; 239 } 240 241 // This test will allocate a 2D polynomial and verify the structure allocated 242 psS32 testDPolynomial2DAlloc(void) 243 { 244 psDPolynomial2D* my2DDPoly = NULL; 245 246 // Allocate polynomial 247 my2DDPoly = psDPolynomial2DAlloc(ORDER,ORDER+1,PS_POLYNOMIAL_CHEB); 248 // Verify structure allocated 249 if(my2DDPoly == NULL) { 250 psError(PS_ERR_UNKNOWN,true,"Returned NULL not expected"); 251 return 1; 252 } 253 // Verify polynomial structure members set properly 254 if(my2DDPoly->nX != ORDER) { 255 psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d", 256 my2DDPoly->nX, ORDER); 257 return 2; 258 } 259 // Verify polynomial structure members set properly 260 if(my2DDPoly->nY != ORDER+1) { 261 psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d", 262 my2DDPoly->nY, ORDER+1); 263 return 3; 264 } 265 if(my2DDPoly->type != PS_POLYNOMIAL_CHEB) { 266 psError(PS_ERR_UNKNOWN,true,"Type %d not as expected %d", 267 my2DDPoly->type, PS_POLYNOMIAL_ORD); 268 return 4; 269 } 270 for(psS32 i = 0; i < ORDER; i++) { 271 for(psS32 j = 0; j < ORDER+1; j++) { 272 if(my2DDPoly->coeff[i][j] != 0.0) { 273 psError(PS_ERR_UNKNOWN,true,"Coeff[%d][%d] %lg not as expected %lg", 274 i, j, my2DDPoly->coeff[i][j], 0.0); 275 return 5; 276 } 277 if(my2DDPoly->coeffErr[i][j] != 0.0) { 278 psError(PS_ERR_UNKNOWN,true,"CoeffErr[%d][%d] %lg not as expected %lg", 279 i, j, my2DDPoly->coeffErr[i][j], 0.0); 280 return 6; 281 } 282 if(my2DDPoly->mask[i][j] != 0) { 283 psError(PS_ERR_UNKNOWN,true,"Mask[%d][%d] %d not as expected %d", 284 i, j, my2DDPoly->mask[i][j], 0); 285 return 7; 286 } 287 } 288 } 289 psFree(my2DDPoly); 290 291 // Attempt to allocate with negative order 292 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms"); 293 if(psDPolynomial2DAlloc(-1,1,PS_POLYNOMIAL_ORD) != NULL) { 294 psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL"); 295 return 8; 296 } 297 // Attempt to allocate with negative order 298 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms"); 299 if(psDPolynomial2DAlloc(1,-1,PS_POLYNOMIAL_ORD) != NULL) { 300 psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL"); 301 return 9; 302 } 303 304 return 0; 305 } 306 307 // This test will allocate a 3D polynomial and verify the structure allocated 308 psS32 testPolynomial3DAlloc(void) 309 { 310 psPolynomial3D* my3DPoly = NULL; 311 312 // Allocate polynomial 313 my3DPoly = psPolynomial3DAlloc(ORDER,ORDER+1,ORDER+2,PS_POLYNOMIAL_ORD); 314 // Verify structure allocated 315 if(my3DPoly == NULL) { 316 psError(PS_ERR_UNKNOWN,true,"Returned NULL not expected"); 317 return 1; 318 } 319 // Verify polynomial structure members set properly 320 if(my3DPoly->nX != ORDER) { 321 psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d", 322 my3DPoly->nX, ORDER); 323 return 2; 324 } 325 // Verify polynomial structure members set properly 326 if(my3DPoly->nY != ORDER+1) { 327 psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d", 328 my3DPoly->nY, ORDER+1); 329 return 3; 330 } 331 // Verify polynomial structure members set properly 332 if(my3DPoly->nZ != ORDER+2) { 333 psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d", 334 my3DPoly->nZ, ORDER+2); 335 return 4; 336 } 337 if(my3DPoly->type != PS_POLYNOMIAL_ORD) { 338 psError(PS_ERR_UNKNOWN,true,"Type %d not as expected %d", 339 my3DPoly->type, PS_POLYNOMIAL_ORD); 340 return 5; 341 } 342 for(psS32 i = 0; i < ORDER; i++) { 343 for(psS32 j = 0; j < ORDER+1; j++) { 344 for(psS32 k = 0; k < ORDER+2; k++) { 345 if(my3DPoly->coeff[i][j][k] != 0.0) { 346 psError(PS_ERR_UNKNOWN,true,"Coeff[%d][%d][%d] %lg not as expected %lg", 347 i, j, k, my3DPoly->coeff[i][j][k], 0.0); 348 return 6; 349 } 350 if(my3DPoly->coeffErr[i][j][k] != 0.0) { 351 psError(PS_ERR_UNKNOWN,true,"CoeffErr[%d][%d][%d] %lg not as expected %lg", 352 i, j, k, my3DPoly->coeffErr[i][j][k], 0.0); 353 return 7; 354 } 355 if(my3DPoly->mask[i][j][k] != 0) { 356 psError(PS_ERR_UNKNOWN,true,"Mask[%d][%d] %d not as expected %d", 357 i, j, k, my3DPoly->mask[i][j][k], 0); 358 return 8; 359 } 360 } 361 } 362 } 363 psFree(my3DPoly); 364 365 // Attempt to allocate with negative order 366 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms"); 367 if(psPolynomial3DAlloc(-1,1,1,PS_POLYNOMIAL_ORD) != NULL) { 368 psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL"); 369 return 9; 370 } 371 // Attempt to allocate with negative order 372 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms"); 373 if(psPolynomial3DAlloc(1,-1,1,PS_POLYNOMIAL_ORD) != NULL) { 374 psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL"); 375 return 10; 376 } 377 // Attempt to allocate with negative order 378 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms"); 379 if(psPolynomial3DAlloc(1,1,-1,PS_POLYNOMIAL_ORD) != NULL) { 380 psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL"); 381 return 11; 382 } 383 384 return 0; 385 } 386 387 // This test will allocate a 3D polynomial and verify the structure allocated 388 psS32 testDPolynomial3DAlloc(void) 389 { 390 psDPolynomial3D* my3DDPoly = NULL; 391 392 // Allocate polynomial 393 my3DDPoly = psDPolynomial3DAlloc(ORDER,ORDER+1,ORDER+2,PS_POLYNOMIAL_CHEB); 394 // Verify structure allocated 395 if(my3DDPoly == NULL) { 396 psError(PS_ERR_UNKNOWN,true,"Returned NULL not expected"); 397 return 1; 398 } 399 // Verify polynomial structure members set properly 400 if(my3DDPoly->nX != ORDER) { 401 psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d", 402 my3DDPoly->nX, ORDER); 403 return 2; 404 } 405 // Verify polynomial structure members set properly 406 if(my3DDPoly->nY != ORDER+1) { 407 psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d", 408 my3DDPoly->nY, ORDER+1); 409 return 3; 410 } 411 // Verify polynomial structure members set properly 412 if(my3DDPoly->nZ != ORDER+2) { 413 psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d", 414 my3DDPoly->nZ, ORDER+2); 415 return 4; 416 } 417 if(my3DDPoly->type != PS_POLYNOMIAL_CHEB) { 418 psError(PS_ERR_UNKNOWN,true,"Type %d not as expected %d", 419 my3DDPoly->type, PS_POLYNOMIAL_ORD); 420 return 5; 421 } 422 for(psS32 i = 0; i < ORDER; i++) { 423 for(psS32 j = 0; j < ORDER+1; j++) { 424 for(psS32 k = 0; k < ORDER+2; k++) { 425 if(my3DDPoly->coeff[i][j][k] != 0.0) { 426 psError(PS_ERR_UNKNOWN,true,"Coeff[%d][%d][%d] %lg not as expected %lg", 427 i, j, k, my3DDPoly->coeff[i][j][k], 0.0); 428 return 6; 429 } 430 if(my3DDPoly->coeffErr[i][j][k] != 0.0) { 431 psError(PS_ERR_UNKNOWN,true,"CoeffErr[%d][%d][%d] %lg not as expected %lg", 432 i, j, k, my3DDPoly->coeffErr[i][j][k], 0.0); 433 return 7; 434 } 435 if(my3DDPoly->mask[i][j][k] != 0) { 436 psError(PS_ERR_UNKNOWN,true,"Mask[%d][%d] %d not as expected %d", 437 i, j, k, my3DDPoly->mask[i][j][k], 0); 438 return 8; 439 } 440 } 441 } 442 } 443 psFree(my3DDPoly); 444 445 // Attempt to allocate with negative order 446 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms"); 447 if(psDPolynomial3DAlloc(-1,1,1,PS_POLYNOMIAL_ORD) != NULL) { 448 psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL"); 449 return 9; 450 } 451 // Attempt to allocate with negative order 452 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms"); 453 if(psDPolynomial3DAlloc(1,-1,1,PS_POLYNOMIAL_ORD) != NULL) { 454 psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL"); 455 return 10; 456 } 457 // Attempt to allocate with negative order 458 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms"); 459 if(psDPolynomial3DAlloc(1,1,-1,PS_POLYNOMIAL_ORD) != NULL) { 460 psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL"); 461 return 11; 462 } 463 464 return 0; 465 } 466 467 // This test will allocate a 4D polynomial and verify the structure allocated 468 psS32 testPolynomial4DAlloc(void) 469 { 470 psPolynomial4D* my4DPoly = NULL; 471 472 // Allocate polynomial 473 my4DPoly = psPolynomial4DAlloc(ORDER+3,ORDER,ORDER+1,ORDER+2,PS_POLYNOMIAL_ORD); 474 // Verify structure allocated 475 if(my4DPoly == NULL) { 476 psError(PS_ERR_UNKNOWN,true,"Returned NULL not expected"); 477 return 1; 478 } 479 // Verify polynomial structure members set properly 480 if(my4DPoly->nX != ORDER) { 481 psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d", 482 my4DPoly->nX, ORDER); 483 return 2; 484 } 485 // Verify polynomial structure members set properly 486 if(my4DPoly->nY != ORDER+1) { 487 psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d", 488 my4DPoly->nY, ORDER+1); 489 return 3; 490 } 491 // Verify polynomial structure members set properly 492 if(my4DPoly->nZ != ORDER+2) { 493 psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d", 494 my4DPoly->nZ, ORDER+2); 495 return 4; 496 } 497 // Verify polynomial structure members set properly 498 if(my4DPoly->nW != ORDER+3) { 499 psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d", 500 my4DPoly->nW, ORDER+3); 501 return 5; 502 } 503 if(my4DPoly->type != PS_POLYNOMIAL_ORD) { 504 psError(PS_ERR_UNKNOWN,true,"Type %d not as expected %d", 505 my4DPoly->type, PS_POLYNOMIAL_ORD); 506 return 6; 507 } 508 for(psS32 i = 0; i < ORDER+3; i++) { 509 for(psS32 j = 0; j < ORDER; j++) { 510 for(psS32 k = 0; k < ORDER+1; k++) { 511 for(psS32 l = 0; l < ORDER+2; l++) { 512 if(my4DPoly->coeff[i][j][k][l] != 0.0) { 513 psError(PS_ERR_UNKNOWN,true,"Coeff[%d][%d][%d][%d] %lg not as expected %lg", 514 i, j, k, l, my4DPoly->coeff[i][j][k][l], 0.0); 515 return 7; 516 } 517 if(my4DPoly->coeffErr[i][j][k][l] != 0.0) { 518 psError(PS_ERR_UNKNOWN,true,"CoeffErr[%d][%d][%d][l] %lg not as expected %lg", 519 i, j, k, l, my4DPoly->coeffErr[i][j][k][l], 0.0); 520 return 8; 521 } 522 if(my4DPoly->mask[i][j][k][l] != 0) { 523 psError(PS_ERR_UNKNOWN,true,"Mask[%d][%d][%d][%d] %d not as expected %d", 524 i, j, k, l, my4DPoly->mask[i][j][k][l], 0); 525 return 9; 526 } 527 } 528 } 529 } 530 } 531 psFree(my4DPoly); 532 533 // Attempt to allocate with negative order 534 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms"); 535 if(psPolynomial4DAlloc(-1,1,1,1,PS_POLYNOMIAL_ORD) != NULL) { 536 psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL"); 537 return 10; 538 } 539 // Attempt to allocate with negative order 540 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms"); 541 if(psPolynomial4DAlloc(1,-1,1,1,PS_POLYNOMIAL_ORD) != NULL) { 542 psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL"); 543 return 11; 544 } 545 // Attempt to allocate with negative order 546 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms"); 547 if(psPolynomial4DAlloc(1,1,-1,1,PS_POLYNOMIAL_ORD) != NULL) { 548 psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL"); 549 return 12; 550 } 551 // Attempt to allocate with negative order 552 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms"); 553 if(psPolynomial4DAlloc(1,1,1,-1,PS_POLYNOMIAL_ORD) != NULL) { 554 psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL"); 555 return 13; 556 } 557 558 return 0; 559 } 560 561 // This test will allocate a 4D polynomial and verify the structure allocated 562 psS32 testDPolynomial4DAlloc(void) 563 { 564 psDPolynomial4D* my4DDPoly = NULL; 565 566 // Allocate polynomial 567 my4DDPoly = psDPolynomial4DAlloc(ORDER+3,ORDER,ORDER+1,ORDER+2,PS_POLYNOMIAL_ORD); 568 // Verify structure allocated 569 if(my4DDPoly == NULL) { 570 psError(PS_ERR_UNKNOWN,true,"Returned NULL not expected"); 571 return 1; 572 } 573 // Verify polynomial structure members set properly 574 if(my4DDPoly->nX != ORDER) { 575 psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d", 576 my4DDPoly->nX, ORDER); 577 return 2; 578 } 579 // Verify polynomial structure members set properly 580 if(my4DDPoly->nY != ORDER+1) { 581 psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d", 582 my4DDPoly->nY, ORDER+1); 583 return 3; 584 } 585 // Verify polynomial structure members set properly 586 if(my4DDPoly->nZ != ORDER+2) { 587 psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d", 588 my4DDPoly->nZ, ORDER+2); 589 return 4; 590 } 591 // Verify polynomial structure members set properly 592 if(my4DDPoly->nW != ORDER+3) { 593 psError(PS_ERR_UNKNOWN,true,"Number of terms %d not as expected %d", 594 my4DDPoly->nW, ORDER+3); 595 return 5; 596 } 597 if(my4DDPoly->type != PS_POLYNOMIAL_ORD) { 598 psError(PS_ERR_UNKNOWN,true,"Type %d not as expected %d", 599 my4DDPoly->type, PS_POLYNOMIAL_ORD); 600 return 6; 601 } 602 for(psS32 i = 0; i < ORDER+3; i++) { 603 for(psS32 j = 0; j < ORDER; j++) { 604 for(psS32 k = 0; k < ORDER+1; k++) { 605 for(psS32 l = 0; l < ORDER+2; l++) { 606 if(my4DDPoly->coeff[i][j][k][l] != 0.0) { 607 psError(PS_ERR_UNKNOWN,true,"Coeff[%d][%d][%d][%d] %lg not as expected %lg", 608 i, j, k, l, my4DDPoly->coeff[i][j][k][l], 0.0); 609 return 7; 610 } 611 if(my4DDPoly->coeffErr[i][j][k][l] != 0.0) { 612 psError(PS_ERR_UNKNOWN,true,"CoeffErr[%d][%d][%d][l] %lg not as expected %lg", 613 i, j, k, l, my4DDPoly->coeffErr[i][j][k][l], 0.0); 614 return 8; 615 } 616 if(my4DDPoly->mask[i][j][k][l] != 0) { 617 psError(PS_ERR_UNKNOWN,true,"Mask[%d][%d][%d][%d] %d not as expected %d", 618 i, j, k, l, my4DDPoly->mask[i][j][k][l], 0); 619 return 9; 620 } 621 } 622 } 623 } 624 } 625 psFree(my4DDPoly); 626 627 // Attempt to allocate with negative order 628 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms"); 629 if(psDPolynomial4DAlloc(-1,1,1,1,PS_POLYNOMIAL_ORD) != NULL) { 630 psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL"); 631 return 10; 632 } 633 // Attempt to allocate with negative order 634 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms"); 635 if(psDPolynomial4DAlloc(1,-1,1,1,PS_POLYNOMIAL_ORD) != NULL) { 636 psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL"); 637 return 11; 638 } 639 // Attempt to allocate with negative order 640 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms"); 641 if(psDPolynomial4DAlloc(1,1,-1,1,PS_POLYNOMIAL_ORD) != NULL) { 642 psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL"); 643 return 12; 644 } 645 // Attempt to allocate with negative order 646 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error msg for negative terms"); 647 if(psDPolynomial4DAlloc(1,1,1,-1,PS_POLYNOMIAL_ORD) != NULL) { 648 psError(PS_ERR_UNKNOWN,true,"Returned structure but expected NULL"); 649 return 13; 650 } 651 652 return 0; 653 } 654 655 27 656 // XXX: This test comes from Paul Price. We should add into the code. 28 657 #define ORDER 3 29 658 #define BAD 1 30 int t01()659 psS32 t01(void) 31 660 { 32 661 psPolynomial1D *poly = psPolynomial1DAlloc(ORDER, PS_POLYNOMIAL_ORD); … … 55 684 56 685 57 psS32 m ain()686 psS32 myTest() 58 687 { 59 688 t01(); … … 503 1132 /* Allocate and initialize data structures */ 504 1133 /*************************************************************************/ 505 506 // HEY507 508 1134 printPositiveTestHeader(stdout, 509 1135 "psFunctions functions", … … 533 1159 "Allocate/Deallocate the psDPolynomial1D structure (CHEBYSHEV).", 534 1160 testStatus); 535 536 537 538 return (!testStatus);539 540 1161 541 1162 printPositiveTestHeader(stdout,
Note:
See TracChangeset
for help on using the changeset viewer.
