Skip to content

Commit

Permalink
Fix test fail due to double precision
Browse files Browse the repository at this point in the history
  • Loading branch information
f0reachARR committed Jan 23, 2025
1 parent 4320d36 commit c7e5e50
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2122,10 +2122,12 @@ TEST_F(HdMapUtilsTest_KashiwanohaMap, getLongitudinalDistance_PullRequest1348)

traffic_simulator::RoutingConfiguration lane_changeable_routing_configuration;
lane_changeable_routing_configuration.allow_lane_change = true;
EXPECT_NO_THROW(EXPECT_DOUBLE_EQ(

EXPECT_NO_THROW(EXPECT_NEAR(
hdmap_utils.getLongitudinalDistance(pose_from, pose_to, lane_changeable_routing_configuration)
.value(),
54.18867466433655977198213804513216018676757812500000));
54.188674664, 0.000000001));
// Previous value: 54.18867466433655977198213804513216018676757812500000 is too precise to absorb the error between architectures.
}

/**
Expand Down
6 changes: 4 additions & 2 deletions simulation/traffic_simulator/test/src/utils/test_distance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,8 @@ TEST_F(distanceTest_IntersectionMap, longitudinalDistance_adjacent_noOpposite_ch
pose_from.value(), pose_to.value(), true, false, lane_changeable_routing_configuration,
hdmap_utils_ptr);
ASSERT_TRUE(result.has_value());
EXPECT_DOUBLE_EQ(result.value(), 97.648110014340688);
EXPECT_NEAR(result.value(), 97.648110014, 0.000000001);
// Previous value: 97.648110014340688 is too precise
}
{
const auto pose_from = traffic_simulator::toCanonicalizedLaneletPose(
Expand All @@ -540,7 +541,8 @@ TEST_F(distanceTest_IntersectionMap, longitudinalDistance_adjacent_noOpposite_ch
pose_from.value(), pose_to.value(), true, false, lane_changeable_routing_configuration,
hdmap_utils_ptr);
ASSERT_TRUE(result.has_value());
EXPECT_DOUBLE_EQ(result.value(), 127.99532311325152);
EXPECT_NEAR(result.value(), 127.99532311325152, 0.000000001);
// Previous value: 127.99532311325152 is too precise
}
}

Expand Down

0 comments on commit c7e5e50

Please sign in to comment.