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

Use approximate equality checks for 3D point tests #906

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
17 changes: 17 additions & 0 deletions tests/include/detray/test/common/assert.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/** Detray library, part of the ACTS project (R&D line)
*
* (c) 2024 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

#include <gtest/gtest.h>

#pragma once

#define EXPECT_POINT3_NEAR(point1, point2, abs_error) \
do { \
EXPECT_NEAR(point1[0], point2[0], abs_error); \
EXPECT_NEAR(point1[1], point2[1], abs_error); \
EXPECT_NEAR(point1[2], point2[2], abs_error); \
} while (false)
niermann999 marked this conversation as resolved.
Show resolved Hide resolved
14 changes: 8 additions & 6 deletions tests/unit_tests/device/cuda/sf_finders_grid_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/

// Detray test include(s)
#include <detray/test/common/assert.hpp>

#include "sf_finders_grid_cuda_kernel.hpp"

// VecMem include(s).
Expand Down Expand Up @@ -316,11 +318,11 @@ TEST(grids_cuda, grid2_attach_populator) {
int pt_idx{0};
for (const auto& pt : bin) {
if (pt_idx == 0) {
EXPECT_EQ(pt, first_tp);
EXPECT_POINT3_NEAR(pt, first_tp, 1e-6);
} else if (pt_idx == 1) {
EXPECT_EQ(pt, tp);
EXPECT_POINT3_NEAR(pt, tp, 1e-6);
} else {
EXPECT_EQ(pt, invalid_tp);
EXPECT_POINT3_NEAR(pt, invalid_tp, 1e-6);
}
pt_idx++;
}
Expand Down Expand Up @@ -426,11 +428,11 @@ TEST(grids_cuda, grid2_dynamic_attach_populator) {
int pt_idx{0};
for (const auto& e : bin) {
if (pt_idx == 0) {
EXPECT_EQ(e, first_tp) << pt_idx;
EXPECT_POINT3_NEAR(e, first_tp, 1e-6);
} else if (pt_idx == 1) {
EXPECT_EQ(e, tp) << pt_idx;
EXPECT_POINT3_NEAR(e, tp, 1e-6);
} else {
EXPECT_EQ(e, invalid_tp) << pt_idx;
EXPECT_POINT3_NEAR(e, invalid_tp, 1e-6);
}
pt_idx++;
}
Expand Down
Loading