Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: f4e4462eead8
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 438d530e6880
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Oct 29, 2021

  1. Copy the full SHA
    6009e06 View commit details

Commits on Oct 30, 2021

  1. Merge pull request #3177 from pleroy/Fixes

    Serialization of empty segments
    pleroy authored Oct 30, 2021
    Copy the full SHA
    438d530 View commit details
Showing with 16 additions and 2 deletions.
  1. +4 −2 physics/discrete_trajectory_segment_body.hpp
  2. +12 −0 physics/discrete_trajectory_segment_test.cpp
6 changes: 4 additions & 2 deletions physics/discrete_trajectory_segment_body.hpp
Original file line number Diff line number Diff line change
@@ -213,8 +213,10 @@ void DiscreteTrajectorySegment<Frame>::WriteToMessage(
for (auto const it : exact) {
exact_set.insert(&*it);
}
exact_set.insert(&*timeline_.cbegin());
exact_set.insert(&*timeline_.crbegin());
if (!timeline_.empty()) {
exact_set.insert(&*timeline_.cbegin());
exact_set.insert(&*timeline_.crbegin());
}

// Serialize the exact points.
for (auto const* ptr : exact_set) {
12 changes: 12 additions & 0 deletions physics/discrete_trajectory_segment_test.cpp
Original file line number Diff line number Diff line change
@@ -443,5 +443,17 @@ TEST_F(DiscreteTrajectorySegmentTest, SerializationRoundTrip) {
EXPECT_THAT(message2, EqualsProto(message1));
}

TEST_F(DiscreteTrajectorySegmentTest, SerializationEmpty) {
DiscreteTrajectorySegment<World> segment;
serialization::DiscreteTrajectorySegment message;
segment.WriteToMessage(&message, /*exact=*/{});
auto const deserialized_segments = MakeSegments(1);
auto& deserialized_segment = *deserialized_segments->begin();
deserialized_segment = DiscreteTrajectorySegment<World>::ReadFromMessage(
message,
/*self=*/MakeIterator(deserialized_segments.get(),
deserialized_segments->begin()));
}

} // namespace physics
} // namespace principia