Changeset 980 for trunk/psLib/test/image/tst_psImage.c
- Timestamp:
- Jun 9, 2004, 5:16:13 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/image/tst_psImage.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/image/tst_psImage.c
r953 r980 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.1 5$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-06- 09 21:20:53 $8 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-06-10 03:16:13 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 26 26 static int testImageClip(void); 27 27 static int testImageClipNAN(void); 28 static int testImageOverlay(void); 28 29 29 30 testDescription tests[] = { … … 33 34 {testImageClip,"571-testImageClip",0}, 34 35 {testImageClipNAN,"572-testImageClipNAN",0}, 36 {testImageOverlay,"573-testImageOverlay",0}, 35 37 {NULL} 36 38 }; … … 38 40 int main() 39 41 { 40 ps SetLogLevel(PS_LOG_INFO);41 42 psLogSetLevel(PS_LOG_INFO); 43 testImageOverlay(); 42 44 if (! runTestSuite(stderr,"psImage",tests)) { 43 45 psAbort(__FILE__,"One or more tests failed"); … … 787 789 return 0; 788 790 } 791 792 int testImageOverlay(void) 793 { 794 795 psImage* img = NULL; 796 psImage* img2 = NULL; 797 unsigned int c = 128; 798 unsigned int r = 256; 799 int retVal; 800 801 /* 802 psImageSectionOverlay shall modified pixel values in a psImage structure to 803 be equal to the value of the originaldata and an overlay image with a 804 specified operation. Valid operations include =, +, -, *, /. 805 806 Verify the returned integer is equal to the number of pixels modified 807 and the input parameter psImage structure is modified at the specified 808 location and range with the given overlay image and the specified 809 function. Cases should include all the valid operations. Comparison of 810 expected values should include a delta to allow for testing on 811 different platforms. 812 813 Verify the returned integer is equal to zero and the input psImage structure 814 is unmodified, if the overlay specified is not within the data range of the 815 input psImage structure. 816 817 Verify the returned integer is equal to zero, the input psImage 818 structure is unmodified and program execution doesn't stop, if the 819 overlay specified is null. 820 821 Verify the returned integer is equal to zero and program execution 822 doesn't stop, if the input parameter image is null. 823 824 Verify program execution doen't stop, if the overly image contains 825 zero values with division operation is specified. 826 */ 827 828 829 830 #define testOverlayTypeOP(DATATYPE,OP,OPSTRING) \ 831 img = psImageAlloc(c,r,PS_TYPE_##DATATYPE); \ 832 for (unsigned row=0;row<r;row++) { \ 833 ps##DATATYPE* imgRow = img->data.DATATYPE[row]; \ 834 for (unsigned col=0;col<c;col++) { \ 835 imgRow[col] = 6.0; \ 836 } \ 837 } \ 838 img2 = psImageAlloc(c/2,r/2,PS_TYPE_##DATATYPE); \ 839 for (unsigned row=0;row<r/2;row++) { \ 840 ps##DATATYPE* img2Row = img2->data.DATATYPE[row]; \ 841 for (unsigned col=0;col<c/2;col++) { \ 842 img2Row[col] = 2.0; \ 843 } \ 844 } \ 845 retVal = psImageOverlaySection(img,img2,c/4,r/4,OPSTRING); \ 846 if (retVal != 0) { \ 847 psError(__func__,"psImageOverlaySection returned non-zero %s op",OPSTRING); \ 848 return 1; \ 849 } \ 850 for (unsigned row=0;row<r;row++) { \ 851 ps##DATATYPE* imgRow = img->data.DATATYPE[row]; \ 852 for (unsigned col=0;col<c;col++) { \ 853 ps##DATATYPE val = 6.0; \ 854 if ( ! (row < r/4 || row >= r/2+r/4 || col < c/4 || col >= c/2+c/4)) { \ 855 val OP 2.0; \ 856 } \ 857 if (fabsf(imgRow[col] - val) > FLT_EPSILON) { \ 858 psError(__func__,"Value incorrect at %d,%d (%.2f vs %.2f for %s)", \ 859 col,row,imgRow[col],val,OPSTRING); \ 860 return 2; \ 861 } \ 862 } \ 863 } \ 864 psImageFree(img); \ 865 psImageFree(img2); 866 867 #define testOverlayType(DATATYPE) \ 868 testOverlayTypeOP(DATATYPE,+=,"+"); \ 869 testOverlayTypeOP(DATATYPE,-=,"-"); \ 870 testOverlayTypeOP(DATATYPE,*=,"*");\ 871 testOverlayTypeOP(DATATYPE,/=,"/");\ 872 testOverlayTypeOP(DATATYPE,=,"="); 873 874 testOverlayType(C64); 875 testOverlayType(C32); 876 testOverlayType(F64); 877 testOverlayType(F32); 878 testOverlayType(S16); 879 testOverlayType(S8); 880 testOverlayType(U16); 881 testOverlayType(U8); 882 883 return 0; 884 }
Note:
See TracChangeset
for help on using the changeset viewer.
