Skip to content

Commit

Permalink
Merge pull request #3798 from pleroy/NoCheck
Browse files Browse the repository at this point in the history
Change a flight plan test to systematically trigger the generation of a negative period, and change the checks into warnings
  • Loading branch information
pleroy authored Nov 9, 2023
2 parents 61dee14 + d6ea49d commit c32f90c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 5 additions & 2 deletions astronomy/orbital_elements_body.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,11 @@ inline absl::Status OrbitalElements::ComputePeriodsAndPrecession() {
nodal_period_ = 2 * π * Radian * Δt³ / (12 * ʃ_ut_dt);
nodal_precession_ = 12 * ʃ_Ωt_dt / Δt³;

CHECK_LT(0 * Second, anomalistic_period_);
CHECK_LT(0 * Second, nodal_period_);
// TODO(egg): Fix the unwinding and turn these into CHECKs.
LOG_IF(WARNING, anomalistic_period_ <= 0 * Second)
<< "Incorrect anomalistic period " << anomalistic_period_;
LOG_IF(WARNING, nodal_period_ <= 0 * Second)
<< "Incorrect nodal period " << nodal_period_;

return absl::OkStatus();
}
Expand Down
7 changes: 7 additions & 0 deletions ksp_plugin_test/flight_plan_test.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#include "ksp_plugin/flight_plan.hpp"

#include <chrono>
#include <limits>
#include <memory>
#include <utility>
#include <vector>
#include <thread>

#include "astronomy/epoch.hpp"
#include "base/not_null.hpp"
Expand Down Expand Up @@ -70,6 +72,7 @@ using namespace principia::testing_utilities::_approximate_quantity;
using namespace principia::testing_utilities::_is_near;
using namespace principia::testing_utilities::_matchers;
using namespace principia::testing_utilities::_numerics;
using namespace std::chrono_literals;

class FlightPlanTest : public testing::Test {
protected:
Expand Down Expand Up @@ -562,6 +565,10 @@ TEST_F(FlightPlanTest, Serialization) {
EXPECT_EQ(t0_ + 42 * Second, flight_plan_read->desired_final_time());
EXPECT_EQ(2, flight_plan_read->number_of_manœuvres());
EXPECT_EQ(5, flight_plan_read->number_of_segments());

// This sleep causes the analyzer to continue running and produce an
// anomalistic period of -1.42708553168389347e+01 s.
std::this_thread::sleep_for(5s);
}

TEST_F(FlightPlanTest, Copy) {
Expand Down

0 comments on commit c32f90c

Please sign in to comment.