Skip to content

Commit 69fb0f9

Browse files
authored
Merge pull request #3195 from pleroy/CompatibilityTest
Convert the plugin compatibility test to DiscreteTraject0ry
2 parents 6cfa80c + cbe2e68 commit 69fb0f9

File tree

2 files changed

+23
-25
lines changed

2 files changed

+23
-25
lines changed

ksp_plugin_test/plugin_compatibility_test.cpp

+22-24
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "ksp_plugin/frames.hpp"
1919
#include "ksp_plugin/interface.hpp"
2020
#include "ksp_plugin/plugin.hpp"
21-
#include "physics/discrete_trajectory.hpp"
21+
#include "physics/discrete_traject0ry.hpp"
2222
#include "serialization/ksp_plugin.pb.h"
2323
#include "testing_utilities/is_near.hpp"
2424
#include "testing_utilities/serialization.hpp"
@@ -40,7 +40,7 @@ using base::PullSerializer;
4040
using base::PushDeserializer;
4141
using ksp_plugin::Barycentric;
4242
using ksp_plugin::Plugin;
43-
using physics::DiscreteTrajectory;
43+
using physics::DiscreteTraject0ry;
4444
using quantities::Speed;
4545
using quantities::si::Kilo;
4646
using testing_utilities::operator""_⑴;
@@ -57,6 +57,7 @@ using ::testing::HasSubstr;
5757
using ::testing::Not;
5858
using ::testing::NotNull;
5959
using ::testing::Pair;
60+
using ::testing::SizeIs;
6061
using ::testing::internal::CaptureStderr;
6162
using ::testing::internal::GetCapturedStderr;
6263

@@ -191,17 +192,17 @@ TEST_F(PluginCompatibilityTest, Reach) {
191192
AllOf(HasSubstr("pre-Galileo"), Not(HasSubstr("pre-Frobenius"))));
192193
auto const test = plugin->GetVessel("f2d77873-4776-4809-9dfb-de9e7a0620a6");
193194
EXPECT_THAT(test->name(), Eq("TEST"));
194-
EXPECT_THAT(TTSecond(test->psychohistory().front().time),
195+
EXPECT_THAT(TTSecond(test->history()->front().time),
195196
Eq("1970-08-14T08:03:18"_DateTime));
196-
EXPECT_THAT(TTSecond(test->psychohistory().back().time),
197+
EXPECT_THAT(TTSecond(test->psychohistory()->back().time),
197198
Eq("1970-08-14T08:47:05"_DateTime));
198199
EXPECT_FALSE(test->has_flight_plan());
199200

200201
auto const ifnity = plugin->GetVessel("29142a79-7acd-47a9-a34d-f9f2a8e1b4ed");
201202
EXPECT_THAT(ifnity->name(), Eq("IFNITY-5.2"));
202-
EXPECT_THAT(TTSecond(ifnity->psychohistory().front().time),
203+
EXPECT_THAT(TTSecond(ifnity->history()->front().time),
203204
Eq("1970-08-14T08:03:46"_DateTime));
204-
EXPECT_THAT(TTSecond(ifnity->psychohistory().back().time),
205+
EXPECT_THAT(TTSecond(ifnity->psychohistory()->back().time),
205206
Eq("1970-08-14T08:47:05"_DateTime));
206207
ASSERT_TRUE(ifnity->has_flight_plan());
207208
EXPECT_THAT(ifnity->flight_plan().number_of_manœuvres(), Eq(16));
@@ -262,11 +263,11 @@ TEST_F(PluginCompatibilityTest, DISABLED_Butcher) {
262263
/*compressor=*/"gipfeli",
263264
/*decoder=*/"base64");
264265
EXPECT_THAT(log_warning.string(),
265-
AllOf(HasSubstr("pre-Haar"), Not(HasSubstr("pre-Gröbner"))));
266+
AllOf(HasSubstr("pre-Haar"), Not(HasSubstr(u8"pre-Gröbner"))));
266267
auto const& orbiter =
267268
*plugin->GetVessel("e180ca12-492f-45bf-a194-4c5255aec8a0");
268269
EXPECT_THAT(orbiter.name(), Eq("Mercury Orbiter 1"));
269-
auto const begin = orbiter.psychohistory().begin();
270+
auto const begin = orbiter.history()->begin();
270271
EXPECT_THAT(begin->time,
271272
Eq("1966-05-10T00:14:03"_TT + 0.0879862308502197 * Second));
272273
EXPECT_THAT(begin->degrees_of_freedom,
@@ -308,7 +309,7 @@ TEST_F(PluginCompatibilityTest, DISABLED_Butcher) {
308309
-7.76112133789062500e+03 * (Metre / Second)}))));
309310

310311
// We arrive in late August. Check the state in the beginning of September.
311-
auto const it = orbiter.psychohistory().LowerBound("1966-09-01T00:00:00"_TT);
312+
auto const it = orbiter.trajectory().lower_bound("1966-09-01T00:00:00"_TT);
312313
EXPECT_THAT(it->time, Eq(MercuryOrbiterInitialTime));
313314
EXPECT_THAT(it->degrees_of_freedom,
314315
Eq(MercuryOrbiterInitialDegreesOfFreedom<Barycentric>));
@@ -326,19 +327,16 @@ TEST_F(PluginCompatibilityTest, DISABLED_Lpg) {
326327
R"(P:\Public Mockingbird\Principia\Saves\3136\3136.proto.b64)",
327328
/*compressor=*/"gipfeli",
328329
/*decoder=*/"base64");
329-
// TODO(phl): Check that we mention a compatibility path here once something
330-
// changes.
331330
EXPECT_THAT(log_warning.string(),
332-
Not(HasSubstr("pre-Haar")));
331+
AllOf(HasSubstr(u8"pre-Ζήνων"), Not(HasSubstr("pre-Haar"))));
333332

334333
// The vessel with the longest history.
335334
auto const& vessel =
336335
*plugin->GetVessel("77ddea45-47ee-48c0-aee9-d55cdb35ffcd");
337-
auto& psychohistory =
338-
const_cast<DiscreteTrajectory<Barycentric>&>(vessel.psychohistory());
339-
auto const history = psychohistory.root();
340-
EXPECT_EQ(435'927, history->Size());
341-
EXPECT_EQ(435'929, psychohistory.Size());
336+
auto history = vessel.history();
337+
auto psychohistory = vessel.psychohistory();
338+
EXPECT_THAT(*history, SizeIs(435'927));
339+
EXPECT_THAT(*psychohistory, SizeIs(3));
342340

343341
// Evaluate a point in each of the two segments.
344342
EXPECT_THAT(history->EvaluateDegreesOfFreedom("1957-10-04T19:28:34"_TT),
@@ -351,7 +349,7 @@ TEST_F(PluginCompatibilityTest, DISABLED_Lpg) {
351349
{-6.28845231836519179e+03 * (Metre / Second),
352350
+2.34046542233168329e+04 * (Metre / Second),
353351
+4.64410011408655919e+03 * (Metre / Second)}))));
354-
EXPECT_THAT(psychohistory.EvaluateDegreesOfFreedom("1958-10-07T09:38:30"_TT),
352+
EXPECT_THAT(psychohistory->EvaluateDegreesOfFreedom("1958-10-07T09:38:30"_TT),
355353
Eq(DegreesOfFreedom<Barycentric>(
356354
Barycentric::origin + Displacement<Barycentric>(
357355
{+1.45814173315801941e+11 * Metre,
@@ -365,7 +363,8 @@ TEST_F(PluginCompatibilityTest, DISABLED_Lpg) {
365363
// Serialize the history and psychohistory to a temporary file.
366364
{
367365
serialization::DiscreteTrajectory message;
368-
history->WriteToMessage(&message, /*forks=*/{&psychohistory}, /*exact=*/{});
366+
vessel.trajectory().WriteToMessage(
367+
&message, /*tracked=*/{history, psychohistory}, /*exact=*/{});
369368
auto const serialized_message = base::SerializeAsBytes(message);
370369
WriteToBinaryFile(TEMP_DIR / "trajectory_3136.proto.bin",
371370
serialized_message.get());
@@ -377,11 +376,10 @@ TEST_F(PluginCompatibilityTest, DISABLED_Lpg) {
377376
ReadFromBinaryFile(TEMP_DIR / "trajectory_3136.proto.bin");
378377
auto const message =
379378
ParseFromBytes<serialization::DiscreteTrajectory>(serialized_message);
380-
DiscreteTrajectory<Barycentric>* psychohistory = nullptr;
381-
auto const history = DiscreteTrajectory<Barycentric>::ReadFromMessage(
382-
message, /*forks=*/{&psychohistory});
383-
EXPECT_EQ(435'927, history->Size());
384-
EXPECT_EQ(435'929, psychohistory->Size());
379+
auto const trajectory = DiscreteTraject0ry<Barycentric>::ReadFromMessage(
380+
message, /*tracked=*/{&history, &psychohistory});
381+
EXPECT_THAT(*history, SizeIs(435'927));
382+
EXPECT_THAT(*psychohistory, SizeIs(3));
385383
}
386384

387385
// Make sure that we can upgrade, save, and reload.

physics/discrete_traject0ry_body.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ DiscreteTraject0ry<Frame>::ReadFromMessage(
511511

512512
bool const is_pre_ζήνων = message.segment_size() == 0;
513513
if (is_pre_ζήνων) {
514-
LOG_IF(WARNING, is_pre_ζήνων) << "Reading pre-Ζήνων DiscreteTrajectory";
514+
LOG_IF(WARNING, is_pre_ζήνων) << u8"Reading pre-Ζήνων DiscreteTrajectory";
515515
ReadFromPreΖήνωνMessage(
516516
message, tracked, /*fork_point=*/std::nullopt, trajectory);
517517
CHECK_OK(trajectory.ConsistencyStatus());

0 commit comments

Comments
 (0)