Changeset 2717
- Timestamp:
- Dec 15, 2004, 2:11:42 PM (22 years ago)
- Location:
- trunk/psLib/test/dataManip
- Files:
-
- 2 added
- 1 edited
-
tst_psFunc02.c (modified) (4 diffs)
-
verified/tst_psFunc02.stderr (added)
-
verified/tst_psFunc02.stdout (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/dataManip/tst_psFunc02.c
r2392 r2717 21 21 psS32 currentId = psMemGetId(); 22 22 psSpline1D *tmpSpline; 23 psVector* bounds; 23 24 24 25 /****************************************************************************/ … … 83 84 "psSpline1DAlloc(): linear, min/max are equal"); 84 85 86 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message."); 85 87 tmpSpline = psSpline1DAlloc(N, LINEAR, 1.0, 1.0); 86 88 … … 217 219 "psSpline1DAlloc(): cubic, min/max are equal"); 218 220 221 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message"); 219 222 tmpSpline = psSpline1DAlloc(N, CUBIC, 1.0, 1.0); 220 223 … … 290 293 testStatus); 291 294 295 /****************************************************************************/ 296 /****************************************************************************/ 297 testStatus = true; 298 printPositiveTestHeader(stdout, 299 "psFunction functions", 300 "psSpline1DAllocGeneric(): linear, normal"); 301 302 bounds = psVectorAlloc(5,PS_TYPE_F32); 303 bounds->n = bounds->nalloc; 304 for(psU32 n = 0; n < 5; n++ ) { 305 bounds->data.F32[n] = (n+1) * 2; 306 } 307 tmpSpline = psSpline1DAllocGeneric(bounds, LINEAR); 308 if (tmpSpline == NULL) { 309 printf("ERROR: Could not allocate psSpline1D data structure\n"); 310 testStatus = false; 311 } 312 if (tmpSpline->spline == NULL) { 313 printf("ERROR: Could not allocate psSpline1D->spline data structure\n"); 314 testStatus = false; 315 } 316 317 if (tmpSpline->n != N) { 318 printf("ERROR: spline->n set incorrectly (%d)\n", tmpSpline->n); 319 testStatus = false; 320 } 321 322 for (i=0;i<N;i++) { 323 if (tmpSpline->spline[i] == NULL) { 324 printf("ERROR: Could not allocate spline %d\n", i); 325 testStatus = false; 326 } 327 if ((tmpSpline->spline[i])->n != LINEAR+1) { 328 printf("ERROR: Spline created with order %d\n", (tmpSpline->spline[i])->n); 329 testStatus = false; 330 } 331 } 332 333 if (tmpSpline->domains == NULL) { 334 printf("ERROR: Could not allocate psSpline1D->domains data structure\n"); 335 testStatus = false; 336 } 337 338 for (i=0;i<N+1;i++) { 339 printf("psSpline1D->domains[%d] is %f\n", i, tmpSpline->domains[i]); 340 } 341 psFree(bounds); 342 psFree(tmpSpline); 343 psMemCheckCorruption(1); 344 memLeaks = psMemCheckLeaks(currentId,NULL,stderr,false); 345 if (0 != memLeaks) { 346 psError(PS_ERR_UNKNOWN,true,"Memory Leaks! (%d leaks)", memLeaks); 347 testStatus = false; 348 } 349 printFooter(stdout, 350 "psFunctions functions", 351 "psSpline1DAllocGeneric(): linear, normal", 352 testStatus); 353 354 /****************************************************************************/ 355 /****************************************************************************/ 356 testStatus = true; 357 printPositiveTestHeader(stdout, 358 "psFunction functions", 359 "psSpline1DAllocGeneric(): negative order"); 360 361 bounds = psVectorAlloc(5,PS_TYPE_F32); 362 bounds->n = bounds->nalloc; 363 for(psU32 n = 0; n < 5; n++ ) { 364 bounds->data.F32[n] = (n+1) * 2; 365 } 366 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message."); 367 tmpSpline = psSpline1DAllocGeneric(bounds, -1); 368 if (tmpSpline != NULL) { 369 psError(PS_ERR_UNKNOWN,true,"Did not return null for negative order"); 370 return 10; 371 } 372 psFree(bounds); 373 psMemCheckCorruption(1); 374 memLeaks = psMemCheckLeaks(currentId,NULL,stderr,false); 375 if (0 != memLeaks) { 376 psError(PS_ERR_UNKNOWN,true,"Memory Leaks! (%d leaks)", memLeaks); 377 testStatus = false; 378 } 379 printFooter(stdout, 380 "psFunctions functions", 381 "psSpline1DAllocGeneric(): negative order", 382 testStatus); 383 384 /****************************************************************************/ 385 /****************************************************************************/ 386 testStatus = true; 387 printPositiveTestHeader(stdout, 388 "psFunction functions", 389 "psSpline1DAllocGeneric(): bound equal to NULL"); 390 391 bounds = NULL; 392 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message."); 393 tmpSpline = psSpline1DAllocGeneric(bounds, LINEAR); 394 if (tmpSpline != NULL) { 395 psError(PS_ERR_UNKNOWN,true,"Did not return null for bounds equal to NULL"); 396 return 20; 397 } 398 psMemCheckCorruption(1); 399 memLeaks = psMemCheckLeaks(currentId,NULL,stderr,false); 400 if (0 != memLeaks) { 401 psError(PS_ERR_UNKNOWN,true,"Memory Leaks! (%d leaks)", memLeaks); 402 testStatus = false; 403 } 404 printFooter(stdout, 405 "psFunctions functions", 406 "psSpline1DAllocGeneric(): bound equal to NULL", 407 testStatus); 408 409 /****************************************************************************/ 410 /****************************************************************************/ 411 testStatus = true; 412 printPositiveTestHeader(stdout, 413 "psFunction functions", 414 "psSpline1DAllocGeneric(): bounds with zero elements"); 415 416 bounds = psVectorAlloc(5,PS_TYPE_F32); 417 bounds->n = 0; 418 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message."); 419 tmpSpline = psSpline1DAllocGeneric(bounds, LINEAR); 420 if (tmpSpline != NULL) { 421 psError(PS_ERR_UNKNOWN,true,"Did not return null for negative order"); 422 return 30; 423 } 424 psFree(bounds); 425 psMemCheckCorruption(1); 426 memLeaks = psMemCheckLeaks(currentId,NULL,stderr,false); 427 if (0 != memLeaks) { 428 psError(PS_ERR_UNKNOWN,true,"Memory Leaks! (%d leaks)", memLeaks); 429 testStatus = false; 430 } 431 printFooter(stdout, 432 "psFunctions functions", 433 "psSpline1DAllocGeneric(): bounds with zero elements", 434 testStatus); 435 292 436 return (!testStatus); 293 437 }
Note:
See TracChangeset
for help on using the changeset viewer.
