Browse Source

Use tolerance constants (ANG_TOL, R_TOL) instead of hardcoded values

test-refactor
cinnaboot 2 months ago
parent
commit
e5275eda9e
  1. 7
      tests/test_true_anomaly_roundtrip.cpp

7
tests/test_true_anomaly_roundtrip.cpp

@ -2,6 +2,7 @@
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include "../src/physics.h"
#include "../src/orbital_mechanics.h"
#include "../src/test_utilities.h"
#include <cmath>
using Catch::Matchers::WithinAbs;
@ -28,7 +29,7 @@ SCENARIO("True anomaly round-trip conversion and radius sanity checks",
INFO("Expected nu: " << expected_nu);
INFO("Reconstructed: " << reconstructed.true_anomaly);
REQUIRE_THAT(reconstructed.true_anomaly, WithinAbs(expected_nu, 1e-12));
REQUIRE_THAT(reconstructed.true_anomaly, WithinAbs(expected_nu, ANG_TOL));
};
SECTION("at periapsis (nu = 0)") { check_roundtrip(0.0); }
@ -43,7 +44,7 @@ SCENARIO("True anomaly round-trip conversion and radius sanity checks",
INFO("Expected r: " << expected_r_peri);
INFO("Calculated r: " << r_peri);
REQUIRE_THAT(r_peri, WithinAbs(expected_r_peri, 1e-6));
REQUIRE_THAT(r_peri, WithinAbs(expected_r_peri, R_TOL));
}
SECTION("apoapsis radius = a*(1+e)") {
@ -54,6 +55,6 @@ SCENARIO("True anomaly round-trip conversion and radius sanity checks",
INFO("Expected r: " << expected_r_apo);
INFO("Calculated r: " << r_apo);
REQUIRE_THAT(r_apo, WithinAbs(expected_r_apo, 1e-6));
REQUIRE_THAT(r_apo, WithinAbs(expected_r_apo, R_TOL));
}
}

Loading…
Cancel
Save