From 9af4aec785ae4757fec945559c6f7e72cc0ed938 Mon Sep 17 00:00:00 2001 From: pleroy Date: Sat, 6 Nov 2021 17:03:01 +0100 Subject: [PATCH 1/3] Compatibility test compiles. --- ksp_plugin_test/plugin_compatibility_test.cpp | 39 +++++++++---------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/ksp_plugin_test/plugin_compatibility_test.cpp b/ksp_plugin_test/plugin_compatibility_test.cpp index 4cf54ffec2..bb644a291e 100644 --- a/ksp_plugin_test/plugin_compatibility_test.cpp +++ b/ksp_plugin_test/plugin_compatibility_test.cpp @@ -18,7 +18,7 @@ #include "ksp_plugin/frames.hpp" #include "ksp_plugin/interface.hpp" #include "ksp_plugin/plugin.hpp" -#include "physics/discrete_trajectory.hpp" +#include "physics/discrete_traject0ry.hpp" #include "serialization/ksp_plugin.pb.h" #include "testing_utilities/is_near.hpp" #include "testing_utilities/serialization.hpp" @@ -40,7 +40,7 @@ using base::PullSerializer; using base::PushDeserializer; using ksp_plugin::Barycentric; using ksp_plugin::Plugin; -using physics::DiscreteTrajectory; +using physics::DiscreteTraject0ry; using quantities::Speed; using quantities::si::Kilo; using testing_utilities::operator""_⑴; @@ -191,17 +191,17 @@ TEST_F(PluginCompatibilityTest, Reach) { AllOf(HasSubstr("pre-Galileo"), Not(HasSubstr("pre-Frobenius")))); auto const test = plugin->GetVessel("f2d77873-4776-4809-9dfb-de9e7a0620a6"); EXPECT_THAT(test->name(), Eq("TEST")); - EXPECT_THAT(TTSecond(test->psychohistory().front().time), + EXPECT_THAT(TTSecond(test->history()->front().time), Eq("1970-08-14T08:03:18"_DateTime)); - EXPECT_THAT(TTSecond(test->psychohistory().back().time), + EXPECT_THAT(TTSecond(test->psychohistory()->back().time), Eq("1970-08-14T08:47:05"_DateTime)); EXPECT_FALSE(test->has_flight_plan()); auto const ifnity = plugin->GetVessel("29142a79-7acd-47a9-a34d-f9f2a8e1b4ed"); EXPECT_THAT(ifnity->name(), Eq("IFNITY-5.2")); - EXPECT_THAT(TTSecond(ifnity->psychohistory().front().time), + EXPECT_THAT(TTSecond(ifnity->history()->front().time), Eq("1970-08-14T08:03:46"_DateTime)); - EXPECT_THAT(TTSecond(ifnity->psychohistory().back().time), + EXPECT_THAT(TTSecond(ifnity->psychohistory()->back().time), Eq("1970-08-14T08:47:05"_DateTime)); ASSERT_TRUE(ifnity->has_flight_plan()); EXPECT_THAT(ifnity->flight_plan().number_of_manœuvres(), Eq(16)); @@ -266,7 +266,7 @@ TEST_F(PluginCompatibilityTest, DISABLED_Butcher) { auto const& orbiter = *plugin->GetVessel("e180ca12-492f-45bf-a194-4c5255aec8a0"); EXPECT_THAT(orbiter.name(), Eq("Mercury Orbiter 1")); - auto const begin = orbiter.psychohistory().begin(); + auto const begin = orbiter.history()->begin(); EXPECT_THAT(begin->time, Eq("1966-05-10T00:14:03"_TT + 0.0879862308502197 * Second)); EXPECT_THAT(begin->degrees_of_freedom, @@ -308,7 +308,7 @@ TEST_F(PluginCompatibilityTest, DISABLED_Butcher) { -7.76112133789062500e+03 * (Metre / Second)})))); // We arrive in late August. Check the state in the beginning of September. - auto const it = orbiter.psychohistory().LowerBound("1966-09-01T00:00:00"_TT); + auto const it = orbiter.trajectory().lower_bound("1966-09-01T00:00:00"_TT); EXPECT_THAT(it->time, Eq(MercuryOrbiterInitialTime)); EXPECT_THAT(it->degrees_of_freedom, Eq(MercuryOrbiterInitialDegreesOfFreedom)); @@ -334,11 +334,10 @@ TEST_F(PluginCompatibilityTest, DISABLED_Lpg) { // The vessel with the longest history. auto const& vessel = *plugin->GetVessel("77ddea45-47ee-48c0-aee9-d55cdb35ffcd"); - auto& psychohistory = - const_cast&>(vessel.psychohistory()); - auto const history = psychohistory.root(); - EXPECT_EQ(435'927, history->Size()); - EXPECT_EQ(435'929, psychohistory.Size()); + auto history = vessel.history(); + auto psychohistory = vessel.psychohistory(); + EXPECT_EQ(435'927, history->size()); + EXPECT_EQ(435'929, psychohistory->size()); // Evaluate a point in each of the two segments. EXPECT_THAT(history->EvaluateDegreesOfFreedom("1957-10-04T19:28:34"_TT), @@ -351,7 +350,7 @@ TEST_F(PluginCompatibilityTest, DISABLED_Lpg) { {-6.28845231836519179e+03 * (Metre / Second), +2.34046542233168329e+04 * (Metre / Second), +4.64410011408655919e+03 * (Metre / Second)})))); - EXPECT_THAT(psychohistory.EvaluateDegreesOfFreedom("1958-10-07T09:38:30"_TT), + EXPECT_THAT(psychohistory->EvaluateDegreesOfFreedom("1958-10-07T09:38:30"_TT), Eq(DegreesOfFreedom( Barycentric::origin + Displacement( {+1.45814173315801941e+11 * Metre, @@ -365,7 +364,8 @@ TEST_F(PluginCompatibilityTest, DISABLED_Lpg) { // Serialize the history and psychohistory to a temporary file. { serialization::DiscreteTrajectory message; - history->WriteToMessage(&message, /*forks=*/{&psychohistory}, /*exact=*/{}); + vessel.trajectory().WriteToMessage( + &message, /*tracked=*/{&history, &psychohistory}, /*exact=*/{}); auto const serialized_message = base::SerializeAsBytes(message); WriteToBinaryFile(TEMP_DIR / "trajectory_3136.proto.bin", serialized_message.get()); @@ -377,11 +377,10 @@ TEST_F(PluginCompatibilityTest, DISABLED_Lpg) { ReadFromBinaryFile(TEMP_DIR / "trajectory_3136.proto.bin"); auto const message = ParseFromBytes(serialized_message); - DiscreteTrajectory* psychohistory = nullptr; - auto const history = DiscreteTrajectory::ReadFromMessage( - message, /*forks=*/{&psychohistory}); - EXPECT_EQ(435'927, history->Size()); - EXPECT_EQ(435'929, psychohistory->Size()); + auto const trajectory = DiscreteTraject0ry::ReadFromMessage( + message, /*tracked=*/{&history, &psychohistory}); + EXPECT_EQ(435'927, history->size()); + EXPECT_EQ(435'929, psychohistory->size()); } // Make sure that we can upgrade, save, and reload. From 1fb6a6bcdb0e36ac4f3e7c46bf7b80d4cb0d7088 Mon Sep 17 00:00:00 2001 From: pleroy Date: Sat, 6 Nov 2021 18:25:51 +0100 Subject: [PATCH 2/3] Compatibility test passing. --- ksp_plugin_test/plugin_compatibility_test.cpp | 12 +++++------- physics/discrete_traject0ry_body.hpp | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/ksp_plugin_test/plugin_compatibility_test.cpp b/ksp_plugin_test/plugin_compatibility_test.cpp index bb644a291e..84dd71850f 100644 --- a/ksp_plugin_test/plugin_compatibility_test.cpp +++ b/ksp_plugin_test/plugin_compatibility_test.cpp @@ -262,7 +262,7 @@ TEST_F(PluginCompatibilityTest, DISABLED_Butcher) { /*compressor=*/"gipfeli", /*decoder=*/"base64"); EXPECT_THAT(log_warning.string(), - AllOf(HasSubstr("pre-Haar"), Not(HasSubstr("pre-Gröbner")))); + AllOf(HasSubstr("pre-Haar"), Not(HasSubstr(u8"pre-Gröbner")))); auto const& orbiter = *plugin->GetVessel("e180ca12-492f-45bf-a194-4c5255aec8a0"); EXPECT_THAT(orbiter.name(), Eq("Mercury Orbiter 1")); @@ -326,10 +326,8 @@ TEST_F(PluginCompatibilityTest, DISABLED_Lpg) { R"(P:\Public Mockingbird\Principia\Saves\3136\3136.proto.b64)", /*compressor=*/"gipfeli", /*decoder=*/"base64"); - // TODO(phl): Check that we mention a compatibility path here once something - // changes. EXPECT_THAT(log_warning.string(), - Not(HasSubstr("pre-Haar"))); + AllOf(HasSubstr(u8"pre-Ζήνων"), Not(HasSubstr("pre-Haar")))); // The vessel with the longest history. auto const& vessel = @@ -337,7 +335,7 @@ TEST_F(PluginCompatibilityTest, DISABLED_Lpg) { auto history = vessel.history(); auto psychohistory = vessel.psychohistory(); EXPECT_EQ(435'927, history->size()); - EXPECT_EQ(435'929, psychohistory->size()); + EXPECT_EQ(3, psychohistory->size()); // Evaluate a point in each of the two segments. EXPECT_THAT(history->EvaluateDegreesOfFreedom("1957-10-04T19:28:34"_TT), @@ -365,7 +363,7 @@ TEST_F(PluginCompatibilityTest, DISABLED_Lpg) { { serialization::DiscreteTrajectory message; vessel.trajectory().WriteToMessage( - &message, /*tracked=*/{&history, &psychohistory}, /*exact=*/{}); + &message, /*tracked=*/{history, psychohistory}, /*exact=*/{}); auto const serialized_message = base::SerializeAsBytes(message); WriteToBinaryFile(TEMP_DIR / "trajectory_3136.proto.bin", serialized_message.get()); @@ -380,7 +378,7 @@ TEST_F(PluginCompatibilityTest, DISABLED_Lpg) { auto const trajectory = DiscreteTraject0ry::ReadFromMessage( message, /*tracked=*/{&history, &psychohistory}); EXPECT_EQ(435'927, history->size()); - EXPECT_EQ(435'929, psychohistory->size()); + EXPECT_EQ(3, psychohistory->size()); } // Make sure that we can upgrade, save, and reload. diff --git a/physics/discrete_traject0ry_body.hpp b/physics/discrete_traject0ry_body.hpp index 58dd28c3ec..168a7df3f0 100644 --- a/physics/discrete_traject0ry_body.hpp +++ b/physics/discrete_traject0ry_body.hpp @@ -511,7 +511,7 @@ DiscreteTraject0ry::ReadFromMessage( bool const is_pre_ζήνων = message.segment_size() == 0; if (is_pre_ζήνων) { - LOG_IF(WARNING, is_pre_ζήνων) << "Reading pre-Ζήνων DiscreteTrajectory"; + LOG_IF(WARNING, is_pre_ζήνων) << u8"Reading pre-Ζήνων DiscreteTrajectory"; ReadFromPreΖήνωνMessage( message, tracked, /*fork_point=*/std::nullopt, trajectory); CHECK_OK(trajectory.ConsistencyStatus()); From cbe2e68f828a99dc07cc8f67c3ebfddf78de7b81 Mon Sep 17 00:00:00 2001 From: pleroy Date: Sat, 6 Nov 2021 20:23:32 +0100 Subject: [PATCH 3/3] After egg's review. --- ksp_plugin_test/plugin_compatibility_test.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ksp_plugin_test/plugin_compatibility_test.cpp b/ksp_plugin_test/plugin_compatibility_test.cpp index 84dd71850f..49ec04b332 100644 --- a/ksp_plugin_test/plugin_compatibility_test.cpp +++ b/ksp_plugin_test/plugin_compatibility_test.cpp @@ -57,6 +57,7 @@ using ::testing::HasSubstr; using ::testing::Not; using ::testing::NotNull; using ::testing::Pair; +using ::testing::SizeIs; using ::testing::internal::CaptureStderr; using ::testing::internal::GetCapturedStderr; @@ -334,8 +335,8 @@ TEST_F(PluginCompatibilityTest, DISABLED_Lpg) { *plugin->GetVessel("77ddea45-47ee-48c0-aee9-d55cdb35ffcd"); auto history = vessel.history(); auto psychohistory = vessel.psychohistory(); - EXPECT_EQ(435'927, history->size()); - EXPECT_EQ(3, psychohistory->size()); + EXPECT_THAT(*history, SizeIs(435'927)); + EXPECT_THAT(*psychohistory, SizeIs(3)); // Evaluate a point in each of the two segments. EXPECT_THAT(history->EvaluateDegreesOfFreedom("1957-10-04T19:28:34"_TT), @@ -377,8 +378,8 @@ TEST_F(PluginCompatibilityTest, DISABLED_Lpg) { ParseFromBytes(serialized_message); auto const trajectory = DiscreteTraject0ry::ReadFromMessage( message, /*tracked=*/{&history, &psychohistory}); - EXPECT_EQ(435'927, history->size()); - EXPECT_EQ(3, psychohistory->size()); + EXPECT_THAT(*history, SizeIs(435'927)); + EXPECT_THAT(*psychohistory, SizeIs(3)); } // Make sure that we can upgrade, save, and reload.