Skip to content

Commit

Permalink
Removed the unused tolerance parameter from
Browse files Browse the repository at this point in the history
ExpectCostFunctionsAreEqual, and replaced EXPECT_NEAR
with EXPECT_DOUBLE_EQ to prevent jenkins error.
  • Loading branch information
oscarmendezm committed Nov 27, 2023
1 parent 6bb6233 commit 5ab5580
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions fuse_constraints/test/cost_function_gtest.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@
*
* @param[in] cost_function The expected cost function
* @param[in] actual_cost_function The actual cost function
* @param[in] tolerance The tolerance to use when comparing the cost functions are equal. Defaults to 1e-18
*/
static void ExpectCostFunctionsAreEqual(const ceres::CostFunction& cost_function,
const ceres::CostFunction& actual_cost_function, double tolerance = 1e-18)
const ceres::CostFunction& actual_cost_function)
{
EXPECT_EQ(cost_function.num_residuals(), actual_cost_function.num_residuals());
const size_t num_residuals = cost_function.num_residuals();
Expand Down Expand Up @@ -95,20 +94,20 @@ static void ExpectCostFunctionsAreEqual(const ceres::CostFunction& cost_function
EXPECT_TRUE(actual_cost_function.Evaluate(parameter_blocks.get(), actual_residuals.get(), nullptr));
for (size_t i = 0; i < num_residuals; ++i)
{
EXPECT_NEAR(residuals[i], actual_residuals[i], tolerance) << "residual id: " << i;
EXPECT_DOUBLE_EQ(residuals[i], actual_residuals[i]) << "residual id: " << i;
}

EXPECT_TRUE(cost_function.Evaluate(parameter_blocks.get(), residuals.get(), jacobian_blocks.get()));
EXPECT_TRUE(
actual_cost_function.Evaluate(parameter_blocks.get(), actual_residuals.get(), actual_jacobian_blocks.get()));
for (size_t i = 0; i < num_residuals; ++i)
{
EXPECT_NEAR(residuals[i], actual_residuals[i], tolerance) << "residual : " << i;
EXPECT_DOUBLE_EQ(residuals[i], actual_residuals[i]) << "residual : " << i;
}

for (size_t i = 0; i < num_residuals * num_parameters; ++i)
{
EXPECT_NEAR(jacobians[i], actual_jacobians[i], tolerance)
EXPECT_DOUBLE_EQ(jacobians[i], actual_jacobians[i])
<< "jacobian : " << i << " " << jacobians[i] << " " << actual_jacobians[i];
}
}
Expand Down

0 comments on commit 5ab5580

Please sign in to comment.