Changeset 5435 for trunk/psModules/test/objects
- Timestamp:
- Oct 20, 2005, 1:06:24 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psModules/test/objects/tst_pmObjects01.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/test/objects/tst_pmObjects01.c
r5258 r5435 1 /** @file tst_pm FindObjects.c1 /** @file tst_pmObjects.c 2 2 * 3 * @brief Contains the tests for pm SubtractSky.c:3 * @brief Contains the tests for pmObjects.c: 4 4 * 5 5 * test00: This code will ... … … 9 9 * XXX: Must test 10 10 * pmSourceRoughClass 11 * many others... 12 * 11 13 * 12 14 * XXX: Must test output results for many other functions. … … 23 25 Weakly Tested: 24 26 pmSourceMoments() 25 27 most of psObjects.c is not tested 26 28 * 27 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $28 * @date $Date: 2005-10- 10 21:55:42$29 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 30 * @date $Date: 2005-10-20 23:06:24 $ 29 31 * 30 32 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 47 49 //static int test06(void); 48 50 //static int test07(void); 49 /* 50 static int test08(void); 51 //static int test08(void); 51 52 static int test09(void); 52 53 static int test15(void); 53 54 static int test16(void); 54 55 static int test20(void); 55 */56 56 testDescription tests[] = { 57 57 {test00, 000, "pmObjects: structure allocators and deallocators", true, false}, … … 63 63 // {test06, 001, "pmObjects: pmSourceSetPixelsCircle()", true, false}, 64 64 // {test07, 001, "pmObjects: pmMin()", 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 */ 65 // {test08, 001, "pmObjects: pmSourceModelGuess()", true, false}, 66 {test09, 001, "pmObjects: pmSourceContour()", true, false}, 67 {test15, 001, "pmObjects: pmSourceAddModel()", true, false}, 68 {test16, 001, "pmObjects: pmSourceSubModel()", true, false}, 69 {test20, 001, "pmObjects: pmSourceSubModel()", true, false}, 72 70 {NULL} 73 71 }; … … 975 973 } 976 974 975 #define TST09_NUM_ROWS 70 976 #define TST09_NUM_COLS 70 977 #define TST09_SKY 5.0 978 #define TST09_INNER_RADIUS 3 979 #define TST09_OUTER_RADIUS 10 980 #define LEVEL (TST09_SKY + 10.0) 981 /****************************************************************************** 982 test09(): We first test pmSourceContour() with various NULL and unallowable 983 input parameters. 984 985 XXX: We don't verify the numbers. 986 *****************************************************************************/ 987 int test09( void ) 988 { 989 bool testStatus = true; 990 psImage *imgData = psImageAlloc(TST09_NUM_COLS, TST09_NUM_ROWS, PS_TYPE_F32); 991 psImageInit(imgData, TST09_SKY); 992 psImage *imgMask = psImageAlloc(TST09_NUM_COLS, TST09_NUM_ROWS, PS_TYPE_U8); 993 psImageInit(imgMask, 0); 994 pmPeak *tmpPeak = pmPeakAlloc((psF32) (TST09_NUM_ROWS / 2), 995 (psF32) (TST09_NUM_COLS / 2), 996 200.0, 997 PM_PEAK_LONE); 998 pmSource *tmpSource = pmSourceAlloc(); 999 tmpSource->pixels = imgData; 1000 tmpSource->mask = imgMask; 1001 tmpSource->peak = tmpPeak; 1002 psBool rc = pmSourceLocalSky(tmpSource, PS_STAT_SAMPLE_MEAN, 10.0); 1003 if (rc == false) { 1004 printf("TEST ERROR: pmSourceLocalSky() returned a FALSE pmSource.\n"); 1005 testStatus = false; 1006 } 1007 1008 printf("----------------------------------------------------------------------------------\n"); 1009 printf("Calling pmSourceContour with NULL pmSource . Should generate error, return FALSE.\n"); 1010 rc = pmSourceContour(NULL, imgData, LEVEL, PS_CONTOUR_CRUDE); 1011 if (rc != false) { 1012 printf("TEST ERROR: pmSourceContour() returned TRUE.\n"); 1013 testStatus = false; 1014 psFree(rc); 1015 } 1016 1017 printf("----------------------------------------------------------------------------------\n"); 1018 printf("Calling pmSourceContour with NULL psImage . Should generate error, return FALSE.\n"); 1019 rc = pmSourceContour(tmpSource, NULL, LEVEL, PS_CONTOUR_CRUDE); 1020 if (rc != FALSE) { 1021 printf("TEST ERROR: pmSourceContour() returned TRUE.\n"); 1022 testStatus = false; 1023 psFree(rc); 1024 } 1025 1026 // 1027 // XXX: pmSourceContour() has a problem with contour tops/bottoms. 1028 // Must correct this. 1029 // 1030 if (1) { 1031 printf("----------------------------------------------------------------------------------\n"); 1032 printf("Calling pmSourceContour with acceptable data.\n"); 1033 printf("NOTE: must figure out the parameters for this test to be meaningful.\n"); 1034 tmpSource->modelPSF->params->data.F32[0] = TST09_SKY; 1035 tmpSource->modelPSF->params->data.F32[1] = 15.0; 1036 tmpSource->modelPSF->params->data.F32[2] = (psF32) (TST09_NUM_ROWS / 2); 1037 tmpSource->modelPSF->params->data.F32[3] = (psF32) (TST09_NUM_COLS / 2); 1038 tmpSource->modelPSF->params->data.F32[4] = 2.0; 1039 tmpSource->modelPSF->params->data.F32[5] = 2.0; 1040 tmpSource->modelPSF->params->data.F32[6] = 2.0; 1041 rc = pmSourceContour(tmpSource, imgData, LEVEL, PS_CONTOUR_CRUDE); 1042 if (rc == false) { 1043 printf("TEST ERROR: pmSourceContour() returned FALSE.\n"); 1044 testStatus = false; 1045 } else { 1046 psFree(rc); 1047 } 1048 } 1049 1050 psFree(tmpSource); 1051 return(testStatus); 1052 } 1053 1054 #define TST15_NUM_ROWS 100 1055 #define TST15_NUM_COLS 100 1056 #define TST15_SKY 10.0 1057 #define TST15_INNER_RADIUS 3 1058 #define TST15_OUTER_RADIUS 5 1059 /****************************************************************************** 1060 test15(): We first test pmSourceAddModel() with various NULL and unallowable 1061 input parameters. 1062 1063 XXX: We don't verify the numbers. 1064 *****************************************************************************/ 1065 int test15( void ) 1066 { 1067 bool testStatus = true; 1068 psImage *imgData = psImageAlloc(TST15_NUM_COLS, TST15_NUM_ROWS, PS_TYPE_F32); 1069 psImageInit(imgData, TST15_SKY); 1070 psImage *imgMask = psImageAlloc(TST15_NUM_COLS, TST15_NUM_ROWS, PS_TYPE_U8); 1071 psImageInit(imgMask, 0); 1072 pmPeak *tmpPeak = pmPeakAlloc((psF32) (TST15_NUM_ROWS / 2), 1073 (psF32) (TST15_NUM_COLS / 2), 1074 200.0, 1075 PM_PEAK_LONE); 1076 pmSource *tmpSource = pmSourceAlloc(); 1077 tmpSource->pixels = imgData; 1078 tmpSource->mask = imgMask; 1079 tmpSource->peak = tmpPeak; 1080 psBool rc = pmSourceLocalSky(tmpSource, PS_STAT_SAMPLE_MEAN, 10.0); 1081 if (rc == false) { 1082 printf("TEST ERROR: pmSourceLocalSky() returned a FALSE pmSource.\n"); 1083 testStatus = false; 1084 } 1085 1086 1087 tmpSource->modelPSF = pmModelAlloc(PS_MODEL_GAUSS); 1088 tmpSource->modelPSF->params->data.F32[0] = 5.0; 1089 tmpSource->modelPSF->params->data.F32[1] = 70.0; 1090 tmpSource->modelPSF->params->data.F32[2] = (psF32) (TST15_NUM_ROWS / 2); 1091 tmpSource->modelPSF->params->data.F32[3] = (psF32) (TST15_NUM_COLS / 2); 1092 tmpSource->modelPSF->params->data.F32[4] = 1.0; 1093 tmpSource->modelPSF->params->data.F32[5] = 1.0; 1094 tmpSource->modelPSF->params->data.F32[6] = 2.0; 1095 1096 printf("----------------------------------------------------------------------------------\n"); 1097 printf("Calling pmSourceAddModel with NULL psImage. Should generate error, return FALSE.\n"); 1098 rc = pmSourceAddModel(NULL, tmpSource, true); 1099 if (rc == true) { 1100 printf("TEST ERROR: pmSourceAddModel() returned TRUE.\n"); 1101 testStatus = false; 1102 } 1103 1104 printf("----------------------------------------------------------------------------------\n"); 1105 printf("Calling pmSourceAddModel with NULL psSrc. Should generate error, return FALSE.\n"); 1106 rc = pmSourceAddModel(imgData, NULL, true); 1107 if (rc == true) { 1108 printf("TEST ERROR: pmSourceAddModel() returned TRUE.\n"); 1109 testStatus = false; 1110 } 1111 1112 printf("----------------------------------------------------------------------------------\n"); 1113 printf("Calling pmSourceAddModel with acceptable data.\n"); 1114 rc = pmSourceAddModel(imgData, tmpSource, true); 1115 if (rc != true) { 1116 printf("TEST ERROR: pmSourceAddModel() returned FALSE.\n"); 1117 testStatus = false; 1118 } 1119 1120 psFree(tmpSource); 1121 psFree(imgData); 1122 return(testStatus); 1123 } 1124 1125 #define TST16_NUM_ROWS 100 1126 #define TST16_NUM_COLS 100 1127 #define TST16_SKY 10.0 1128 #define TST16_INNER_RADIUS 3 1129 #define TST16_OUTER_RADIUS 5 1130 /****************************************************************************** 1131 test16(): We first test pmSourceSubModel() with various NULL and unallowable 1132 input parameters. 1133 1134 XXX: We don't verify the numbers. 1135 *****************************************************************************/ 1136 int test16( void ) 1137 { 1138 bool testStatus = true; 1139 psImage *imgData = psImageAlloc(TST16_NUM_COLS, TST16_NUM_ROWS, PS_TYPE_F32); 1140 for (psS32 i = 0 ; i < imgData->numRows; i++) { 1141 for (psS32 j = 0 ; j < imgData->numCols; j++) { 1142 imgData->data.F32[i][j] = TST16_SKY; 1143 } 1144 } 1145 pmSource *tmpSource = NULL; 1146 psBool rc = false; 1147 1148 pmPeak *tmpPeak = pmPeakAlloc((psF32) (TST16_NUM_ROWS / 2), 1149 (psF32) (TST16_NUM_COLS / 2), 1150 200.0, 1151 PM_PEAK_LONE); 1152 1153 printf("Calling pmSourceLocalSky with valid data.\n"); 1154 tmpPeak->x = (psF32) (TST16_NUM_ROWS / 2); 1155 tmpPeak->y = (psF32) (TST16_NUM_COLS / 2); 1156 tmpSource = pmSourceLocalSky(imgData, 1157 tmpPeak, 1158 PS_STAT_SAMPLE_MEAN, 1159 (psF32) TST16_INNER_RADIUS, 1160 (psF32) TST16_OUTER_RADIUS); 1161 1162 if (tmpSource == NULL) { 1163 printf("TEST ERROR: pmSourceLocalSky() returned a NULL pmSource.\n"); 1164 testStatus = false; 1165 } 1166 1167 tmpSource->modelPSF = pmModelAlloc(PS_MODEL_GAUSS); 1168 tmpSource->modelPSF->params->data.F32[0] = 5.0; 1169 tmpSource->modelPSF->params->data.F32[1] = 70.0; 1170 tmpSource->modelPSF->params->data.F32[2] = (psF32) (TST16_NUM_ROWS / 2); 1171 tmpSource->modelPSF->params->data.F32[3] = (psF32) (TST16_NUM_COLS / 2); 1172 tmpSource->modelPSF->params->data.F32[4] = 1.0; 1173 tmpSource->modelPSF->params->data.F32[5] = 1.0; 1174 tmpSource->modelPSF->params->data.F32[6] = 2.0; 1175 1176 printf("----------------------------------------------------------------------------------\n"); 1177 printf("Calling pmSourceSubModel with NULL psImage. Should generate error, return FALSE.\n"); 1178 rc = pmSourceSubModel(NULL, tmpSource, true); 1179 if (rc == true) { 1180 printf("TEST ERROR: pmSourceSubModel() returned TRUE.\n"); 1181 testStatus = false; 1182 } 1183 1184 printf("----------------------------------------------------------------------------------\n"); 1185 printf("Calling pmSourceSubModel with NULL psSrc. Should generate error, return FALSE.\n"); 1186 rc = pmSourceSubModel(imgData, NULL, true); 1187 if (rc == true) { 1188 printf("TEST ERROR: pmSourceSubModel() returned TRUE.\n"); 1189 testStatus = false; 1190 } 1191 1192 printf("----------------------------------------------------------------------------------\n"); 1193 printf("Calling pmSourceSubModel with acceptable data.\n"); 1194 rc = pmSourceSubModel(imgData, tmpSource, true); 1195 if (rc != true) { 1196 printf("TEST ERROR: pmSourceSubModel() returned FALSE.\n"); 1197 testStatus = false; 1198 } 1199 1200 psFree(tmpSource); 1201 psFree(imgData); 1202 return(testStatus); 1203 } 1204 1205 #define TST20_NUM_ROWS 100 1206 #define TST20_NUM_COLS 100 1207 #define TST20_SKY 10.0 1208 #define TST20_INNER_RADIUS 3 1209 #define TST20_OUTER_RADIUS 5 1210 /****************************************************************************** 1211 test20(): We first test pmSourceSubModel() with various NULL and unallowable 1212 input parameters. 1213 1214 XXX: We don't verify the numbers. 1215 *****************************************************************************/ 1216 int test20( void ) 1217 { 1218 bool testStatus = true; 1219 psImage *imgData = psImageAlloc(TST20_NUM_COLS, TST20_NUM_ROWS, PS_TYPE_F32); 1220 for (psS32 i = 0 ; i < imgData->numRows; i++) { 1221 for (psS32 j = 0 ; j < imgData->numCols; j++) { 1222 imgData->data.F32[i][j] = TST20_SKY; 1223 } 1224 } 1225 pmSource *tmpSource = NULL; 1226 psBool rc = false; 1227 1228 pmPeak *tmpPeak = pmPeakAlloc((psF32) (TST20_NUM_ROWS / 2), 1229 (psF32) (TST20_NUM_COLS / 2), 1230 200.0, 1231 PM_PEAK_LONE); 1232 1233 printf("Calling pmSourceLocalSky with valid data.\n"); 1234 tmpPeak->x = (psF32) (TST20_NUM_ROWS / 2); 1235 tmpPeak->y = (psF32) (TST20_NUM_COLS / 2); 1236 tmpSource = pmSourceLocalSky(imgData, 1237 tmpPeak, 1238 PS_STAT_SAMPLE_MEAN, 1239 (psF32) TST20_INNER_RADIUS, 1240 (psF32) TST20_OUTER_RADIUS); 1241 1242 if (tmpSource == NULL) { 1243 printf("TEST ERROR: pmSourceLocalSky() returned a NULL pmSource.\n"); 1244 testStatus = false; 1245 } 1246 1247 tmpSource->modelPSF = pmModelAlloc(PS_MODEL_GAUSS); 1248 1249 1250 tmpSource->modelPSF->params->data.F32[0] = 5.0; 1251 tmpSource->modelPSF->params->data.F32[1] = 70.0; 1252 tmpSource->modelPSF->params->data.F32[2] = (psF32) (TST20_NUM_ROWS / 2); 1253 tmpSource->modelPSF->params->data.F32[3] = (psF32) (TST20_NUM_COLS / 2); 1254 tmpSource->modelPSF->params->data.F32[4] = 1.0; 1255 tmpSource->modelPSF->params->data.F32[5] = 1.0; 1256 tmpSource->modelPSF->params->data.F32[6] = 2.0; 1257 1258 printf("----------------------------------------------------------------------------------\n"); 1259 printf("Calling pmSourceFitModel with NULL psImage. Should generate error, return FALSE.\n"); 1260 rc = pmSourceFitModel(tmpSource, NULL); 1261 if (rc == true) { 1262 printf("TEST ERROR: pmSourceFitModel() returned TRUE.\n"); 1263 testStatus = false; 1264 } 1265 1266 printf("----------------------------------------------------------------------------------\n"); 1267 printf("Calling pmSourceFitModel with NULL pmSource. Should generate error, return FALSE.\n"); 1268 rc = pmSourceFitModel(NULL, imgData); 1269 if (rc == true) { 1270 printf("TEST ERROR: pmSourceFitModel() returned TRUE.\n"); 1271 testStatus = false; 1272 } 1273 1274 printf("----------------------------------------------------------------------------------\n"); 1275 printf("Calling pmSourceFitModel with acceptable data.\n"); 1276 rc = pmSourceFitModel(tmpSource, imgData); 1277 printf("pmSourceFitModel returned %d\n", rc); 1278 1279 // XXX: Memory leaks are not being tested 1280 psVector *junk = psVectorAlloc(10, PS_TYPE_F32); 1281 junk->data.F32[0] = 0.0; 1282 1283 psFree(tmpSource); 1284 psFree(imgData); 1285 return(testStatus); 1286 } 1287 1288 977 1289 // this code will 978 1290
Note:
See TracChangeset
for help on using the changeset viewer.
