Skip to content

Commit

Permalink
[core] epsilonEquals in distance for test 21
Browse files Browse the repository at this point in the history
  • Loading branch information
alemuntoni committed Feb 18, 2025
1 parent 8f871e0 commit bc23dd0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions tests/core/021-grid-query/k_nearest.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ void kNearestFacesTest(

for (vcl::uint i = 0; i < points.size(); i++) {
for (vcl::uint j = 0; j < k; j++) {
if (nearestAndDists[i][j].second != nearestGrid[i][j].second) {
auto distGrid = nearestGrid[i][j].second;
auto dist = nearestAndDists[i][j].second;
if (!vcl::epsilonEquals(dist, distGrid)) {
std::cerr << "Error point " << i << std::endl;
std::cerr << "Point: " << points[i] << std::endl;
std::cerr << j << " closest\n";
Expand All @@ -134,7 +136,7 @@ void kNearestFacesTest(
<< " FaceGrid: " << nearestGrid[i][j].first
<< std::endl;
}
REQUIRE(nearestAndDists[i][j].second == nearestGrid[i][j].second);
REQUIRE(vcl::epsilonEquals(dist, distGrid));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/core/021-grid-query/nearest.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void closestFacesTest(
gridNearestFaces(grid, points, meshName<MeshType>(), gridName);

for (vcl::uint i = 0; i < points.size(); i++) {
if (dists[i] != distsGrid[i]) {
if (!vcl::epsilonEquals(dists[i], distsGrid[i])) {
std::cerr << "Error point " << i << std::endl;
std::cerr << "coord: \n" << points[i] << std::endl;
std::cerr << "cell: \n";
Expand All @@ -109,7 +109,7 @@ void closestFacesTest(
std::cerr << "computed closest: " << nearest[i]
<< " grid closest: " << nearestGrid[i] << std::endl;
}
REQUIRE(dists[i] == distsGrid[i]);
REQUIRE(vcl::epsilonEquals(dists[i], distsGrid[i]));
}
}

Expand Down

0 comments on commit bc23dd0

Please sign in to comment.