Skip to content

Commit

Permalink
NDEBUG and remove at_end() and first().
Browse files Browse the repository at this point in the history
  • Loading branch information
pleroy committed Nov 1, 2015
1 parent 4c71a3a commit ad4536b
Show file tree
Hide file tree
Showing 19 changed files with 36 additions and 14 deletions.
1 change: 1 addition & 0 deletions astronomy/astronomy.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<Import Project="..\..\Google\glog\vsprojects\static_linking.props" />
<Import Project="..\..\Google\glog\vsprojects\portability_macros.props" />
<Import Project="..\google_glog.props" />
<Import Project="..\define_ndebug.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
Expand Down
1 change: 1 addition & 0 deletions base/base.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<Import Project="..\..\Google\glog\vsprojects\portability_macros.props" />
<Import Project="..\google_glog.props" />
<Import Project="..\generate_version_header.props" />
<Import Project="..\define_ndebug.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_LLVM|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
Expand Down
1 change: 1 addition & 0 deletions benchmarks/benchmarks.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
<Import Project="..\google_benchmark.props" />
<Import Project="..\..\Google\benchmark\msvc\portability_macros.props" />
<Import Project="..\..\Google\benchmark\msvc\windows_libraries.props" />
<Import Project="..\define_ndebug.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_LLVM|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
Expand Down
12 changes: 12 additions & 0 deletions define_ndebug.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup />
</Project>
1 change: 1 addition & 0 deletions geometry/geometry.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<Import Project="..\..\Google\glog\vsprojects\portability_macros.props" />
<Import Project="..\google_glog.props" />
<Import Project="..\generate_version_header.props" />
<Import Project="..\define_ndebug.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_LLVM|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
Expand Down
1 change: 1 addition & 0 deletions integrators/integrators.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
<Import Project="..\..\Google\glog\vsprojects\portability_macros.props" />
<Import Project="..\google_glog.props" />
<Import Project="..\generate_version_header.props" />
<Import Project="..\define_ndebug.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_LLVM|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
Expand Down
1 change: 1 addition & 0 deletions ksp_plugin/ksp_plugin.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
<Import Project="..\..\Google\glog\vsprojects\portability_macros.props" />
<Import Project="..\google_glog.props" />
<Import Project="..\generate_version_header.props" />
<Import Project="..\define_ndebug.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_LLVM|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
Expand Down
1 change: 1 addition & 0 deletions ksp_plugin_test/ksp_plugin_test.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
<Import Project="..\..\Google\glog\vsprojects\portability_macros.props" />
<Import Project="..\google_glog.props" />
<Import Project="..\generate_version_header.props" />
<Import Project="..\define_ndebug.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_LLVM|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
Expand Down
1 change: 1 addition & 0 deletions mathematica/mathematica.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
<Import Project="..\..\Google\glog\vsprojects\portability_macros.props" />
<Import Project="..\google_glog.props" />
<Import Project="..\generate_version_header.props" />
<Import Project="..\define_ndebug.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_LLVM|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
Expand Down
1 change: 1 addition & 0 deletions numerics/numerics.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<Import Project="..\..\Google\glog\vsprojects\portability_macros.props" />
<Import Project="..\google_glog.props" />
<Import Project="..\generate_version_header.props" />
<Import Project="..\define_ndebug.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_LLVM|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
Expand Down
1 change: 0 additions & 1 deletion physics/discrete_trajectory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ class DiscreteTrajectory : public Forkable<DiscreteTrajectory<Frame>> {
public:
Iterator(typename Forkable<DiscreteTrajectory<Frame>>::Iterator it);

bool at_end() const;
Instant const& time() const;
DegreesOfFreedom<Frame> const& degrees_of_freedom() const;

Expand Down
5 changes: 0 additions & 5 deletions physics/discrete_trajectory_body.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,6 @@ DiscreteTrajectory<Frame>::Iterator::Iterator(
typename Forkable<DiscreteTrajectory<Frame>>::Iterator it)
: Forkable<DiscreteTrajectory<Frame>>::Iterator(std::move(it)) {}

template<typename Frame>
bool DiscreteTrajectory<Frame>::Iterator::at_end() const {
return *this == this->trajectory()->End();
}

template<typename Frame>
Instant const& DiscreteTrajectory<Frame>::Iterator::time() const {
return this->current()->first;
Expand Down
16 changes: 8 additions & 8 deletions physics/discrete_trajectory_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,15 +522,15 @@ TEST_F(DiscreteTrajectoryDeathTest, IteratorError) {
}

TEST_F(DiscreteTrajectoryTest, IteratorSuccess) {
DiscreteTrajectory<World>::Iterator it = massive_trajectory_->first();
EXPECT_TRUE(it.at_end());
DiscreteTrajectory<World>::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;
Expand All @@ -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<DiscreteTrajectory<World>*> 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;
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions physics/forkable_body.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ std::experimental::optional<Instant> Forkable<Tr4jectory>::ForkTime() const {

template<typename Tr4jectory>
bool Forkable<Tr4jectory>::Iterator::operator==(Iterator const& right) const {
DCHECK_EQ(trajectory(), right.trajectory());
return ancestry_ == right.ancestry_ && current_ == right.current_;
}

Expand Down
2 changes: 2 additions & 0 deletions physics/forkable_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
Expand All @@ -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_);
Expand Down
1 change: 1 addition & 0 deletions physics/physics.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
<Import Project="..\..\Google\glog\vsprojects\portability_macros.props" />
<Import Project="..\google_glog.props" />
<Import Project="..\generate_version_header.props" />
<Import Project="..\define_ndebug.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_LLVM|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
Expand Down
1 change: 1 addition & 0 deletions quantities/quantities.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<Import Project="..\..\Google\glog\vsprojects\portability_macros.props" />
<Import Project="..\google_glog.props" />
<Import Project="..\generate_version_header.props" />
<Import Project="..\define_ndebug.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_LLVM|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
Expand Down
1 change: 1 addition & 0 deletions serialization/serialization.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<Import Project="..\..\Google\glog\vsprojects\portability_macros.props" />
<Import Project="..\google_glog.props" />
<Import Project="..\generate_version_header.props" />
<Import Project="..\define_ndebug.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_LLVM|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
Expand Down
1 change: 1 addition & 0 deletions testing_utilities/testing_utilities.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
<Import Project="..\..\Google\glog\vsprojects\portability_macros.props" />
<Import Project="..\google_glog.props" />
<Import Project="..\generate_version_header.props" />
<Import Project="..\define_ndebug.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_LLVM|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
Expand Down

0 comments on commit ad4536b

Please sign in to comment.