Changeset 13614 for trunk/psLib/test/imageops/tap_psImageStructManip.c
- Timestamp:
- Jun 4, 2007, 10:25:32 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/imageops/tap_psImageStructManip.c
r13123 r13614 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2007-05-02 04:14:33 $ 7 * psLib functions tested: 8 * psImageSubset() 9 * psImageCopy() 10 * psImageTrim() 11 * 12 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2007-06-04 20:25:32 $ 9 14 * 10 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 16 21 #include "pstap.h" 17 22 18 psS32 main( psS32 argc, char* argv[] ) 23 24 void genericImageSubsetTest(int numRows, int numCols) 19 25 { 20 psLogSetFormat("HLNM");21 psLogSetLevel(PS_LOG_INFO);22 plan_tests(185);23 24 25 26 // psImageSubset shall create child image of a specified size from a 26 27 // parent psImage structure … … 29 30 psMemId id = psMemGetId(); 30 31 psImage preSubsetStruct; 31 psS32 c = 128; 32 psS32 r = 256; 33 psRegion region1 = psRegionSet(0, c/2, 0, r/2); 34 psRegion region2 = psRegionSet(c/4, c/4+c/2, r/4, r/4+r/2); 35 36 psImage* original = psImageAlloc(c,r,PS_TYPE_U32); 37 for (psS32 row=0;row<r;row++) { 38 for (psS32 col=0;col<c;col++) { 32 psRegion region1 = psRegionSet(0, numCols/2, 0, numRows/2); 33 psRegion region2 = psRegionSet(numCols/4, numCols/4+numCols/2, numRows/4, numRows/4+numRows/2); 34 35 psImage* original = psImageAlloc(numCols,numRows,PS_TYPE_U32); 36 for (psS32 row=0;row<numRows;row++) { 37 for (psS32 col=0;col<numCols;col++) { 39 38 original->data.F32[row][col] = row*1000+col; 40 39 } 41 40 } 42 41 43 memcpy(&preSubsetStruct, original,sizeof(psImage));44 psImage* subset2 = psImageSubset(original, region2);42 memcpy(&preSubsetStruct, original, sizeof(psImage)); 43 psImage* subset2 = psImageSubset(original, region2); 45 44 ok(subset2, "psImageSubset() returned non-NULL (subset2)"); 46 45 skip_start(subset2 == NULL, 25, "Skipping tests because psImageSubset() returned NULL"); 47 psImage* subset3 = psImageSubset(original, region1);46 psImage* subset3 = psImageSubset(original, region1); 48 47 ok(subset3, "psImageSubset() returned non-NULL (subset3)"); 49 48 skip_start(subset3 == NULL, 24, "Skipping tests because psImageSubset() returned NULL"); … … 51 50 // Verify the returned psImage structure members nrow and ncol are equal to 52 51 // the input parameter nrow and ncol respectively 53 ok(subset2->numCols == c/2 && subset2->numRows == r/2,52 ok(subset2->numCols == numCols/2 && subset2->numRows == numRows/2, 54 53 "psImageSubset output size set properly"); 55 ok(subset3->numCols == c/2 && subset3->numRows == r/2,54 ok(subset3->numCols == numCols/2 && subset3->numRows == numRows/2, 56 55 "psImageSubset output size set properly"); 57 56 58 57 // Verify the returned psImage structure contains expected values in the 59 58 // row member, if the input psImage structure image contains known values 60 61 59 bool errorFlag = false; 62 for (psS32 row=0;row< r/2;row++) {63 for (psS32 col=0;col< c/2;col++) {64 if (subset2->data.U32[row][col] != original->data.U32[row+ r/4][col+c/4]) {60 for (psS32 row=0;row<numRows/2;row++) { 61 for (psS32 col=0;col<numCols/2;col++) { 62 if (subset2->data.U32[row][col] != original->data.U32[row+numRows/4][col+numCols/4]) { 65 63 diag("psImageSubset output #1 was wrong at %dx%d (%d vs %d).", 66 row,col,subset2->data.U32[row][col], original->data.U32[row+ r/4][col+c/4]);64 row,col,subset2->data.U32[row][col], original->data.U32[row+numRows/4][col+numCols/4]); 67 65 errorFlag = true; 68 66 } … … 83 81 // Verify the returned psImage structure members row0 and col0 are equal to 84 82 // the input parameters row0 and col0 respectively 85 ok(subset2->col0 == c/4 && subset2->row0 == r/4,83 ok(subset2->col0 == numCols/4 && subset2->row0 == numRows/4, 86 84 "psImageSubset() set col0/row0 correctly (subset2)"); 87 85 ok(subset3->col0 == 0 && subset3->row0 == 0, … … 101 99 ok(original->children->data[0] == subset2 && original->children->data[1] == subset3, 102 100 "psImageSubset did properly store the children pointers."); 103 104 101 105 102 // Verify the returned psImage structure pointer is null and program … … 111 108 ok(subset1 == NULL, "psImageSubset returned NULL when input image was NULL."); 112 109 113 114 110 // Verify the returned psImage structure pointer is null and program 115 111 // execution doesn't stop, if the input parameters nrow and/or ncol are zero. … … 117 113 // An error should follow... 118 114 // XXX: Verify error 119 memcpy(&preSubsetStruct,original,sizeof(psImage)); 120 subset1 = psImageSubset(original, psRegionSet(0,c/2,r/2,r/2)); 121 ok(subset1 == NULL, "psImageSubset returned NULL when numRows=0."); 122 // An error should follow... 123 // XXX: Verify error 124 subset1 = psImageSubset(original,psRegionSet(c/2,c/2,0,r/2)); 125 ok(subset1 == NULL, "psImageSubset returned NULL when numCols=0."); 126 ok(memcmp(original,&preSubsetStruct,sizeof(psImage)) == 0, 127 "psImageSubset didn't change the original struct though it failed to subset."); 115 { 116 memcpy(&preSubsetStruct,original,sizeof(psImage)); 117 subset1 = psImageSubset(original, psRegionSet(0,numCols/2,numRows/2,numRows/2)); 118 ok(subset1 == NULL, "psImageSubset returned NULL when numRows=0."); 119 // An error should follow... 120 // XXX: Verify error 121 subset1 = psImageSubset(original,psRegionSet(numCols/2,numCols/2,0,numRows/2)); 122 ok(subset1 == NULL, "psImageSubset returned NULL when numCols=0."); 123 ok(memcmp(original,&preSubsetStruct,sizeof(psImage)) == 0, 124 "psImageSubset didn't change the original struct though it failed to subset."); 125 } 128 126 129 127 // Verify the returned psImage structure pointer is null and program … … 132 130 // An error should follow... 133 131 // XXX: Verify error 134 subset1 = psImageSubset(original, psRegionSet(0,c/2, 0,r*2)); 135 ok(subset1 == NULL, 136 "psImageSubset returned NULL when subset origin was outside of image (via cols)"); 137 // An error should follow... 138 // XXX: Verify error 139 subset1 = psImageSubset(original,psRegionSet(0,c*2,0,r/2)); 140 ok(subset1 == NULL, 141 "psImageSubset returned NULL when subset origin was outside of image (via rows)"); 142 // An error should follow... 143 // XXX: Verify error 144 subset1 = psImageSubset(original, psRegionSet(-1,c/2,0,r/2)); 145 ok(subset1 == NULL, 146 "psImageSubset returned NULL when subset origin was outside of image (col0=-1)"); 147 // An error should follow... 148 // XXX: Verify error 149 subset1 = psImageSubset(original, psRegionSet(0,c/2,-1,r/2)); 150 ok(subset1 == NULL, 151 "psImageSubset returned NULL when subset origin was outside of image (row0=-1)"); 152 132 { 133 subset1 = psImageSubset(original, psRegionSet(0,numCols/2, 0,numRows*2)); 134 ok(subset1 == NULL, 135 "psImageSubset returned NULL when subset origin was outside of image (via cols)"); 136 // An error should follow... 137 // XXX: Verify error 138 subset1 = psImageSubset(original,psRegionSet(0,numCols*2,0,numRows/2)); 139 ok(subset1 == NULL, 140 "psImageSubset returned NULL when subset origin was outside of image (via rows)"); 141 // An error should follow... 142 // XXX: Verify error 143 subset1 = psImageSubset(original, psRegionSet(-1,numCols/2,0,numRows/2)); 144 ok(subset1 == NULL, 145 "psImageSubset returned NULL when subset origin was outside of image (col0=-1)"); 146 // An error should follow... 147 // XXX: Verify error 148 subset1 = psImageSubset(original, psRegionSet(0,numCols/2,-1,numRows/2)); 149 ok(subset1 == NULL, 150 "psImageSubset returned NULL when subset origin was outside of image (row0=-1)"); 151 } 153 152 154 153 // Verify the returned psImage structure pointer is null and program … … 158 157 // An error should follow... 159 158 // XXX: Verify error 160 subset1 = psImageSubset(original,psRegionSet(0,c/2,0,r+1)); 161 ok(subset1 == NULL, 162 "psImageSubset returned NULL when subset was outside of image (via rows)"); 163 // An error should follow... 164 // XXX: Verify error 165 subset1 = psImageSubset(original, psRegionSet(0,c+1,0,r/2)); 166 ok(subset1 == NULL, 167 "psImageSubset returned NULL when subset was outside of image (via cols)"); 168 // An error should follow... 169 // XXX: Verify error 170 subset1 = psImageSubset(original,psRegionSet(0,c+1,0,r+1)); 171 ok(subset1 == NULL, 172 "psImageSubset returned NULL when subset was outside of image (via row+cols)"); 173 159 { 160 subset1 = psImageSubset(original,psRegionSet(0,numCols/2,0,numRows+1)); 161 ok(subset1 == NULL, 162 "psImageSubset returned NULL when subset was outside of image (via rows)"); 163 // An error should follow... 164 // XXX: Verify error 165 subset1 = psImageSubset(original, psRegionSet(0,numCols+1,0,numRows/2)); 166 ok(subset1 == NULL, 167 "psImageSubset returned NULL when subset was outside of image (via cols)"); 168 // An error should follow... 169 // XXX: Verify error 170 subset1 = psImageSubset(original,psRegionSet(0,numCols+1,0,numRows+1)); 171 ok(subset1 == NULL, 172 "psImageSubset returned NULL when subset was outside of image (via row+cols)"); 173 } 174 174 175 175 // psImageFreeChildren shall deallocate any children images of a … … 196 196 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 197 197 } 198 } 199 200 psS32 main(psS32 argc, char* argv[]) 201 { 202 psLogSetFormat("HLNM"); 203 psLogSetLevel(PS_LOG_INFO); 204 plan_tests(239); 205 206 genericImageSubsetTest(128, 256); 207 genericImageSubsetTest(256, 128); 208 genericImageSubsetTest(128, 128); 198 209 199 210 // psImageCopy()
Note:
See TracChangeset
for help on using the changeset viewer.
