forked from celeritas-project/celeritas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AllGeoTypedTestBase.hh
96 lines (85 loc) · 2.62 KB
/
AllGeoTypedTestBase.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//----------------------------------*-C++-*----------------------------------//
// Copyright 2023-2024 UT-Battelle, LLC, and other Celeritas developers.
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
//---------------------------------------------------------------------------//
//! \file celeritas/AllGeoTypedTestBase.hh
//---------------------------------------------------------------------------//
#pragma once
#include <string>
#include <gtest/gtest.h>
#include "celeritas_config.h"
#include "orange/OrangeTestBase.hh"
#if CELERITAS_USE_VECGEOM
# include "geocel/vg/VecgeomTestBase.hh"
#endif
#if CELERITAS_USE_GEANT4
# include "geocel/g4/GeantGeoTestBase.hh"
#endif
namespace celeritas
{
namespace test
{
//---------------------------------------------------------------------------//
/*!
* Type-parameterized geometry test harness.
*
* \tparam HP Geometry host Params class
*
* To use this class to test all available geometry types, add
* \code
* ${_needs_geo} LINK_LIBRARIES ${_all_geo_libs}
* \endcode
*
* to the \c celeritas_add_test argument in CMakeLists.txt, and instantiate all
* the types with:
*
\code
template<class HP>
class MyFooTest : public AllGeoTypedTestBase<HP>
{
std::string geometry_basename() const final { return "simple-cms"; }
};
TYPED_TEST_SUITE(MyFooTest, AllGeoTestingTypes, AllGeoTestingTypeNames);
TYPED_TEST(MyFooTest, bar)
{
using GeoTrackView = typename TestFixture::GeoTrackView;
auto geo = this->geometry();
auto track = this->make_track_view({1, 2, 3}, {0, 0, 1});
}
\endcode
*/
template<class HP>
class AllGeoTypedTestBase : public GenericGeoTestBase<HP>
{
public:
using SPConstGeo = typename GenericGeoTestBase<HP>::SPConstGeo;
static std::string geo_name() { return GeoTraits<HP>::name; }
SPConstGeo build_geometry() override
{
return this->build_geometry_from_basename();
}
};
//---------------------------------------------------------------------------//
// TYPE ALIASES
//---------------------------------------------------------------------------//
using AllGeoTestingTypes = ::testing::Types<
#if CELERITAS_USE_VECGEOM
VecgeomParams,
#endif
#if CELERITAS_USE_GEANT4 && CELERITAS_REAL_TYPE == CELERITAS_REAL_TYPE_DOUBLE
GeantGeoParams,
#endif
OrangeParams>;
//! Helper class for returning type names
struct AllGeoTestingTypeNames
{
template<class U>
static std::string GetName(int)
{
return GeoTraits<U>::name;
}
};
//---------------------------------------------------------------------------//
} // namespace test
} // namespace celeritas