Changeset 13614 for trunk/psLib/test/imageops/tap_psImagePixelExtract.c
- Timestamp:
- Jun 4, 2007, 10:25:32 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/imageops/tap_psImagePixelExtract.c
r13127 r13614 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 5$ $Name: not supported by cvs2svn $9 * @date $Date: 2007-0 5-02 04:34:13$8 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-06-04 20:25:32 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 17 17 #include "pstap.h" 18 18 19 void genericImageRowColTests(int numRows, int numCols) 20 { 21 psMemId id = psMemGetId(); 22 psImage *image = psImageAlloc(numCols, numRows, PS_TYPE_F32); 23 for (int i = 0 ; i < numRows; i++) { 24 for (int j = 0 ; j < numCols; j++) { 25 image->data.F32[0][0] = (float) i+j; 26 } 27 } 28 29 bool errorFlag = false; 30 for (int i = 0 ; i < numRows; i++) { 31 psVector *out = psImageRow(NULL, image, i); 32 ok(out != NULL, "psImageRow returned non-NULL"); 33 if (out != NULL) { 34 for (int j = 0 ; j < numCols; j++) { 35 if (out->data.F32[j] != image->data.F32[i][j]) { 36 diag("TEST ERROR: image->data.F32[%d][%d] is %f, should be %f", i, j, 37 image->data.F32[i][j], out->data.F32[j]); 38 errorFlag = true; 39 } 40 } 41 psFree(out); 42 } else { 43 errorFlag = true; 44 } 45 } 46 ok(!errorFlag, "psImageRow() passed tests with correct data inputs"); 47 psFree(image); 48 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 49 } 50 51 52 19 53 psS32 main(psS32 argc, char* argv[]) 20 54 { 21 55 psLogSetFormat("HLNM"); 22 56 psLogSetLevel(PS_LOG_INFO); 23 plan_tests(2 48);57 plan_tests(295); 24 58 25 59 // test psImageSlice() … … 807 841 ok(out == NULL, "psImageCol() returned NULL"); 808 842 809 810 //Test valid cases. 811 //XXX: We do not verify the data values. 812 P_PSIMAGE_SET_COL0(image, 10); 813 P_PSIMAGE_SET_ROW0(image, 5); 814 *(int*)&(image->numRows) = 3; 815 *(int*)&(image->numCols) = 3; 843 // Test on correct input data for several sizes 844 genericImageRowColTests(1, 8); 845 genericImageRowColTests(8, 1); 846 genericImageRowColTests(8, 8); 847 genericImageRowColTests(8, 16); 848 genericImageRowColTests(16, 8); 849 psFree(image); 850 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 851 } 852 853 // testImageRowColF64() 854 { 855 psMemId id = psMemGetId(); 856 psVector *rowcol = NULL; 857 psVector *empty = NULL; 858 psImage *image = NULL; 859 860 image = psImageAlloc(3, 3, PS_TYPE_F64); 861 rowcol = psVectorAlloc(3, PS_TYPE_F64); 862 816 863 image->data.F64[0][0] = 666.666; 817 864 image->data.F64[1][0] = 66.6; … … 823 870 image->data.F64[1][2] = 666.66; 824 871 image->data.F64[2][2] = 66.66; 825 num = 7;826 out = psImageRow(out, image, num);827 828 829 ok(out != NULL, "psImageRow returned non-NULL");830 psFree(out);831 out = NULL;832 num = 11;833 out = psImageCol(NULL, image, num);834 ok(out != NULL, "psImageCol returned non-NULL");835 psFree(out);836 out = NULL;837 838 839 num = -3;840 out = psImageRow(out, image, num);841 ok(out != NULL, "psImageRow returned non-NULL");842 psFree(out);843 out = NULL;844 845 846 num = -1;847 out = psImageCol(NULL, image, num);848 ok(out != NULL, "psImageCol returned non-NULL");849 psFree(out);850 psFree(image);851 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");852 }853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 // testImageRowColF64()870 {871 psMemId id = psMemGetId();872 psVector *rowcol = NULL;873 psVector *empty = NULL;874 psImage *image = NULL;875 876 image = psImageAlloc(3, 3, PS_TYPE_F64);877 rowcol = psVectorAlloc(3, PS_TYPE_F64);878 879 image->data.F64[0][0] = 666.666;880 image->data.F64[1][0] = 66.6;881 image->data.F64[2][0] = 6.66;882 image->data.F64[0][1] = 6.6;883 image->data.F64[1][1] = 6.666;884 image->data.F64[2][1] = 66.666;885 image->data.F64[0][2] = 666.6;886 image->data.F64[1][2] = 666.66;887 image->data.F64[2][2] = 66.66;888 872 889 873 //Test for error with NULL image
Note:
See TracChangeset
for help on using the changeset viewer.
