Changeset 13623
- Timestamp:
- Jun 4, 2007, 3:10:22 PM (19 years ago)
- Location:
- trunk/psLib/test/astro
- Files:
-
- 8 edited
-
tap_psCoord.c (modified) (8 diffs)
-
tap_psCoord02.c (modified) (2 diffs)
-
tap_psEarthOrientation_corrections.c (modified) (3 diffs)
-
tap_psEarthOrientation_motion.c (modified) (28 diffs)
-
tap_psSphereOps_all.c (modified) (17 diffs)
-
tap_psTime_01.c (modified) (13 diffs)
-
tap_psTime_02.c (modified) (6 diffs)
-
tap_psTime_03.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/astro/tap_psCoord.c
r13084 r13623 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $8 * @date $Date: 2007-0 5-01 00:08:52 $7 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2007-06-05 01:10:22 $ 9 9 * 10 10 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 50 50 psPlaneTransform *myPT = psPlaneTransformAlloc(ORDER_X, ORDER_Y); 51 51 ok(myPT != NULL, "psPlaneTransformAlloc() returned non-NULL"); 52 skip_start(myPT == NULL, 6, "Skipping tests because psPlaneTransformAlloc() returned NULL");52 skip_start(myPT == NULL, 4, "Skipping tests because psPlaneTransformAlloc() returned NULL"); 53 53 ok(myPT->x->nX == ORDER_X, "psPlaneTransform->x->nX set correctly"); 54 54 ok(myPT->y->nX == ORDER_X, "psPlaneTransform->y->nX set correctly"); … … 64 64 65 65 myPT = psPlaneTransformAlloc(1, -1); 66 ok(myPT == NULL, "psPlaneTransformAlloc(1, -1 1) returned NULL");66 ok(myPT == NULL, "psPlaneTransformAlloc(1, -1) returned NULL"); 67 67 psFree(myPT); 68 68 … … 127 127 in->yErr = 0.0; 128 128 129 // XXX: psPlane *out = psPlaneTransformApply(out, pt, in); causes a seg-fault. Why? 129 // XXX: psPlane *out = psPlaneTransformApply(out, pt, in); causes a seg-fault. 130 // Why? 130 131 psPlane *out = psPlaneTransformApply(NULL, pt, in); 131 132 if(out == NULL) { … … 154 155 155 156 // psPlaneTransformApply should generate error message for NULL psPlaneTransform 156 if (1){157 { 157 158 psMemId id = psMemGetId(); 158 159 psPlane* in = psPlaneAlloc(); … … 165 166 166 167 // psPlaneTransformApply should generate error message for NULL x coeff psPlaneTransform 167 if (1){168 { 168 169 psMemId id = psMemGetId(); 169 170 psPlane *in = psPlaneAlloc(); … … 180 181 181 182 // psPlaneTransformApply Should generate error message for NULL y coeff psPlaneTransform"); 182 if (1){183 { 183 184 psMemId id = psMemGetId(); 184 185 psPlane* in = psPlaneAlloc(); … … 195 196 196 197 // psPlaneTransformApply() should generate error message for NULL psPlane"); 197 if (1){198 { 198 199 psMemId id = psMemGetId(); 199 200 psPlaneTransform* pt = psPlaneTransformAlloc(2,2); -
trunk/psLib/test/astro/tap_psCoord02.c
r13084 r13623 7 7 * XXX: These tests should probably be split among several files 8 8 * 9 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $10 * @date $Date: 2007-0 5-01 00:08:52 $9 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2007-06-05 01:10:22 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 449 449 // We calling psPlaneTransformInvert with acceptable linear transformations 450 450 for (psS32 n = 0 ; n < NUM_TRANSFORMS ; n++) 451 {452 if (n == 0) {451 { 452 if (n == 0) { 453 453 // I ensure that we test the identity transformation since this was 454 454 // giving us probs before. -
trunk/psLib/test/astro/tap_psEarthOrientation_corrections.c
r13084 r13623 71 71 void testAberration(void) 72 72 { 73 // diag(" >>>Test 2: psAberration "); 73 // psAberration() 74 74 psSphere *apparent = NULL; 75 75 psSphere *empty = NULL; … … 152 152 void testGravDef(void) 153 153 { 154 // diag(" >>>Test 3: psGravityDeflection "); 155 // Test for psGravityDeflection156 // Return properly allocated psEarthPole157 /* 154 // psGravityDeflection 155 // Test for psGravityDeflection 156 // Return properly allocated psEarthPole 157 /* XXX: Fix this 158 158 psSphere *apparent = NULL; 159 159 psSphere *empty = NULL; … … 282 282 void testEOC_Corrs(void) 283 283 { 284 // diag(" >>>Test 4:psEOC Correction Functions");284 // psEOC Correction Functions"); 285 285 //Tests for psEOC_PrecessionCorr 286 /* 286 /* XXX: Fix this 287 287 psTime *empty = NULL; 288 288 psTime *time2 = psTimeAlloc(PS_TIME_UTC); -
trunk/psLib/test/astro/tap_psEarthOrientation_motion.c
r12607 r13623 11 11 * 12 12 */ 13 14 13 #include <pslib.h> 15 14 #include <string.h> 16 17 15 #include "tap.h" 18 16 #include "pstap.h" … … 22 20 static void testSphereRots(void); 23 21 static void testSpherePrecess(void); 24 25 22 #define MJD_1900 15021.0 // Modified Julian Day 1/1/1900 00:00:00 26 23 #define MJD_2100 88069.0 // Modified Julian Day 1/1/2100 00:00:00 … … 30 27 psLogSetFormat("HLNM"); 31 28 psLogSetLevel(PS_LOG_INFO); 32 plan_tests(48); 33 34 // diag("Tests for psEarthOrientation Motion Functions"); 35 29 plan_tests(78); 30 31 // Tests for psEarthOrientation Motion Functions 36 32 // Initialize library internal structures 37 33 psLibInit("pslib.config"); … … 42 38 testSpherePrecess(); 43 39 44 // Cleanup library45 40 psLibFinalize(); 46 47 41 done(); 48 42 } … … 50 44 void testPrecessionModel(void) 51 45 { 52 // diag(" >>>Test 1: psEOC_PrecessionModel"); 46 // psEOC_PrecessionModel 53 47 54 48 psEarthPole *ep = NULL; 55 49 psTime *testTime = NULL; 56 50 51 57 52 //Test for psEarthPoleAlloc 58 53 //Return properly allocated psEarthPole 59 54 { 55 psMemId id = psMemGetId(); 60 56 ep = psEarthPoleAlloc(); 61 ok( ep != NULL, 62 "psEarthPoleAlloc: return properly allocated psEarthPole."); 57 ok( ep != NULL, "psEarthPoleAlloc: return properly allocated psEarthPole."); 63 58 psFree(ep); 64 59 ep = NULL; 65 } 60 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 61 } 62 63 66 64 //Tests for psEOC_PrecessionModel 67 65 //Return NULL for NULL time input. 68 66 { 67 psMemId id = psMemGetId(); 69 68 ep = psEOC_PrecessionModel(NULL); 70 ok( ep == NULL, 71 "psEOC_PrecessionModel: return NULL for NULL time input."); 72 } 69 ok( ep == NULL, "psEOC_PrecessionModel: return NULL for NULL time input."); 70 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 71 } 72 73 73 74 //Return NULL for UT1 time input. 74 75 { 76 psMemId id = psMemGetId(); 75 77 testTime = psTimeAlloc(PS_TIME_UT1); 76 78 ep = psEOC_PrecessionModel(testTime); 77 ok( ep == NULL, 78 "psEOC_PrecessionModel: return NULL for UT1 time input."); 79 } 79 ok( ep == NULL, "psEOC_PrecessionModel: return NULL for UT1 time input."); 80 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 81 } 82 83 80 84 //Return NULL for invalid time input. 81 85 { 86 psMemId id = psMemGetId(); 82 87 psFree(testTime); 83 88 testTime = psTimeAlloc(PS_TIME_UTC); … … 87 92 "psEOC_PrecessionModel: return NULL for invalid time input."); 88 93 testTime->nsec = 0; 89 } 94 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 95 } 96 97 90 98 //Return NULL for failed eoc init - missing file 91 99 //printf("\n filename = '%s' \n", p_psGetConfigFileName()); … … 93 101 //to define where the real pslib config is. 94 102 { 103 psMemId id = psMemGetId(); 95 104 testTime->sec = 1049160600; 96 105 testTime->nsec = 0; … … 103 112 rename("../../etc/pslib/pslib_config.bak", "../../etc/pslib/pslib.config"); 104 113 skip_end(); 105 } 114 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 115 } 116 106 117 107 118 //Return valid EarthPole for valid time input 108 119 { 120 psMemId id = psMemGetId(); 109 121 double x, y, s; 110 122 x = 2.857175590089105e-4; … … 121 133 "psEOC_PrecessionModel: return valid EarthPole for valid inputs (s)."); 122 134 skip_end(); 135 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 123 136 } 124 137 … … 147 160 void testPolarMotion(void) 148 161 { 149 // diag(" >>>Test 2: psEOC_GetPolarMotion "); 162 // psEOC_GetPolarMotion() 150 163 151 164 psTime *in = psTimeAlloc(PS_TIME_UTC); … … 155 168 psEarthPole *polarMotion = NULL; 156 169 170 157 171 //Tests for psEOC_GetPolarMotion 158 172 //Return NULL for NULL time input. 159 173 { 174 psMemId id = psMemGetId(); 160 175 polarMotion = psEOC_GetPolarMotion(NULL, PS_IERS_B); 161 ok( polarMotion == NULL, 162 "psEOC_GetPolarMotion: return NULL for NULL time input."); 163 } 176 ok( polarMotion == NULL, "psEOC_GetPolarMotion: return NULL for NULL time input."); 177 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 178 } 179 180 164 181 //Return NULL for invalid IERS table input 165 182 { 183 psMemId id = psMemGetId(); 166 184 polarMotion = psEOC_GetPolarMotion(NULL, PS_IERS_B+1); 167 ok( polarMotion == NULL, 168 "psEOC_GetPolarMotion: return NULL for invalid IERS table input."); 169 } 185 ok( polarMotion == NULL, "psEOC_GetPolarMotion: return NULL for invalid IERS table input."); 186 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 187 } 188 189 170 190 //Return NULL for invalid time input. 171 191 { 192 psMemId id = psMemGetId(); 172 193 in->nsec = 2e9; 173 194 polarMotion = psEOC_GetPolarMotion(in, PS_IERS_B); 174 ok( polarMotion == NULL, 175 "psEOC_GetPolarMotion: return NULL for invalid time input."); 195 ok( polarMotion == NULL, "psEOC_GetPolarMotion: return NULL for invalid time input."); 176 196 in->nsec = 0; 177 } 197 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 198 } 199 200 178 201 //Return NULL for failed eoc init - missing file 179 202 //XXX: Use the PS_CONFIG_FILE_DEFAULT macro, or PS_CONFIG_FILE environment variable 180 203 //to define where the real pslib config is. 181 204 { 205 psMemId id = psMemGetId(); 182 206 p_psEOCFinalize(); 183 207 skip_start(rename("../../etc/pslib/pslib.config", "../../etc/pslib/pslib_config.bak"), 184 208 1, "Skipping 1 tests because file rename failed!"); 185 209 polarMotion = psEOC_GetPolarMotion(in, PS_IERS_B); 186 ok( polarMotion == NULL, 187 "psEOC_GetPolarMotion: return NULL for failed eoc init."); 210 ok( polarMotion == NULL, "psEOC_GetPolarMotion: return NULL for failed eoc init."); 188 211 rename("../../etc/pslib/pslib_config.bak", "../../etc/pslib/pslib.config"); 189 212 skip_end(); 190 } 213 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 214 } 215 216 191 217 //Return valid EarthPole for valid time input - IERS B 192 218 { 219 psMemId id = psMemGetId(); 193 220 double x, y, s; 194 221 x = -6.454389659777e-07; … … 199 226 "Skipping 3 tests because psEarthPole is NULL!"); 200 227 is_double_tol(polarMotion->x, x, 0.1, 201 "psEOC_GetPolarMotion: return valid EarthPole for valid inputs "228 "psEOC_GetPolarMotion: return valid EarthPole for valid inputs " 202 229 "(x) - IERS B."); 203 230 is_double_tol(polarMotion->y, y, 0.1, 204 "psEOC_GetPolarMotion: return valid EarthPole for valid inputs "231 "psEOC_GetPolarMotion: return valid EarthPole for valid inputs " 205 232 "(y) - IERS B."); 206 233 is_double_tol(polarMotion->s, s, 0.1, 207 "psEOC_GetPolarMotion: return valid EarthPole for valid inputs "234 "psEOC_GetPolarMotion: return valid EarthPole for valid inputs " 208 235 "(s) - IERS B."); 209 236 skip_end(); 210 237 psFree(polarMotion); 211 } 238 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 239 } 240 241 212 242 //Return valid EarthPole for valid time input - IERS A 213 243 { 244 psMemId id = psMemGetId(); 214 245 double x, y, s; 215 246 x = -6.45381397904e-07; … … 220 251 "Skipping 3 tests because psEarthPole is NULL!"); 221 252 is_double_tol(polarMotion->x, x, 0.1, 222 "psEOC_GetPolarMotion: return valid EarthPole for valid inputs "253 "psEOC_GetPolarMotion: return valid EarthPole for valid inputs " 223 254 "(x) - IERS A."); 224 255 is_double_tol(polarMotion->y, y, 0.1, 225 "psEOC_GetPolarMotion: return valid EarthPole for valid inputs "256 "psEOC_GetPolarMotion: return valid EarthPole for valid inputs " 226 257 "(y) - IERS A."); 227 258 is_double_tol(polarMotion->s, s, 0.1, 228 "psEOC_GetPolarMotion: return valid EarthPole for valid inputs "259 "psEOC_GetPolarMotion: return valid EarthPole for valid inputs " 229 260 "(s) - IERS A."); 230 261 skip_end(); 231 262 psFree(polarMotion); 232 } 263 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 264 } 265 266 233 267 //Return valid EarthPole for valid time input - IERS A 234 268 { 269 psMemId id = psMemGetId(); 235 270 psTime *firstTime = psTimeFromMJD(41684.50); 236 271 polarMotion = psEOC_GetPolarMotion(firstTime, PS_IERS_B); 237 272 ok( polarMotion != NULL, 238 "psEOC_GetPolarMotion: return valid EarthPole for valid inputs.");273 "psEOC_GetPolarMotion: return valid EarthPole for valid inputs."); 239 274 psFree(firstTime); 275 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 240 276 } 241 277 … … 264 300 void testSphereRots(void) 265 301 { 266 // diag(" >>>Test 3: psSphereRot Functions"); 302 // psSphereRot Functions 267 303 psSphereRot *out = NULL; 268 304 psEarthPole *in = NULL; … … 276 312 //Return NULL for NULL earthPole input 277 313 { 314 psMemId id = psMemGetId(); 278 315 out = psSphereRot_CEOtoGCRS(in); 279 ok( out == NULL, 280 "psSphereRot_CEOtoGCRS: return NULL for NULL earthPole input."); 316 ok( out == NULL, "psSphereRot_CEOtoGCRS: return NULL for NULL earthPole input."); 281 317 in = psEarthPoleAlloc(); 282 } 318 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 319 } 320 321 283 322 in->x = 2.857175590089105e-4; 284 323 in->y = 2.3968739377734732e-5; … … 286 325 //Return correct psSphereRot for valid input 287 326 { 327 psMemId id = psMemGetId(); 288 328 out = psSphereRot_CEOtoGCRS(in); 289 329 skip_start( out == NULL, 4, 290 330 "Skipping 4 tests because psSphereRot output is NULL!"); 291 331 is_double_tol( out->q0, q0, 0.0001, 292 "psSphereRot_CEOtoGCRS: return correct psSphereRot for valid input (q0).");332 "psSphereRot_CEOtoGCRS: return correct psSphereRot for valid input (q0)."); 293 333 is_double_tol( out->q1, q1, 0.0001, 294 "psSphereRot_CEOtoGCRS: return correct psSphereRot for valid input (q1).");334 "psSphereRot_CEOtoGCRS: return correct psSphereRot for valid input (q1)."); 295 335 is_double_tol( out->q2, q2, 0.0001, 296 "psSphereRot_CEOtoGCRS: return correct psSphereRot for valid input (q2).");336 "psSphereRot_CEOtoGCRS: return correct psSphereRot for valid input (q2)."); 297 337 is_double_tol( out->q3, -q3, 0.0001, 298 "psSphereRot_CEOtoGCRS: return correct psSphereRot for valid input (q3)."); 299 skip_end(); 300 } 338 "psSphereRot_CEOtoGCRS: return correct psSphereRot for valid input (q3)."); 339 skip_end(); 340 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 341 } 342 301 343 302 344 //Tests for psSphereRot_TEOtoCEO … … 311 353 //Return NULL for NULL time input 312 354 { 355 psMemId id = psMemGetId(); 313 356 out = psSphereRot_TEOtoCEO(NULL, NULL); 314 ok( out == NULL, 315 "psSphereRot_TEOtoCEO: return NULL for NULL time input."); 316 } 357 ok( out == NULL, "psSphereRot_TEOtoCEO: return NULL for NULL time input."); 358 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 359 } 360 361 317 362 //Return NULL for invalid time input - large nsec, UTC time type 318 363 { 364 psMemId id = psMemGetId(); 319 365 time2->nsec = 3e9; 320 366 out = psSphereRot_TEOtoCEO(time2, NULL); 321 ok( out == NULL, 322 "psSphereRot_TEOtoCEO: return NULL for invalid time input."); 323 } 367 ok( out == NULL, "psSphereRot_TEOtoCEO: return NULL for invalid time input."); 368 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 369 } 370 371 324 372 //Return NULL for invalid time input - UT1 time type, large nsec 325 373 { 374 psMemId id = psMemGetId(); 326 375 psFree(time2); 327 376 time2 = psTimeAlloc(PS_TIME_UT1); … … 329 378 temp->s = 1.0; 330 379 out = psSphereRot_TEOtoCEO(time2, temp); 331 ok( out == NULL, 332 "psSphereRot_TEOtoCEO: return NULL for invalid time input."); 333 } 380 ok( out == NULL, "psSphereRot_TEOtoCEO: return NULL for invalid time input."); 381 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 382 } 383 384 334 385 //Return NULL for invalid earthPole input 335 386 { 387 psMemId id = psMemGetId(); 336 388 time2->nsec = 0; 337 389 psEarthPole *temp = psEarthPoleAlloc(); 338 390 temp->s = -2.0; 339 391 out = psSphereRot_TEOtoCEO(time2, temp); 340 ok( out == NULL, 341 "psSphereRot_TEOtoCEO: return NULL for invalid earthPole input."); 342 } 392 ok( out == NULL, "psSphereRot_TEOtoCEO: return NULL for invalid earthPole input."); 393 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 394 } 395 396 343 397 //Return correct psSphereRot for valid inputs 344 398 double x, y, z; … … 347 401 z = 0.7496183628158023; 348 402 { 403 psMemId id = psMemGetId(); 349 404 psEarthPole *polarTideCorr = psEOC_PolarTideCorr(time); 350 405 out = psSphereRot_TEOtoCEO(time, polarTideCorr); … … 356 411 psCube *cube = psSphereToCube(result); 357 412 is_double_tol( cube->x, x, 0.0001, 358 "psSphereRot_TEOtoCEO: return NULL for NULL time input. (x)");413 "psSphereRot_TEOtoCEO: return NULL for NULL time input. (x)"); 359 414 is_double_tol( cube->y, y, 0.0001, 360 "psSphereRot_TEOtoCEO: return NULL for NULL time input. (y)"); 361 is_double_tol( cube->z, z, 0.0001, 362 "psSphereRot_TEOtoCEO: return NULL for NULL time input. (z)"); 415 "psSphereRot_TEOtoCEO: return NULL for NULL time input. (y)"); 416 is_double_tol( cube->z, z, 0.0001, "psSphereRot_TEOtoCEO: return NULL for NULL time input. (z)"); 363 417 psFree(earthRot); 364 418 psFree(result); … … 367 421 skip_end(); 368 422 psFree(polarTideCorr); 369 } 423 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 424 } 425 370 426 371 427 //Tests for psSphereRot_ITRStoTEO 372 428 //Return NULL for NULL earthPole input 373 429 { 430 psMemId id = psMemGetId(); 374 431 psFree(out); 375 432 out = psSphereRot_ITRStoTEO(NULL); … … 377 434 "psSphereRot_ITRStoTEO: return NULL for NULL earthPole input."); 378 435 in = psEarthPoleAlloc(); 379 } 436 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 437 } 438 439 380 440 //Return correct psSphereRot for valid input 381 441 { 442 psMemId id = psMemGetId(); 382 443 q0 = -1.0567571848664005e-6; 383 444 q1 = 3.218036562931509e-7; … … 391 452 "Skipping 4 tests because psSphereRot output is NULL!"); 392 453 is_double_tol( out->q0, q0, 0.0001, 393 "psSphereRot_ITRStoTEO: return correct psSphereRot for valid input (q0).");454 "psSphereRot_ITRStoTEO: return correct psSphereRot for valid input (q0)."); 394 455 is_double_tol( out->q1, q1, 0.0001, 395 "psSphereRot_ITRStoTEO: return correct psSphereRot for valid input (q1).");456 "psSphereRot_ITRStoTEO: return correct psSphereRot for valid input (q1)."); 396 457 is_double_tol( out->q2, q2, 0.0001, 397 "psSphereRot_ITRStoTEO: return correct psSphereRot for valid input (q2).");458 "psSphereRot_ITRStoTEO: return correct psSphereRot for valid input (q2)."); 398 459 is_double_tol( out->q3, q3, 0.0001, 399 "psSphereRot_ITRStoTEO: return correct psSphereRot for valid input (q3)."); 400 skip_end(); 460 "psSphereRot_ITRStoTEO: return correct psSphereRot for valid input (q3)."); 461 skip_end(); 462 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 401 463 } 402 464 … … 428 490 void testSpherePrecess(void) 429 491 { 430 // diag(" >>>Test 4: psSpherePrecess"); 492 // psSpherePrecess 431 493 psSphereRot *rot = NULL; 432 494 psTime *fromTime = NULL; … … 435 497 psSphere* outputCoord = NULL; 436 498 499 437 500 //Return NULL for NULL time inputs 438 501 { 502 psMemId id = psMemGetId(); 439 503 rot = psSpherePrecess(fromTime, toTime, PS_PRECESS_ROUGH); 440 ok( rot == NULL, 441 "psSpherePrecess: return NULL for NULL time inputs."); 442 } 504 ok( rot == NULL, "psSpherePrecess: return NULL for NULL time inputs."); 505 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 506 } 507 508 443 509 //Return NULL for invalid mode input 444 510 { 511 psMemId id = psMemGetId(); 445 512 fromTime = psTimeFromMJD(MJD_2100); 446 513 toTime = psTimeFromMJD(MJD_1900); 447 514 rot = psSpherePrecess(fromTime, toTime, -1); 448 ok( rot == NULL, 449 "psSpherePrecess: return NULL for invalid mode input."); 450 } 515 ok( rot == NULL, "psSpherePrecess: return NULL for invalid mode input."); 516 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 517 } 518 519 451 520 //Return correct psSphereRot for valid inputs, mode = ROUGH 452 521 { 522 psMemId id = psMemGetId(); 453 523 inputCoord->r = SPHERE_PRECESS_TP1_R; 454 524 inputCoord->d = SPHERE_PRECESS_TP1_D; … … 463 533 "Skipping 2 tests because psSphereRot output is NULL!"); 464 534 is_double_tol( outputCoord->r, SPHERE_PRECESS_TP1_EXPECT_R, ERROR_TOL, 465 "psSpherePrecess: return correct psSphereRot for valid"535 "psSpherePrecess: return correct psSphereRot for valid" 466 536 " inputs and PS_PRECESS_ROUGH mode. (r)"); 467 537 is_double_tol( outputCoord->d, SPHERE_PRECESS_TP1_EXPECT_D, ERROR_TOL, 468 "psSpherePrecess: return correct psSphereRot for valid"538 "psSpherePrecess: return correct psSphereRot for valid" 469 539 " inputs and PS_PRECESS_ROUGH mode. (d)"); 470 540 skip_end(); 471 541 psFree(outputCoord); 472 542 psFree(rot); 473 } 543 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 544 } 545 546 474 547 //Return correct psSphereRot for valid inputs, mode = ROUGH 475 548 { 549 psMemId id = psMemGetId(); 476 550 inputCoord->r = SPHERE_PRECESS_TP2_R; 477 551 inputCoord->d = SPHERE_PRECESS_TP2_D; … … 486 560 "Skipping 2 tests because psSphereRot output is NULL!"); 487 561 is_double_tol( outputCoord->r, SPHERE_PRECESS_TP2_EXPECT_R, ERROR_TOL, 488 "psSpherePrecess: return correct psSphereRot for valid"562 "psSpherePrecess: return correct psSphereRot for valid" 489 563 " inputs and PS_PRECESS_ROUGH mode. (r)"); 490 564 is_double_tol( outputCoord->d, SPHERE_PRECESS_TP2_EXPECT_D, ERROR_TOL, 491 "psSpherePrecess: return correct psSphereRot for valid"565 "psSpherePrecess: return correct psSphereRot for valid" 492 566 " inputs and PS_PRECESS_ROUGH mode. (d)"); 493 567 skip_end(); 494 568 psFree(outputCoord); 495 569 psFree(rot); 496 } 570 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 571 } 572 573 497 574 //Return correct psSphereRot for valid inputs, mode = ROUGH 498 575 { 576 psMemId id = psMemGetId(); 499 577 inputCoord->r = SPHERE_PRECESS_TP3_R; 500 578 inputCoord->d = SPHERE_PRECESS_TP3_D; … … 509 587 "Skipping 2 tests because psSphereRot output is NULL!"); 510 588 is_double_tol( outputCoord->r, SPHERE_PRECESS_TP3_EXPECT_R, ERROR_TOL, 511 "psSpherePrecess: return correct psSphereRot for valid"589 "psSpherePrecess: return correct psSphereRot for valid" 512 590 " inputs and PS_PRECESS_ROUGH mode. (r)"); 513 591 is_double_tol( outputCoord->d, SPHERE_PRECESS_TP3_EXPECT_D, ERROR_TOL, 514 "psSpherePrecess: return correct psSphereRot for valid"592 "psSpherePrecess: return correct psSphereRot for valid" 515 593 " inputs and PS_PRECESS_ROUGH mode. (d)"); 516 594 skip_end(); 517 595 psFree(outputCoord); 518 596 psFree(rot); 519 } 597 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 598 } 599 600 520 601 //Return correct psSphereRot for valid inputs, mode = COMPLETE_A 521 602 { 603 psMemId id = psMemGetId(); 522 604 rot = psSpherePrecess(NULL, toTime, PS_PRECESS_COMPLETE_A); 523 605 outputCoord = psSphereRotApply(NULL, rot, inputCoord); 524 606 ok( outputCoord != NULL && rot != NULL, 525 "psSpherePrecess: return correct psSphereRot for valid"607 "psSpherePrecess: return correct psSphereRot for valid" 526 608 " inputs and PS_PRECESS_COMPLETE_A mode."); 527 609 psFree(outputCoord); 528 610 psFree(rot); 529 } 611 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 612 } 613 614 530 615 //Return correct psSphereRot for valid inputs, mode = COMPLETE_B 531 616 { 617 psMemId id = psMemGetId(); 532 618 rot = psSpherePrecess(NULL, toTime, PS_PRECESS_COMPLETE_B); 533 619 outputCoord = psSphereRotApply(NULL, rot, inputCoord); 534 620 ok( outputCoord != NULL && rot != NULL, 535 "psSpherePrecess: return correct psSphereRot for valid"621 "psSpherePrecess: return correct psSphereRot for valid" 536 622 " inputs and PS_PRECESS_COMPLETE_B mode."); 537 623 psFree(outputCoord); 538 624 psFree(rot); 539 } 625 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 626 } 627 628 540 629 //Return correct psSphereRot for valid inputs, mode = IAU2000A 541 630 { 631 psMemId id = psMemGetId(); 542 632 rot = psSpherePrecess(NULL, toTime, PS_PRECESS_IAU2000A); 543 633 outputCoord = psSphereRotApply(NULL, rot, inputCoord); 544 634 ok( outputCoord != NULL && rot != NULL, 545 "psSpherePrecess: return correct psSphereRot for valid"635 "psSpherePrecess: return correct psSphereRot for valid" 546 636 " inputs and PS_PRECESS_IAU2000A mode."); 637 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 547 638 } 548 639 -
trunk/psLib/test/astro/tap_psSphereOps_all.c
r12607 r13623 13 13 * 14 14 */ 15 16 15 #include <pslib.h> 17 16 #include <string.h> 18 19 17 #include "tap.h" 20 18 #include "pstap.h" 21 19 22 20 #define DEG_INC 30.0 23 24 21 #define MJD_1900 15021.0 // Modified Julian Day 1/1/1900 00:00:00 25 22 #define MJD_2000 51544.0 // Modified Julian Day 1/1/2000 00:00:00 26 23 #define MJD_2100 88069.0 // Modified Julian Day 1/1/2100 00:00:00 27 28 24 #define ERROR_TOL 0.0001 29 30 25 #define ALPHA_P 4*M_PI/3 31 26 #define DELTA_P M_PI/4 … … 39 34 { 40 35 psLogSetFormat("HLNM"); 41 plan_tests(57); 42 // diag("Tests for psSphereOps Functions"); 43 36 plan_tests(86); 44 37 testSphereRotCreate(); 45 38 testSphereRotConvert(); 46 39 testSphereOffsets(); 47 48 done();49 40 } 50 41 51 42 void testSphereRotCreate(void) 52 43 { 53 // diag(" >>>Test 1: psSphereRot Creation Functions"); 54 55 // Allocate data structure 56 psSphereRot* myST = NULL; 57 myST = psSphereRotAlloc(ALPHA_P, DELTA_P, PHI_P); 44 // ---------------------------------------------------------------- 45 //Tests for psSphereRotAlloc 46 //Return NULL for NAN input alpha 47 { 48 psMemId id = psMemGetId(); 49 psSphereRot *s1 = psSphereRotAlloc(NAN, DELTA_P, PHI_P); 50 ok( s1 == NULL, "psSphereRotAlloc(): return NULL for NAN input alpha"); 51 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 52 } 53 54 55 //Return NULL for NAN input delta 56 { 57 psMemId id = psMemGetId(); 58 psSphereRot *s1 = psSphereRotAlloc(ALPHA_P, NAN, PHI_P); 59 ok( s1 == NULL, "psSphereRotAlloc(): return NULL for NAN input delta"); 60 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 61 } 62 63 64 //Return NULL for NAN input phi 65 { 66 psMemId id = psMemGetId(); 67 psSphereRot *s1 = psSphereRotAlloc(ALPHA_P, DELTA_P, NAN); 68 ok( s1 == NULL, "psSphereRotAlloc(): return NULL for NAN input phi"); 69 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 70 } 71 72 58 73 double a0 = (ALPHA_P - PHI_P)/2.0; 59 74 double a1 = (ALPHA_P - PHI_P)/2.0; … … 65 80 double q2 = sin(a2)*cos(DELTA_P/2); 66 81 double q3 = cos(a3)*cos(DELTA_P/2); 67 68 //Tests for psSphereRotAlloc 69 //Return NULL for NAN input 70 { 71 psSphereRot *s1 = psSphereRotAlloc(ALPHA_P, NAN, PHI_P); 72 ok( s1 == NULL, 73 "psSphereRotAlloc: return NULL for NAN input."); 74 } 75 //Return valid psSphereRot (allocated) for valid inputs 76 { 77 ok( myST != NULL && psMemCheckSphereRot(myST), 78 "psSphereRotAlloc: return allocated SphereRot for valid inputs."); 79 is_double(q0, myST->q0, 80 "psSphereRotAlloc: return correct q0 value."); 81 is_double(q1, myST->q1, 82 "psSphereRotAlloc: return correct q1 value."); 83 is_double(q2, myST->q2, 84 "psSphereRotAlloc: return correct q2 value."); 85 is_double(q3, myST->q3, 86 "psSphereRotAlloc: return correct q3 value."); 87 } 82 // Test psSphereRot() for valid inputs 83 { 84 psMemId id = psMemGetId(); 85 psSphereRot* myST = NULL; 86 myST = psSphereRotAlloc(ALPHA_P, DELTA_P, PHI_P); 87 ok(myST != NULL && psMemCheckSphereRot(myST), 88 "psSphereRotAlloc: return allocated SphereRot for valid inputs."); 89 is_double(q0, myST->q0, "psSphereRotAlloc: return correct q0 value."); 90 is_double(q1, myST->q1, "psSphereRotAlloc: return correct q1 value."); 91 is_double(q2, myST->q2, "psSphereRotAlloc: return correct q2 value."); 92 is_double(q3, myST->q3, "psSphereRotAlloc: return correct q3 value."); 93 psFree(myST); 94 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 95 } 96 97 98 // ---------------------------------------------------------------- 88 99 //Tests for psMemCheckSphereRot 89 100 //Make sure psMemCheckSphereRot works correctly - return false 90 { 101 //for non-psSphereRot input 102 { 103 psMemId id = psMemGetId(); 91 104 int j = 2; 92 ok( !psMemCheckSphereRot(&j), 93 "psMemCheckSphereRot: return false for non-SphereRot input."); 94 } 105 ok( !psMemCheckSphereRot(&j), "psMemCheckSphereRot: return false for non-SphereRot input."); 106 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 107 } 108 109 110 // ---------------------------------------------------------------- 95 111 //Tests for psSphereRotQuat 96 //Return NULL for NAN input 97 { 112 //Return NULL for NAN input q0 113 { 114 psMemId id = psMemGetId(); 115 psSphereRot *s1 = psSphereRotQuat(NAN, q1, q2, q3); 116 ok( s1 == NULL, "psSphereRotQuat: return NULL for NAN input q0"); 117 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 118 } 119 120 121 //Return NULL for NAN input q1 122 { 123 psMemId id = psMemGetId(); 124 psSphereRot *s1 = psSphereRotQuat(q0, NAN, q2, q3); 125 ok( s1 == NULL, "psSphereRotQuat: return NULL for NAN input q1"); 126 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 127 } 128 129 130 //Return NULL for NAN input q2 131 { 132 psMemId id = psMemGetId(); 133 psSphereRot *s1 = psSphereRotQuat(q0, q1, NAN, q3); 134 ok( s1 == NULL, "psSphereRotQuat: return NULL for NAN input q2"); 135 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 136 } 137 138 139 //Return NULL for NAN input q3 140 { 141 psMemId id = psMemGetId(); 98 142 psSphereRot *s1 = psSphereRotQuat(q0, q1, q2, NAN); 99 ok( s1 == NULL, 100 "psSphereRotQuat: return NULL for NAN input."); 101 } 143 ok( s1 == NULL, "psSphereRotQuat: return NULL for NAN input q3"); 144 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 145 } 146 147 102 148 //Return valid psSphereRot (allocated) for valid inputs 103 psFree(myST); 104 myST = NULL; 105 myST = psSphereRotQuat(q0*2.0, q1*2.0, q2*2.0, q3*2.0); 106 { 149 psSphereRot* myST = psSphereRotQuat(q0*2.0, q1*2.0, q2*2.0, q3*2.0); 150 { 151 psMemId id = psMemGetId(); 107 152 ok( myST != NULL && psMemCheckSphereRot(myST), 108 "psSphereRotQuat: return allocated SphereRot for valid inputs."); 109 is_double(q0, myST->q0, 110 "psSphereRotQuat: return correct q0 value."); 111 is_double(q1, myST->q1, 112 "psSphereRotQuat: return correct q1 value."); 113 is_double(q2, myST->q2, 114 "psSphereRotQuat: return correct q2 value."); 115 is_double(q3, myST->q3, 116 "psSphereRotQuat: return correct q3 value."); 117 } 118 119 120 //Check for Memory leaks 121 { 122 psFree(myST); 123 checkMem(); 124 } 125 153 "psSphereRotQuat: return allocated SphereRot for valid inputs."); 154 is_double(q0, myST->q0, "psSphereRotQuat: return correct q0 value."); 155 is_double(q1, myST->q1, "psSphereRotQuat: return correct q1 value."); 156 is_double(q2, myST->q2, "psSphereRotQuat: return correct q2 value."); 157 is_double(q3, myST->q3, "psSphereRotQuat: return correct q3 value."); 158 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 159 } 126 160 } 161 127 162 128 163 void testSphereRotConvert(void) 129 164 { 130 // diag(" >>>Test 2: psSphereRot Conversion Functions");131 132 165 // Allocate data structure 133 166 psSphereRot* myST = NULL; … … 147 180 icrs->d = DEG_TO_RAD(90.0); 148 181 182 183 // --------------------------------------------------------- 149 184 //Tests for psSphereRotCombine 150 185 //Return NULL for NULL sphere input 151 186 { 187 psMemId id = psMemGetId(); 152 188 s1 = psSphereRotCombine(s1, myST, NULL); 153 ok( s1 == NULL, 154 "psSphereRotCombine: return NULL for NULL input."); 155 } 189 ok( s1 == NULL, "psSphereRotCombine: return NULL for NULL input."); 190 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 191 } 192 193 156 194 //Return NULL for NULL transform input 157 195 { 196 psMemId id = psMemGetId(); 158 197 s1 = psSphereRotCombine(s1, NULL, myST); 159 ok( s1 == NULL, 160 "psSphereRotCombine: return NULL for NULL input."); 161 } 198 ok( s1 == NULL, "psSphereRotCombine: return NULL for NULL input."); 199 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 200 } 201 // XXX: Must test with legitimate input data. 202 203 204 // --------------------------------------------------------- 162 205 //Tests for psSphereRotApply 163 206 //Return NULL for NULL sphere input 164 207 { 208 psMemId id = psMemGetId(); 165 209 out = psSphereRotApply(out, myST, NULL); 166 ok( out == NULL, 167 "psSphereRotApply: return NULL for NULL sphere input."); 168 } 210 ok( out == NULL, "psSphereRotApply: return NULL for NULL sphere input."); 211 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 212 } 213 214 169 215 //Return NULL for NULL transform input 170 216 { 217 psMemId id = psMemGetId(); 171 218 out = psSphereRotApply(out, NULL, sphere); 172 ok( out == NULL, 173 "psSphereRotApply: return NULL for NULL transform input."); 174 } 175 219 ok( out == NULL, "psSphereRotApply: return NULL for NULL transform input."); 220 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 221 } 222 223 224 // --------------------------------------------------------- 176 225 //Tests for psSphereRotConjugate 177 226 //Return NULL for NULL inputs 178 227 { 228 psMemId id = psMemGetId(); 179 229 s1 = psSphereRotConjugate(s1, NULL); 180 ok( s1 == NULL,181 "psSphereRotConjugate: return NULL SphereRot for NULL inputs.");230 ok(s1 == NULL, "psSphereRotConjugate: return NULL SphereRot for NULL inputs"); 231 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 182 232 } 183 233 //Return correct conjugate for valid inputs 184 234 { 235 psMemId id = psMemGetId(); 185 236 s1 = psSphereRotConjugate(s1, myST); 186 skip_start( s1 == NULL, 1, 187 "Skipping 1 tests because psSphereRot is NULL!"); 237 skip_start(s1 == NULL, 1, "Skipping 1 tests because psSphereRot is NULL!"); 188 238 out = psSphereRotApply(out, myST, sphere); 189 skip_start( out == NULL || out->r == 0, 2,190 "Skipping 1 tests because psSphereRotApply failed!");239 skip_start(out == NULL || out->r == 0, 2, 240 "Skipping 1 tests because psSphereRotApply failed!"); 191 241 out2 = psSphereRotApply(out2, s1, out); 192 is_double( out2->r, 0.0, 193 "psSphereRotConjugate: return correct SphereRot values."); 194 is_double( out2->d, 0.0, 195 "psSphereRotConjugate: return correct SphereRot values."); 242 is_double( out2->r, 0.0, "psSphereRotConjugate: return correct SphereRot values."); 243 is_double( out2->d, 0.0, "psSphereRotConjugate: return correct SphereRot values."); 196 244 skip_end(); 197 245 psFree(s1); … … 202 250 out2 = NULL; 203 251 skip_end(); 204 } 252 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 253 } 254 255 256 // --------------------------------------------------------- 205 257 //Tests for psSphereRotInvert 206 258 //Return correct inversion for valid inputs 207 259 { 260 psMemId id = psMemGetId(); 208 261 s1 = psSphereRotInvert(-PHI_P, -DELTA_P, -ALPHA_P); 209 is_double(s1->q0, myST->q0, 210 "psSphereRotInvert: return correct q0 value."); 211 is_double(s1->q1, myST->q1, 212 "psSphereRotInvert: return correct q1 value."); 213 is_double(s1->q2, myST->q2, 214 "psSphereRotInvert: return correct q2 value."); 215 is_double(s1->q3, myST->q3, 216 "psSphereRotInvert: return correct q3 value."); 262 is_double(s1->q0, myST->q0, "psSphereRotInvert: return correct q0 value."); 263 is_double(s1->q1, myST->q1, "psSphereRotInvert: return correct q1 value."); 264 is_double(s1->q2, myST->q2, "psSphereRotInvert: return correct q2 value."); 265 is_double(s1->q3, myST->q3, "psSphereRotInvert: return correct q3 value."); 217 266 psFree(s1); 218 267 s1 = NULL; 219 } 220 268 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 269 } 270 271 272 // --------------------------------------------------------- 221 273 //Tests for psSphereRotICRSToEcliptic 222 274 //Return NULL for NULL input 223 275 { 276 psMemId id = psMemGetId(); 224 277 s1 = psSphereRotICRSToEcliptic(NULL); 225 ok( s1 == NULL, 226 "psSphereRotICRSToEcliptic: return NULL SphereRot for NULL inputs."); 227 } 278 ok( s1 == NULL, "psSphereRotICRSToEcliptic: return NULL SphereRot for NULL inputs."); 279 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 280 } 281 282 228 283 //Return NULL for Pre-MJD_1900 Date 229 284 { 285 psMemId id = psMemGetId(); 230 286 s1 = psSphereRotICRSToEcliptic(pre1900); 231 ok( s1 == NULL, 232 "psSphereRotICRSToEcliptic: return NULL SphereRot for pre-1900 MJD date."); 233 } 287 ok( s1 == NULL, "psSphereRotICRSToEcliptic: return NULL SphereRot for pre-1900 MJD date."); 288 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 289 } 290 291 234 292 //Return correct SphereRot for MJD_2000 235 293 { 294 psMemId id = psMemGetId(); 236 295 s1 = psSphereRotICRSToEcliptic(mjd2k); 237 skip_start( s1 == NULL, 2, 238 "Skipping 2 tests because psSphereRot is NULL!"); 296 skip_start( s1 == NULL, 2, "Skipping 2 tests because psSphereRot is NULL!"); 239 297 icrs->r = DEG_TO_RAD(0.0); 240 298 icrs->d = DEG_TO_RAD(90.0); 241 299 psSphere* ecliptic = psSphereRotApply(NULL, s1, icrs); 242 300 is_double_tol(DEG_TO_RAD(90.0), ecliptic->r, 0.00001, 243 "psSphereRotICRSToEcliptic: return correct SphereRot for MJD_2000 date.");301 "psSphereRotICRSToEcliptic: return correct SphereRot for MJD_2000 date."); 244 302 is_double_tol(DEG_TO_RAD(66.560719), ecliptic->d, 0.00001, 245 "psSphereRotICRSToEcliptic: return correct SphereRot for MJD_2000 date.");303 "psSphereRotICRSToEcliptic: return correct SphereRot for MJD_2000 date."); 246 304 psFree(ecliptic); 247 305 skip_end(); 248 306 psFree(s1); 249 307 s1 = NULL; 250 } 308 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 309 } 310 311 312 // -------------------------------------------------------------- 251 313 //Tests for psSphereRotEclipticToICRS 252 314 //Return NULL for NULL input 253 315 { 316 psMemId id = psMemGetId(); 254 317 s1 = psSphereRotEclipticToICRS(NULL); 255 ok( s1 == NULL, 256 "psSphereRotEclipticToICRS: return NULL SphereRot for NULL inputs."); 257 } 318 ok( s1 == NULL, "psSphereRotEclipticToICRS: return NULL SphereRot for NULL inputs."); 319 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 320 } 321 322 258 323 //Return NULL for Pre-MJD_1900 Date 259 324 { 325 psMemId id = psMemGetId(); 260 326 s1 = psSphereRotEclipticToICRS(pre1900); 261 ok( s1 == NULL, 262 "psSphereRotEclipticToICRS: return NULL SphereRot for pre-1900 MJD date."); 263 } 327 ok( s1 == NULL, "psSphereRotEclipticToICRS: return NULL SphereRot for pre-1900 MJD date."); 328 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 329 } 330 331 264 332 //Return correct SphereRot for MJD_2000 265 333 { 334 psMemId id = psMemGetId(); 266 335 s1 = psSphereRotEclipticToICRS(mjd2k); 267 skip_start( s1 == NULL, 2, 268 "Skipping 2 tests because psSphereRot is NULL!"); 336 skip_start( s1 == NULL, 2, "Skipping 2 tests because psSphereRot is NULL!"); 269 337 psSphere* ecliptic = psSphereRotApply(NULL, s1, icrs); 270 338 s2 = psSphereRotICRSToEcliptic(mjd2k); … … 272 340 //XXX: Pretty sure the following can be 180 degrees OR 0 degrees. (= the poles) 273 341 is_double_tol(DEG_TO_RAD(180.0), fromEcliptic->r, 0.00001, 274 "psSphereRotEclipticToICRS: return correct SphereRot for MJD_2000 date.");342 "psSphereRotEclipticToICRS: return correct SphereRot for MJD_2000 date."); 275 343 is_double_tol(DEG_TO_RAD(90.0), fromEcliptic->d, 0.00001, 276 "psSphereRotEclipticToICRS: return correct SphereRot for MJD_2000 date.");344 "psSphereRotEclipticToICRS: return correct SphereRot for MJD_2000 date."); 277 345 psFree(ecliptic); 278 346 psFree(fromEcliptic); … … 282 350 psFree(s2); 283 351 s2 = NULL; 284 } 285 352 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 353 } 354 355 356 // -------------------------------------------------------------- 286 357 //Tests for psSphereRotICRSToGalactic 287 358 //Return correct transformation 288 359 { 360 psMemId id = psMemGetId(); 289 361 s2 = psSphereRotICRSToGalactic(); 290 362 galactic = psSphereRotApply(NULL, s2, icrs); 291 363 is_double_tol(DEG_TO_RAD(122.93192), galactic->r, 0.00001, 292 "psSphereRotICRSToGalactic: return correct SphereRot.");364 "psSphereRotICRSToGalactic: return correct SphereRot."); 293 365 is_double_tol(DEG_TO_RAD(27.12825), galactic->d, 0.00001, 294 "psSphereRotICRSToGalactic: return correct SphereRot."); 295 } 366 "psSphereRotICRSToGalactic: return correct SphereRot."); 367 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 368 } 369 370 371 // -------------------------------------------------------------- 296 372 //Tests for psSphereRotGalacticToICRS 297 373 //Return correct transformation 298 374 { 375 psMemId id = psMemGetId(); 299 376 s1 = psSphereRotGalacticToICRS(); 300 377 psSphere *test = psSphereRotApply(NULL, s1, galactic); 301 //XXX: Pretty sure the following can be 180 degrees OR 0 degrees. (= the poles)378 //XXX: Pretty sure the following can be 180 degrees OR 0 degrees. (= the poles) 302 379 is_double_tol(DEG_TO_RAD(180.0), test->r, 0.00001, 303 "psSphereRotGalacticToICRS: return correct SphereRot.");380 "psSphereRotGalacticToICRS: return correct SphereRot."); 304 381 is_double_tol(DEG_TO_RAD(90.0), test->d, 0.00001, 305 "psSphereRotGalacticToICRS: return correct SphereRot.");382 "psSphereRotGalacticToICRS: return correct SphereRot."); 306 383 psFree(test); 307 }308 309 //Check for Memory leaks 384 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 385 } 386 310 387 { 311 388 psFree(galactic); … … 317 394 psFree(sphere); 318 395 psFree(myST); 319 checkMem();320 396 } 321 397 322 398 } 399 323 400 324 401 void testSphereOffsets(void) 325 402 { 326 // diag(" >>>Test 3: psSphereGet/SetOffset Functions");327 328 // Allocate data structure329 403 psSphereRot* myST = NULL; 330 404 myST = psSphereRotAlloc(ALPHA_P, DELTA_P, PHI_P); … … 335 409 psSphere *output = NULL; 336 410 411 // ----------------------------------------------------------- 337 412 //Tests for psSphereGetOffset 338 413 //Test Get for NULL position1 339 414 { 340 415 output = psSphereGetOffset(empty, origin, PS_LINEAR, PS_RADIAN); 341 ok( output == NULL, 342 "psSphereGetOffset: return NULL for NULL position1 input."); 343 } 416 ok( output == NULL, "psSphereGetOffset: return NULL for NULL position1 input."); 417 } 418 419 344 420 //Test Get for NULL position2 345 421 { 346 422 output = psSphereGetOffset(origin, empty, PS_LINEAR, PS_RADIAN); 347 ok( output == NULL, 348 "psSphereGetOffset: return NULL for NULL position2 input."); 349 } 423 ok( output == NULL, "psSphereGetOffset: return NULL for NULL position2 input."); 424 } 425 426 350 427 //Return NULL for position1 declination > 90 degrees 351 428 { 352 429 origin->d = 100.0; 353 430 output = psSphereGetOffset(origin, offset, PS_LINEAR, PS_RADIAN); 354 ok( output == NULL, 355 "psSphereGetOffset: return NULL for position1->d > 90 degrees."); 356 } 431 ok( output == NULL, "psSphereGetOffset: return NULL for position1->d > 90 degrees."); 432 } 433 434 357 435 //Return NULL for position1 declination > 90 degrees 358 436 { … … 360 438 offset->d = 100.0; 361 439 output = psSphereGetOffset(origin, offset, PS_LINEAR, PS_RADIAN); 362 ok( output == NULL, 363 "psSphereGetOffset: return NULL for position2->d > 90 degrees."); 364 } 440 ok( output == NULL, "psSphereGetOffset: return NULL for position2->d > 90 degrees."); 441 } 442 443 365 444 //Return NULL for invalid mode specification 366 445 { 367 446 offset->d = 0.0; 368 447 output = psSphereGetOffset(origin, offset, -1, PS_RADIAN); 369 ok( output == NULL, 370 "psSphereGetOffset: return NULL for invalid mode input."); 371 } 448 ok( output == NULL, "psSphereGetOffset: return NULL for invalid mode input."); 449 } 450 451 372 452 //Return NULL for invalid unit specification 373 453 { 374 454 output = psSphereGetOffset(origin, offset, PS_SPHERICAL, -1); 375 ok( output == NULL, 376 "psSphereGetOffset: return NULL for invalid unit input."); 455 ok( output == NULL, "psSphereGetOffset: return NULL for invalid unit input."); 377 456 } 378 457 //Return matching sphere offsets regardless of units … … 383 462 empty = psSphereGetOffset(origin, offset, PS_SPHERICAL, PS_DEGREE); 384 463 is_double_tol(DEG_TO_RAD(empty->r), MIN_TO_RAD(output->r), 0.0001, 385 "psSphereGetOffset: return correct offset for differing units.");464 "psSphereGetOffset: return correct offset for differing units."); 386 465 is_double_tol(DEG_TO_RAD(empty->d), MIN_TO_RAD(output->d), 0.0001, 387 "psSphereGetOffset: return correct offset for differing units.");466 "psSphereGetOffset: return correct offset for differing units."); 388 467 psFree(output); 389 468 psFree(empty); … … 396 475 { 397 476 output = psSphereSetOffset(empty, offset, PS_SPHERICAL, PS_DEGREE); 398 ok( output == NULL, 399 "psSphereSetOffset: return NULL for NULL position input."); 477 ok( output == NULL, "psSphereSetOffset: return NULL for NULL position input."); 400 478 } 401 479 //Return NULL for NULL offset 402 480 { 403 481 output = psSphereSetOffset(offset, empty, PS_SPHERICAL, PS_DEGREE); 404 ok( output == NULL, 405 "psSphereSetOffset: return NULL for NULL offset input."); 482 ok( output == NULL, "psSphereSetOffset: return NULL for NULL offset input."); 406 483 } 407 484 //Return NULL for invalid mode specification 408 485 { 409 486 output = psSphereSetOffset(origin, offset, -1, PS_RADIAN); 410 ok( output == NULL, 411 "psSphereSetOffset: return NULL for for invalid mode input."); 487 ok( output == NULL, "psSphereSetOffset: return NULL for for invalid mode input."); 412 488 } 413 489 //Return NULL for invalid unit specification 414 490 { 415 491 output = psSphereSetOffset(origin, offset, PS_SPHERICAL, PS_RADIAN+1); 416 ok( output == NULL, 417 "psSphereSetOffset: return NULL for for invalid unit input."); 492 ok( output == NULL, "psSphereSetOffset: return NULL for for invalid unit input."); 418 493 } 419 494 //Test Set using Spherical mode, Degree units … … 424 499 { 425 500 output = psSphereSetOffset(origin, offset, PS_SPHERICAL, PS_DEGREE); 426 skip_start( output == NULL, 2, 427 "Skipping 2 tests because Sphere output is NULL!"); 428 is_double(output->r, M_PI/4.0, 429 "psSphereSetOffset: return correct spherical offset."); 430 is_double(output->d, M_PI/6.0, 431 "psSphereSetOffset: return correct spherical offset."); 501 skip_start(output == NULL, 2, "Skipping 2 tests because Sphere output is NULL!"); 502 is_double(output->r, M_PI/4.0, "psSphereSetOffset: return correct spherical offset."); 503 is_double(output->d, M_PI/6.0, "psSphereSetOffset: return correct spherical offset."); 432 504 skip_end(); 433 505 psFree(output); … … 441 513 output = psSphereSetOffset(origin, offset, PS_LINEAR, PS_RADIAN); 442 514 empty = psSphereGetOffset(origin, output, PS_LINEAR, PS_RADIAN); 443 skip_start( empty == NULL, 2, 444 "Skipping 2 tests because Sphere output is NULL!"); 515 skip_start(empty == NULL, 2, "Skipping 2 tests because Sphere output is NULL!"); 445 516 is_double_tol(empty->r, offset->r, 0.00001, 446 "psSphereGetOffset: return correct spherical offset.");517 "psSphereGetOffset: return correct spherical offset."); 447 518 is_double_tol(empty->d, offset->d, 0.00001, 448 "psSphereGetOffset: return correct spherical offset.");519 "psSphereGetOffset: return correct spherical offset."); 449 520 skip_end(); 450 521 psFree(output); … … 462 533 empty->r = SEC_TO_RAD(empty->r); 463 534 empty->d = SEC_TO_RAD(empty->d); 464 skip_start( empty == NULL, 2, 465 "Skipping 2 tests because Sphere output is NULL!"); 535 skip_start(empty == NULL, 2, "Skipping 2 tests because Sphere output is NULL!"); 466 536 is_double_tol(empty->r, (M_PI / 4.0), 0.0001, 467 "psSphereGetOffset: return correct spherical offset.");537 "psSphereGetOffset: return correct spherical offset."); 468 538 is_double_tol(empty->d, (M_PI / 6.0), 0.0001, 469 "psSphereGetOffset: return correct spherical offset.");539 "psSphereGetOffset: return correct spherical offset."); 470 540 skip_end(); 471 541 psFree(output); … … 481 551 empty = psSphereSetOffset(origin, offset, PS_SPHERICAL, PS_RADIAN); 482 552 is_double_tol(empty->r, offset->r, 0.0001, 483 "psSphereSetOffset: return correct offset for differing units.");553 "psSphereSetOffset: return correct offset for differing units."); 484 554 is_double_tol(empty->d, offset->d, 0.0001, 485 "psSphereSetOffset: return correct offset for differing units.");555 "psSphereSetOffset: return correct offset for differing units."); 486 556 psFree(output); 487 557 psFree(empty); … … 496 566 } 497 567 } 498 -
trunk/psLib/test/astro/tap_psTime_01.c
r13614 r13623 23 23 * @author Eric Van Alst, MHPCC 24 24 * 25 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $26 * @date $Date: 2007-06-0 4 20:25:32 $25 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 26 * @date $Date: 2007-06-05 01:10:22 $ 27 27 * 28 28 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 709 709 710 710 // psTimeFromISO() 711 // Convert valid ISO string 712 { 713 psMemId id = psMemGetId(); 714 psTime *time = psTimeFromISO(testTime1Str, PS_TIME_TAI); 715 ok(time->type == PS_TIME_TAI, "psTimeFromISO() returned the correct type"); 716 is_long(time->sec, testTime1SecondsUTC, "psTimeFromISO()->sec"); 717 psFree(time); 718 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 719 } 720 721 722 // psTimeFromISO() 711 723 // Attempt to convert NULL string 712 724 // Following should generate error message for NULL ISO string"); … … 714 726 psMemId id = psMemGetId(); 715 727 psTime *time = psTimeFromISO(NULL, PS_TIME_TAI); 716 717 728 ok(time == NULL, "psTimeFromISO(NULL, PS_TIME_TAI) returned NULL"); 718 719 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");720 }721 722 723 // psTimeFromISO()724 // Convert valid ISO string725 {726 psMemId id = psMemGetId();727 psTime *time = psTimeFromISO(testTime1Str, PS_TIME_TAI);728 729 ok(time->type == PS_TIME_TAI, "psTimeFromISO() returned the correct type");730 is_long(time->sec, testTime1SecondsUTC, "psTimeFromISO()->sec");731 732 psFree(time);733 729 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 734 730 } … … 742 738 psMemId id = psMemGetId(); 743 739 psTime *time = psTimeFromISO("Here I am", PS_TIME_TAI); 744 745 740 ok(time == NULL, "psTimeFromISO() returned NULL for incorrect ISO string"); 746 747 741 psFree(time); 748 742 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 757 751 psMemId id = psMemGetId(); 758 752 psTime *time = psTimeFromTimeval(NULL); 759 760 753 ok(time == NULL, "psTimeFromTimeval(NULL) returned NULL"); 761 762 754 psFree(time); 763 755 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 773 765 timevalTime->tv_usec = testTime1NanosecondsTAI / 1000; 774 766 psTime *time = psTimeFromTimeval(timevalTime); 775 776 ok(time != NULL, "psTimeFromTimeval() returned NULL for correct timeval structure"); 767 ok(time != NULL, "psTimeFromTimeval() returned non-NULL for correct timeval structure"); 777 768 skip_start(time == NULL, 3, "Skipping tests because psTimeFromTimeval() returned NULL"); 778 769 ok(time->type == PS_TIME_TAI, "psTimeFromTimeval() returned the correct type"); … … 780 771 is_long(time->nsec, testTime1NanosecondsTAI, "psTimeFromTimeval() returned the correct ->nsec"); 781 772 skip_end(); 782 783 773 psFree(timevalTime); 784 774 psFree(time); … … 794 784 psMemId id = psMemGetId(); 795 785 psTime *time = psTimeFromTM(NULL); 796 797 786 ok(time == NULL, "psTimeFromTM(NULL) returned NULL"); 798 799 787 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 800 788 } … … 802 790 803 791 // psTimeFromTM() 804 {805 psMemId id = psMemGetId();806 // Verify convert for valid tm structure792 // Verify convert for valid tm structure 793 { 794 psMemId id = psMemGetId(); 807 795 struct tm *tmTime = (struct tm*)psAlloc(sizeof(struct tm)); 808 796 tmTime->tm_year = testTime7TmYear; … … 813 801 tmTime->tm_sec = testTime7TmSec; 814 802 psTime *time = psTimeFromTM(tmTime); 815 816 803 ok(time != NULL, "psTimeFromTM(NULL) returned non-NULL"); 817 804 skip_start(time == NULL, 2, "Skipping tests because psTimeFromTM() returned NULL"); … … 819 806 is_long(time->nsec, testTime7Nanoseconds, "psTimeFromTM() returned the correct ->nsec"); 820 807 skip_end(); 821 822 808 psFree(tmTime); 823 809 psFree(time); … … 838 824 tmTime->tm_sec = testTime8TmSec; 839 825 psTime *time = psTimeFromTM(tmTime); 840 841 826 // XXX should test all fields here 842 827 ok(time != NULL, "psTimeFromTM(NULL) returned non-NULL"); … … 845 830 is_long(time->nsec, testTime8Nanoseconds, "psTimeFromTM() returned the correct ->nsec"); 846 831 skip_end(); 847 848 832 psFree(tmTime); 849 833 psFree(time); -
trunk/psLib/test/astro/tap_psTime_02.c
r13614 r13623 12 12 * @author Eric Van Alst, MHPCC 13 13 * 14 * @version $Revision: 1. 5$ $Name: not supported by cvs2svn $15 * @date $Date: 2007-06-0 4 20:25:32 $14 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2007-06-05 01:10:22 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 332 332 { 333 333 psMemId id = psMemGetId(); 334 335 334 psTime *time = psTimeFromTT(0,2e9); 336 335 ok(time == NULL, "psTimeFromTT() returned NULL with incorrect time"); 337 338 336 psFree(time); 339 337 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 345 343 { 346 344 psMemId id = psMemGetId(); 347 348 345 psTime *time = psTimeFromTT(testTime1SecondsUTC,testTime1NanosecondsUTC); 349 346 ok(time != NULL, "psTimeFromTT() returned non-NULL with valid time"); 350 347 skip_start(time == NULL, 2, "Skipping tests because psTimeFromTT() returned NULL"); 351 352 348 ok(time->type == PS_TIME_TT, "psTimeFromTT() returned correct type"); 353 349 is_long(time->sec, testTime1SecondsUTC, "psTimeFromTT() returned correct ->sec"); 354 350 is_long(time->nsec, testTime1NanosecondsUTC, "psTimeFromTT() returned correct ->nsec"); 355 is_bool(time->leapsecond, false, "psTimeFrom UTC() returned the correct leapsecond flag");351 is_bool(time->leapsecond, false, "psTimeFromTT() returned the correct leapsecond flag"); 356 352 skip_end(); 357 358 353 psFree(time); 359 354 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); … … 367 362 { 368 363 psMemId id = psMemGetId(); 369 370 364 psTime *time = psTimeFromUTC(0, 2e9, true); 371 365 ok(time == NULL, "psTimeFromUTC() returned NULL with incorrect time input"); 372 373 366 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 374 367 } … … 376 369 377 370 // psTimeFromUTC() 378 // Attempt to create psTime with valid non-leapsecond time and leapsecond flag true 371 // Attempt to create psTime with valid leapsecond time but leapsecond 372 // flag false 373 { 374 psMemId id = psMemGetId(); 375 376 psTime *time = psTimeFromUTC(testTime3SecondsUTC, testTime3NanosecondsUTC, false); 377 ok(time != NULL, "psTimeFromUTC() returned non-NULL with correct input"); 378 skip_start(time == NULL, 5, "Skipping tests because psTimeFromUTC() returned NULL"); 379 ok(time->type == PS_TIME_UTC, "psTimeFromUTC() returned the correct type"); 380 is_long(time->sec, testTime3SecondsUTC, "psTimeFromUTC() returned the correct ->sec"); 381 is_long(time->nsec, testTime3NanosecondsUTC, "psTimeFromUTC() returned the correct ->nsec"); 382 is_bool(time->leapsecond, true, "psTimeFromUTC() returned the correct leapsecond flag"); 383 psFree(time); 384 skip_end(); 385 386 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 387 } 388 389 390 // psTimeFromUTC() 391 // Attempt to create psTime with valid non-leapsecond time and 392 // leapsecond flag true 379 393 { 380 394 psMemId id = psMemGetId(); … … 391 405 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 392 406 } 393 394 395 // psTimeFromUTC()396 // Attempt to create psTime with valid leapsecond time but leapsecond flag false397 {398 psMemId id = psMemGetId();399 400 psTime *time = psTimeFromUTC(testTime3SecondsUTC, testTime3NanosecondsUTC, false);401 ok(time != NULL, "psTimeFromUTC() returned non-NULL with correct input");402 skip_start(time == NULL, 5, "Skipping tests because psTimeFromUTC() returned NULL");403 ok(time->type == PS_TIME_UTC, "psTimeFromUTC() returned the correct type");404 is_long(time->sec, testTime3SecondsUTC, "psTimeFromUTC() returned the correct ->sec");405 is_long(time->nsec, testTime3NanosecondsUTC, "psTimeFromUTC() returned the correct ->nsec");406 is_bool(time->leapsecond, true, "psTimeFromUTC() returned the correct leapsecond flag");407 psFree(time);408 skip_end();409 410 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");411 }412 407 } -
trunk/psLib/test/astro/tap_psTime_03.c
r12607 r13623 11 11 * @author Eric Van Alst, MHPCC 12 12 * 13 * @version $Revision: 1. 5$ $Name: not supported by cvs2svn $14 * @date $Date: 2007-0 3-27 22:52:02 $13 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2007-06-05 01:10:22 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 179 179 psLibInit("pslib.config"); 180 180 181 181 182 // psTimeMath() 182 183 // Attempt to perform math operation on NULL time … … 185 186 { 186 187 psMemId id = psMemGetId(); 187 188 188 ok(psTimeMath(NULL, -1.1) == NULL, "psTimeMath(NULL, -1.1) returned NULL"); 189 190 189 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 191 190 } … … 201 200 time->sec = 0; 202 201 time->nsec = 2e9; 203 204 202 ok(psTimeMath(time, -1.1) == NULL, "psTimeMath() returns NULL for unallowable time input"); 205 206 203 ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); 207 204 } … … 215 212 time->sec = testTime1SecondsUTC; 216 213 time->nsec = testTime1NanosecondsUTC; 217 218 214 psTime *newTime = psTimeMath(time, deltaTime1); 219 215 ok(newTime != NULL, "psTimeMath() returns non-NULL for allowable time input (PS_TIME_UTC)"); … … 223 219 is_long(newTime->nsec, newTestTime1NanosecondsUTC, "psTimeMath() returns the correct ->nsec"); 224 220 skip_end(); 225 226 221 psFree(newTime); 227 222 psFree(time);
Note:
See TracChangeset
for help on using the changeset viewer.
