File indexing completed on 2025-08-03 08:09:25
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #define BOOST_TEST_MODULE AbortList Tests
0011
0012 #include <boost/test/included/unit_test.hpp>
0013
0014
0015 #include <boost/test/data/test_case.hpp>
0016
0017
0018 #include <boost/test/output_test_stream.hpp>
0019
0020
0021 #include "Fatras/Kernel/PhysicsList.hpp"
0022
0023 namespace bdata = boost::unit_test::data;
0024 namespace tt = boost::test_tools;
0025
0026 namespace Fatras {
0027
0028 namespace Test {
0029
0030
0031 struct Generator {};
0032
0033 struct Detector {};
0034
0035 struct Particle {};
0036
0037
0038 struct SterileProcess {
0039
0040 int some_parameter = 0;
0041
0042
0043 template <typename generator_t, typename detector_t, typename particle_t>
0044 bool operator()(generator_t &, const detector_t &, particle_t &,
0045 std::vector<particle_t> &) const {
0046 return false;
0047 }
0048 };
0049
0050
0051 struct FatalProcess {
0052
0053
0054 template <typename generator_t, typename detector_t, typename particle_t>
0055 bool operator()(generator_t &, const detector_t &, particle_t &,
0056 std::vector<particle_t> &) const {
0057 return true;
0058 }
0059 };
0060
0061
0062 BOOST_AUTO_TEST_CASE(PhysicsLists_test) {
0063 Generator generator;
0064 Detector detector;
0065 Particle in;
0066 std::vector<Particle> out;
0067
0068
0069 typedef PhysicsList<> ProcessLess;
0070 ProcessLess emptyList;
0071
0072
0073 BOOST_TEST(!emptyList(generator, detector, in, out));
0074
0075
0076 typedef PhysicsList<SterileProcess> SterileList;
0077 SterileList sterileProcess;
0078
0079
0080 auto &sp = sterileProcess.get<SterileProcess>();
0081 sp.some_parameter = 2;
0082 BOOST_TEST(sterileProcess.get<SterileProcess>().some_parameter == 2);
0083
0084
0085 BOOST_TEST(!sterileProcess(generator, detector, in, out));
0086
0087
0088 typedef PhysicsList<FatalProcess> FatalList;
0089 FatalList fatalProcess;
0090
0091
0092 BOOST_TEST(fatalProcess(generator, detector, in, out));
0093
0094
0095 typedef PhysicsList<SterileProcess, FatalProcess> SterileFatalList;
0096 SterileFatalList stfaProcess;
0097
0098
0099 BOOST_TEST(stfaProcess(generator, detector, in, out));
0100 }
0101
0102 }
0103 }