Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for tests on i386: relax SphericalCoordinates and workaround for negative zero #374

Merged
merged 4 commits into from
Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/OrientedBox_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,15 @@ TEST(OrientedBoxTest, OperatorStreamOut)
Pose3d(3.4, 4.5, 5.6, 0.0, -0.1, 0.2));
std::ostringstream stream;
stream << b;
EXPECT_EQ(stream.str(),
"Size[0.1 1.2 2.3] Pose[3.4 4.5 5.6 0 -0.1 0.2] Material[]");

// some compiler optimizations returns negative zero (-0) in the stream,
// workaround using prefix and postfix check. Not nice I know
EXPECT_TRUE(stream.str().find(
chapulina marked this conversation as resolved.
Show resolved Hide resolved
"Size[0.1 1.2 2.3] Pose[3.4 4.5 5.6") != std::string::npos) <<
"stream.str is: " << stream.str();
EXPECT_TRUE(stream.str().find(
"0 -0.1 0.2] Material[]") != std::string::npos) <<
"stream.str is: " << stream.str();
}

//////////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions src/SphericalCoordinates_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ TEST(SphericalCoordinatesTest, NoHeading)
auto latLonAlt = sc.SphericalFromLocalPosition({0, 0, 0});
EXPECT_DOUBLE_EQ(lat.Degree(), latLonAlt.X());
EXPECT_DOUBLE_EQ(lon.Degree(), latLonAlt.Y());
EXPECT_DOUBLE_EQ(elev, latLonAlt.Z());
EXPECT_NEAR(elev, latLonAlt.Z(), 1e-6);

auto xyzOrigin = sc.LocalFromSphericalPosition(latLonAlt);
EXPECT_EQ(math::Vector3d::Zero, xyzOrigin);
Expand Down Expand Up @@ -556,7 +556,7 @@ TEST(SphericalCoordinatesTest, WithHeading)
auto latLonAlt = sc.SphericalFromLocalPosition({0, 0, 0});
EXPECT_DOUBLE_EQ(lat.Degree(), latLonAlt.X());
EXPECT_DOUBLE_EQ(lon.Degree(), latLonAlt.Y());
EXPECT_DOUBLE_EQ(elev, latLonAlt.Z());
EXPECT_NEAR(elev, latLonAlt.Z(), 1e-6);

auto xyzOrigin = sc.LocalFromSphericalPosition(latLonAlt);
EXPECT_EQ(math::Vector3d::Zero, xyzOrigin);
Expand Down