Skip to content

Commit

Permalink
Fix tests (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbovbel authored Dec 11, 2023
1 parent 75ea820 commit 27423b0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions fuse_constraints/test/cost_function_gtest.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
* @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 +95,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 27423b0

Please sign in to comment.