From ad4536b53386571b6865479db4ccf442a243d8f7 Mon Sep 17 00:00:00 2001 From: pleroy Date: Sun, 1 Nov 2015 14:46:17 +0100 Subject: [PATCH] NDEBUG and remove at_end() and first(). --- astronomy/astronomy.vcxproj | 1 + base/base.vcxproj | 1 + benchmarks/benchmarks.vcxproj | 1 + define_ndebug.props | 12 ++++++++++++ geometry/geometry.vcxproj | 1 + integrators/integrators.vcxproj | 1 + ksp_plugin/ksp_plugin.vcxproj | 1 + ksp_plugin_test/ksp_plugin_test.vcxproj | 1 + mathematica/mathematica.vcxproj | 1 + numerics/numerics.vcxproj | 1 + physics/discrete_trajectory.hpp | 1 - physics/discrete_trajectory_body.hpp | 5 ----- physics/discrete_trajectory_test.cpp | 16 ++++++++-------- physics/forkable_body.hpp | 1 + physics/forkable_test.cpp | 2 ++ physics/physics.vcxproj | 1 + quantities/quantities.vcxproj | 1 + serialization/serialization.vcxproj | 1 + testing_utilities/testing_utilities.vcxproj | 1 + 19 files changed, 36 insertions(+), 14 deletions(-) create mode 100644 define_ndebug.props diff --git a/astronomy/astronomy.vcxproj b/astronomy/astronomy.vcxproj index 6d367097e6..136e2a1fb7 100644 --- a/astronomy/astronomy.vcxproj +++ b/astronomy/astronomy.vcxproj @@ -57,6 +57,7 @@ + diff --git a/base/base.vcxproj b/base/base.vcxproj index 7290f751a3..050626d593 100644 --- a/base/base.vcxproj +++ b/base/base.vcxproj @@ -73,6 +73,7 @@ + diff --git a/benchmarks/benchmarks.vcxproj b/benchmarks/benchmarks.vcxproj index c643c81086..7128eb89fb 100644 --- a/benchmarks/benchmarks.vcxproj +++ b/benchmarks/benchmarks.vcxproj @@ -85,6 +85,7 @@ + diff --git a/define_ndebug.props b/define_ndebug.props new file mode 100644 index 0000000000..efd7d48f6a --- /dev/null +++ b/define_ndebug.props @@ -0,0 +1,12 @@ + + + + + + + + NDEBUG;%(PreprocessorDefinitions) + + + + \ No newline at end of file diff --git a/geometry/geometry.vcxproj b/geometry/geometry.vcxproj index 3338599fac..5394dd7bb4 100644 --- a/geometry/geometry.vcxproj +++ b/geometry/geometry.vcxproj @@ -74,6 +74,7 @@ + diff --git a/integrators/integrators.vcxproj b/integrators/integrators.vcxproj index e3189058bc..feb4879400 100644 --- a/integrators/integrators.vcxproj +++ b/integrators/integrators.vcxproj @@ -76,6 +76,7 @@ + diff --git a/ksp_plugin/ksp_plugin.vcxproj b/ksp_plugin/ksp_plugin.vcxproj index 96a77d3d88..4b8a44727b 100644 --- a/ksp_plugin/ksp_plugin.vcxproj +++ b/ksp_plugin/ksp_plugin.vcxproj @@ -76,6 +76,7 @@ + diff --git a/ksp_plugin_test/ksp_plugin_test.vcxproj b/ksp_plugin_test/ksp_plugin_test.vcxproj index 49fa608e5f..ec65ec9ecd 100644 --- a/ksp_plugin_test/ksp_plugin_test.vcxproj +++ b/ksp_plugin_test/ksp_plugin_test.vcxproj @@ -99,6 +99,7 @@ + diff --git a/mathematica/mathematica.vcxproj b/mathematica/mathematica.vcxproj index 1a1a71c9b3..6432f5b14e 100644 --- a/mathematica/mathematica.vcxproj +++ b/mathematica/mathematica.vcxproj @@ -76,6 +76,7 @@ + diff --git a/numerics/numerics.vcxproj b/numerics/numerics.vcxproj index c880dacd10..4dd49ba2ed 100644 --- a/numerics/numerics.vcxproj +++ b/numerics/numerics.vcxproj @@ -73,6 +73,7 @@ + diff --git a/physics/discrete_trajectory.hpp b/physics/discrete_trajectory.hpp index 9ec3ec3f58..1971b4b6fb 100644 --- a/physics/discrete_trajectory.hpp +++ b/physics/discrete_trajectory.hpp @@ -112,7 +112,6 @@ class DiscreteTrajectory : public Forkable> { public: Iterator(typename Forkable>::Iterator it); - bool at_end() const; Instant const& time() const; DegreesOfFreedom const& degrees_of_freedom() const; diff --git a/physics/discrete_trajectory_body.hpp b/physics/discrete_trajectory_body.hpp index 331606711b..cc93318649 100644 --- a/physics/discrete_trajectory_body.hpp +++ b/physics/discrete_trajectory_body.hpp @@ -172,11 +172,6 @@ DiscreteTrajectory::Iterator::Iterator( typename Forkable>::Iterator it) : Forkable>::Iterator(std::move(it)) {} -template -bool DiscreteTrajectory::Iterator::at_end() const { - return *this == this->trajectory()->End(); -} - template Instant const& DiscreteTrajectory::Iterator::time() const { return this->current()->first; diff --git a/physics/discrete_trajectory_test.cpp b/physics/discrete_trajectory_test.cpp index 4815956349..5f9373a417 100644 --- a/physics/discrete_trajectory_test.cpp +++ b/physics/discrete_trajectory_test.cpp @@ -522,15 +522,15 @@ TEST_F(DiscreteTrajectoryDeathTest, IteratorError) { } TEST_F(DiscreteTrajectoryTest, IteratorSuccess) { - DiscreteTrajectory::Iterator it = massive_trajectory_->first(); - EXPECT_TRUE(it.at_end()); + DiscreteTrajectory::Iterator it = massive_trajectory_->Begin(); + EXPECT_TRUE(it == massive_trajectory_->End()); massless_trajectory_->Append(t1_, d1_); massless_trajectory_->Append(t2_, d2_); massless_trajectory_->Append(t3_, d3_); - it = massless_trajectory_->first(); - EXPECT_FALSE(it.at_end()); + it = massless_trajectory_->Begin(); + EXPECT_FALSE(it == massless_trajectory_->End()); EXPECT_EQ(t1_, it.time()); EXPECT_EQ(d1_, it.degrees_of_freedom()); ++it; @@ -540,14 +540,14 @@ TEST_F(DiscreteTrajectoryTest, IteratorSuccess) { EXPECT_EQ(t3_, it.time()); EXPECT_EQ(d3_, it.degrees_of_freedom()); ++it; - EXPECT_TRUE(it.at_end()); + EXPECT_TRUE(it == massless_trajectory_->End()); not_null*> const fork = massless_trajectory_->NewForkWithCopy(t2_); fork->Append(t4_, d4_); - it = fork->first(); - EXPECT_FALSE(it.at_end()); + it = fork->Begin(); + EXPECT_FALSE(it == fork->End()); EXPECT_EQ(t1_, it.time()); EXPECT_EQ(d1_, it.degrees_of_freedom()); ++it; @@ -560,7 +560,7 @@ TEST_F(DiscreteTrajectoryTest, IteratorSuccess) { EXPECT_EQ(t4_, it.time()); EXPECT_EQ(d4_, it.degrees_of_freedom()); ++it; - EXPECT_TRUE(it.at_end()); + EXPECT_TRUE(it == fork->End()); } } // namespace physics diff --git a/physics/forkable_body.hpp b/physics/forkable_body.hpp index f18ca66060..cc8c107114 100644 --- a/physics/forkable_body.hpp +++ b/physics/forkable_body.hpp @@ -59,6 +59,7 @@ std::experimental::optional Forkable::ForkTime() const { template bool Forkable::Iterator::operator==(Iterator const& right) const { + DCHECK_EQ(trajectory(), right.trajectory()); return ancestry_ == right.ancestry_ && current_ == right.current_; } diff --git a/physics/forkable_test.cpp b/physics/forkable_test.cpp index 3dfed1f55e..5567770107 100644 --- a/physics/forkable_test.cpp +++ b/physics/forkable_test.cpp @@ -408,6 +408,7 @@ TEST_F(ForkableTest, IteratorIncrementMultipleForksSuccess) { EXPECT_EQ(it, fork3->End()); } +#if !defined(_DEBUG) TEST_F(ForkableTest, IteratorEndEquality) { trajectory_.push_back(t1_); trajectory_.push_back(t2_); @@ -417,6 +418,7 @@ TEST_F(ForkableTest, IteratorEndEquality) { auto it2 = fork2->End(); EXPECT_NE(it1, it2); } +#endif TEST_F(ForkableTest, Root) { trajectory_.push_back(t1_); diff --git a/physics/physics.vcxproj b/physics/physics.vcxproj index 1c0a91c8a3..a5b12467ba 100644 --- a/physics/physics.vcxproj +++ b/physics/physics.vcxproj @@ -76,6 +76,7 @@ + diff --git a/quantities/quantities.vcxproj b/quantities/quantities.vcxproj index 659368b3df..febd55f560 100644 --- a/quantities/quantities.vcxproj +++ b/quantities/quantities.vcxproj @@ -75,6 +75,7 @@ + diff --git a/serialization/serialization.vcxproj b/serialization/serialization.vcxproj index 3a6f01fcde..8c1a41d14f 100644 --- a/serialization/serialization.vcxproj +++ b/serialization/serialization.vcxproj @@ -63,6 +63,7 @@ + diff --git a/testing_utilities/testing_utilities.vcxproj b/testing_utilities/testing_utilities.vcxproj index 115db096ce..84267a0072 100644 --- a/testing_utilities/testing_utilities.vcxproj +++ b/testing_utilities/testing_utilities.vcxproj @@ -108,6 +108,7 @@ +