# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl PS-MOPS-JPLEPH.t'

use strict;
use warnings;

#########################

# change 'tests => 1' to 'tests => last_test_to_print';

use Test::More tests => 6;
BEGIN { use_ok('PS::MOPS::JPLEPH') };

#########################

# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.

#$o = modco_retrieve($inst, orbitId => 5);
#$o->q(1.252);
#$o->e(.382);
#$o->i(9.3);
#$o->node(252.1);
#$o->argPeri(185.6);
#$o->timePeri(53015.0);$o->hV(10.315);
#$o->epoch(52860.0);

my %orbit = (
    q => 1.252,
    e => .382,
    i => 9.3,
    node => 252.1,
    argPeri => 185.6,
    timePeri => 53015,
    hV => 10.315,
    epoch => 52860.0,
    objectName => 'foo',
);

my %orbit_bad_q = %orbit;
$orbit_bad_q{q} = -1;     # bad

my %orbit_bad_e = %orbit;
$orbit_bad_e{e} = -1;     # bad

my %orbit_bad_i = %orbit;
$orbit_bad_i{i} = -200;    # bad

my %orbit_sungrazer = %orbit;
$orbit_sungrazer{timePeri} = 54101;       # tp near epoch
$orbit_sungrazer{q} = .001;               # very close to sun

my @inp = (
    obscode => '568',
    epoch_mjd => 54100,
    objectName => 'foo',
);

ok(defined(jpleph_calcEphemeris(@inp, orbit => \%orbit)), 'good orbit');
ok(!defined(jpleph_calcEphemeris(@inp, orbit => \%orbit_bad_q)), 'bad Q');
ok(!defined(jpleph_calcEphemeris(@inp, orbit => \%orbit_bad_e)), 'bad e');
ok(!defined(jpleph_calcEphemeris(@inp, orbit => \%orbit_bad_i)), 'bad i');
ok(defined(jpleph_calcEphemeris(@inp, orbit => \%orbit_sungrazer)), 'sungrazer');
