IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 2, 2008, 10:45:23 AM (18 years ago)
Author:
gusciora
Message:

Significant changes and additions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/test/objects/tap_pmPSF.c

    r15726 r15985  
    2424#define VERBOSE                 0
    2525#define ERR_TRACE_LEVEL         10
    26 #define TEST_FLOATS_EQUAL(X, Y) (abs(X - Y) < 0.0001)
     26#define TEST_FLOATS_EQUAL(X, Y) (abs((X) - (Y)) < 0.0001)
    2727
    2828int main(int argc, char* argv[])
     
    3131    psLogSetLevel(PS_LOG_INFO);
    3232    psTraceSetLevel("err", ERR_TRACE_LEVEL);
    33     plan_tests(15);
     33    plan_tests(83);
    3434
    3535    // ----------------------------------------------------------------------
     
    131131    // ----------------------------------------------------------------------
    132132    // pmPSF_SXYfromModel() tests
    133     // double pmPSF_SXYfromModel (psF32 *modelPar)
    134133    // Call pmPSF_SXYfromModel() with NULL input parameters
    135134    {
     
    160159    // ----------------------------------------------------------------------
    161160    // pmPSF_SXYtoModel() tests
    162     // double pmPSF_SXYtoModel (psF32 *modelPar)
    163161    // Call pmPSF_SXYtoModel() with NULL input parameters
    164162    {
     
    187185
    188186
     187    // ----------------------------------------------------------------------
     188    // pmPSF_FitToModel() tests
     189    // Call pmPSF_FitToModel() with NULL input parameters
     190    {
     191        psMemId id = psMemGetId();
     192        bool rc = pmPSF_FitToModel(NULL, 0.0);
     193        ok(rc == false, "pmPSF_FitToModel() returned NULL with NULL input parameters");
     194        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     195    }
     196
     197
     198    // Call pmPSF_FitToModel() with NULL input parameters
     199    {
     200        #define MIN_MINOR_AXIS 1.0
     201        psMemId id = psMemGetId();
     202        psF32 origFittedPar[3], testFittedPar[3];
     203        psEllipsePol pol;
     204        pol.e0 = origFittedPar[PM_PAR_E0] = testFittedPar[PM_PAR_E0] = 2.0;
     205        pol.e1 = origFittedPar[PM_PAR_E1] = testFittedPar[PM_PAR_E1] = 3.0;
     206        pol.e2 = origFittedPar[PM_PAR_E2] = testFittedPar[PM_PAR_E2] = 5.0;
     207        ok(pmPSF_FitToModel(testFittedPar, MIN_MINOR_AXIS), "pmPSF_FitToModel() returned TRUE with acceptable input parameters");
     208
     209        psEllipseAxes axes;
     210        psEllipsePolToAxes(pol, MIN_MINOR_AXIS, &axes);
     211        psEllipseShape shape = psEllipseAxesToShape(axes);
     212
     213        ok(TEST_FLOATS_EQUAL(testFittedPar[PM_PAR_SXX], shape.sx * M_SQRT2),
     214          "pmPSF_FitToModel() set fittedPar[PM_PAR_SXX] correctly");
     215        ok(TEST_FLOATS_EQUAL(testFittedPar[PM_PAR_SYY], shape.sy * M_SQRT2),
     216          "pmPSF_FitToModel() set fittedPar[PM_PAR_SYY] correctly");
     217        ok(TEST_FLOATS_EQUAL(testFittedPar[PM_PAR_SXY], shape.sxy),
     218          "pmPSF_FitToModel() set fittedPar[PM_PAR_SXY] correctly");
     219        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     220    }
     221
     222
     223    // ----------------------------------------------------------------------
     224    // pmPSF_ModelToFit() tests
     225    // psEllipsePol pmPSF_ModelToFit (psF32 *modelPar)
     226    // Call pmPSF_ModelToFit() with NULL input parameters
     227    {
     228        psMemId id = psMemGetId();
     229        psEllipsePol pol = pmPSF_ModelToFit(NULL);
     230        ok(isnan(pol.e0), "pmPSF_ModelToFit() returned NULL (psEllipsePol) with NULL input parameters");
     231        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     232    }
     233
     234
     235    // Call pmPSF_ModelToFit() with NULL input parameters
     236    {
     237        #define MIN_MINOR_AXIS 1.0
     238        psMemId id = psMemGetId();
     239        psF32 modelPar[3];
     240        modelPar[PM_PAR_SXX] = 2.0;
     241        modelPar[PM_PAR_SYY] = 3.0;
     242        modelPar[PM_PAR_SXY] = 5.0;
     243
     244        psEllipsePol pol = pmPSF_ModelToFit(modelPar);
     245        ok(!isnan(pol.e0), "pmPSF_ModelToFit() returned TRUE with acceptable input parameters");
     246
     247        psEllipseShape shape;
     248        shape.sx  = modelPar[PM_PAR_SXX] / M_SQRT2;
     249        shape.sy  = modelPar[PM_PAR_SYY] / M_SQRT2;
     250        shape.sxy = modelPar[PM_PAR_SXY];
     251        psEllipsePol actPol = psEllipseShapeToPol(shape);
     252        ok(TEST_FLOATS_EQUAL(pol.e0, actPol.e0), "pmPSF_ModelToFit() set psEllipsePol.e0 correctly");
     253        ok(TEST_FLOATS_EQUAL(pol.e1, actPol.e1), "pmPSF_ModelToFit() set psEllipsePol.e1 correctly");
     254        ok(TEST_FLOATS_EQUAL(pol.e2, actPol.e2), "pmPSF_ModelToFit() set psEllipsePol.e2 correctly");
     255
     256        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     257    }
     258
     259
     260    // ----------------------------------------------------------------------
     261    // pmPSF_ModelToAxes() tests
     262    // psEllipseAxes pmPSF_ModelToAxes (psF32 *modelPar, double maxAR)
     263    // Call pmPSF_ModelToAxes() with NULL input parameters
     264    {
     265        psMemId id = psMemGetId();
     266        psEllipseAxes axes = pmPSF_ModelToAxes(NULL, 1.0);
     267        ok(isnan(axes.major), "pmPSF_ModelToAxes() returned NULL (psEllipseAxes) with NULL input parameters");
     268        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     269    }
     270
     271
     272    // Call pmPSF_ModelToAxes() with NULL input parameters
     273    {
     274        #define MAX_AX 1.0
     275        psMemId id = psMemGetId();
     276        psF32 modelPar[3];
     277        modelPar[PM_PAR_SXX] = 2.0;
     278        modelPar[PM_PAR_SYY] = 3.0;
     279        modelPar[PM_PAR_SXY] = 5.0;
     280
     281        psEllipseShape shape;
     282        shape.sx  = modelPar[PM_PAR_SXX] / M_SQRT2;
     283        shape.sy  = modelPar[PM_PAR_SYY] / M_SQRT2;
     284        shape.sxy = modelPar[PM_PAR_SXY];
     285        psEllipseAxes axes = psEllipseShapeToAxes (shape, MAX_AX);
     286
     287        psEllipseAxes actAxes = pmPSF_ModelToAxes(modelPar, MAX_AX);
     288        ok(!isnan(actAxes.major), "pmPSF_ModelToAxes() returned TRUE with acceptable input parameters");
     289        ok(TEST_FLOATS_EQUAL(actAxes.major, axes.major), "pmPSF_ModelToAxes() set psEllipseAxes.major correctly");
     290        ok(TEST_FLOATS_EQUAL(actAxes.minor, axes.minor), "pmPSF_ModelToAxes() set psEllipseAxes.minor correctly");
     291        ok(TEST_FLOATS_EQUAL(actAxes.theta, axes.theta), "pmPSF_ModelToAxes() set psEllipseAxes.theta correctly");
     292
     293        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     294    }
     295
     296
     297    // ----------------------------------------------------------------------
     298    // pmPSF_AxesToModel() tests
     299    // bool pmPSF_AxesToModel (psF32 *modelPar, psEllipseAxes axes)
     300    // Call pmPSF_AxesToModel() with NULL input parameters
     301    {
     302        psMemId id = psMemGetId();
     303        psEllipseAxes axes;
     304        bool rc = pmPSF_AxesToModel(NULL, axes);
     305        ok(rc == false, "pmPSF_AxesToModel() returned NULL with NULL input parameters");
     306        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     307    }
     308
     309
     310    // Call pmPSF_AxesToModel() with NULL input parameters
     311    {
     312        #define MIN_MINOR_AXIS 1.0
     313        psMemId id = psMemGetId();
     314        psF32 modelPar[3];
     315        psEllipseAxes axes;
     316        axes.major = 2.0;
     317        axes.minor = 3.0;
     318        axes.theta = 5.0;
     319        ok(pmPSF_AxesToModel(modelPar, axes), "pmPSF_AxesToModel() returned TRUE with acceptable input parameters");
     320        psEllipseShape shape = psEllipseAxesToShape(axes);
     321        ok(TEST_FLOATS_EQUAL(modelPar[PM_PAR_SXX], shape.sx * M_SQRT2), "pmPSF_AxesToModel() set modelPar[PM_PAR_SXX] correctly");
     322        ok(TEST_FLOATS_EQUAL(modelPar[PM_PAR_SYY], shape.sy * M_SQRT2), "pmPSF_AxesToModel() set modelPar[PM_PAR_SYY] correctly");
     323        ok(TEST_FLOATS_EQUAL(modelPar[PM_PAR_SXY], shape.sxy), "pmPSF_AxesToModel() set modelPar[PM_PAR_SXY] correctly");
     324        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     325    }
    189326}
Note: See TracChangeset for help on using the changeset viewer.