Changeset 939
- Timestamp:
- Jun 8, 2004, 2:28:09 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/image/tst_psImage.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/image/tst_psImage.c
r938 r939 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.1 1$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-06-0 8 23:57:00$8 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-06-09 00:28:09 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 25 25 static int testImageCopy(void); 26 26 static int testImageClip(void); 27 static int testImageClipNAN(void); 27 28 28 29 testDescription tests[] = { … … 31 32 {testImageCopy,"551-testImageCopy",0}, 32 33 {testImageClip,"571-testImageClip",0}, 34 {testImageClipNAN,"572-testImageClipNAN",0}, 33 35 {NULL} 34 36 }; … … 733 735 return 0; 734 736 } 737 738 int testImageClipNAN(void) 739 { 740 psImage* img = NULL; 741 unsigned int c = 128; 742 unsigned int r = 256; 743 int currentId = psMemGetId(); 744 int numClipped = 0; 745 int retVal; 746 747 psLogMsg(__func__,PS_LOG_INFO, 748 "psImageClipNaN shall modified pixel values of NaN with a specified value"); 749 750 /* 751 psImageClipNaN shall modify a psImage structure with pixel values set 752 to NaN to a value specified as an input parameter. 753 754 Verify the returned integer is equal to the number of pixels modified 755 and the psImage is modified at locations where NaN pixels where 756 located to the value specified in the input parameter value. 757 758 Verify the returned integer is zero and program execution doesn't stop, 759 if the input parameter psImage structure pointer is null. 760 */ 761 762 // create image 763 #define testImageClipNaNByType(datatype) \ 764 img = psImageAlloc(c,r,PS_TYPE_##datatype); \ 765 for (unsigned row=0;row<r;row++) { \ 766 ps##datatype* imgRow = img->data.datatype[row]; \ 767 for (unsigned col=0;col<c;col++) { \ 768 if (row == col) { \ 769 imgRow[col] = NAN; \ 770 } else if (row+1 == col) { \ 771 imgRow[col] = INFINITY; \ 772 } else { \ 773 imgRow[col] = (ps##datatype)(row+col); \ 774 } \ 775 } \ 776 } \ 777 \ 778 retVal = psImageClipNaN(img,-1.0f); \ 779 \ 780 numClipped = 0; \ 781 for (unsigned row=0;row<r;row++) { \ 782 ps##datatype* imgRow = img->data.datatype[row]; \ 783 for (unsigned col=0;col<c;col++) { \ 784 ps##datatype value = (ps##datatype)(row+col); \ 785 if ( (row == col) || (row+1 == col) ) { \ 786 numClipped++; \ 787 value = -1.0; \ 788 } \ 789 if (fabsf(imgRow[col]-value) > FLT_EPSILON) { \ 790 psError(__func__,"Pixel value is not as expected (%f vs %f) at %d,%d", \ 791 imgRow[col],value,col,row); \ 792 return 1; \ 793 } \ 794 } \ 795 } \ 796 if (retVal != numClipped) { \ 797 psError(__func__,"Expected %d clips, but got %d", \ 798 numClipped,retVal); \ 799 return 2; \ 800 } \ 801 psImageFree(img); 802 803 testImageClipNaNByType(F32); 804 testImageClipNaNByType(F64); 805 806 // Verify the retuned integer is zero, psImage structure input is unmodified 807 // and program executions doesn't stop, if input parameter psImage structure 808 // pointer is null. 809 retVal = psImageClipNaN(NULL,-1.0f); 810 if (retVal != 0) { 811 psError(__func__,"Expected zero return for clips of a NULL image."); 812 return 3; 813 } 814 815 816 if (psMemCheckLeaks(currentId,NULL,NULL) != 0) { 817 psAbort(__func__,"Memory Leaks!"); 818 } 819 psMemCheckCorruption(1); 820 821 return 0; 822 }
Note:
See TracChangeset
for help on using the changeset viewer.
