Skip to content

Commit

Permalink
adding construction tests for planet_keplerian
Browse files Browse the repository at this point in the history
  • Loading branch information
darioizzo committed Sep 21, 2023
1 parent cae8bf3 commit a953a91
Showing 1 changed file with 61 additions and 8 deletions.
69 changes: 61 additions & 8 deletions test/planet_keplerian_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
#include <fmt/ranges.h>

#include <kep3/core_astro/constants.hpp>
#include <kep3/detail/exceptions.hpp>
#include <kep3/planets/keplerian.hpp>
#include <stdexcept>

#include "catch.hpp"
#include "test_helpers.hpp"
Expand Down Expand Up @@ -44,23 +46,74 @@ TEST_CASE("constructor") {
// Calling constructor with different elements type
{
std::array<double, 6> par{{1., 0., 0., 0., 0., 0.}};
REQUIRE_NOTHROW(kep3::udpla::keplerian{ref_epoch, par, 1.,
"unknown", {-1, -1, -1}, kep3::elements_type::KEP_F});
REQUIRE_NOTHROW(kep3::udpla::keplerian{ref_epoch,
par,
1.,
"unknown",
{-1, -1, -1},
kep3::elements_type::KEP_F});
}
{
std::array<double, 6> par{{1., 0., 0., 0., 0., 0.}};
REQUIRE_NOTHROW(kep3::udpla::keplerian{ref_epoch, par, 1.,
"unknown", {-1, -1, -1}, kep3::elements_type::KEP_M});
REQUIRE_NOTHROW(kep3::udpla::keplerian{ref_epoch,
par,
1.,
"unknown",
{-1, -1, -1},
kep3::elements_type::KEP_M});
}
{
std::array<double, 6> par{{1., 0., 0., 1., 0., 0.}};
REQUIRE_NOTHROW(kep3::udpla::keplerian{ref_epoch, par, 1.,
"unknown", {-1, -1, -1}, kep3::elements_type::MEQ});
REQUIRE_NOTHROW(kep3::udpla::keplerian{
ref_epoch, par, 1., "unknown", {-1, -1, -1}, kep3::elements_type::MEQ});
}
{
std::array<double, 6> par{{1., 0., 0., 1., 0., 0.}};
REQUIRE_NOTHROW(kep3::udpla::keplerian{ref_epoch, par, 1.,
"unknown", {-1, -1, -1}, kep3::elements_type::MEQ_R});
REQUIRE_NOTHROW(kep3::udpla::keplerian{ref_epoch,
par,
1.,
"unknown",
{-1, -1, -1},
kep3::elements_type::MEQ_R});
}
{ // hyperbola and mean anomaly????
std::array<double, 6> par{{-10., 10., 0., 1., 0., 0.}};
REQUIRE_THROWS_AS((kep3::udpla::keplerian{ref_epoch,
par,
1.,
"unknown",
{-1, -1, -1},
kep3::elements_type::KEP_M}),
std::logic_error);
}
{ // posvel as 1x6 orbital parameters????
std::array<double, 6> par{{1., 0., 0., 1., 0., 0.}};
REQUIRE_THROWS_AS((kep3::udpla::keplerian{ref_epoch,
par,
1.,
"unknown",
{-1, -1, -1},
kep3::elements_type::POSVEL}),
std::logic_error);
}
{ // negative a but ecc < 1????
std::array<double, 6> par{{-10., 0., 0., 1., 0., 0.}};
REQUIRE_THROWS_AS((kep3::udpla::keplerian{ref_epoch,
par,
1.,
"unknown",
{-1, -1, -1},
kep3::elements_type::KEP_F}),
std::domain_error);
}
{ // We construct an hyperbolic planet
std::array<double, 6> par{{-10., 10., 0., 0., 0., 0.}};
REQUIRE_NOTHROW((kep3::udpla::keplerian{ref_epoch,
par,
1.,
"unknown",
{-1, -1, -1},
kep3::elements_type::KEP_F}));
}
}

Expand Down

0 comments on commit a953a91

Please sign in to comment.