Changeset 5255 for trunk/psModules/test/objects
- Timestamp:
- Oct 10, 2005, 9:53:54 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/psModules/test/objects/tst_pmObjects01.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/test/objects/tst_pmObjects01.c
r5169 r5255 17 17 * 18 18 * XXX: Memory leaks are not being caught. If I allocated a psVector in these functions 19 * abd never deallocate, no error is generated. 19 * and never deallocate, no error is generated. 20 Fully Tested: 21 pmPeakAlloc() 22 pmMomentsAlloc() 23 Weakly Tested: 24 pmSourceMoments() 25 20 26 * 21 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $22 * @date $Date: 2005- 09-28 20:42:52$27 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 28 * @date $Date: 2005-10-10 19:53:54 $ 23 29 * 24 30 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 27 33 #include "pslib.h" 28 34 #include "pmObjects.h" 35 #include "pmModelGroup.h" 36 29 37 #define NUM_ROWS 10 30 38 #define NUM_COLS 10 … … 37 45 static int test04(void); 38 46 static int test05(void); 39 static int test06(void);47 //static int test06(void); 40 48 static int test07(void); 49 /* 41 50 static int test08(void); 42 51 static int test09(void); … … 44 53 static int test16(void); 45 54 static int test20(void); 55 */ 46 56 testDescription tests[] = { 47 57 {test00, 000, "pmObjects: structure allocators and deallocators", true, false}, … … 50 60 {test03, 001, "pmObjects: pmCullPeaks()", true, false}, 51 61 {test04, 001, "pmObjects: pmSourceLocalSky()", true, false}, 52 {test06, 001, "pmObjects: pmSourceSetPixelsCircle()", true, false},53 62 {test05, 001, "pmObjects: pmSourceMoments()", true, false}, 63 // {test06, 001, "pmObjects: pmSourceSetPixelsCircle()", true, false}, 54 64 {test07, 001, "pmObjects: pmMin()", true, false}, 55 {test08, 001, "pmObjects: pmSourceModelGuess()", true, false}, 56 {test09, 001, "pmObjects: pmSourceContour()", true, false}, 57 {test15, 001, "pmObjects: pmSourceAddModel()", true, false}, 58 {test16, 001, "pmObjects: pmSourceSubModel()", true, false}, 59 {test20, 001, "pmObjects: pmSourceSubModel()", true, false}, 65 /* 66 {test08, 001, "pmObjects: pmSourceModelGuess()", true, false}, 67 {test09, 001, "pmObjects: pmSourceContour()", true, false}, 68 {test15, 001, "pmObjects: pmSourceAddModel()", true, false}, 69 {test16, 001, "pmObjects: pmSourceSubModel()", true, false}, 70 {test20, 001, "pmObjects: pmSourceSubModel()", true, false}, 71 */ 60 72 {NULL} 61 73 }; … … 64 76 { 65 77 psLogSetFormat("HLNM"); 78 // 79 // We include the function names here in psTraceSetLevel() commands for 80 // debugging convenience. There is no guarantee that this list of functions 81 // is complete. 82 // 83 psTraceSetLevel(".", 0); 84 psTraceSetLevel("pmPeakAlloc", 0); 85 psTraceSetLevel("pmMomentsAlloc", 0); 86 psTraceSetLevel("modelFree", 0); 87 psTraceSetLevel("pmModelAlloc", 0); 88 psTraceSetLevel("sourceFree", 0); 89 psTraceSetLevel("pmSourceAlloc", 0); 90 psTraceSetLevel("pmFindVectorPeaks", 0); 91 psTraceSetLevel("getRowVectorFromImage", 0); 92 psTraceSetLevel("myListAddPeak", 0); 93 psTraceSetLevel("pmFindImagePeaks", 0); 94 psTraceSetLevel("isItInThisRegion", 0); 95 psTraceSetLevel("pmCullPeaks", 0); 96 psTraceSetLevel("pmPeaksSubset", 0); 97 psTraceSetLevel("pmSourceLocalSky", 0); 98 psTraceSetLevel("checkRadius2", 0); 99 psTraceSetLevel("pmSourceMoments", 0); 100 psTraceSetLevel("pmComparePeakAscend", 0); 101 psTraceSetLevel("pmComparePeakDescend", 0); 102 psTraceSetLevel("pmSourcePSFClump", 0); 103 psTraceSetLevel("pmSourceRoughClass", 0); 104 psTraceSetLevel("pmSourceDefinePixels", 0); 105 psTraceSetLevel("pmSourceModelGuess", 0); 106 psTraceSetLevel("pmModelEval", 0); 107 psTraceSetLevel("findValue", 0); 108 psTraceSetLevel("pmSourceContour", 0); 109 psTraceSetLevel("pmSourceFitModel_v5", 0); 110 psTraceSetLevel("pmSourceFitModel", 0); 111 psTraceSetLevel("p_pmSourceAddOrSubModel", 0); 112 psTraceSetLevel("pmSourceAddModel", 0); 113 psTraceSetLevel("pmSourceSubModel", 0); 114 66 115 return !runTestSuite(stderr, "Test Point Driver", tests, argc, argv); 67 116 } … … 116 165 (tmpMoments->nPixels != 0)) { 117 166 printf("TEST ERROR: pmMomentsAlloc() did not properly initialize the pmMoments structure.\n"); 167 printf(" tmpMoments->x is %f\n", tmpMoments->x); 168 printf(" tmpMoments->y is %f\n", tmpMoments->y); 169 printf(" tmpMoments->Sx is %f\n", tmpMoments->Sx); 170 printf(" tmpMoments->Sy is %f\n", tmpMoments->Sy); 171 printf(" tmpMoments->Sxy is %f\n", tmpMoments->Sxy); 172 printf(" tmpMoments->Sum is %f\n", tmpMoments->Sum); 173 printf(" tmpMoments->Peak is %f\n", tmpMoments->Peak); 174 printf(" tmpMoments->Sky is %f\n", tmpMoments->Sky); 175 printf(" tmp Moments->nPixels is %d\n", tmpMoments->nPixels); 118 176 testStatus = false; 119 177 } … … 121 179 psFree(tmpMoments); 122 180 123 printf("Testing pmModelAlloc(PS_MODEL_GAUSS)...\n"); 124 pmModel *tmpModel = pmModelAlloc(PS_MODEL_GAUSS); 125 if (tmpModel == NULL) { 126 printf("TEST ERROR: pmModelAlloc(PS_MODEL_GAUSS) returned a NULL pmModel\n"); 127 testStatus = false; 128 } else { 129 if ((tmpModel->params->n != 7) || (tmpModel->dparams->n != 7)) { 130 printf("TEST ERROR: pmModelAlloc(PS_MODEL_GAUSS) allocated an incorrect number of params (%ld, %ld)\n", 131 tmpModel->params->n, tmpModel->dparams->n); 181 182 // 183 // Loop through each type of model 184 // 185 psS32 i = 0; 186 while (0 != pmModelParameterCount(i)) { 187 printf("Testing pmModelAlloc(%s)...\n", pmModelGetType(0)); 188 pmModel *tmpModel = pmModelAlloc(i); 189 if (tmpModel == NULL) { 190 printf("TEST ERROR: pmModelAlloc(%s) returned a NULL pmModel\n", pmModelGetType(0)); 132 191 testStatus = false; 133 192 } else { 134 for (psS32 i = 0 ; i < 7 ; i++) { 135 if ((tmpModel->params->data.F32[i] != 0.0) || 136 (tmpModel->dparams->data.F32[i] != 0.0)) { 137 printf("TEST ERROR: pmModelAlloc(PS_MODEL_GAUSS) did not ininitialize the params/dparams array to 0.0.\n"); 138 testStatus = false; 139 } 140 } 141 } 142 } 143 psFree(tmpModel); 144 145 printf("Testing pmModelAlloc(PS_MODEL_PGAUSS)...\n"); 146 tmpModel = pmModelAlloc(PS_MODEL_PGAUSS); 147 if (tmpModel == NULL) { 148 printf("TEST ERROR: pmModelAlloc(PS_MODEL_PGAUSS) returned a NULL pmModel\n"); 149 testStatus = false; 150 } else { 151 if ((tmpModel->params->n != 7) || (tmpModel->dparams->n != 7)) { 152 printf("TEST ERROR: pmModelAlloc(PS_MODEL_PGAUSS) allocated an incorrect number of params (%ld, %ld)\n", 153 tmpModel->params->n, tmpModel->dparams->n); 154 testStatus = false; 155 } else { 156 for (psS32 i = 0 ; i < 7 ; i++) { 157 if ((tmpModel->params->data.F32[i] != 0.0) || 158 (tmpModel->dparams->data.F32[i] != 0.0)) { 159 printf("TEST ERROR: pmModelAlloc(PS_MODEL_PGAUSS) did not ininitialize the params/dparams array to 0.0.\n"); 160 testStatus = false; 161 } 162 } 163 } 164 } 165 psFree(tmpModel); 166 167 printf("Testing pmModelAlloc(PS_MODEL_TWIST_GAUSS)...\n"); 168 tmpModel = pmModelAlloc(PS_MODEL_TWIST_GAUSS); 169 if (tmpModel == NULL) { 170 printf("TEST ERROR: pmModelAlloc(PS_MODEL_TWIST_GAUSS) returned a NULL pmModel\n"); 171 testStatus = false; 172 } else { 173 if ((tmpModel->params->n != 11) || (tmpModel->dparams->n != 11)) { 174 printf("TEST ERROR: pmModelAlloc(PS_MODEL_TWIST_GAUSS) allocated an incorrect number of params (%ld, %ld)\n", 175 tmpModel->params->n, tmpModel->dparams->n); 176 testStatus = false; 177 } else { 178 for (psS32 i = 0 ; i < 11 ; i++) { 179 if ((tmpModel->params->data.F32[i] != 0.0) || 180 (tmpModel->dparams->data.F32[i] != 0.0)) { 181 printf("TEST ERROR: pmModelAlloc(PS_MODEL_TWIST_GAUSS) did not ininitialize the params/dparams array to 0.0.\n"); 182 testStatus = false; 183 } 184 } 185 } 186 } 187 psFree(tmpModel); 188 189 printf("Testing pmModelAlloc(PS_MODEL_WAUSS)...\n"); 190 tmpModel = pmModelAlloc(PS_MODEL_WAUSS); 191 if (tmpModel == NULL) { 192 printf("TEST ERROR: pmModelAlloc(PS_MODEL_WAUSS) returned a NULL pmModel\n"); 193 testStatus = false; 194 } else { 195 if ((tmpModel->params->n != 9) || (tmpModel->dparams->n != 9)) { 196 printf("TEST ERROR: pmModelAlloc(PS_MODEL_WAUSS) allocated an incorrect number of params (%ld, %ld)\n", 197 tmpModel->params->n, tmpModel->dparams->n); 198 testStatus = false; 199 } else { 200 for (psS32 i = 0 ; i < 9 ; i++) { 201 if ((tmpModel->params->data.F32[i] != 0.0) || 202 (tmpModel->dparams->data.F32[i] != 0.0)) { 203 printf("TEST ERROR: pmModelAlloc(PS_MODEL_WAUSS) did not ininitialize the params/dparams array to 0.0.\n"); 204 testStatus = false; 205 } 206 } 207 } 208 } 209 psFree(tmpModel); 210 211 printf("Testing pmModelAlloc(PS_MODEL_SERSIC)...\n"); 212 tmpModel = pmModelAlloc(PS_MODEL_SERSIC); 213 if (tmpModel == NULL) { 214 printf("TEST ERROR: pmModelAlloc(PS_MODEL_SERSIC) returned a NULL pmModel\n"); 215 testStatus = false; 216 } else { 217 if ((tmpModel->params->n != 8) || (tmpModel->dparams->n != 8)) { 218 printf("TEST ERROR: pmModelAlloc(PS_MODEL_SERSIC) allocated an incorrect number of params (%ld, %ld)\n", 219 tmpModel->params->n, tmpModel->dparams->n); 220 testStatus = false; 221 } else { 222 for (psS32 i = 0 ; i < 8 ; i++) { 223 if ((tmpModel->params->data.F32[i] != 0.0) || 224 (tmpModel->dparams->data.F32[i] != 0.0)) { 225 printf("TEST ERROR: pmModelAlloc(PS_MODEL_SERSIC) did not ininitialize the params/dparams array to 0.0.\n"); 226 testStatus = false; 227 } 228 } 229 } 230 } 231 psFree(tmpModel); 232 233 printf("Testing pmModelAlloc(PS_MODEL_SERSIC_CORE)...\n"); 234 tmpModel = pmModelAlloc(PS_MODEL_SERSIC_CORE); 235 if (tmpModel == NULL) { 236 printf("TEST ERROR: pmModelAlloc(PS_MODEL_SERSIC_CORE) returned a NULL pmModel\n"); 237 testStatus = false; 238 } else { 239 if ((tmpModel->params->n != 12) || (tmpModel->dparams->n != 12)) { 240 printf("TEST ERROR: pmModelAlloc(PS_MODEL_SERSIC_CORE) allocated an incorrect number of params (%ld, %ld)\n", 241 tmpModel->params->n, tmpModel->dparams->n); 242 testStatus = false; 243 } else { 244 for (psS32 i = 0 ; i < 12 ; i++) { 245 if ((tmpModel->params->data.F32[i] != 0.0) || 246 (tmpModel->dparams->data.F32[i] != 0.0)) { 247 printf("TEST ERROR: pmModelAlloc(PS_MODEL_SERSIC_CORE) did not ininitialize the params/dparams array to 0.0.\n"); 248 testStatus = false; 249 } 250 } 251 } 252 } 253 psFree(tmpModel); 193 194 /* XXX: Should we test that the members were set correctly? 195 if ((tmpModel->params->n != 7) || (tmpModel->dparams->n != 7)) { 196 printf("TEST ERROR: pmModelAlloc(PS_MODEL_GAUSS) allocated an incorrect number of params (%ld, %ld)\n", 197 tmpModel->params->n, tmpModel->dparams->n); 198 testStatus = false; 199 } else { 200 for (psS32 i = 0 ; i < 7 ; i++) { 201 if ((tmpModel->params->data.F32[i] != 0.0) || 202 (tmpModel->dparams->data.F32[i] != 0.0)) { 203 printf("TEST ERROR: pmModelAlloc(PS_MODEL_GAUSS) did not ininitialize the params/dparams array to 0.0.\n"); 204 testStatus = false; 205 } 206 } 207 } 208 */ 209 } 210 psFree(tmpModel); 211 i++; 212 } 213 254 214 255 215 pmSource *tmpSource = pmSourceAlloc(); … … 775 735 } 776 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 777 803 #define TST04_NUM_ROWS 100 778 804 #define TST04_NUM_COLS 100 … … 792 818 bool testStatus = true; 793 819 psImage *imgData = psImageAlloc(TST04_NUM_COLS, TST04_NUM_ROWS, PS_TYPE_F32); 794 for (psS32 i = 0 ; i < imgData->numRows; i++) {795 for (psS32 j = 0 ; j < imgData->numCols; j++) {796 imgData->data.F32[i][j] = TST04_SKY;797 }798 }820 psImageInit(imgData, TST04_SKY); 821 psImage *imgMask = psImageAlloc(TST04_NUM_COLS, TST04_NUM_ROWS, PS_TYPE_U8); 822 psImageInit(imgMask, 0); 823 // psImage *imgMaskS8 = psImageAlloc(TST04_NUM_COLS, TST04_NUM_ROWS, PS_TYPE_S8); 824 // psImageInit(imgMaskS8, 0); 799 825 psImage *imgDataF64 = psImageAlloc(TST04_NUM_COLS, TST04_NUM_ROWS, PS_TYPE_F64); 800 for (psS32 i = 0 ; i < imgDataF64->numRows; i++) { 801 for (psS32 j = 0 ; j < imgDataF64->numCols; j++) { 802 imgDataF64->data.F64[i][j] = 0.0; 803 } 804 } 805 pmSource *rc = NULL; 826 psImageInit(imgDataF64, 0.0); 806 827 pmPeak *tmpPeak = pmPeakAlloc((psF32) (TST04_NUM_ROWS / 2), 807 828 (psF32) (TST04_NUM_COLS / 2), 808 829 200.0, 809 830 PM_PEAK_LONE); 810 811 printf("----------------------------------------------------------------------------------\n"); 812 printf("Calling pmSourceLocalSky with NULL psImage. Should generate error and return NULL.\n"); 813 rc = pmSourceLocalSky(NULL, tmpPeak, PS_STAT_SAMPLE_MEAN, 10.0, 20.0); 814 if (rc != NULL) { 815 printf("TEST ERROR: pmSourceLocalSky() returned a non-NULL pmSource.\n"); 816 psFree(rc); 817 testStatus = false; 818 } 819 820 printf("----------------------------------------------------------------------------------\n"); 821 printf("Calling pmSourceLocalSky with wrong-type psImage. Should generate error and return NULL.\n"); 822 rc = pmSourceLocalSky(imgDataF64, tmpPeak, PS_STAT_SAMPLE_MEAN, 10.0, 20.0); 823 if (rc != NULL) { 824 printf("TEST ERROR: pmSourceLocalSky() returned a non-NULL pmSource.\n"); 825 psFree(rc); 826 testStatus = false; 827 } 828 829 printf("----------------------------------------------------------------------------------\n"); 830 printf("Calling pmSourceLocalSky with NULL pmPeak. Should generate error and return NULL.\n"); 831 rc = pmSourceLocalSky(imgData, NULL, PS_STAT_SAMPLE_MEAN, 10.0, 20.0); 832 if (rc != NULL) { 833 printf("TEST ERROR: pmSourceLocalSky() returned a non-NULL pmSource.\n"); 834 psFree(rc); 835 testStatus = false; 836 } 837 838 printf("----------------------------------------------------------------------------------\n"); 839 printf("Calling pmSourceLocalSky with innerRadius<0.0. Should generate error and return NULL.\n"); 840 rc = pmSourceLocalSky(imgData, tmpPeak, PS_STAT_SAMPLE_MEAN, -10.0, 20.0); 841 if (rc != NULL) { 842 printf("TEST ERROR: pmSourceLocalSky() returned a non-NULL pmSource.\n"); 843 psFree(rc); 844 testStatus = false; 845 } 846 847 printf("----------------------------------------------------------------------------------\n"); 848 printf("Calling pmSourceLocalSky with innerRadius>outerRadius. Should generate error and return NULL.\n"); 849 rc = pmSourceLocalSky(imgData, tmpPeak, PS_STAT_SAMPLE_MEAN, 10.0, 5.0); 850 if (rc != NULL) { 851 printf("TEST ERROR: pmSourceLocalSky() returned a non-NULL pmSource.\n"); 852 psFree(rc); 853 testStatus = false; 854 } 855 /* XXX: This is commented out since the EAM modification no longer generated NULLS for these tests. 856 printf("----------------------------------------------------------------------------------\n"); 857 printf("Calling pmSourceLocalSky with subImage startRow < 0. Should generate error and return NULL.\n"); 858 tmpPeak->x = (psF32) (TST04_NUM_ROWS / 2); 859 tmpPeak->y = (psF32) (TST04_NUM_COLS / 2); 860 tmpPeak->y = 1; 861 rc = pmSourceLocalSky(imgData, tmpPeak, PS_STAT_SAMPLE_MEAN, 10.0, 20.0); 862 if (rc != NULL) { 863 printf("TEST ERROR: pmSourceLocalSky() returned a non-NULL pmSource.\n"); 864 psFree(rc); 865 testStatus = false; 866 } 867 printf("----------------------------------------------------------------------------------\n"); 868 printf("Calling pmSourceLocalSky with subImage endRow > numRows. Should generate error and return NULL.\n"); 869 tmpPeak->x = (psF32) (TST04_NUM_ROWS / 2); 870 tmpPeak->y = (psF32) (TST04_NUM_COLS / 2); 871 tmpPeak->y = TST04_NUM_ROWS; 872 rc = pmSourceLocalSky(imgData, tmpPeak, PS_STAT_SAMPLE_MEAN, 10.0, 20.0); 873 if (rc != NULL) { 874 printf("TEST ERROR: pmSourceLocalSky() returned a non-NULL pmSource.\n"); 875 psFree(rc); 876 testStatus = false; 877 } 878 printf("----------------------------------------------------------------------------------\n"); 879 printf("Calling pmSourceLocalSky with subImage startCol < 0. Should generate error and return NULL.\n"); 880 tmpPeak->x = (psF32) (TST04_NUM_ROWS / 2); 881 tmpPeak->y = (psF32) (TST04_NUM_COLS / 2); 882 tmpPeak->x = 1; 883 rc = pmSourceLocalSky(imgData, tmpPeak, PS_STAT_SAMPLE_MEAN, 10.0, 20.0); 884 if (rc != NULL) { 885 printf("TEST ERROR: pmSourceLocalSky() returned a non-NULL pmSource.\n"); 886 psFree(rc); 887 testStatus = false; 888 } 889 printf("----------------------------------------------------------------------------------\n"); 890 printf("Calling pmSourceLocalSky with subImage endCol > numCols. Should generate error and return NULL.\n"); 891 tmpPeak->x = (psF32) (TST04_NUM_ROWS / 2); 892 tmpPeak->y = (psF32) (TST04_NUM_COLS / 2); 893 tmpPeak->x = TST04_NUM_COLS; 894 rc = pmSourceLocalSky(imgData, tmpPeak, PS_STAT_SAMPLE_MEAN, (psF32) TST04_INNER_RADIUS, (psF32) TST04_OUTER_RADIUS); 895 if (rc != NULL) { 896 printf("TEST ERROR: pmSourceLocalSky() returned a non-NULL pmSource.\n"); 897 psFree(rc); 898 testStatus = false; 899 } 900 */ 831 pmSource *tmpSource = pmSourceAlloc(); 832 tmpSource->pixels = imgData; 833 tmpSource->mask = imgMask; 834 tmpSource->peak = tmpPeak; 835 836 printf("----------------------------------------------------------------------------------\n"); 837 printf("Calling pmSourceLocalSky with NULL tmpSource. Should generate error and return FALSE.\n"); 838 bool rc = pmSourceLocalSky(NULL, PS_STAT_SAMPLE_MEAN, 10.0); 839 if (rc != false) { 840 printf("TEST ERROR: pmSourceLocalSky() returned a non-FALSE pmSource.\n"); 841 testStatus = false; 842 } 843 844 printf("----------------------------------------------------------------------------------\n"); 845 printf("Calling pmSourceLocalSky with Radius<0.0. Should generate error and return FALSE.\n"); 846 rc = pmSourceLocalSky(tmpSource, PS_STAT_SAMPLE_MEAN, -10.0); 847 if (rc != false) { 848 printf("TEST ERROR: pmSourceLocalSky() returned a non-FALSE pmSource.\n"); 849 testStatus = false; 850 } 901 851 902 852 // … … 908 858 tmpPeak->x = (psF32) (TST04_NUM_ROWS / 2); 909 859 tmpPeak->y = (psF32) (TST04_NUM_COLS / 2); 910 rc = pmSourceLocalSky(imgData, 911 tmpPeak, 912 PS_STAT_SAMPLE_MEAN, 913 (psF32) TST04_INNER_RADIUS, 914 (psF32) TST04_OUTER_RADIUS); 915 916 if (rc == NULL) { 917 printf("TEST ERROR: pmSourceLocalSky() returned a NULL pmSource.\n"); 860 rc = pmSourceLocalSky(tmpSource, PS_STAT_SAMPLE_MEAN, 10.0); 861 862 if (rc == false) { 863 printf("TEST ERROR: pmSourceLocalSky() returned a FALSE pmSource.\n"); 918 864 testStatus = false; 919 865 } else { 920 if ( rc->peak == NULL) {866 if (tmpSource->peak == NULL) { 921 867 printf("TEST ERROR: pmSourceLocalSky() returned a NULL pmSource->peak.\n"); 922 868 testStatus = false; 923 869 } else { 924 if (rc->peak->x != tmpPeak->x) { 925 printf("TEST ERROR: pmSourceLocalSky() pmSource->peak->x was %d, should have been %d.\n", rc->peak->x, tmpPeak->x); 870 if (tmpSource->peak->x != tmpPeak->x) { 871 printf("TEST ERROR: pmSourceLocalSky() pmSource->peak->x was %d, should have been %d.\n", 872 tmpSource->peak->x, tmpPeak->x); 926 873 testStatus = false; 927 874 } 928 875 929 if (rc->peak->y != tmpPeak->y) { 930 printf("TEST ERROR: pmSourceLocalSky() pmSource->peak->y was %d, should have been %d.\n", rc->peak->y, tmpPeak->y); 876 if (tmpSource->peak->y != tmpPeak->y) { 877 printf("TEST ERROR: pmSourceLocalSky() pmSource->peak->y was %d, should have been %d.\n", 878 tmpSource->peak->y, tmpPeak->y); 931 879 testStatus = false; 932 880 } 933 881 934 if (rc->peak->counts != tmpPeak->counts) { 935 printf("TEST ERROR: pmSourceLocalSky() pmSource->peak->counts was %f, should have been %f.\n", rc->peak->counts, tmpPeak->counts); 882 if (tmpSource->peak->counts != tmpPeak->counts) { 883 printf("TEST ERROR: pmSourceLocalSky() pmSource->peak->counts was %f, should have been %f.\n", 884 tmpSource->peak->counts, tmpPeak->counts); 936 885 testStatus = false; 937 886 } 938 887 939 if (rc->peak->class != tmpPeak->class) { 940 printf("TEST ERROR: pmSourceLocalSky() pmSource->peak->class was %d, should have been %d.\n", rc->peak->class, tmpPeak->class); 888 if (tmpSource->peak->class != tmpPeak->class) { 889 printf("TEST ERROR: pmSourceLocalSky() pmSource->peak->class was %d, should have been %d.\n", 890 tmpSource->peak->class, tmpPeak->class); 941 891 testStatus = false; 942 892 } 943 893 } 944 894 945 if ( rc->pixels == NULL) {946 printf("TEST ERROR: pmSourceLocalSky() pmSource->pixels was NULL.\n");895 if (tmpSource->moments == NULL) { 896 printf("TEST ERROR: pmSourceLocalSky() returned a NULL pmSource->moments.\n"); 947 897 testStatus = false; 948 898 } else { 949 if (rc->pixels->numRows != (2 * TST04_OUTER_RADIUS)) { 950 printf("TEST ERROR: pmSourceLocalSky() pmSource->pixels->numRows was %d, should have been %d.\n", 951 rc->pixels->numRows, (2 * TST04_OUTER_RADIUS)); 899 if (tmpSource->moments->Sky != TST04_SKY) { 900 printf("TEST ERROR: pmSourceLocalSky() pmSource->moments->Sky was %f, should have been %f.\n", tmpSource->moments->Sky, TST04_SKY); 952 901 testStatus = false; 953 902 } 954 955 if (rc->pixels->numCols != (2 * TST04_OUTER_RADIUS)) { 956 printf("TEST ERROR: pmSourceLocalSky() pmSource->pixels->numCols was %d, should have been %d.\n", 957 rc->pixels->numCols, (2 * TST04_OUTER_RADIUS)); 958 testStatus = false; 959 } 960 961 if (rc->pixels->col0 != (tmpPeak->x - TST04_OUTER_RADIUS)) { 962 printf("TEST ERROR: pmSourceLocalSky() pmSource->pixels->col0 was %d, should have been %d.\n", 963 rc->pixels->col0, (tmpPeak->x - TST04_OUTER_RADIUS)); 964 testStatus = false; 965 } 966 967 if (rc->pixels->row0 != (tmpPeak->y - TST04_OUTER_RADIUS)) { 968 printf("TEST ERROR: pmSourceLocalSky() pmSource->pixels->row0 was %d, should have been %d.\n", 969 rc->pixels->row0, (tmpPeak->y - TST04_OUTER_RADIUS)); 970 testStatus = false; 971 } 972 973 if (rc->pixels->type.type != PS_TYPE_F32) { 974 printf("TEST ERROR: pmSourceLocalSky() pmSource->pixels->type was %d, should have been %d.\n", 975 rc->pixels->type.type, PS_TYPE_F32); 976 testStatus = false; 977 } 978 979 // XXX: Test the rc->pixels-> row/col offsets. 980 // XXX: Test that the pixels corresponds to the source image pixels. 981 } 982 983 if (rc->mask == NULL) { 984 printf("TEST ERROR: pmSourceLocalSky() pmSource->mask was NULL.\n"); 985 testStatus = false; 986 } else { 987 if (rc->mask->numRows != (2 * TST04_OUTER_RADIUS)) { 988 printf("TEST ERROR: pmSourceLocalSky() pmSource->mask->numRows was %d, should have been %d.\n", 989 rc->mask->numRows, (2 * TST04_OUTER_RADIUS)); 990 testStatus = false; 991 } 992 993 if (rc->mask->numCols != (2 * TST04_OUTER_RADIUS)) { 994 printf("TEST ERROR: pmSourceLocalSky() pmSource->mask->numCols was %d, should have been %d.\n", 995 rc->mask->numCols, (2 * TST04_OUTER_RADIUS)); 996 testStatus = false; 997 } 998 999 if (rc->mask->type.type != PS_TYPE_U8) { 1000 printf("TEST ERROR: pmSourceLocalSky() pmSource->mask->type was %d, should have been %d.\n", 1001 rc->mask->type.type, PS_TYPE_U8); 1002 testStatus = false; 1003 } 1004 1005 // XXX: Test the rc->mask-> row/col offsets. 1006 // XXX: Test that the correct pixels were masked, not merely the number of masked pixels. 1007 psS32 unmaskedPixels = 0; 1008 psS32 maskedPixels = 0; 1009 1010 for (psS32 row = 0 ; row < rc->mask->numRows; row++) { 1011 for (psS32 col = 0 ; col < rc->mask->numCols; col++) { 1012 if (rc->mask->data.U8[row][col] == 0) { 1013 unmaskedPixels++; 1014 } else { 1015 maskedPixels++; 1016 } 1017 } 1018 } 1019 if (maskedPixels != PS_SQR(2*(TST04_INNER_RADIUS-1))) { 1020 printf("TEST ERROR: pmSourceLocalSky() pmSource->mask had %d masked pixels, should have been %d.\n", 1021 maskedPixels, PS_SQR(2*(TST04_INNER_RADIUS-1))); 1022 testStatus = false; 1023 } 1024 if (unmaskedPixels != (PS_SQR(2*TST04_OUTER_RADIUS) - PS_SQR(2*(TST04_INNER_RADIUS-1)))) { 1025 printf("TEST ERROR: pmSourceLocalSky() pmSource->mask had %d masked pixels, should have been %d.\n", 1026 unmaskedPixels, (PS_SQR(2*TST04_OUTER_RADIUS) - PS_SQR(2*(TST04_INNER_RADIUS-1)))); 1027 testStatus = false; 1028 } 1029 } 1030 1031 if (rc->moments == NULL) { 1032 printf("TEST ERROR: pmSourceLocalSky() returned a NULL pmSource->moments.\n"); 1033 testStatus = false; 1034 } else { 1035 if (rc->moments->Sky != TST04_SKY) { 1036 printf("TEST ERROR: pmSourceLocalSky() pmSource->moments->Sky was %f, should have been %f.\n", rc->moments->Sky, TST04_SKY); 1037 testStatus = false; 1038 } 1039 } 1040 } 1041 1042 printf("----------------------------------------------------------------------------------\n"); 1043 psFree(rc); 1044 psFree(imgData); 1045 psFree(imgDataF64); 1046 return(testStatus); 1047 } 1048 1049 #define TST06_NUM_ROWS 100 1050 #define TST06_NUM_COLS 100 1051 #define TST06_SKY 20.0 1052 #define TST06_INNER_RADIUS 3 1053 #define TST06_OUTER_RADIUS 5 1054 /****************************************************************************** 1055 test06(): We first test pmSourceLocalSky() with various NULL and unallowable 1056 input parameters. 1057 1058 XXX: Should we produce tests with boundary numbers for the inner/outer radius? 1059 1060 XXX: Call this with varying sizes for the image. 1061 *****************************************************************************/ 1062 int test06( void ) 1063 { 1064 bool testStatus = true; 1065 pmSource *tmpSource = NULL; 1066 bool rc = false; 1067 // Create the image used in this test. 1068 psImage *imgData = psImageAlloc(TST06_NUM_COLS, TST06_NUM_ROWS, PS_TYPE_F32); 1069 for (psS32 i = 0 ; i < imgData->numRows; i++) { 1070 for (psS32 j = 0 ; j < imgData->numCols; j++) { 1071 imgData->data.F32[i][j] = TST06_SKY; 1072 } 1073 } 1074 psImage *imgDataF64 = psImageAlloc(TST06_NUM_COLS, TST06_NUM_ROWS, PS_TYPE_F64); 1075 for (psS32 i = 0 ; i < imgDataF64->numRows; i++) { 1076 for (psS32 j = 0 ; j < imgDataF64->numCols; j++) { 1077 imgDataF64->data.F64[i][j] = 0.0; 1078 } 1079 } 1080 1081 // 1082 // Create a pmPeak with the center pixel set to the peak. 1083 // 1084 pmPeak *tmpPeak = pmPeakAlloc((psF32) (TST06_NUM_ROWS / 2), 1085 (psF32) (TST06_NUM_COLS / 2), 1086 200.0, 1087 PM_PEAK_LONE); 1088 1089 tmpSource = pmSourceLocalSky(imgData, 1090 tmpPeak, 1091 PS_STAT_SAMPLE_MEAN, 1092 (psF32) TST06_INNER_RADIUS, 1093 (psF32) TST06_OUTER_RADIUS); 1094 if (tmpSource == NULL) { 1095 printf("TEST ERROR: pmSourceLocalSky() returned a NULL pmSource.\n"); 1096 psFree(imgData); 1097 psFree(imgDataF64); 1098 psFree(tmpSource); 1099 testStatus = false; 1100 return(testStatus); 1101 } 1102 1103 printf("----------------------------------------------------------------------------------\n"); 1104 printf("Calling pmSourceSetPixelsCircle with NULL pmSource. Should generate error and return NULL.\n"); 1105 rc = pmSourceSetPixelsCircle(NULL, imgData, 10.0); 1106 if (rc == true) { 1107 printf("TEST ERROR: pmSourceSetPixelsCircle() returned TRUE.\n"); 1108 testStatus = false; 1109 } 1110 // XXX: test with pmSource->peaks NULL 1111 1112 printf("----------------------------------------------------------------------------------\n"); 1113 printf("Calling pmSourceSetPixelsCircle with NULL psImage. Should generate error and return NULL.\n"); 1114 rc = pmSourceSetPixelsCircle(tmpSource, NULL, 10.0); 1115 if (rc == true) { 1116 printf("TEST ERROR: pmSourceSetPixelsCircle() returned TRUE.\n"); 1117 testStatus = false; 1118 } 1119 1120 printf("----------------------------------------------------------------------------------\n"); 1121 printf("Calling pmSourceSetPixelsCircle with wrong type psImage. Should generate error and return NULL.\n"); 1122 rc = pmSourceSetPixelsCircle(tmpSource, imgDataF64, 10.0); 1123 if (rc == true) { 1124 printf("TEST ERROR: pmSourceSetPixelsCircle() returned TRUE.\n"); 1125 testStatus = false; 1126 } 1127 1128 printf("----------------------------------------------------------------------------------\n"); 1129 printf("Calling pmSourceSetPixelsCircle with radius < 0.0. Should generate error and return NULL.\n"); 1130 rc = pmSourceSetPixelsCircle(tmpSource, imgData, -10.0); 1131 if (rc == true) { 1132 printf("TEST ERROR: pmSourceSetPixelsCircle() returned TRUE.\n"); 1133 testStatus = false; 1134 } 1135 1136 /* XXX: Commented away since the EAM mods no longer produced errors. 1137 printf("----------------------------------------------------------------------------------\n"); 1138 printf("Calling pmSourceSetPixelsCircle with subImage startCol < 0. Should generate error and return NULL.\n"); 1139 tmpSource->peak->x = (psF32) (TST06_NUM_ROWS / 2); 1140 tmpSource->peak->y = (psF32) (TST06_NUM_COLS / 2); 1141 tmpSource->peak->x = 1; 1142 rc = pmSourceSetPixelsCircle(tmpSource, imgData, 10.0); 1143 if (rc == true) { 1144 printf("TEST ERROR: pmSourceSetPixelsCircle() returned TRUE.\n"); 1145 testStatus = false; 1146 } 1147 1148 printf("----------------------------------------------------------------------------------\n"); 1149 printf("Calling pmSourceSetPixelsCircle with subImage endCol > numCols. Should generate error and return NULL.\n"); 1150 tmpSource->peak->x = (psF32) (TST06_NUM_ROWS / 2); 1151 tmpSource->peak->y = (psF32) (TST06_NUM_COLS / 2); 1152 tmpSource->peak->x = TST06_NUM_COLS; 1153 rc = pmSourceSetPixelsCircle(tmpSource, imgData, 10.0); 1154 if (rc == true) { 1155 printf("TEST ERROR: pmSourceSetPixelsCircle() returned TRUE.\n"); 1156 testStatus = false; 1157 } 1158 1159 printf("----------------------------------------------------------------------------------\n"); 1160 printf("Calling pmSourceSetPixelsCircle with subImage startRow < 0. Should generate error and return NULL.\n"); 1161 tmpSource->peak->x = (psF32) (TST06_NUM_ROWS / 2); 1162 tmpSource->peak->y = (psF32) (TST06_NUM_COLS / 2); 1163 tmpSource->peak->y = 1; 1164 rc = pmSourceSetPixelsCircle(tmpSource, imgData, 10.0); 1165 if (rc == true) { 1166 printf("TEST ERROR: pmSourceSetPixelsCircle() returned TRUE.\n"); 1167 testStatus = false; 1168 } 1169 1170 printf("----------------------------------------------------------------------------------\n"); 1171 printf("Calling pmSourceSetPixelsCircle with subImage endRow > numRows. Should generate error and return NULL.\n"); 1172 tmpSource->peak->x = (psF32) (TST06_NUM_ROWS / 2); 1173 tmpSource->peak->y = (psF32) (TST06_NUM_COLS / 2); 1174 tmpSource->peak->y = TST06_NUM_ROWS; 1175 rc = pmSourceSetPixelsCircle(tmpSource, imgData, 10.0); 1176 if (rc == true) { 1177 printf("TEST ERROR: pmSourceSetPixelsCircle() returned TRUE.\n"); 1178 testStatus = false; 1179 } 1180 */ 1181 printf("----------------------------------------------------------------------------------\n"); 1182 printf("Calling pmSourceSetPixelsCircle with valid data.\n"); 1183 tmpSource->peak->x = (psF32) (TST06_NUM_ROWS / 2); 1184 tmpSource->peak->y = (psF32) (TST06_NUM_COLS / 2); 1185 rc = pmSourceSetPixelsCircle(tmpSource, imgData, 10.0); 1186 1187 if (rc == false) { 1188 printf("TEST ERROR: pmSourceSetPixelsCircle() returned FALSE.\n"); 1189 testStatus = false; 1190 } else { 1191 // XXX: Test correctness of the various psSetPixelsCircle members. 1192 } 1193 1194 printf("----------------------------------------------------------------------------------\n"); 903 } 904 } 905 906 printf("----------------------------------------------------------------------------------\n"); 907 psFree(tmpSource); 1195 908 // psFree(imgData); 1196 909 // psFree(imgDataF64); 1197 psFree(tmpSource); 910 // psFree(imgMask); 911 // psFree(imgMaskS8); 1198 912 return(testStatus); 1199 1200 913 } 1201 914 … … 1218 931 { 1219 932 bool testStatus = true; 1220 pmSource *tmpSource = NULL;1221 pmSource *rc = NULL;1222 // Create the image used in this test.1223 psImage *imgData = psImageAlloc(TST05_NUM_COLS, TST05_NUM_ROWS, PS_TYPE_F32);1224 for (psS32 i = 0 ; i < imgData->numRows; i++) {1225 for (psS32 j = 0 ; j < imgData->numCols; j++) {1226 imgData->data.F32[i][j] = TST05_SKY;1227 }1228 }1229 1230 //1231 // Create a pmPeak with the center pixel set to the peak.1232 //1233 pmPeak *tmpPeak = pmPeakAlloc((psF32) (TST05_NUM_ROWS / 2),1234 (psF32) (TST05_NUM_COLS / 2),1235 200.0,1236 PM_PEAK_LONE);1237 1238 tmpSource = pmSourceLocalSky(imgData,1239 tmpPeak,1240 PS_STAT_SAMPLE_MEAN,1241 (psF32) TST05_INNER_RADIUS,1242 (psF32) TST05_OUTER_RADIUS);1243 if (tmpSource == NULL) {1244 printf("TEST ERROR: pmSourceLocalSky() returned a NULL pmSource.\n");1245 psFree(tmpSource);1246 testStatus = false;1247 return(testStatus);1248 }1249 1250 printf("----------------------------------------------------------------------------------\n");1251 printf("Calling pmSourceMoments with NULL pmSource. Should generate error and return NULL.\n");1252 rc = pmSourceMoments(NULL, 10.0);1253 if (rc != NULL) {1254 printf("TEST ERROR: pmSourceMoments() returned a non-NULL pmSource.\n");1255 testStatus = false;1256 }1257 // XXX: test with pmSource->peaks NULL1258 // XXX: test with pmSource->pixels NULL1259 // XXX: test with pmSource->mask NULL1260 1261 printf("----------------------------------------------------------------------------------\n");1262 printf("Calling pmSourceMoments with radius < 0.0. Should generate error and return NULL.\n");1263 rc = pmSourceMoments(tmpSource, -10.0);1264 if (rc != NULL) {1265 printf("TEST ERROR: pmSourceMoments() returned a non-NULL pmSource.\n");1266 testStatus = false;1267 }1268 1269 printf("----------------------------------------------------------------------------------\n");1270 psFree(tmpSource);1271 return(testStatus);1272 1273 }1274 1275 /******************************************************************************1276 test07(): We first test the various psMinLM_... routines with various NULL and1277 unallowable input parameters.1278 1279 XXX: We don't verify the numbers. Must do this.1280 *****************************************************************************/1281 int test07( void )1282 {1283 bool testStatus = true;1284 psF32 rc;1285 psVector *deriv = psVectorAlloc(7, PS_TYPE_F32);1286 psVector *params = psVectorAlloc(7, PS_TYPE_F32);1287 psVector *x = psVectorAlloc(2, PS_TYPE_F32);1288 for (psS32 i = 0 ; i < 7 ; i++) {1289 deriv->data.F32[i] = 1.0;1290 params->data.F32[i] = 1.0;1291 }1292 1293 printf("----------------------------------------------------------------------------------\n");1294 printf("Calling pmMinLM_Gauss2D with NULL deriv vector. Should not generate error.\n");1295 rc = pmMinLM_Gauss2D(NULL, params, x);1296 if (isnan(rc)) {1297 printf("TEST ERROR: pmMinLM_Gauss2D() returned a NAN psF32.\n");1298 testStatus = false;1299 }1300 printf("----------------------------------------------------------------------------------\n");1301 printf("Calling pmMinLM_Gauss2D with NULL params vector. Should generate error and return NAN.\n");1302 rc = pmMinLM_Gauss2D(deriv, NULL, x);1303 if (!isnan(rc)) {1304 printf("TEST ERROR: pmMinLM_Gauss2D() returned a non-NAN psF32 (%f).\n", rc);1305 testStatus = false;1306 }1307 printf("----------------------------------------------------------------------------------\n");1308 printf("Calling pmMinLM_Gauss2D with NULL x vector. Should generate error and return NAN.\n");1309 rc = pmMinLM_Gauss2D(deriv, params, NULL);1310 if (!isnan(rc)) {1311 printf("TEST ERROR: pmMinLM_Gauss2D() returned a non-NAN psF32 (%f).\n", rc);1312 testStatus = false;1313 }1314 psFree(deriv);1315 psFree(params);1316 1317 deriv = psVectorAlloc(7, PS_TYPE_F32);1318 params = psVectorAlloc(7, PS_TYPE_F32);1319 for (psS32 i = 0 ; i < 7 ; i++) {1320 deriv->data.F32[i] = 1.0;1321 params->data.F32[i] = 1.0;1322 }1323 printf("----------------------------------------------------------------------------------\n");1324 printf("Calling pmMinLM_PsuedoGauss2D with NULL deriv vector. Should not generate error.\n");1325 rc = pmMinLM_PsuedoGauss2D(NULL, params, x);1326 if (isnan(rc)) {1327 printf("TEST ERROR: pmMinLM_PsuedoGauss2D() returned a NAN psF32.\n");1328 testStatus = false;1329 }1330 printf("----------------------------------------------------------------------------------\n");1331 printf("Calling pmMinLM_PsuedoGauss2D with NULL params vector. Should generate error and return NAN.\n");1332 rc = pmMinLM_PsuedoGauss2D(deriv, NULL, x);1333 if (!isnan(rc)) {1334 printf("TEST ERROR: pmMinLM_PsuedoGauss2D() returned a non-NAN psF32 (%f).\n", rc);1335 testStatus = false;1336 }1337 printf("----------------------------------------------------------------------------------\n");1338 printf("Calling pmMinLM_PsuedoGauss2D with NULL x vector. Should generate error and return NAN.\n");1339 rc = pmMinLM_PsuedoGauss2D(deriv, params, NULL);1340 if (!isnan(rc)) {1341 printf("TEST ERROR: pmMinLM_PsuedoGauss2D() returned a non-NAN psF32 (%f).\n", rc);1342 testStatus = false;1343 }1344 psFree(deriv);1345 psFree(params);1346 1347 1348 deriv = psVectorAlloc(9, PS_TYPE_F32);1349 params = psVectorAlloc(9, PS_TYPE_F32);1350 for (psS32 i = 0 ; i < 9 ; i++) {1351 deriv->data.F32[i] = 1.0;1352 params->data.F32[i] = 1.0;1353 }1354 printf("----------------------------------------------------------------------------------\n");1355 printf("Calling pmMinLM_Wauss2D with NULL deriv vector. Should not generate error.\n");1356 rc = pmMinLM_Wauss2D(NULL, params, x);1357 if (isnan(rc)) {1358 printf("TEST ERROR: pmMinLM_Wauss2D() returned a NAN psF32.\n");1359 testStatus = false;1360 }1361 printf("----------------------------------------------------------------------------------\n");1362 printf("Calling pmMinLM_Wauss2D with NULL params vector. Should generate error and return NAN.\n");1363 rc = pmMinLM_Wauss2D(deriv, NULL, x);1364 if (!isnan(rc)) {1365 printf("TEST ERROR: pmMinLM_Wauss2D() returned a non-NAN psF32 (%f).\n", rc);1366 testStatus = false;1367 }1368 printf("----------------------------------------------------------------------------------\n");1369 printf("Calling pmMinLM_Wauss2D with NULL x vector. Should generate error and return NAN.\n");1370 rc = pmMinLM_Wauss2D(deriv, params, NULL);1371 if (!isnan(rc)) {1372 printf("TEST ERROR: pmMinLM_Wauss2D() returned a non-NAN psF32 (%f).\n", rc);1373 testStatus = false;1374 }1375 psFree(deriv);1376 psFree(params);1377 1378 deriv = psVectorAlloc(11, PS_TYPE_F32);1379 params = psVectorAlloc(11, PS_TYPE_F32);1380 for (psS32 i = 0 ; i < 11 ; i++) {1381 deriv->data.F32[i] = 1.0;1382 params->data.F32[i] = 1.0;1383 }1384 printf("----------------------------------------------------------------------------------\n");1385 printf("Calling pmMinLM_TwistGauss2D with NULL deriv vector. Should not generate error.\n");1386 rc = pmMinLM_TwistGauss2D(NULL, params, x);1387 if (isnan(rc)) {1388 printf("TEST ERROR: pmMinLM_TwistGauss2D() returned a NAN psF32.\n");1389 testStatus = false;1390 }1391 printf("----------------------------------------------------------------------------------\n");1392 printf("Calling pmMinLM_TwistGauss2D with NULL params vector. Should generate error and return NAN.\n");1393 rc = pmMinLM_TwistGauss2D(deriv, NULL, x);1394 if (!isnan(rc)) {1395 printf("TEST ERROR: pmMinLM_TwistGauss2D() returned a non-NAN psF32 (%f).\n", rc);1396 testStatus = false;1397 }1398 printf("----------------------------------------------------------------------------------\n");1399 printf("Calling pmMinLM_TwistGauss2D with NULL x vector. Should generate error and return NAN.\n");1400 rc = pmMinLM_TwistGauss2D(deriv, params, NULL);1401 if (!isnan(rc)) {1402 printf("TEST ERROR: pmMinLM_TwistGauss2D() returned a non-NAN psF32 (%f).\n", rc);1403 testStatus = false;1404 }1405 psFree(deriv);1406 psFree(params);1407 1408 deriv = psVectorAlloc(8, PS_TYPE_F32);1409 params = psVectorAlloc(8, PS_TYPE_F32);1410 for (psS32 i = 0 ; i < 8 ; i++) {1411 deriv->data.F32[i] = 1.0;1412 params->data.F32[i] = 1.0;1413 }1414 printf("----------------------------------------------------------------------------------\n");1415 printf("Calling pmMinLM_Sersic with NULL deriv vector. Should not generate error.\n");1416 rc = pmMinLM_Sersic(NULL, params, x);1417 if (isnan(rc)) {1418 printf("TEST ERROR: pmMinLM_Sersic() returned a NAN psF32.\n");1419 testStatus = false;1420 }1421 printf("----------------------------------------------------------------------------------\n");1422 printf("Calling pmMinLM_Sersic with NULL params vector. Should generate error and return NAN.\n");1423 rc = pmMinLM_Sersic(deriv, NULL, x);1424 if (!isnan(rc)) {1425 printf("TEST ERROR: pmMinLM_Sersic() returned a non-NAN psF32 (%f).\n", rc);1426 testStatus = false;1427 }1428 printf("----------------------------------------------------------------------------------\n");1429 printf("Calling pmMinLM_Sersic with NULL x vector. Should generate error and return NAN.\n");1430 rc = pmMinLM_Sersic(deriv, params, NULL);1431 if (!isnan(rc)) {1432 printf("TEST ERROR: pmMinLM_Sersic() returned a non-NAN psF32 (%f).\n", rc);1433 testStatus = false;1434 }1435 psFree(deriv);1436 psFree(params);1437 1438 deriv = psVectorAlloc(12, PS_TYPE_F32);1439 params = psVectorAlloc(12, PS_TYPE_F32);1440 for (psS32 i = 0 ; i < 12 ; i++) {1441 deriv->data.F32[i] = 1.0;1442 params->data.F32[i] = 1.0;1443 }1444 printf("----------------------------------------------------------------------------------\n");1445 printf("Calling pmMinLM_SersicCore with NULL deriv vector. Should not generate error.\n");1446 rc = pmMinLM_SersicCore(NULL, params, x);1447 if (isnan(rc)) {1448 printf("TEST ERROR: pmMinLM_SersicCore() returned a NAN psF32.\n");1449 testStatus = false;1450 }1451 printf("----------------------------------------------------------------------------------\n");1452 printf("Calling pmMinLM_SersicCore with NULL params vector. Should generate error and return NAN.\n");1453 rc = pmMinLM_SersicCore(deriv, NULL, x);1454 if (!isnan(rc)) {1455 printf("TEST ERROR: pmMinLM_SersicCore() returned a non-NAN psF32 (%f).\n", rc);1456 testStatus = false;1457 }1458 printf("----------------------------------------------------------------------------------\n");1459 printf("Calling pmMinLM_SersicCore with NULL x vector. Should generate error and return NAN.\n");1460 rc = pmMinLM_SersicCore(deriv, params, NULL);1461 if (!isnan(rc)) {1462 printf("TEST ERROR: pmMinLM_SersicCore() returned a non-NAN psF32 (%f).\n", rc);1463 testStatus = false;1464 }1465 1466 psFree(deriv);1467 psFree(params);1468 psFree(x);1469 return(testStatus);1470 }1471 1472 /******************************************************************************1473 test08(): We first test pmSourceModelGuess() with various NULL and unallowable1474 input parameters.1475 1476 XXX: We don't verify the numbers.1477 *****************************************************************************/1478 int test08( void )1479 {1480 bool testStatus = true;1481 933 psImage *imgData = psImageAlloc(TST04_NUM_COLS, TST04_NUM_ROWS, PS_TYPE_F32); 1482 for (psS32 i = 0 ; i < imgData->numRows; i++) { 1483 for (psS32 j = 0 ; j < imgData->numCols; j++) { 1484 imgData->data.F32[i][j] = TST04_SKY; 1485 } 1486 } 1487 pmSource *mySrc = NULL; 1488 bool rc = false; 934 psImageInit(imgData, TST04_SKY); 935 psImage *imgMask = psImageAlloc(TST04_NUM_COLS, TST04_NUM_ROWS, PS_TYPE_U8); 936 psImageInit(imgMask, 0); 1489 937 pmPeak *tmpPeak = pmPeakAlloc((psF32) (TST04_NUM_ROWS / 2), 1490 938 (psF32) (TST04_NUM_COLS / 2), 1491 939 200.0, 1492 940 PM_PEAK_LONE); 1493 1494 printf("Calling pmSourceLocalSky with valid data.\n"); 1495 tmpPeak->x = (psF32) (TST04_NUM_ROWS / 2); 1496 tmpPeak->y = (psF32) (TST04_NUM_COLS / 2); 1497 mySrc = pmSourceLocalSky(imgData, 1498 tmpPeak, 1499 PS_STAT_SAMPLE_MEAN, 1500 (psF32) TST04_INNER_RADIUS, 1501 (psF32) TST04_OUTER_RADIUS); 1502 1503 if (mySrc == NULL) { 1504 printf("TEST ERROR: pmSourceLocalSky() returned a NULL pmSource.\n"); 1505 testStatus = false; 1506 } 1507 1508 printf("----------------------------------------------------------------------------------\n"); 1509 printf("Calling pmSourceModelGuess with NULL pmSource. Should generate error, return FALSE.\n"); 1510 rc = pmSourceModelGuess(NULL, imgData, PS_MODEL_GAUSS); 1511 if (rc == true) { 1512 printf("TEST ERROR: pmSourceModelGuess() returned TRUE.\n"); 1513 testStatus = false; 1514 } 1515 1516 printf("----------------------------------------------------------------------------------\n"); 1517 printf("Calling pmSourceModelGuess with NULL psImage. Should generate error, return FALSE.\n"); 1518 rc = pmSourceModelGuess(mySrc, NULL, PS_MODEL_GAUSS); 1519 if (rc == true) { 1520 printf("TEST ERROR: pmSourceModelGuess() returned TRUE.\n"); 1521 testStatus = false; 1522 } 1523 1524 printf("----------------------------------------------------------------------------------\n"); 1525 printf("Calling pmSourceModelGuess with bad model type. Should generate error, return FALSE.\n"); 1526 rc = pmSourceModelGuess(mySrc, imgData, PS_MODEL_UNDEFINED); 1527 if (rc == true) { 1528 printf("TEST ERROR: pmSourceModelGuess() returned TRUE.\n"); 1529 testStatus = false; 1530 } 1531 1532 printf("----------------------------------------------------------------------------------\n"); 1533 printf("Calling pmSourceModelGuess with PS_MODEL_GAUSS\n"); 1534 rc = pmSourceModelGuess(mySrc, imgData, PS_MODEL_GAUSS); 1535 if (rc != true) { 1536 printf("TEST ERROR: pmSourceModelGuess() returned FALSE.\n"); 1537 testStatus = false; 1538 } 1539 1540 printf("----------------------------------------------------------------------------------\n"); 1541 printf("Calling pmSourceModelGuess with PS_MODEL_PGAUSS\n"); 1542 rc = pmSourceModelGuess(mySrc, imgData, PS_MODEL_PGAUSS); 1543 if (rc != true) { 1544 printf("TEST ERROR: pmSourceModelGuess() returned FALSE.\n"); 1545 testStatus = false; 1546 } 1547 1548 printf("----------------------------------------------------------------------------------\n"); 1549 printf("Calling pmSourceModelGuess with PS_MODEL_TWIST_GAUSS\n"); 1550 rc = pmSourceModelGuess(mySrc, imgData, PS_MODEL_TWIST_GAUSS); 1551 if (rc != true) { 1552 printf("TEST ERROR: pmSourceModelGuess() returned FALSE.\n"); 1553 testStatus = false; 1554 } 1555 1556 printf("----------------------------------------------------------------------------------\n"); 1557 printf("Calling pmSourceModelGuess with PS_MODEL_WAUSS\n"); 1558 rc = pmSourceModelGuess(mySrc, imgData, PS_MODEL_WAUSS); 1559 if (rc != true) { 1560 printf("TEST ERROR: pmSourceModelGuess() returned FALSE.\n"); 1561 testStatus = false; 1562 } 1563 1564 printf("----------------------------------------------------------------------------------\n"); 1565 printf("Calling pmSourceModelGuess with PS_MODEL_SERSIC\n"); 1566 rc = pmSourceModelGuess(mySrc, imgData, PS_MODEL_SERSIC); 1567 if (rc != true) { 1568 printf("TEST ERROR: pmSourceModelGuess() returned FALSE.\n"); 1569 testStatus = false; 1570 } 1571 1572 printf("----------------------------------------------------------------------------------\n"); 1573 printf("Calling pmSourceModelGuess with PS_MODEL_SERSIC_CORE\n"); 1574 rc = pmSourceModelGuess(mySrc, imgData, PS_MODEL_SERSIC_CORE); 1575 if (rc != true) { 1576 printf("TEST ERROR: pmSourceModelGuess() returned FALSE.\n"); 1577 testStatus = false; 1578 } 1579 1580 psFree(mySrc); 1581 // psFree(tmpPeak); 1582 psFree(imgData); 941 pmSource *tmpSource = pmSourceAlloc(); 942 tmpSource->pixels = imgData; 943 tmpSource->mask = imgMask; 944 tmpSource->peak = tmpPeak; 945 psBool rc = pmSourceLocalSky(tmpSource, PS_STAT_SAMPLE_MEAN, 10.0); 946 947 if (rc == false) { 948 printf("TEST ERROR: pmSourceLocalSky() returned a FALSE pmSource.\n"); 949 testStatus = false; 950 } 951 952 printf("----------------------------------------------------------------------------------\n"); 953 printf("Calling pmSourceMoments with NULL pmSource. Should generate error and return FALSE.\n"); 954 rc = pmSourceMoments(NULL, 10.0); 955 if (rc != false) { 956 printf("TEST ERROR: pmSourceMoments() returned TRUE.\n"); 957 testStatus = false; 958 } 959 // XXX: test with pmSource->peaks NULL 960 // XXX: test with pmSource->pixels NULL 961 // XXX: test with pmSource->mask NULL 962 963 printf("----------------------------------------------------------------------------------\n"); 964 printf("Calling pmSourceMoments with radius < 0.0. Should generate error and return FALSE.\n"); 965 rc = pmSourceMoments(tmpSource, -10.0); 966 if (rc != false) { 967 printf("TEST ERROR: pmSourceMoments() returned TRUE.\n"); 968 testStatus = false; 969 } 970 971 printf("----------------------------------------------------------------------------------\n"); 972 psFree(tmpSource); 1583 973 return(testStatus); 974 1584 975 } 1585 976 1586 1587 #define TST09_NUM_ROWS 701588 #define TST09_NUM_COLS 701589 #define TST09_SKY 5.01590 #define TST09_INNER_RADIUS 31591 #define TST09_OUTER_RADIUS 101592 #define LEVEL (TST09_SKY + 10.0)1593 /******************************************************************************1594 test09(): We first test pmSourceContour() with various NULL and unallowable1595 input parameters.1596 1597 XXX: We don't verify the numbers.1598 *****************************************************************************/1599 int test09( void )1600 {1601 bool testStatus = true;1602 psImage *imgData = psImageAlloc(TST09_NUM_COLS, TST09_NUM_ROWS, PS_TYPE_F32);1603 for (psS32 i = 0 ; i < imgData->numRows; i++) {1604 for (psS32 j = 0 ; j < imgData->numCols; j++) {1605 imgData->data.F32[i][j] = TST09_SKY;1606 }1607 }1608 pmSource *mySrc = NULL;1609 psArray *rc = NULL;1610 1611 pmPeak *tmpPeak = pmPeakAlloc((psF32) (TST09_NUM_ROWS / 2),1612 (psF32) (TST09_NUM_COLS / 2),1613 200.0,1614 PM_PEAK_LONE);1615 1616 printf("Calling pmSourceLocalSky with valid data.\n");1617 tmpPeak->x = (psF32) (TST09_NUM_ROWS / 2);1618 tmpPeak->y = (psF32) (TST09_NUM_COLS / 2);1619 mySrc = pmSourceLocalSky(imgData,1620 tmpPeak,1621 PS_STAT_SAMPLE_MEAN,1622 (psF32) TST09_INNER_RADIUS,1623 (psF32) TST09_OUTER_RADIUS);1624 1625 if (mySrc == NULL) {1626 printf("TEST ERROR: pmSourceLocalSky() returned a NULL pmSource.\n");1627 testStatus = false;1628 }1629 1630 bool rcBool = pmSourceModelGuess(mySrc, imgData, PS_MODEL_GAUSS);1631 if (rcBool != true) {1632 printf("TEST ERROR: pmSourceModelGuess() returned FALSE.\n");1633 testStatus = false;1634 }1635 1636 printf("----------------------------------------------------------------------------------\n");1637 printf("Calling pmSourceContour with NULL pmSource . Should generate error, return NULL.\n");1638 rc = pmSourceContour(NULL, imgData, LEVEL, PS_CONTOUR_CRUDE);1639 if (rc != NULL) {1640 printf("TEST ERROR: pmSourceContour() returned non-NULL.\n");1641 testStatus = false;1642 psFree(rc);1643 }1644 1645 printf("----------------------------------------------------------------------------------\n");1646 printf("Calling pmSourceContour with NULL psImage . Should generate error, return NULL.\n");1647 rc = pmSourceContour(mySrc, NULL, LEVEL, PS_CONTOUR_CRUDE);1648 if (rc != NULL) {1649 printf("TEST ERROR: pmSourceContour() returned non-NULL.\n");1650 testStatus = false;1651 psFree(rc);1652 }1653 1654 //1655 // XXX: pmSourceContour() has a problem with contour tops/bottoms.1656 // Must correct this.1657 //1658 if (0) {1659 printf("----------------------------------------------------------------------------------\n");1660 printf("Calling pmSourceContour with acceptable data.\n");1661 printf("NOTE: must figure out the parameters for this test to be meaningful.\n");1662 mySrc->modelPSF->params->data.F32[0] = TST09_SKY;1663 mySrc->modelPSF->params->data.F32[1] = 15.0;1664 mySrc->modelPSF->params->data.F32[2] = (psF32) (TST09_NUM_ROWS / 2);1665 mySrc->modelPSF->params->data.F32[3] = (psF32) (TST09_NUM_COLS / 2);1666 mySrc->modelPSF->params->data.F32[4] = 2.0;1667 mySrc->modelPSF->params->data.F32[5] = 2.0;1668 mySrc->modelPSF->params->data.F32[6] = 2.0;1669 rc = pmSourceContour(mySrc, imgData, LEVEL, PS_CONTOUR_CRUDE);1670 if (rc == NULL) {1671 printf("TEST ERROR: pmSourceContour() returned NULL.\n");1672 testStatus = false;1673 } else {1674 psFree(rc);1675 }1676 }1677 1678 psFree(mySrc);1679 psFree(imgData);1680 // XXX: This psFree() causes an error. Why?1681 //psFree(tmpPeak);1682 return(testStatus);1683 }1684 1685 #define TST15_NUM_ROWS 1001686 #define TST15_NUM_COLS 1001687 #define TST15_SKY 10.01688 #define TST15_INNER_RADIUS 31689 #define TST15_OUTER_RADIUS 51690 /******************************************************************************1691 test15(): We first test pmSourceAddModel() with various NULL and unallowable1692 input parameters.1693 1694 XXX: We don't verify the numbers.1695 *****************************************************************************/1696 int test15( void )1697 {1698 bool testStatus = true;1699 psImage *imgData = psImageAlloc(TST15_NUM_COLS, TST15_NUM_ROWS, PS_TYPE_F32);1700 for (psS32 i = 0 ; i < imgData->numRows; i++) {1701 for (psS32 j = 0 ; j < imgData->numCols; j++) {1702 imgData->data.F32[i][j] = TST15_SKY;1703 }1704 }1705 pmSource *mySrc = NULL;1706 psBool rc = false;1707 1708 pmPeak *tmpPeak = pmPeakAlloc((psF32) (TST15_NUM_ROWS / 2),1709 (psF32) (TST15_NUM_COLS / 2),1710 200.0,1711 PM_PEAK_LONE);1712 1713 printf("Calling pmSourceLocalSky with valid data.\n");1714 tmpPeak->x = (psF32) (TST15_NUM_ROWS / 2);1715 tmpPeak->y = (psF32) (TST15_NUM_COLS / 2);1716 mySrc = pmSourceLocalSky(imgData,1717 tmpPeak,1718 PS_STAT_SAMPLE_MEAN,1719 (psF32) TST15_INNER_RADIUS,1720 (psF32) TST15_OUTER_RADIUS);1721 1722 if (mySrc == NULL) {1723 printf("TEST ERROR: pmSourceLocalSky() returned a NULL pmSource.\n");1724 testStatus = false;1725 }1726 1727 mySrc->modelPSF = pmModelAlloc(PS_MODEL_GAUSS);1728 mySrc->modelPSF->params->data.F32[0] = 5.0;1729 mySrc->modelPSF->params->data.F32[1] = 70.0;1730 mySrc->modelPSF->params->data.F32[2] = (psF32) (TST15_NUM_ROWS / 2);1731 mySrc->modelPSF->params->data.F32[3] = (psF32) (TST15_NUM_COLS / 2);1732 mySrc->modelPSF->params->data.F32[4] = 1.0;1733 mySrc->modelPSF->params->data.F32[5] = 1.0;1734 mySrc->modelPSF->params->data.F32[6] = 2.0;1735 1736 printf("----------------------------------------------------------------------------------\n");1737 printf("Calling pmSourceAddModel with NULL psImage. Should generate error, return FALSE.\n");1738 rc = pmSourceAddModel(NULL, mySrc, true);1739 if (rc == true) {1740 printf("TEST ERROR: pmSourceAddModel() returned TRUE.\n");1741 testStatus = false;1742 }1743 1744 printf("----------------------------------------------------------------------------------\n");1745 printf("Calling pmSourceAddModel with NULL psSrc. Should generate error, return FALSE.\n");1746 rc = pmSourceAddModel(imgData, NULL, true);1747 if (rc == true) {1748 printf("TEST ERROR: pmSourceAddModel() returned TRUE.\n");1749 testStatus = false;1750 }1751 1752 printf("----------------------------------------------------------------------------------\n");1753 printf("Calling pmSourceAddModel with acceptable data.\n");1754 rc = pmSourceAddModel(imgData, mySrc, true);1755 if (rc != true) {1756 printf("TEST ERROR: pmSourceAddModel() returned FALSE.\n");1757 testStatus = false;1758 }1759 1760 psFree(mySrc);1761 psFree(imgData);1762 return(testStatus);1763 }1764 1765 #define TST16_NUM_ROWS 1001766 #define TST16_NUM_COLS 1001767 #define TST16_SKY 10.01768 #define TST16_INNER_RADIUS 31769 #define TST16_OUTER_RADIUS 51770 /******************************************************************************1771 test16(): We first test pmSourceSubModel() with various NULL and unallowable1772 input parameters.1773 1774 XXX: We don't verify the numbers.1775 *****************************************************************************/1776 int test16( void )1777 {1778 bool testStatus = true;1779 psImage *imgData = psImageAlloc(TST16_NUM_COLS, TST16_NUM_ROWS, PS_TYPE_F32);1780 for (psS32 i = 0 ; i < imgData->numRows; i++) {1781 for (psS32 j = 0 ; j < imgData->numCols; j++) {1782 imgData->data.F32[i][j] = TST16_SKY;1783 }1784 }1785 pmSource *mySrc = NULL;1786 psBool rc = false;1787 1788 pmPeak *tmpPeak = pmPeakAlloc((psF32) (TST16_NUM_ROWS / 2),1789 (psF32) (TST16_NUM_COLS / 2),1790 200.0,1791 PM_PEAK_LONE);1792 1793 printf("Calling pmSourceLocalSky with valid data.\n");1794 tmpPeak->x = (psF32) (TST16_NUM_ROWS / 2);1795 tmpPeak->y = (psF32) (TST16_NUM_COLS / 2);1796 mySrc = pmSourceLocalSky(imgData,1797 tmpPeak,1798 PS_STAT_SAMPLE_MEAN,1799 (psF32) TST16_INNER_RADIUS,1800 (psF32) TST16_OUTER_RADIUS);1801 1802 if (mySrc == NULL) {1803 printf("TEST ERROR: pmSourceLocalSky() returned a NULL pmSource.\n");1804 testStatus = false;1805 }1806 1807 mySrc->modelPSF = pmModelAlloc(PS_MODEL_GAUSS);1808 mySrc->modelPSF->params->data.F32[0] = 5.0;1809 mySrc->modelPSF->params->data.F32[1] = 70.0;1810 mySrc->modelPSF->params->data.F32[2] = (psF32) (TST16_NUM_ROWS / 2);1811 mySrc->modelPSF->params->data.F32[3] = (psF32) (TST16_NUM_COLS / 2);1812 mySrc->modelPSF->params->data.F32[4] = 1.0;1813 mySrc->modelPSF->params->data.F32[5] = 1.0;1814 mySrc->modelPSF->params->data.F32[6] = 2.0;1815 1816 printf("----------------------------------------------------------------------------------\n");1817 printf("Calling pmSourceSubModel with NULL psImage. Should generate error, return FALSE.\n");1818 rc = pmSourceSubModel(NULL, mySrc, true);1819 if (rc == true) {1820 printf("TEST ERROR: pmSourceSubModel() returned TRUE.\n");1821 testStatus = false;1822 }1823 1824 printf("----------------------------------------------------------------------------------\n");1825 printf("Calling pmSourceSubModel with NULL psSrc. Should generate error, return FALSE.\n");1826 rc = pmSourceSubModel(imgData, NULL, true);1827 if (rc == true) {1828 printf("TEST ERROR: pmSourceSubModel() returned TRUE.\n");1829 testStatus = false;1830 }1831 1832 printf("----------------------------------------------------------------------------------\n");1833 printf("Calling pmSourceSubModel with acceptable data.\n");1834 rc = pmSourceSubModel(imgData, mySrc, true);1835 if (rc != true) {1836 printf("TEST ERROR: pmSourceSubModel() returned FALSE.\n");1837 testStatus = false;1838 }1839 1840 psFree(mySrc);1841 psFree(imgData);1842 return(testStatus);1843 }1844 1845 #define TST20_NUM_ROWS 1001846 #define TST20_NUM_COLS 1001847 #define TST20_SKY 10.01848 #define TST20_INNER_RADIUS 31849 #define TST20_OUTER_RADIUS 51850 /******************************************************************************1851 test20(): We first test pmSourceSubModel() with various NULL and unallowable1852 input parameters.1853 1854 XXX: We don't verify the numbers.1855 *****************************************************************************/1856 int test20( void )1857 {1858 bool testStatus = true;1859 psImage *imgData = psImageAlloc(TST20_NUM_COLS, TST20_NUM_ROWS, PS_TYPE_F32);1860 for (psS32 i = 0 ; i < imgData->numRows; i++) {1861 for (psS32 j = 0 ; j < imgData->numCols; j++) {1862 imgData->data.F32[i][j] = TST20_SKY;1863 }1864 }1865 pmSource *mySrc = NULL;1866 psBool rc = false;1867 1868 pmPeak *tmpPeak = pmPeakAlloc((psF32) (TST20_NUM_ROWS / 2),1869 (psF32) (TST20_NUM_COLS / 2),1870 200.0,1871 PM_PEAK_LONE);1872 1873 printf("Calling pmSourceLocalSky with valid data.\n");1874 tmpPeak->x = (psF32) (TST20_NUM_ROWS / 2);1875 tmpPeak->y = (psF32) (TST20_NUM_COLS / 2);1876 mySrc = pmSourceLocalSky(imgData,1877 tmpPeak,1878 PS_STAT_SAMPLE_MEAN,1879 (psF32) TST20_INNER_RADIUS,1880 (psF32) TST20_OUTER_RADIUS);1881 1882 if (mySrc == NULL) {1883 printf("TEST ERROR: pmSourceLocalSky() returned a NULL pmSource.\n");1884 testStatus = false;1885 }1886 1887 mySrc->modelPSF = pmModelAlloc(PS_MODEL_GAUSS);1888 1889 1890 mySrc->modelPSF->params->data.F32[0] = 5.0;1891 mySrc->modelPSF->params->data.F32[1] = 70.0;1892 mySrc->modelPSF->params->data.F32[2] = (psF32) (TST20_NUM_ROWS / 2);1893 mySrc->modelPSF->params->data.F32[3] = (psF32) (TST20_NUM_COLS / 2);1894 mySrc->modelPSF->params->data.F32[4] = 1.0;1895 mySrc->modelPSF->params->data.F32[5] = 1.0;1896 mySrc->modelPSF->params->data.F32[6] = 2.0;1897 1898 printf("----------------------------------------------------------------------------------\n");1899 printf("Calling pmSourceFitModel with NULL psImage. Should generate error, return FALSE.\n");1900 rc = pmSourceFitModel(mySrc, NULL);1901 if (rc == true) {1902 printf("TEST ERROR: pmSourceFitModel() returned TRUE.\n");1903 testStatus = false;1904 }1905 1906 printf("----------------------------------------------------------------------------------\n");1907 printf("Calling pmSourceFitModel with NULL pmSource. Should generate error, return FALSE.\n");1908 rc = pmSourceFitModel(NULL, imgData);1909 if (rc == true) {1910 printf("TEST ERROR: pmSourceFitModel() returned TRUE.\n");1911 testStatus = false;1912 }1913 1914 printf("----------------------------------------------------------------------------------\n");1915 printf("Calling pmSourceFitModel with acceptable data.\n");1916 rc = pmSourceFitModel(mySrc, imgData);1917 printf("pmSourceFitModel returned %d\n", rc);1918 1919 // XXX: Memory leaks are not being tested1920 psVector *junk = psVectorAlloc(10, PS_TYPE_F32);1921 junk->data.F32[0] = 0.0;1922 1923 psFree(mySrc);1924 psFree(imgData);1925 return(testStatus);1926 }1927 1928 1929 977 // this code will 1930 978
Note:
See TracChangeset
for help on using the changeset viewer.
