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: 2f32c561b592
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: cfb60a600f6d
Choose a head ref
  • 3 commits
  • 4 files changed
  • 1 contributor

Commits on Feb 16, 2019

  1. Copy the full SHA
    93c80c6 View commit details
  2. Copy the full SHA
    8084b56 View commit details
  3. Merge pull request #2078 from pleroy/TrajectoryBugs

    Fix bugs in DiscreteTrajectory and friends
    pleroy authored Feb 16, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    cfb60a6 View commit details
Showing with 21 additions and 3 deletions.
  1. +1 −2 physics/discrete_trajectory_body.hpp
  2. +6 −0 physics/discrete_trajectory_test.cpp
  3. +4 −1 physics/forkable_body.hpp
  4. +10 −0 physics/forkable_test.cpp
3 changes: 1 addition & 2 deletions physics/discrete_trajectory_body.hpp
Original file line number Diff line number Diff line change
@@ -239,10 +239,9 @@ void DiscreteTrajectory<Frame>::ForgetBefore(Instant const& time) {
// Get an iterator denoting the first entry with time >= |time|. Remove all
// the entries that precede it. This preserves any entry with time == |time|.
auto const first_kept_in_timeline = timeline_.lower_bound(time);
Instant const& first_kept_time = first_kept_in_timeline->first;
if (downsampling_.has_value() &&
(first_kept_in_timeline == timeline_.end() ||
downsampling_->first_dense_time() < first_kept_time)) {
downsampling_->first_dense_time() < first_kept_in_timeline->first)) {
// The start of the dense timeline will be invalidated.
downsampling_->SetStartOfDenseTimeline(first_kept_in_timeline, timeline_);
}
6 changes: 6 additions & 0 deletions physics/discrete_trajectory_test.cpp
Original file line number Diff line number Diff line change
@@ -666,6 +666,12 @@ TEST_F(DiscreteTrajectoryTest, ForgetBeforeSuccess) {
EXPECT_THAT(times, ElementsAre(t2_, t3_));
}

TEST_F(DiscreteTrajectoryTest, ForgetBeforeEmpty) {
massive_trajectory_->Append(t1_, d1_);
massive_trajectory_->ForgetBefore(t4_);
EXPECT_TRUE(massive_trajectory_->Empty());
}

TEST_F(DiscreteTrajectoryDeathTest, TrajectorySerializationError) {
EXPECT_DEATH({
massive_trajectory_->Append(t1_, d1_);
5 changes: 4 additions & 1 deletion physics/forkable_body.hpp
Original file line number Diff line number Diff line change
@@ -365,7 +365,10 @@ void Forkable<Tr4jectory, It3rator>::AttachForkToCopiedBegin(
// Set the pointer into this object. Note that |fork| is no longer usable.
child_it->second->parent_ = that();
child_it->second->position_in_parent_children_ = child_it;
child_it->second->position_in_parent_timeline_ = --timeline_end();
child_it->second->position_in_parent_timeline_ = timeline_end();
if (!timeline_empty()) {
--*child_it->second->position_in_parent_timeline_;
}
}

template<typename Tr4jectory, typename It3rator>
10 changes: 10 additions & 0 deletions physics/forkable_test.cpp
Original file line number Diff line number Diff line change
@@ -359,6 +359,16 @@ TEST_F(ForkableTest, AttachForkWithCopiedBeginSuccess) {
EXPECT_THAT(times, ElementsAre(t1_, t2_, t3_, t4_));
}

TEST_F(ForkableTest, AttachForkWithCopiedBeginEmpty) {
trajectory_.push_back(t1_);
not_null<FakeTrajectory*> const fork1 =
trajectory_.NewFork(trajectory_.timeline_find(t1_));
not_null<std::unique_ptr<FakeTrajectory>> fork2 =
make_not_null_unique<FakeTrajectory>();
fork2->push_back(t3_);
fork1->AttachForkToCopiedBegin(std::move(fork2));
}

TEST_F(ForkableDeathTest, DetachForkWithCopiedBeginError) {
EXPECT_DEATH({
trajectory_.push_back(t1_);