Changeset 13123
- Timestamp:
- May 1, 2007, 6:14:33 PM (19 years ago)
- Location:
- trunk/psLib/test
- Files:
-
- 1 added
- 17 edited
-
TABLE-SDRS-CH06-DataManip (added)
-
imageops/Makefile.am (modified) (1 diff)
-
imageops/tap_psImageGeomManip.c (modified) (28 diffs)
-
imageops/tap_psImageMaskOps.c (modified) (3 diffs)
-
imageops/tap_psImagePixelExtract.c (modified) (25 diffs)
-
imageops/tap_psImagePixelManip.c (modified) (10 diffs)
-
imageops/tap_psImageStats.c (modified) (5 diffs)
-
imageops/tap_psImageStructManip.c (modified) (22 diffs)
-
math/Makefile.am (modified) (1 diff)
-
math/tap_psMatrix03.c (modified) (4 diffs)
-
math/tap_psMatrixVectorArithmetic01.c (modified) (2 diffs)
-
math/tap_psMatrixVectorArithmetic02.c (modified) (2 diffs)
-
math/tap_psMatrixVectorArithmetic03.c (modified) (3 diffs)
-
math/tap_psMinimizePowell.c (modified) (3 diffs)
-
math/tap_psRandom.c (modified) (13 diffs)
-
math/tap_psSparse.c (modified) (18 diffs)
-
mathtypes/tap_psVector.c (modified) (2 diffs)
-
types/tap_psPixels_all.c (modified) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/imageops/Makefile.am
r13042 r13123 21 21 tap_psImageConvolve2 \ 22 22 tap_psImagePixelExtract \ 23 tap_psImageInterpolate2 23 tap_psImageInterpolate2 \ 24 tap_psImageMaskOps 24 25 25 26 # tap_psImageShiftKernel -
trunk/psLib/test/imageops/tap_psImageGeomManip.c
r13084 r13123 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $8 * @date $Date: 2007-05-0 1 00:08:52$7 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2007-05-02 04:14:33 $ 9 9 * 10 10 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 154 154 plan_tests(237); 155 155 156 // test ImageRebin()157 // This function shall generate a rescaled version of a psImage structure158 // derived from a specified statistics method.156 // test psImageRebin() 157 // This function shall generate a rescaled version of a psImage 158 // structure derived from a specified statistics method. 159 159 if (1) { 160 160 psMemId id = psMemGetId(); … … 295 295 testRebinType(U16); 296 296 testRebinType(S8); 297 // Verify the returned psImage structure is nulland program execution297 // Verify the returned psImage structure is NULL and program execution 298 298 // doesn't stop, if the input image type is not supported. 299 299 // Following should be an error for unsupported type … … 305 305 ok(out == NULL, "psImageRebin returned NULL for unsupported type"); 306 306 307 // Verify the returned psImage structure is nulland program execution307 // Verify the returned psImage structure is NULL and program execution 308 308 // doesn't stop, if the mask type is not U8 309 309 // Following should be an error for invallid mask type … … 314 314 psFree(in); 315 315 316 // Verify the returned psImage structure is nulland program execution317 // doesn't stop, if the input parameter input is null.316 // Verify the returned psImage structure is NULL and program execution 317 // doesn't stop, if the input parameter input is NULL. 318 318 out2 = psImageRebin(NULL,NULL,NULL,0,1,&stats); 319 319 ok(out2 == NULL, "psImageRebin returned NULL with NULL input"); 320 320 321 // Verify the returned psImage structure is nulland program execution321 // Verify the returned psImage structure is NULL and program execution 322 322 // doesn't stop, if the input parameter scale is less than or equal to zero. 323 323 in = psImageAlloc(16, 16, PS_TYPE_F32); … … 327 327 ok(out2 == NULL, "psImageRebin returned NULL when the scale was zero"); 328 328 329 // Verify the returned psImage structure is nulland program execution330 // doesn't stop, if the input parameter stats is null.331 // Following should be an error for stats null329 // Verify the returned psImage structure is NULL and program execution 330 // doesn't stop, if the input parameter stats is NULL. 331 // Following should be an error for stats NULL 332 332 // XXX: Verify error 333 333 out2 = psImageRebin(NULL,in,NULL,0,1,NULL); 334 334 ok(out2 == NULL, "psImageRebin returned an NULL when the stats was NULL"); 335 335 336 // Verify the returned psImage structure is nulland program execution336 // Verify the returned psImage structure is NULL and program execution 337 337 // doesn't stop, if the input parameter psStats structure member options 338 338 // is zero or any value which doesn't correspond to a valid statistical … … 350 350 ok(out2 == NULL, "psImageRebin returned an image though the stats options was PS_STAT_USE_RANGE"); 351 351 352 // Verify the returned psImage structure is nulland program execution352 // Verify the returned psImage structure is NULL and program execution 353 353 // doesn't stop, if the input parameter psStats structure member options 354 354 // specifies more than one valid statistical method. … … 363 363 } 364 364 365 // test ImageRoll()365 // test psImageRoll() 366 366 if (1) { 367 367 psMemId id = psMemGetId(); … … 387 387 388 388 in = psImageAlloc(cols,rows,PS_TYPE_F32); 389 for (psS32 row=0;row<rows;row++) 390 { 391 psF32 *inRow = in->data.F32[row]; 392 for (psS32 col=0;col<cols;col++) { 393 inRow[col] = (psF32)row+(psF32)col/1000.0f; 389 for (psS32 row=0;row<rows;row++) { 390 for (psS32 col=0;col<cols;col++) { 391 in->data.F32[row][col] = (psF32)row+(psF32)col/1000.0f; 394 392 } 395 393 } … … 397 395 out = psImageRoll(NULL,in,0,0); 398 396 bool errorFlag = false; 399 for (psS32 row=0;row<rows;row++) 400 { 397 for (psS32 row=0;row<rows;row++) { 401 398 psF32 *inRow = in->data.F32[row]; 402 399 psF32 *outRow = out->data.F32[row]; … … 519 516 520 517 521 // Verify the returned psImage structure pointer is nulland program522 // execution doesn't stop, if input parameter input is null.518 // Verify the returned psImage structure pointer is NULL and program 519 // execution doesn't stop, if input parameter input is NULL. 523 520 out2 = psImageRoll(NULL,NULL,0,0); 524 if (out2 != NULL) 525 { 521 if (out2 != NULL) { 526 522 psError(PS_ERR_UNKNOWN, true,"psImageRoll did not return NULL though input image was NULL!?"); 527 523 return 2; … … 567 563 } 568 564 569 570 // testImageRotate() 565 // test psImageRotate() 571 566 if (1) { 572 567 psMemId id = psMemGetId(); … … 599 594 psImage *sImg = psImageAlloc(cols,rows,PS_TYPE_S16); 600 595 601 for(psS32 row=0;row<rows;row++) 602 { 596 for(psS32 row=0;row<rows;row++) { 603 597 psF32 *fRow = fImg->data.F32[row]; 604 598 psS16 *sRow = sImg->data.S16[row]; … … 612 606 // is to verify the results manually and bless it for automated comparison 613 607 // thereafter 614 615 608 616 609 // write results of various rotates to a file and verify with truth images … … 796 789 } 797 790 //HERE 798 // Verify the returned psImage structure pointer is nulland program799 // execution doesn't stop, if the input parameter input is null.791 // Verify the returned psImage structure pointer is NULL and program 792 // execution doesn't stop, if the input parameter input is NULL. 800 793 // Following should be an error 801 794 // XXX: Verify error … … 803 796 ok(fOut == NULL, "NULL was returned when the input image was NULL"); 804 797 805 // Verify the returned psImage structure pointer is nulland program798 // Verify the returned psImage structure pointer is NULL and program 806 799 // execution doesn't stop, if the specified interpolation mode is unallowed 807 800 // Following should be an error for unallowed interpolation type … … 882 875 ok(fRecycle == fOut, "psImageShift did recycle my image"); 883 876 884 // Verify the returned psImage structure pointer is nulland program885 // execution doesn't stop, if the input psImage structure pointer is null.877 // Verify the returned psImage structure pointer is NULL and program 878 // execution doesn't stop, if the input psImage structure pointer is NULL. 886 879 // Following should be an error 887 880 // XXX: Verify error … … 889 882 ok(fOut == NULL, "psImageShift did return NULL given a NULL input image"); 890 883 891 // Verify the returned psImage structure is nulland program execution884 // Verify the returned psImage structure is NULL and program execution 892 885 // doesn't stop, if the specified interpolation mode is unallowed. 893 886 // Following should be an error for unallowed interpolation mode … … 901 894 902 895 903 // test ImageResample()896 // test psImageResample() 904 897 if (1) { 905 898 psMemId id = psMemGetId(); 906 907 899 psS32 rows = 60; 908 900 psS32 cols = 80; … … 911 903 psErr *err; 912 904 913 psImage *image = psImageAlloc(cols,rows,PS_TYPE_F32); 914 for(psS32 row=0;row<rows;row++) 915 { 916 psF32 *imageRow = image->data.F32[row]; 917 for (psS32 col=0;col<cols;col++) { 918 imageRow[col] = row+2*col; 905 psImage *image = psImageAlloc(cols, rows, PS_TYPE_F32); 906 for(psS32 row=0;row<rows;row++) { 907 for (psS32 col=0;col<cols;col++) { 908 image->data.F32[row][col] = row+2*col; 919 909 } 920 910 } … … 925 915 ok(result == orig, "psImageResample() recycled image"); 926 916 ok(result->type.type == PS_TYPE_F32, "psImageResample() produced the correct type"); 927 928 929 917 ok(result->numCols == image->numCols*scale && result->numRows == image->numRows*scale, 930 918 "psImageResample() produced the correct size"); 931 932 919 933 920 bool errorFlag = false; … … 939 926 psMaskType maskVal; 940 927 psF32 truthValue; 941 for(psS32 row=0;row<result->numRows;row++) 942 { 928 for(psS32 row=0;row<result->numRows;row++) { 943 929 for (psS32 col=0;col<result->numCols;col++) { 944 930 // truthValue = psImagePixelInterpolate(image, … … 961 947 ok(!errorFlag, "psImageResample() produced the correct data values"); 962 948 963 // verify that image= nullis handled properly.949 // verify that image=NULL is handled properly. 964 950 psErrorClear(); 965 951 result = psImageResample(result,NULL,scale,PS_INTERPOLATE_FLAT); … … 1002 988 1003 989 1004 // test ImageTransform()990 // test psImageTransform() 1005 991 if (1) { 1006 992 psMemId id = psMemGetId(); … … 1013 999 1014 1000 psImage *in = psImageAlloc(cols,rows,PS_TYPE_F32); 1015 for (psS32 row=0;row<rows;row++) 1016 { 1017 psF32 *inRow = in->data.F32[row]; 1018 for (psS32 col=0;col<cols;col++) { 1019 inRow[col] = (psF32)row+(psF32)col/1000.0f; 1001 for (psS32 row=0;row<rows;row++) { 1002 for (psS32 col=0;col<cols;col++) { 1003 in->data.F32[row][col] = (psF32)row+(psF32)col/1000.0f; 1020 1004 } 1021 1005 } 1022 1006 P_PSIMAGE_SET_COL0(in, 1); 1023 psImage *out = psImageTransform(NULL, 1024 NULL, 1025 in, 1026 NULL, 1027 0, 1028 trans, 1029 psRegionSet(1,1+cols*2,0,rows*2), 1030 NULL, 1031 PS_INTERPOLATE_FLAT, 1032 -1); 1007 psImage *out = psImageTransform(NULL, NULL, in, NULL, 0, trans, 1008 psRegionSet(1,1+cols*2,0,rows*2), NULL, 1009 PS_INTERPOLATE_FLAT, -1); 1033 1010 1034 1011 ok(out != NULL, "psImageTransform() returned non-NULL"); … … 1036 1013 ok(out->numRows == rows*2 && out->numCols == cols*2, "psImageTransform() produced the correct size"); 1037 1014 1038 if ( 0) {1015 if (1) { 1039 1016 psMemId id = psMemGetId(); 1040 1017 psImageInterpolateOptions *tmpIntOpts = psImageInterpolateOptionsAlloc( … … 1045 1022 psMaskType maskVal; 1046 1023 bool errorFlag = false; 1047 for (psS32 row=0;row<out->numRows;row++) 1048 { 1049 psF32 *outRow = out->data.F32[row]; 1024 for (psS32 row=0;row<out->numRows;row++) { 1050 1025 for (psS32 col=0;col<cols;col++) { 1051 1026 psImageInterpolate(&imgVal, &varVal, &maskVal, … … 1054 1029 tmpIntOpts); 1055 1030 float inValue = imgVal; 1056 if (fabsf(outRow[col] - inValue) > 0.01) { 1057 diag("out at %d,%d was %g, expected %g", col,row,outRow[col], inValue); 1031 if (fabsf(out->data.F32[row][col] - inValue) > 0.01) { 1032 diag("out at %d,%d was %g, expected %g", col,row, 1033 out->data.F32[row][col], inValue); 1058 1034 errorFlag = true; 1059 1035 } -
trunk/psLib/test/imageops/tap_psImageMaskOps.c
r11729 r13123 3 3 * @brief Contains the tests for psMaskOps.[ch] 4 4 * 5 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $6 * @date $Date: 2007-0 2-09 20:40:22$5 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2007-05-02 04:14:33 $ 7 7 * 8 8 * XXX: In general, the image tests with (1, N) and (N, 1) failed and have … … 721 721 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 722 722 } 723 // XXX: These seg fault 723 724 if (0) genericImageMaskCircleTest(N, 1, N/2, 1, N/4); 724 725 if (0) genericImageMaskCircleTest(1, N, 1, N/2, N/4); … … 734 735 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 735 736 } 737 // XXX: These seg fault 736 738 if (0) genericImageKeepCircleTest(N, 1, N/2, 1, N/4); 737 739 if (0) genericImageKeepCircleTest(1, N, 1, N/2, N/4); -
trunk/psLib/test/imageops/tap_psImagePixelExtract.c
r13042 r13123 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $9 * @date $Date: 2007-0 4-26 22:18:03 $8 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-05-02 04:14:33 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 17 17 #include "pstap.h" 18 18 19 psS32 main( psS32 argc, char* argv[])19 psS32 main(psS32 argc, char* argv[]) 20 20 { 21 21 psLogSetFormat("HLNM"); … … 23 23 plan_tests(248); 24 24 25 // test ImageSlice()25 // test psImageSlice() 26 26 { 27 27 psMemId id = psMemGetId(); … … 31 31 const psS32 n = r / 4 -1; 32 32 psImage* image; 33 psPixels* positions = psPixelsAlloc( r);34 psImage* mask = psImageAlloc( c, r, PS_TYPE_MASK);35 psStats* stat = psStatsAlloc( PS_STAT_SAMPLE_MEDIAN);33 psPixels* positions = psPixelsAlloc(r); 34 psImage* mask = psImageAlloc(c, r, PS_TYPE_MASK); 35 psStats* stat = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN); 36 36 37 37 … … 46 46 // cases should be used for each possible direction. Data region cases 47 47 // should include 0x0, 1x1, Nx1, 1xN, NxN, MxN 48 for ( psS32 row = 0;row < r;row++) {48 for (psS32 row = 0;row < r;row++) { 49 49 psMaskType* maskRow = mask->data.PS_TYPE_MASK_DATA[row]; 50 for ( psS32 col = 0;col < c;col++) {51 maskRow[ col] = 0;50 for (psS32 col = 0;col < c;col++) { 51 maskRow[col] = 0; 52 52 } 53 53 } … … 58 58 psVector* out = NULL; \ 59 59 bool errorFlag = false; \ 60 image = psImageAlloc( c, r, PS_TYPE_##TYPE); \61 for ( psS32 row = 0;row < r;row++) { \62 ps##TYPE *imageRow = image->data.TYPE[ row]; \60 image = psImageAlloc(c, r, PS_TYPE_##TYPE); \ 61 for (psS32 row = 0;row < r;row++) { \ 62 ps##TYPE *imageRow = image->data.TYPE[row]; \ 63 63 ps##TYPE rowOffset = row * 2; \ 64 for ( psS32 col = 0;col < c;col++) { \65 imageRow[ col] = col + rowOffset; \64 for (psS32 col = 0;col < c;col++) { \ 65 imageRow[col] = col + rowOffset; \ 66 66 } \ 67 67 } \ … … 111 111 // 112 112 #define PSIMAGESLICE_TEST(TYPE) \ 113 PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_X_POS, m, i, n / 2, 0 ); \114 PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_X_NEG, m, m - 1 - i, n / 2, 1 ); \115 PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_Y_POS, n, m / 2, i, 2 ); \116 PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_Y_NEG, n, m / 2, n - 1 - i, 3 ); \113 PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_X_POS, m, i, n / 2, 0); \ 114 PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_X_NEG, m, m - 1 - i, n / 2, 1); \ 115 PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_Y_POS, n, m / 2, i, 2); \ 116 PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_Y_NEG, n, m / 2, n - 1 - i, 3); \ 117 117 \ 118 PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_X_POS, m, i, 0, 4 ); \119 PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_X_NEG, m, m - 1 - i, 0, 5 ); \120 PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_Y_POS, 1, m / 2, 0, 6 ); \121 PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_Y_NEG, 1, m / 2, 0, 7 ); \118 PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_X_POS, m, i, 0, 4); \ 119 PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_X_NEG, m, m - 1 - i, 0, 5); \ 120 PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_Y_POS, 1, m / 2, 0, 6); \ 121 PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_Y_NEG, 1, m / 2, 0, 7); \ 122 122 \ 123 PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_X_POS, 1, 0, n / 2, 8 ); \124 PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_X_NEG, 1, 0, n / 2, 9 ); \125 PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_Y_POS, n, 0, i, 10 ); \126 PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_Y_NEG, n, 0, n - 1 - i, 11 ); \123 PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_X_POS, 1, 0, n / 2, 8); \ 124 PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_X_NEG, 1, 0, n / 2, 9); \ 125 PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_Y_POS, n, 0, i, 10); \ 126 PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_Y_NEG, n, 0, n - 1 - i, 11); \ 127 127 \ 128 PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_X_POS, 1, 0, 0, 12 ); \129 PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_X_NEG, 1, 0, 0, 13 ); \130 PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_Y_POS, 1, 0, 0, 14 ); \131 PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_Y_NEG, 1, 0, 0, 15 ); \128 PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_X_POS, 1, 0, 0, 12); \ 129 PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_X_NEG, 1, 0, 0, 13); \ 130 PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_Y_POS, 1, 0, 0, 14); \ 131 PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_Y_NEG, 1, 0, 0, 15); \ 132 132 133 133 PSIMAGESLICE_TEST(F32); … … 149 149 psRegionSet(c/10, c/10 + 1, r/10, r/10 + 1), 150 150 PS_CUT_X_POS, 151 stat );151 stat); 152 152 ok(out == NULL, "psImageSlice() returned NULL with NULL input"); 153 153 … … 156 156 // Following should be an error 157 157 // XXX: Verify error 158 out = psImageSlice( out,158 out = psImageSlice(out, 159 159 NULL, image, 160 160 mask, 1, 161 161 psRegionSet(c/10, c/10 + 1, r/10, r/10 + 1), 162 162 PS_CUT_X_POS, 163 NULL );163 NULL); 164 164 ok(out == NULL, "psImageSlice() returned NULL with NULL psStats"); 165 psError( PS_ERR_UNKNOWN,true, "Giving a NULL stat struct, psImageSlice didn't return NULL as expected");165 psError(PS_ERR_UNKNOWN,true, "Giving a NULL stat struct, psImageSlice didn't return NULL as expected"); 166 166 167 167 // Verify the returned psVector structure pointer is null and program … … 182 182 // Following should be an error 183 183 // XXX: Verify error 184 out = psImageSlice( out,184 out = psImageSlice(out, 185 185 NULL, 186 186 image, … … 188 188 psRegionSet(c/10, c/10, r/10, r/10), 189 189 PS_CUT_X_POS, 190 stat );190 stat); 191 191 ok(out == NULL, "psImageSlice() returned NULL with 0x0 region"); 192 192 … … 196 196 // Following should be an error 197 197 // XXX: Verify error 198 out = psImageSlice( out, NULL,198 out = psImageSlice(out, NULL, 199 199 image, 200 200 mask, 1, 201 201 psRegionSet(c+1, c+2, r/10, r/10 + 10), 202 202 PS_CUT_X_POS, 203 stat );203 stat); 204 204 ok(out == NULL, "psImageSlice() returned NULL with unallowed x position"); 205 205 206 206 // Following should be an error 207 207 // XXX: Verify error 208 out = psImageSlice( out, NULL,208 out = psImageSlice(out, NULL, 209 209 image, 210 210 mask, 1, 211 211 psRegionSet(c/10, c/10 + 1, r+1,r+5), 212 212 PS_CUT_X_POS, 213 stat );213 stat); 214 214 ok(out == NULL, "psImageSlice() returned NULL with unallowed y position"); 215 215 216 216 // Following should be an error 217 217 // XXX: Verify error 218 out = psImageSlice( out, NULL,218 out = psImageSlice(out, NULL, 219 219 image, 220 220 mask, 1, … … 226 226 // Following should be an error 227 227 // XXX: Verify error 228 out = psImageSlice( out, NULL,228 out = psImageSlice(out, NULL, 229 229 image, 230 230 mask, 1, … … 240 240 // XXX: Verify error 241 241 stat->options = 0; 242 out = psImageSlice( out, NULL,242 out = psImageSlice(out, NULL, 243 243 image, 244 244 mask, 1, … … 253 253 // XXX: Verify error 254 254 stat->options = PS_STAT_SAMPLE_MEDIAN; 255 psImage* maskSz = psImageAlloc( r, c, PS_TYPE_MASK);256 out = psImageSlice( out, NULL,255 psImage* maskSz = psImageAlloc(r, c, PS_TYPE_MASK); 256 out = psImageSlice(out, NULL, 257 257 image, 258 258 maskSz, 1, … … 265 265 // Following should be an error unallowed mask type 266 266 // XXX: Verify error 267 psImage* maskS8 = psImageAlloc( c, r, PS_TYPE_S8);268 out = psImageSlice( out, NULL,267 psImage* maskS8 = psImageAlloc(c, r, PS_TYPE_S8); 268 out = psImageSlice(out, NULL, 269 269 image, 270 270 maskS8, 1, … … 276 276 //Added tests after subimage changes. 277 277 psFree(image); 278 image = psImageAlloc( c, r, PS_TYPE_F64);279 for ( psS32 row = 0;row < r;row++) {280 psF64 *imageRow = image->data.F64[ row];278 image = psImageAlloc(c, r, PS_TYPE_F64); 279 for (psS32 row = 0;row < r;row++) { 280 psF64 *imageRow = image->data.F64[row]; 281 281 psF64 rowOffset = row * 2; 282 for ( psS32 col = 0;col < c;col++) {283 imageRow[ col] = col + rowOffset;282 for (psS32 col = 0;col < c;col++) { 283 imageRow[col] = col + rowOffset; 284 284 } 285 285 } … … 441 441 float y = (float)startRow[n]+(float)i*deltaRow; 442 442 if (n == 1) { 443 // truth = psImagePixelInterpolate( image, x, y,443 // truth = psImagePixelInterpolate(image, x, y, 444 444 // NULL,0,0,PS_INTERPOLATE_FLAT); 445 445 psImageInterpolate(&imgVal, &varVal, &maskVal, x, y, tmpIntOptsNoMask); 446 446 truth = imgVal; 447 447 } else { 448 // truth = psImagePixelInterpolate( image, x, y,448 // truth = psImagePixelInterpolate(image, x, y, 449 449 // mask,1,0,PS_INTERPOLATE_FLAT); 450 450 psImageInterpolate(&imgVal, &varVal, &maskVal, x, y, tmpIntOptsMask); … … 520 520 521 521 522 // test ImageRadialCut()522 // test psImageRadialCut() 523 523 { 524 524 psMemId id = psMemGetId(); … … 557 557 if (fabs(result->data.F64[i] - (15.0+i*10)) > 1) { 558 558 diag("Result was not as expected for radii #%d (%g, expected %d +/- 1)", 559 result->data.F64[i], (15.0+i*10) );559 result->data.F64[i], (15.0+i*10)); 560 560 errorFlag = true; 561 561 } … … 574 574 if (fabs(result->data.F64[i] - (15.0+i*10)) > 1) { 575 575 diag("Result was not as expected for radii #%d (%g, expected %d +/- 1)", 576 result->data.F64[i], (15.0+i*10) );576 result->data.F64[i], (15.0+i*10)); 577 577 errorFlag = true; 578 578 } … … 709 709 // Following should generate error message(for row) 710 710 // XXX: Verify error 711 out = psImageRow(NULL, image, num);711 out = psImageRow(NULL, NULL, num); 712 712 ok(out == NULL, "psImageRow() returned NULL with NULL input image"); 713 713 714 714 // Following should generate error message(for col) 715 715 // XXX: Verify error 716 out = psImageCol(NULL, image, num);716 out = psImageCol(NULL, NULL, num); 717 717 ok(out == NULL, "psImagecol() returned NULL with NULL input image"); 718 719 718 image = psImageAlloc(3, 3, PS_TYPE_F64); 720 719 721 720 722 721 //Test for unallowed row0. 723 *(psS32*)&(image->row0) = -1;722 P_PSIMAGE_SET_ROW0(image, -2); 724 723 // Following should generate error message(for row) 725 724 // XXX: Verify error … … 810 809 811 810 //Test valid cases. 811 //XXX: We do not verify the data values. 812 812 P_PSIMAGE_SET_COL0(image, 10); 813 813 P_PSIMAGE_SET_ROW0(image, 5); … … 875 875 876 876 //Test for error with NULL image 877 empty = psImageCol(empty, emptyImage, 0);877 empty = psImageCol(empty, NULL, 0); 878 878 ok(empty == NULL, "psImageCol returned NULL for NULL image input"); 879 879 //Test for error with Out of Range Row … … 894 894 test1 = fabs(rowcol->data.F64[0]-66.6); 895 895 test2 = fabs(rowcol->data.F64[2]-666.66); 896 ok(!( (test1>TOLTST) || (test2>TOLTST)),896 ok(!((test1>TOLTST) || (test2>TOLTST)), 897 897 "psImageRow returned correct values"); 898 898 psFree(rowcol); -
trunk/psLib/test/imageops/tap_psImagePixelManip.c
r12440 r13123 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $9 * @date $Date: 2007-0 3-14 21:20:28$8 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-05-02 04:14:33 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 22 22 psLogSetFormat("HLNM"); 23 23 psLogSetLevel(PS_LOG_INFO); 24 plan_tests( 47);25 26 // test ImageClip()24 plan_tests(107); 25 26 // test psImageClip() 27 27 { 28 28 psMemId id = psMemGetId(); … … 44 44 // Verify the retuned integer is zero, psImage structure input is unmodified 45 45 // and program executions doesn't stop, if input parameter psImage structure 46 // pointer is null.46 // pointer is NULL. 47 47 // 48 48 // Verify the retuned integer is zero, psImage structure input is unmodified … … 111 111 // Verify the retuned integer is zero, psImage structure input is unmodified 112 112 // and program executions doesn't stop, if input parameter psImage structure 113 // pointer is null.113 // pointer is NULL. 114 114 retVal = psImageClip(NULL,min,-1.0f,max,-2.0f); 115 115 ok(retVal == 0, "Expected zero return for clips of a NULL image"); … … 144 144 // 145 145 // Verify the returned integer is zero and program execution doesn't stop, 146 // if the input parameter psImage structure pointer is null.146 // if the input parameter psImage structure pointer is NULL. 147 147 // create image 148 148 #define testImageClipNaNByType(datatype) \ … … 193 193 // Verify the retuned integer is zero, psImage structure input is unmodified 194 194 // and program executions doesn't stop, if input parameter psImage structure 195 // pointer is null.195 // pointer is NULL. 196 196 retVal = psImageClipNaN(NULL,-1.0f); 197 197 ok(retVal == 0, "Expected zero return for clips of a NULL image"); … … 286 286 testOverlayTypeOP(DATATYPE,=,"="); 287 287 288 289 // testOverlayType(F64); 290 // testOverlayType(F32); 291 // testOverlayType(S16); 292 // testOverlayType(S8); 293 // testOverlayType(U16); 294 // testOverlayType(U8); 288 testOverlayType(F64); 289 testOverlayType(F32); 290 testOverlayType(S16); 291 testOverlayType(S8); 292 testOverlayType(U16); 293 testOverlayType(U8); 295 294 296 295 // Verify the returned integer is equal to non-zero and the input psImage structure … … 351 350 // Verify the returned integer is equal to non-zero, the input psImage 352 351 // structure is unmodified and program execution doesn't stop, if the 353 // overlay specified is null.352 // overlay specified is NULL. 354 353 // Following should error as overlay is NULL 355 354 // XXX: Verify error … … 371 370 372 371 // Verify the returned integer is equal to non-zero and program execution 373 // doesn't stop, if the input parameter image is null.372 // doesn't stop, if the input parameter image is NULL. 374 373 // Following should error as image input is NULL 375 374 // XXX: Verify error … … 416 415 ok(retVal != 0, "psImageOverlaySection returned non-zero when checking divide-by-zero"); 417 416 errorFlag = false; 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 417 449 418 for (unsigned row=0;row<r;row++) -
trunk/psLib/test/imageops/tap_psImageStats.c
r11729 r13123 273 273 const int CHEBY_Y_DIM = 8; 274 274 const int THRESHOLD = 1; 275 psImage *imgIn = psImageAlloc( IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_F32);276 psImage *imgOut = psImageAlloc( IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_F32);277 for (int i = 0;i < IMAGE_SIZE;i++ ) {278 for (int j = 0;j < IMAGE_SIZE;j++ ) {275 psImage *imgIn = psImageAlloc(IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_F32); 276 psImage *imgOut = psImageAlloc(IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_F32); 277 for (int i = 0;i < IMAGE_SIZE;i++) { 278 for (int j = 0;j < IMAGE_SIZE;j++) { 279 279 imgIn->data.F32[ i ][ j ] = 4.0; 280 imgIn->data.F32[ i ][ j ] = ( float ) ( i + j);281 imgIn->data.F32[ i ][ j ] = ( float ) ( i + j ) + ( 4.0 * ( float ) i);280 imgIn->data.F32[ i ][ j ] = (float) (i + j); 281 imgIn->data.F32[ i ][ j ] = (float) (i + j) + (4.0 * (float) i); 282 282 imgOut->data.F32[ i ][ j ] = 0.0; 283 283 } 284 284 } 285 285 psPolynomial2D *my2DPoly = psPolynomial2DAlloc(PS_POLYNOMIAL_CHEB, CHEBY_X_DIM-1, CHEBY_Y_DIM-1); 286 my2DPoly = psImageFitPolynomial(my2DPoly, imgIn );286 my2DPoly = psImageFitPolynomial(my2DPoly, imgIn); 287 287 ok(my2DPoly != NULL, "psImageFitPolynomial() returned non-NULL"); 288 288 289 imgOut = psImageEvalPolynomial( imgOut, my2DPoly);289 imgOut = psImageEvalPolynomial(imgOut, my2DPoly); 290 290 bool errorFlag = false; 291 for (int i = 0;i < IMAGE_SIZE;i++ ) {292 for (int j = 0;j < IMAGE_SIZE;j++ ) {293 if ( fabs( imgOut->data.F32[ i ][ j ] - imgIn->data.F32[ i ][ j ] ) > THRESHOLD) {291 for (int i = 0;i < IMAGE_SIZE;i++) { 292 for (int j = 0;j < IMAGE_SIZE;j++) { 293 if (fabs(imgOut->data.F32[ i ][ j ] - imgIn->data.F32[ i ][ j ]) > THRESHOLD) { 294 294 diag("Pixel (%d, %d) is %.2f, should be %.2f\n", i, j, 295 295 imgOut->data.F32[ i ][ j ], … … 357 357 ok(hist2 == hist, "psImageHistogram() correctly recycled the input psHistogram"); 358 358 bool errorFlag = false; 359 for (int i = 0;i < numBins;i++ ) {359 for (int i = 0;i < numBins;i++) { 360 360 if (hist2->nums->data.F32[i] != (numCols * (numRows/numBins))) { 361 361 diag("ERROR: Bin number %d bounds: (%.1f - %.1f) data (%.2f)\n", i, … … 434 434 } 435 435 436 // Ensure psImageCountPixelMask returns -1 for NULL input image436 // Ensure psImageCountPixelMask returns -1 for wrong input image type 437 437 // Following should generate error 438 438 // XXX: Verify error … … 486 486 // -------------------------------------------------------------- 487 487 // psImageStats() 488 // Ensure psImageStats() return es NULL for NULL input image488 // Ensure psImageStats() returns NULL for NULL input image 489 489 // Following should generate error 490 490 // XXX: Verify error … … 499 499 } 500 500 501 // Ensure psImageStats() return es NULL for NULL psStats501 // Ensure psImageStats() returns NULL for NULL psStats 502 502 // Following should generate error 503 503 // XXX: Verify error -
trunk/psLib/test/imageops/tap_psImageStructManip.c
r11688 r13123 1 /** @file t st_psImageExtraction.c1 /** @file tap_psImageStructManip.c 2 2 * 3 3 * @brief Contains the tests for psImageExtraction.[ch] 4 4 * 5 *6 5 * @author Robert DeSonia, MHPCC 7 6 * 8 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $9 * @date $Date: 2007-0 2-08 01:21:50$7 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2007-05-02 04:14:33 $ 10 9 * 11 10 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 26 25 // psImageSubset shall create child image of a specified size from a 27 26 // parent psImage structure 28 29 27 // psImageSubset() 30 28 { … … 33 31 psS32 c = 128; 34 32 psS32 r = 256; 35 psRegion region1 = psRegionSet(0, c/2,0,r/2);36 psRegion region2 = psRegionSet(c/4, c/4+c/2,r/4,r/4+r/2);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); 37 35 38 36 psImage* original = psImageAlloc(c,r,PS_TYPE_U32); 39 for (psS32 row=0;row<r;row++) 40 { 37 for (psS32 row=0;row<r;row++) { 41 38 for (psS32 col=0;col<c;col++) { 42 39 original->data.F32[row][col] = row*1000+col; … … 63 60 64 61 bool errorFlag = false; 65 for (psS32 row=0;row<r/2;row++) 66 { 62 for (psS32 row=0;row<r/2;row++) { 67 63 for (psS32 col=0;col<c/2;col++) { 68 64 if (subset2->data.U32[row][col] != original->data.U32[row+r/4][col+c/4]) { … … 99 95 ok(subset2->children == NULL && subset3->children == NULL, "psImageSubset() set ->children correctly"); 100 96 101 102 97 // Verify the input psImage structure image only has the following members 103 98 // changed: 1) Nchildren is increased by one. 2) parent contains pointer psImage structure … … 107 102 "psImageSubset did properly store the children pointers."); 108 103 104 109 105 // Verify the returned psImage structure pointer is null and program 110 106 // execution doesn't stop, if the input parameter image is null. … … 114 110 psImage* subset1 = psImageSubset(NULL,region1); 115 111 ok(subset1 == NULL, "psImageSubset returned NULL when input image was NULL."); 112 116 113 117 114 // Verify the returned psImage structure pointer is null and program … … 153 150 ok(subset1 == NULL, 154 151 "psImageSubset returned NULL when subset origin was outside of image (row0=-1)"); 152 155 153 156 154 // Verify the returned psImage structure pointer is null and program … … 205 203 psU32 r = 256; 206 204 207 psImage* img = psImageAlloc(c,r,PS_TYPE_F32); 208 for (unsigned row=0;row<r;row++) 209 { 210 psF32* imgRow = img->data.F32[row]; 205 psImage *img = psImageAlloc(c,r,PS_TYPE_F32); 206 for (unsigned row=0;row<r;row++) { 211 207 for (unsigned col=0;col<c;col++) { 212 imgRow[col] = (psF32)(row+col); 213 } 214 } 215 psImage* img2 = psImageAlloc(c,r,PS_TYPE_F32); 216 for (unsigned row=0;row<r;row++) 217 { 218 psF32* img2Row = img2->data.F32[row]; 208 img->data.F32[row][col] = (psF32)(row+col); 209 } 210 } 211 psImage *img2 = psImageAlloc(c,r,PS_TYPE_F32); 212 for (unsigned row=0;row<r;row++) { 219 213 for (unsigned col=0;col<c;col++) { 220 img2Row[col] = 0.0f; 221 } 222 } 223 224 psImage* img3 = psImageCopy(img2,img,PS_TYPE_F32); 225 // Verify the returned psImage structure pointer is equal to the input parameter output. 214 img2->data.F32[row][col] = 0.0f; 215 } 216 } 217 218 psImage *img3 = psImageCopy(img2,img,PS_TYPE_F32); 219 // Verify the returned psImage structure pointer is equal to the input 220 // parameter output. 226 221 ok(img2 == img3, "psImageCopy(): recycled input image"); 227 222 228 // Verify the returned psImage structure is the same type as the input image structure229 // if the specified output argument is NULL.230 psImage *img4 = psImageCopy(NULL,img,PS_TYPE_F32);223 // Verify the returned psImage structure is the same type as the input image 224 // structure if the specified output argument is NULL. 225 psImage *img4 = psImageCopy(NULL,img,PS_TYPE_F32); 231 226 ok(img4 != NULL, "psImageCopy() returned non-NULL with NULL output argument"); 232 227 ok(img4->type.type == img->type.type, "psImageCopy() set the correct image type"); 233 228 bool errorFlag = false; 234 for (psU32 row=0;row<r;row++) 235 { 229 for (psU32 row=0;row<r;row++) { 236 230 psF32* imgInRow = img->data.F32[row]; 237 231 psF32* imgOutRow = img4->data.F32[row]; … … 326 320 psS32 halfR = r/2; 327 321 psS32 halfC = c/2; 328 psRegion centerHalf = {qtrC, qtrC+halfC,qtrR,qtrR+halfR};322 psRegion centerHalf = {qtrC, qtrC+halfC, qtrR, qtrR+halfR}; 329 323 330 324 psImage* image = psImageAlloc(c,r,PS_TYPE_F32); 331 for (psS32 row = 0; row < image->numRows; row++) 332 { 325 for (psS32 row = 0; row < image->numRows; row++) { 333 326 for (psS32 col = 0; col < image->numCols; col++) { 334 327 image->data.F32[row][col] = (psF32)col + (psF32)row/1000.0f; 335 328 } 336 329 } 337 338 330 // invoke psImageTrim with non-NULL image, and a valid region 339 331 // x0,y0->x1,y1 (using only positive values). Verify that: … … 350 342 351 343 bool errorFlag = false; 352 for (psS32 row = 0; row < image2->numRows; row++) 353 { 344 for (psS32 row = 0; row < image2->numRows; row++) { 354 345 for (psS32 col = 0; col < image2->numCols; col++) { 355 346 if (fabsf(image2->data.F32[row][col] - image->data.F32[row+qtrR][col+qtrC]) … … 379 370 image->numCols-qtrC, image->numRows-qtrR); 380 371 381 for (psS32 row = 0; row < image2->numRows; row++) 382 { 372 for (psS32 row = 0; row < image2->numRows; row++) { 383 373 for (psS32 col = 0; col < image2->numCols; col++) { 384 374 if (fabsf(image2->data.F32[row][col] - … … 394 384 ok(!errorFlag, "psImageTrim() set image data correctly"); 395 385 396 // 4. invoke psImageTrim with x1<0, y1<0. Verify: 386 387 // Invoke psImageTrim with x1<0, y1<0. Verify: 397 388 // a. the psImage size is (numCols+x1)-x0 by (numRows+y1)-y0. 398 389 // b. the pixel values coorespond to the region … … 405 396 image2->numCols, image2->numRows, 406 397 image->numCols-qtrC, image->numRows-qtrR); 407 408 for (psS32 row = 0; row < image2->numRows; row++) 409 { 398 for (psS32 row = 0; row < image2->numRows; row++) { 410 399 for (psS32 col = 0; col < image2->numCols; col++) { 411 400 if (fabsf(image2->data.F32[row][col] - … … 422 411 psFree(image1); 423 412 424 // 6. invoke psImageTrim with image=NULL Verify: 413 414 // Invoke psImageTrim with image=NULL Verify: 425 415 // a. execution does not cease. 426 416 // b. return value is NULL … … 428 418 // An error should follow... 429 419 // XXX: Verify errors 430 431 432 420 image2 = psImageTrim(NULL, psRegionSet(qtrC,0,qtrR,0)); 433 421 ok(image2 == NULL, "psImageTrim returned NULL given a NULL input image"); … … 438 426 439 427 428 // Verify when psRegion has a coord at -1 440 429 image1 = psImageCopy(NULL,image,PS_TYPE_F32); 441 430 image2 = psImageTrim(image1, psRegionSet(-1,0,0,0)); … … 447 436 448 437 438 // Verify when psRegion has a coord at -1 449 439 image1 = psImageCopy(NULL,image,PS_TYPE_F32); 450 440 image2 = psImageTrim(image1, psRegionSet(0,0,-1,0)); … … 456 446 457 447 448 // Verify when psRegion has a coord at outside the image range 458 449 image1 = psImageCopy(NULL,image,PS_TYPE_F32); 459 450 image2 = psImageTrim(image1, psRegionSet(0,image->numCols+1,0,0)); … … 465 456 466 457 458 // Verify when psRegion has a coord at outside the image range 467 459 image1 = psImageCopy(NULL,image,PS_TYPE_F32); 468 460 image2 = psImageTrim(image1, psRegionSet(0,0,0,image->numRows+1)); … … 474 466 475 467 468 // Verify when psRegion has a coord at outside the image range 476 469 image1 = psImageCopy(NULL,image,PS_TYPE_F32); 477 470 image2 = psImageTrim(image1, psRegionSet(0,0,0,(((psF32)image->numRows)*-1.0))); … … 483 476 484 477 478 // Verify when psRegion has a coord at outside the image range 485 479 image1 = psImageCopy(NULL,image,PS_TYPE_F32); 486 480 image2 = psImageTrim(image1, psRegionSet(0,(((psF32)image->numCols)*-1.0),0,0)); -
trunk/psLib/test/math/Makefile.am
r12094 r13123 47 47 tap_psStatsTiming \ 48 48 tap_psFunc01 \ 49 tap_psStats_Sample_01 49 tap_psStats_Sample_01 \ 50 tap_psMatrixVectorArithmetic01 \ 51 tap_psMatrixVectorArithmetic04 \ 52 tap_psRandom \ 53 tap_psMinimizePowell 50 54 51 55 if BUILD_TESTS -
trunk/psLib/test/math/tap_psMatrix03.c
r10816 r13123 16 16 * @author Ross Harman, MHPCC 17 17 * 18 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $19 * @date $Date: 200 6-12-20 20:02:29$18 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 19 * @date $Date: 2007-05-02 04:14:33 $ 20 20 * 21 21 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 184 184 185 185 // Attempt to use null image input argument 186 // XXX: This test should generate an error or warning, but we don't know how to test that. 186 // XXX: This test should generate an error or warning 187 // XXX: This seg-faults 187 188 if (0) { 188 189 psMemId id = psMemGetId(); … … 195 196 196 197 // Attempt to use null input vector argument 197 // XXX: This test should generate an error or warning, but we don't know how to test that. 198 // XXX: This test should generate an error or warning 199 // XXX: This seg-faulta 198 200 if (0) { 199 201 psMemId id = psMemGetId(); … … 212 214 // Attempt to use null LU image argument 213 215 // XXX: This test should generate an error or warning, but we don't know how to test that. 216 // XXX: This seg-faulta 214 217 if (0) { 215 218 psMemId id = psMemGetId(); -
trunk/psLib/test/math/tap_psMatrixVectorArithmetic01.c
r12431 r13123 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $13 * @date $Date: 2007-0 3-14 00:39:51$12 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2007-05-02 04:14:33 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 128 128 bool errorFlag = false; 129 129 bool memoryFlag = false; 130 plan_tests( 90);130 plan_tests(72); 131 131 132 132 //Test matrix-matrix binary operations -
trunk/psLib/test/math/tap_psMatrixVectorArithmetic02.c
r12431 r13123 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $13 * @date $Date: 2007-0 3-14 00:39:51$12 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2007-05-02 04:14:33 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 18 18 #include <stdio.h> 19 19 #include <string.h> 20 #include <math.h> 20 21 #include <pslib.h> 21 22 #include "tap.h" -
trunk/psLib/test/math/tap_psMatrixVectorArithmetic03.c
r12431 r13123 15 15 * @author Ross Harman, MHPCC 16 16 * 17 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $18 * @date $Date: 2007-0 3-14 00:39:51$17 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 18 * @date $Date: 2007-05-02 04:14:33 $ 19 19 * 20 20 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 68 68 // Check for NULL input argument #1 69 69 70 if ( 0) {70 if (1) { 71 71 psMemId id = psMemGetId(); 72 72 psImage* image6 = (psImage*)psBinaryOp(image6, NULL, "+", image2); … … 249 249 psFree(image3); 250 250 psFree(image4); 251 psFree(image5);252 251 psFree(vector1); 253 252 psFree(vector2); -
trunk/psLib/test/math/tap_psMinimizePowell.c
r10945 r13123 74 74 { 75 75 psLogSetFormat("HLNM"); 76 plan_tests( 2);76 plan_tests(1); 77 77 78 78 // Check for various errors on unallowed input parameters … … 134 134 135 135 // Powell minimize with parameter mask 136 {136 if (0) { 137 137 psMemId id = psMemGetId(); 138 138 psVector *myParams = psVectorAlloc(NUM_PARAMS, PS_TYPE_F32); … … 186 186 // Powell minimize with parameter mask 187 187 // The only difference from the previous block is that paramMask is now NULL 188 {188 if (0) { 189 189 psMemId id = psMemGetId(); 190 190 psVector *myParams = psVectorAlloc(NUM_PARAMS, PS_TYPE_F32); -
trunk/psLib/test/math/tap_psRandom.c
r13084 r13123 47 47 plan_tests(34); 48 48 49 diag("ensure that psRandom structs are properly allocated by psRandomAlloc()");50 49 // ensure that psRandom structs are properly allocated by psRandomAlloc() 51 50 { … … 81 80 // testRandomUniform(void) 82 81 { 83 diag("testRandomUniform()");82 // testRandomUniform() 84 83 psMemId id = psMemGetId(); 85 84 psVector *rans = psVectorAlloc(NUM_DATA, PS_TYPE_F64); … … 91 90 92 91 // Initialize vector data with random number 93 for (psS32 i = 0 ; i < NUM_DATA ; i++) 94 { 92 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 95 93 rans->data.F64[i] = psRandomUniform(myRNG); 96 94 } 97 95 98 96 // Perform vector stats on random data (mean, stdev) 99 stats =psVectorStats(stats, rans, NULL, NULL, 0);97 psVectorStats(stats, rans, NULL, NULL, 0); 100 98 stats->options = PS_STAT_SAMPLE_STDEV; 101 stats =psVectorStats(stats, rans, NULL, NULL, 0);99 psVectorStats(stats, rans, NULL, NULL, 0); 102 100 103 101 // Verify mean and stdev … … 132 130 133 131 // Initialize vector with random data 134 for (psS32 i = 0 ; i < NUM_DATA ; i++) 135 { 132 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 136 133 rans->data.F64[i] = psRandomGaussian(myRNG); 137 134 } 138 135 139 136 // Perform vector stats on data (mean, stdev) 140 stats =psVectorStats(stats, rans, NULL, NULL, 0);137 psVectorStats(stats, rans, NULL, NULL, 0); 141 138 stats->options = PS_STAT_SAMPLE_STDEV; 142 stats =psVectorStats(stats, rans, NULL, NULL, 0);139 psVectorStats(stats, rans, NULL, NULL, 0); 143 140 144 141 // Verify mean and stdev … … 175 172 176 173 // Initialize vector with random data 177 for (psS32 i = 0 ; i < NUM_DATA ; i++) 178 { 174 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 179 175 rans->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN); 180 176 } 181 177 182 178 // Perform vector stats on random data (mean, stdev) 183 stats =psVectorStats(stats, rans, NULL, NULL, 0);179 psVectorStats(stats, rans, NULL, NULL, 0); 184 180 stats->options = PS_STAT_SAMPLE_STDEV; 185 stats =psVectorStats(stats, rans, NULL, NULL, 0);181 psVectorStats(stats, rans, NULL, NULL, 0); 186 182 // Verify mean and stdev 187 183 is_float_tol_per(stats->sampleMean, POISSON_MEAN, ERROR_TOLERANCE, "Mean is within expected range"); … … 221 217 // Random reset 222 218 psRandomReset(myRNG, SEED); 223 for (psS32 i = 0 ; i < NUM_DATA ; i++) 224 { 219 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 225 220 rans00->data.F64[i] = psRandomUniform(myRNG); 226 221 } 227 222 psRandomReset(myRNG, SEED2); 228 for (psS32 i = 0 ; i < NUM_DATA ; i++) 229 { 223 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 230 224 rans01->data.F64[i] = psRandomUniform(myRNG); 231 225 } 232 226 psRandomReset(myRNG, SEED); 233 for (psS32 i = 0 ; i < NUM_DATA ; i++) 234 { 227 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 235 228 rans02->data.F64[i] = psRandomUniform(myRNG); 236 229 } … … 273 266 // testRandomResetGaussian(void) 274 267 { 275 diag("testRandomGaussian(): ensure the seed resets properly");268 // testRandomGaussian(): ensure the seed resets properly 276 269 psMemId id = psMemGetId(); 277 270 psVector *rans00 = psVectorAlloc(NUM_DATA, PS_TYPE_F64); … … 289 282 // Initialize random data in vectors 290 283 psRandomReset(myRNG, SEED); 291 for (psS32 i = 0 ; i < NUM_DATA ; i++) 292 { 284 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 293 285 rans00->data.F64[i] = psRandomGaussian(myRNG); 294 286 } 295 287 psRandomReset(myRNG, SEED2); 296 for (psS32 i = 0 ; i < NUM_DATA ; i++) 297 { 288 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 298 289 rans01->data.F64[i] = psRandomGaussian(myRNG); 299 290 } 300 291 psRandomReset(myRNG, SEED); 301 for (psS32 i = 0 ; i < NUM_DATA ; i++) 302 { 292 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 303 293 rans02->data.F64[i] = psRandomGaussian(myRNG); 304 294 } … … 306 296 // Verify data from original seed produces same data after reset 307 297 psBool errorFlag = false; 308 for (psS32 i = 0 ; i < NUM_DATA ; i++) 309 { 298 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 310 299 if (rans00->data.F64[i] != rans02->data.F64[i]) { 311 300 if (VERBOSE) { … … 315 304 } 316 305 } 317 ok(!errorFlag, "psRandom Uniform() produced the same results with the same seed");306 ok(!errorFlag, "psRandomGaussian() produced the same results with the same seed"); 318 307 skip_end(); 319 308 psFree(myRNG); … … 342 331 // Initialize vectors with random data 343 332 psRandomReset(myRNG, SEED); 344 for (psS32 i = 0 ; i < NUM_DATA ; i++) 345 { 333 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 346 334 rans00->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN); 347 335 } 348 336 psRandomReset(myRNG, SEED2); 349 for (psS32 i = 0 ; i < NUM_DATA ; i++) 350 { 337 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 351 338 rans01->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN); 352 339 } 353 340 psRandomReset(myRNG, SEED); 354 for (psS32 i = 0 ; i < NUM_DATA ; i++) 355 { 341 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 356 342 rans02->data.F64[i] = psRandomPoisson(myRNG, POISSON_MEAN); 357 343 } … … 359 345 // Verify the original seed produces same data after reset 360 346 psBool errorFlag = false; 361 for (psS32 i = 0 ; i < NUM_DATA ; i++) 362 { 347 for (psS32 i = 0 ; i < NUM_DATA ; i++) { 363 348 if (rans00->data.F64[i] != rans02->data.F64[i]) { 364 349 if (VERBOSE) { … … 368 353 } 369 354 } 370 ok(!errorFlag, "psRandom Uniform() produced the same results with the same seed");355 ok(!errorFlag, "psRandomPoisson() produced the same results with the same seed"); 371 356 skip_end(); 372 357 psFree(myRNG); -
trunk/psLib/test/math/tap_psSparse.c
r12607 r13123 10 10 plan_tests(26); 11 11 12 // diag("psSparse() tests");13 14 12 // test psSparseSolve for a simple normal example matrix 15 13 { 16 14 psMemId id = psMemGetId(); 17 15 18 // diag ("solve a normalized matrix equation with psSparseSolve"); 16 //solve a normalized matrix equation with psSparseSolve 19 17 20 18 // the basic equation is Ax = b … … 28 26 skip_start(matrix == NULL, 5, "Skipping tests because psSparseAlloc() failed"); 29 27 30 for (int i = 0; i < 100; i++) 31 { 28 for (int i = 0; i < 100; i++) { 32 29 psSparseMatrixElement (matrix, i, i, 1.0); 33 30 if (i + 1 < 100) { … … 38 35 // incoming matrix elements do not need to be in order; sort before 39 36 // applying sparse matrix 40 psSparseResort (matrix);37 psSparseResort(matrix); 41 38 42 39 psVector *xRef = psVectorAlloc (100, PS_TYPE_F32); … … 46 43 } 47 44 48 psVector *bVec = psSparseMatrixTimesVector (NULL, matrix, xRef); 49 50 for (int i = 0; i < 100; i++) 51 { 52 psSparseVectorElement (matrix, i, bVec->data.F32[i]); 45 psVector *bVec = psSparseMatrixTimesVector(NULL, matrix, xRef); 46 47 for (int i = 0; i < 100; i++) { 48 psSparseVectorElement(matrix, i, bVec->data.F32[i]); 53 49 } 54 50 … … 59 55 60 56 // solve for normalization terms (need include local sky?) 61 psVector *xFit = psSparseSolve (NULL, constraint, matrix, 4);57 psVector *xFit = psSparseSolve(NULL, constraint, matrix, 4); 62 58 63 59 // measure stdev between xFit and xRes … … 89 85 psMemId id = psMemGetId(); 90 86 91 // diag ("solve a non-normalized matrix equation with psSparseSolve"); 92 87 //solve a non-normalized matrix equation with psSparseSolve 93 88 // the basic equation is Ax = b 94 95 89 // create a matrix A with diagonals of 1 and a small number of off diagonal elements. 96 90 // construct a vector x, construct the corresponding vector b by multiplication. solve … … 101 95 skip_start(matrix == NULL, 5, "Skipping tests because psSparseAlloc() failed"); 102 96 103 for (int i = 0; i < 100; i++) 104 { 97 for (int i = 0; i < 100; i++) { 105 98 psSparseMatrixElement (matrix, i, i, 5.0); 106 99 if (i + 1 < 100) { … … 111 104 // incoming matrix elements do not need to be in order; sort before 112 105 // applying sparse matrix 113 psSparseResort (matrix);106 psSparseResort(matrix); 114 107 115 108 psVector *xRef = psVectorAlloc (100, PS_TYPE_F32); … … 119 112 } 120 113 121 psVector *bVec = psSparseMatrixTimesVector (NULL, matrix, xRef); 122 123 for (int i = 0; i < 100; i++) 124 { 125 psSparseVectorElement (matrix, i, bVec->data.F32[i]); 114 psVector *bVec = psSparseMatrixTimesVector(NULL, matrix, xRef); 115 116 for (int i = 0; i < 100; i++) { 117 psSparseVectorElement(matrix, i, bVec->data.F32[i]); 126 118 } 127 119 … … 132 124 133 125 // solve for normalization terms (need include local sky?) 134 psVector *xFit = psSparseSolve (NULL, constraint, matrix, 4);126 psVector *xFit = psSparseSolve(NULL, constraint, matrix, 4); 135 127 136 128 // measure stdev between xFit and xRes … … 173 165 psMemId id = psMemGetId(); 174 166 175 // diag ("solve a simple, small matrix equation "); 167 //solve a simple, small matrix equation 176 168 177 169 // the basic equation (Ax = b) is: … … 192 184 skip_start(matrix == NULL, 5, "Skipping tests because psSparseAlloc() failed"); 193 185 194 psSparseMatrixElement (matrix, 0, 0, 1.0);195 psSparseMatrixElement (matrix, 1, 1, 1.0);196 psSparseMatrixElement (matrix, 1, 0, 0.1);197 psSparseResort (matrix);186 psSparseMatrixElement(matrix, 0, 0, 1.0); 187 psSparseMatrixElement(matrix, 1, 1, 1.0); 188 psSparseMatrixElement(matrix, 1, 0, 0.1); 189 psSparseResort(matrix); 198 190 199 191 // border region has a width of 1: … … 244 236 245 237 // supply the fVec and gVec data to the border 246 for (int i = 0; i < Nrows; i++) 247 { 248 psSparseVectorElement (border->sparse, i, fVec->data.F32[i]); 249 } 250 for (int i = 0; i < Nborder; i++) 251 { 252 psSparseBorderElementG (border, i, gVec->data.F32[i]); 238 for (int i = 0; i < Nrows; i++) { 239 psSparseVectorElement(border->sparse, i, fVec->data.F32[i]); 240 } 241 for (int i = 0; i < Nborder; i++) { 242 psSparseBorderElementG(border, i, gVec->data.F32[i]); 253 243 } 254 244 … … 262 252 psVector *xFit = NULL; 263 253 psVector *yFit = NULL; 264 psSparseBorderSolve (&xFit, &yFit, constraint, border, 4);254 psSparseBorderSolve(&xFit, &yFit, constraint, border, 4); 265 255 is_float_tol (xFit->data.F32[0], 1.0, 1e-4, "f(0): %f", xFit->data.F32[0]); 266 256 is_float_tol (xFit->data.F32[1], 1.0, 1e-4, "f(1): %f", xFit->data.F32[1]); … … 283 273 psMemId id = psMemGetId(); 284 274 285 // diag ("solve a simple, small matrix equation "); 275 // solve a simple, small matrix equation 286 276 287 277 // the basic equation (Ax = b) is: … … 302 292 skip_start(matrix == NULL, 5, "Skipping tests because psSparseAlloc() failed"); 303 293 304 for (int i = 0; i < Nrows; i++) 305 { 306 psSparseMatrixElement (matrix, i, i, 1.0); 294 for (int i = 0; i < Nrows; i++) { 295 psSparseMatrixElement(matrix, i, i, 1.0); 307 296 if (i + 1 < Nrows) { 308 psSparseMatrixElement (matrix, i + 1, i, 0.1);309 } 310 } 311 psSparseResort (matrix);297 psSparseMatrixElement(matrix, i + 1, i, 0.1); 298 } 299 } 300 psSparseResort(matrix); 312 301 313 302 // border region has a width of 1: … … 349 338 350 339 // supply the fVec and gVec data to the border 351 for (int i = 0; i < Nrows; i++) 352 { 353 psSparseVectorElement (border->sparse, i, fVec->data.F32[i]); 354 } 355 for (int i = 0; i < Nborder; i++) 356 { 357 psSparseBorderElementG (border, i, gVec->data.F32[i]); 340 for (int i = 0; i < Nrows; i++) { 341 psSparseVectorElement(border->sparse, i, fVec->data.F32[i]); 342 } 343 for (int i = 0; i < Nborder; i++) { 344 psSparseBorderElementG(border, i, gVec->data.F32[i]); 358 345 } 359 346 … … 367 354 psVector *xFit = NULL; 368 355 psVector *yFit = NULL; 369 psSparseBorderSolve (&xFit, &yFit, constraint, border, 4);356 psSparseBorderSolve(&xFit, &yFit, constraint, border, 4); 370 357 371 358 // measure stdev between xFit and xRef -
trunk/psLib/test/mathtypes/tap_psVector.c
r13084 r13123 8 8 int main (void) 9 9 { 10 psLogSetFormat("HLNM"); 11 psLogSetLevel(PS_LOG_INFO); 10 12 plan_tests(285); 11 13 … … 626 628 vec->data.U8[4] = 0; 627 629 long numPix = psVectorCountPixelMask(vec, 1); 628 ok(numPix != -1, " returned-1 for correct Vector input");630 ok(numPix != -1, "did not return -1 for correct Vector input"); 629 631 ok(numPix == 2, "returned pixel count %d", numPix); 630 632 psFree(vec); -
trunk/psLib/test/types/tap_psPixels_all.c
r12781 r13123 23 23 plan_tests(36); 24 24 25 note("Tests for psPixels Functions"); 26 25 //Tests for psPixels Functions 27 26 testPixelsCreate(); 28 27 testPixelsManip(); … … 33 32 void testPixelsCreate(void) 34 33 { 35 note(" >>>Test 1: psPixels Creation Fxns"); 36 34 //Test 1: psPixels Creation Fxns 37 35 //Return allocated psPixels of length 0 with NULL data. 38 36 psPixels* p0 = psPixelsAlloc(0); … … 49 47 //Make sure psMemCheckPixels works correctly - return true 50 48 { 51 ok( psMemCheckPixels(p1),49 ok(psMemCheckPixels(p1), 52 50 "psMemCheckPixels: return true for psPixels input."); 53 51 } … … 55 53 { 56 54 int j = 2; 57 ok( !psMemCheckPixels(&j),55 ok(!psMemCheckPixels(&j), 58 56 "psMemCheckPixels: return false for non-psPixels input."); 59 57 } … … 62 60 psPixels *noPix = psPixelsAlloc(1); 63 61 noPix = psPixelsRealloc(noPix, 0); 64 ok( noPix->n == 0 && noPix->nalloc == 0,62 ok(noPix->n == 0 && noPix->nalloc == 0, 65 63 "psPixelsRealloc: return re-allocated psPixels of 0 length."); 66 64 psFree(noPix); … … 75 73 "Skipping 1 tests because psPixels input is of wrong size! =%ld", p0->n); 76 74 p0 = psPixelsRealloc(p0, 2); 77 ok( p0->n == 2 && fabs(p0->data[0].x - 1.1) < FLT_EPSILON && p0->nalloc == 2,75 ok(p0->n == 2 && fabs(p0->data[0].x - 1.1) < FLT_EPSILON && p0->nalloc == 2, 78 76 "psPixelsRealloc: return properly down-sized psPixels."); 79 77 skip_end(); … … 83 81 psPixels *noPix = NULL; 84 82 noPix = psPixelsCopy(noPix, p0); 85 ok( noPix->n == 2 && fabs(noPix->data[0].x - 1.1) < FLT_EPSILON && noPix->nalloc == 2,83 ok(noPix->n == 2 && fabs(noPix->data[0].x - 1.1) < FLT_EPSILON && noPix->nalloc == 2, 86 84 "psPixelsCopy: return properly copied psPixels."); 87 85 psFree(noPix); … … 91 89 psPixels *noPix = NULL; 92 90 noPix = psPixelsCopy(noPix, NULL); 93 ok( noPix == NULL,91 ok(noPix == NULL, 94 92 "psPixelsCopy: return NULL for NULL psPixels input."); 95 93 } … … 105 103 void testPixelsManip(void) 106 104 { 107 note(" >>>Test 2: psPixels Manipulation Fxns"); 108 105 //psPixels Manipulation Fxns 109 106 //Tests for psPixelsSet 110 107 psPixels *p0 = psPixelsAlloc(1); … … 114 111 //Return false for NULL pixels input 115 112 { 116 ok( !psPixelsSet(NULL, 0, in),113 ok(!psPixelsSet(NULL, 0, in), 117 114 "psPixelsSet: return false for NULL pixels input."); 118 115 } 119 116 //Return true for valid inputs 120 117 { 121 ok( psPixelsSet(p0, 0, in),118 ok(psPixelsSet(p0, 0, in), 122 119 "psPixelsSet: return true for valid inputs."); 123 120 } 124 121 //Return false for position == nalloc 125 122 { 126 ok( !psPixelsSet(p0, 1, in),123 ok(!psPixelsSet(p0, 1, in), 127 124 "psPixelsSet: return false for position == nalloc."); 128 125 } 129 126 //Return false for out-of-range position 130 127 { 131 ok( !psPixelsSet(p0, 2, in),128 ok(!psPixelsSet(p0, 2, in), 132 129 "psPixelsSet: return false for out-of-range position."); 133 130 } 134 131 //Return false for negative out-of-range position 135 132 { 136 ok( !psPixelsSet(p0, -2, in),133 ok(!psPixelsSet(p0, -2, in), 137 134 "psPixelsSet: return false for negative out-of-range position."); 138 135 } 139 136 //Return true for valid negative position 140 137 { 141 ok( psPixelsSet(p0, -1, in),138 ok(psPixelsSet(p0, -1, in), 142 139 "psPixelsSet: return true for valid negative position."); 143 140 } … … 148 145 { 149 146 out = psPixelsGet(NULL, 1); 150 ok( isnan(out.x) && isnan(out.y),147 ok(isnan(out.x) && isnan(out.y), 151 148 "psPixelsGet: return NANs for NULL pixels input."); 152 149 } … … 154 151 { 155 152 out = psPixelsGet(p0, 2); 156 ok( isnan(out.x) && isnan(out.y),153 ok(isnan(out.x) && isnan(out.y), 157 154 "psPixelsGet: return NANs for out-of-range position."); 158 155 } … … 160 157 { 161 158 out = psPixelsGet(p0, -2); 162 ok( isnan(out.x) && isnan(out.y),159 ok(isnan(out.x) && isnan(out.y), 163 160 "psPixelsGet: return NANs for out-of-range negative position."); 164 161 } … … 166 163 { 167 164 out = psPixelsGet(p0, 0); 168 ok( fabs(out.x - 1.1) < FLT_EPSILON && fabs(out.y - 1.2) < FLT_EPSILON,165 ok(fabs(out.x - 1.1) < FLT_EPSILON && fabs(out.y - 1.2) < FLT_EPSILON, 169 166 "psPixelsGet: return correct values for valid inputs."); 170 167 } … … 172 169 { 173 170 out = psPixelsGet(p0, -1); 174 ok( fabs(out.x - 1.1) < FLT_EPSILON && fabs(out.y - 1.2) < FLT_EPSILON,171 ok(fabs(out.x - 1.1) < FLT_EPSILON && fabs(out.y - 1.2) < FLT_EPSILON, 175 172 "psPixelsGet: return correct values for valid negative position."); 176 173 } … … 180 177 { 181 178 FILE *newFD = fopen("psPixels.out", "w+"); 182 ok (p_psPixelsPrint(newFD, p0, "PS-PIXELS"),179 ok(p_psPixelsPrint(newFD, p0, "PS-PIXELS"), 183 180 "p_psPixelsPrint: return true for valid input."); 184 181 fflush(NULL); … … 188 185 { 189 186 FILE *dummy = fopen("psPixels.out", "r"); 190 ok (!p_psPixelsPrint(dummy, p0, "failed test"),187 ok(!p_psPixelsPrint(dummy, p0, "failed test"), 191 188 "p_psPixelsPrint: return false for invalid file input."); 192 189 fclose(dummy); … … 196 193 //Return false for NULL pixels and name inputs 197 194 { 198 ok (!p_psPixelsPrint(stdout, NULL, NULL),195 ok(!p_psPixelsPrint(stdout, NULL, NULL), 199 196 "p_psPixelsPrint: return false for NULL pixels and name inputs."); 200 197 } … … 202 199 psPixels *p1 = psPixelsAlloc(0); 203 200 { 204 ok (p_psPixelsPrint(NULL, p1, "noPix"),201 ok(p_psPixelsPrint(NULL, p1, "noPix"), 205 202 "p_psPixelsPrint: return true for NULL file and empty pixel data inputs."); 206 203 } 207 204 205 206 //---------------------------------------------------------------------- 208 207 //psPixelsToMask Tests 209 208 psImage *outImage = NULL; … … 214 213 region.y1 = 5.0; 215 214 psMaskType maskVal = 1; 216 217 215 //Return NULL for NULL pixels input 218 216 { 217 psMemId id = psMemGetId(); 219 218 outImage = psPixelsToMask(outImage, NULL, region, maskVal); 220 ok ( outImage == NULL, 221 "psPixelsToMask: return NULL for NULL pixels input."); 222 } 219 ok(outImage == NULL, "psPixelsToMask: return NULL for NULL pixels input."); 220 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 221 } 222 223 223 224 //Return NULL for empty pixel data 224 225 { 226 psMemId id = psMemGetId(); 225 227 outImage = psPixelsToMask(outImage, p1, region, maskVal); 226 ok ( outImage == NULL, 227 "psPixelsToMask: return NULL for NULL pixels data input."); 228 } 228 ok(outImage == NULL, "psPixelsToMask: return NULL for NULL pixels data input."); 229 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 230 } 231 232 229 233 //Return NULL for bad region input - negative value 230 234 { 235 psMemId id = psMemGetId(); 231 236 outImage = psPixelsToMask(outImage, p0, region, maskVal); 232 ok ( outImage == NULL, 233 "psPixelsToMask: return NULL for negative value in region."); 234 } 237 ok(outImage == NULL, "psPixelsToMask: return NULL for negative value in region."); 238 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 239 } 240 241 235 242 //Return NULL for bad region input - upper bound less than lower bound 236 243 region.x0 = 3.0; 237 244 region.x1 = 1.0; 238 245 { 246 psMemId id = psMemGetId(); 239 247 outImage = psPixelsToMask(outImage, p0, region, maskVal); 240 ok ( outImage == NULL, 241 "psPixelsToMask: return NULL for bad region input."); 242 } 248 ok(outImage == NULL, "psPixelsToMask: return NULL for bad region input."); 249 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 250 } 251 252 253 //Return NULL for un-recyclable image - out->type.dimen != PS_DIMEN_IMAGE 243 254 region.x0 = 1.0; 244 255 region.x1 = 3.0; 245 //Return NULL for un-recyclable image - out->type.dimen != PS_DIMEN_IMAGE246 256 outImage = psImageAlloc(1, 1, PS_TYPE_S32); 247 257 *(psDimen*)&(outImage->type.dimen) = PS_DIMEN_OTHER; 248 258 { 259 psMemId id = psMemGetId(); 249 260 outImage = psPixelsToMask(outImage, p0, region, maskVal); 250 ok ( outImage == NULL, 251 "psPixelsToMask: return NULL for bad image input."); 252 } 261 ok(outImage == NULL, "psPixelsToMask: return NULL for bad image input."); 262 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 263 } 264 265 253 266 //Return valid image for valid inputs 267 //XXX: Musr check pixel values 254 268 p0 = psPixelsAdd(p0, 1, 2.1, 2.2); 255 269 p0 = psPixelsAdd(p0, 1, 3.1, 3.2); 256 270 p0 = psPixelsAdd(p0, 1, 1.0, 1.0); 257 271 { 272 psMemId id = psMemGetId(); 258 273 outImage = psPixelsToMask(outImage, p0, region, maskVal); 259 ok ( outImage != NULL, 260 "psPixelsToMask: return valid image for valid input."); 261 } 262 274 ok(outImage != NULL, "psPixelsToMask: return valid image for valid input."); 275 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 276 } 277 psFree(outImage); 278 279 280 //---------------------------------------------------------------------- 263 281 //psPixelsFromMask Tests 264 //Return valid psPixels for valid inputs265 psFree(outImage);266 282 outImage = psImageAlloc(31, 99, PS_TYPE_MASK); 267 283 for (int i = 0; i < outImage->numCols; i++) { … … 270 286 } 271 287 } 272 273 { 288 //Return valid psPixels for valid inputs 289 //XXX: We never check output psPixels 290 { 291 psMemId id = psMemGetId(); 274 292 psPixels *outPixels = NULL; 275 293 outPixels = psPixelsFromMask(outPixels, outImage, maskVal); 276 ok ( outPixels != NULL, 277 "psPixelsFromMask: return valid pixels for valid input."); 294 ok(outPixels != NULL, "psPixelsFromMask: return valid pixels for valid input."); 278 295 psFree(outPixels); 279 } 296 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 297 } 298 280 299 281 300 // Return NULL for NULL image input 282 301 { 302 psMemId id = psMemGetId(); 283 303 psPixels *outPixels = NULL; 284 304 outPixels = psPixelsFromMask(outPixels, NULL, maskVal); 285 ok ( outPixels == NULL, 286 "psPixelsFromMask: return NULL for NULL image input."); 287 } 305 ok(outPixels == NULL, "psPixelsFromMask: return NULL for NULL image input."); 306 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 307 } 308 288 309 289 310 // Return NULL for image with wrong maskType 290 *(psElemType*)&(outImage->type.type) = PS_TYPE_U32; 291 { 311 { 312 *(psElemType*)&(outImage->type.type) = PS_TYPE_U32; 313 psMemId id = psMemGetId(); 292 314 psPixels *outPixels = NULL; 293 315 outPixels = psPixelsFromMask(outPixels, outImage, maskVal); 294 ok ( outPixels == NULL, 295 "psPixelsFromMask: return NULL for image with wrong maskType."); 296 } 297 316 ok(outPixels == NULL, "psPixelsFromMask: return NULL for image with wrong maskType."); 317 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 318 *(psElemType*)&(outImage->type.type) = PS_TYPE_U8; 319 } 320 321 322 323 //---------------------------------------------------------------------- 298 324 // psPixelsConcatenate Tests 299 325 // Return NULL for NULL pixels input 300 326 { 327 psMemId id = psMemGetId(); 301 328 psPixels *outPixels = NULL; 302 329 outPixels = psPixelsConcatenate(outPixels, NULL); 303 ok ( outPixels == NULL,304 "psPixelsConcatenate: return NULL for NULL pixels input.");330 ok(outPixels == NULL, "psPixelsConcatenate: return NULL for NULL pixels input."); 331 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 305 332 } 306 333 … … 308 335 //Return copy of input pixels for NULL out pixels 309 336 { 337 psMemId id = psMemGetId(); 310 338 psPixels *outPixels = NULL; 311 339 outPixels = psPixelsFromMask(outPixels, outImage, maskVal); 312 340 outPixels = psPixelsConcatenate(outPixels, p0); 313 ok (outPixels->n == 4 && fabs(outPixels->data[0].x - 1.1) < FLT_EPSILON &&341 ok(outPixels->n == 4 && fabs(outPixels->data[0].x - 1.1) < FLT_EPSILON && 314 342 fabs(outPixels->data[0].y - 1.2) < FLT_EPSILON , 315 343 "psPixelsConcatenate: return copy of input pixels for NULL out input."); 316 344 psFree(outPixels); 317 } 318 345 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 346 } 347 348 349 //test psPixelsConcatenate() 319 350 //Return properly concatenated psPixels list 320 //Set all the compare cases to cover 'comparePixelCoord' as well. 321 psPixels *outPixels = psPixelsAlloc(5); 322 in.x = 1.0; 323 in.y = 1.0; 324 psPixelsSet(outPixels, 0, in); //1, 1 325 psPixelsSet(outPixels, 1, in); //1, 1 326 in.y = 2.0; 327 psPixelsSet(outPixels, 2, in); //1, 2 328 in.y = 1.0; 329 psPixelsSet(outPixels, 3, in); //1, 1 330 in.x = 2.0; 331 psPixelsSet(outPixels, 4, in); //2, 1 332 333 psPixels *testPixels = psPixelsAlloc(6); 334 in.x = 1.0; 335 in.y = 1.0; 336 psPixelsSet(testPixels, 0, in); //1, 1 337 in.y = 2.0; 338 psPixelsSet(testPixels, 1, in); //1, 2 339 in.y = 1.0; 340 psPixelsSet(testPixels, 2, in); //1, 1 341 in.x = 2.0; 342 psPixelsSet(testPixels, 3, in); //2, 1 343 in.x = 1.0; 344 psPixelsSet(testPixels, 4, in); //1, 1 345 in.x = 5.0; 346 in.y = 3.0; 347 psPixelsSet(testPixels, 5, in); //5, 3 348 //Return properly concatenate pixel list 349 { 351 { 352 psMemId id = psMemGetId(); 353 psPixels *outPixels = psPixelsAlloc(5); 354 in.x = 1.0; 355 in.y = 1.0; 356 psPixelsSet(outPixels, 0, in); //1, 1 357 psPixelsSet(outPixels, 1, in); //1, 1 358 in.y = 2.0; 359 psPixelsSet(outPixels, 2, in); //1, 2 360 in.y = 1.0; 361 psPixelsSet(outPixels, 3, in); //1, 1 362 in.x = 2.0; 363 psPixelsSet(outPixels, 4, in); //2, 1 364 psPixels *testPixels = psPixelsAlloc(6); 365 in.x = 1.0; 366 in.y = 1.0; 367 psPixelsSet(testPixels, 0, in); //1, 1 368 in.y = 2.0; 369 psPixelsSet(testPixels, 1, in); //1, 2 370 in.y = 1.0; 371 psPixelsSet(testPixels, 2, in); //1, 1 372 in.x = 2.0; 373 psPixelsSet(testPixels, 3, in); //2, 1 374 in.x = 1.0; 375 psPixelsSet(testPixels, 4, in); //1, 1 376 in.x = 5.0; 377 in.y = 3.0; 378 psPixelsSet(testPixels, 5, in); //5, 3 350 379 outPixels = psPixelsConcatenate(outPixels, testPixels); 351 ok ( outPixels->n == 6, 352 "psPixelsConcatenate: return properly concatenate pixel list for valid inputs."); 353 } 354 355 356 //Check for Memory leaks 357 { 380 ok(outPixels->n == 6, "psPixelsConcatenate: return properly concatenate pixel list for valid inputs."); 358 381 psFree(testPixels); 359 382 psFree(outPixels); 383 ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks"); 384 } 385 386 387 //Check for Memory leaks 388 //XXX: Remove this, add memory checks to individual blocks 389 { 360 390 psFree(outImage); 361 391 psFree(p1);
Note:
See TracChangeset
for help on using the changeset viewer.
