testProcessSequence.cpp 33.13 KiB
/*
* (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
*/
#define CORSIKA_UNIT_TESTING
#include <corsika/framework/process/ProcessSequence.hpp>
#include <corsika/framework/process/SwitchProcessSequence.hpp>
#include <corsika/framework/process/ProcessTraits.hpp>
#include <corsika/framework/process/ContinuousProcessStepLength.hpp>
#include <corsika/framework/core/PhysicalUnits.hpp>
#include <corsika/framework/core/Step.hpp>
#include <corsika/framework/utility/COMBoost.hpp>
#include <corsika/media/NuclearComposition.hpp>
#include <catch2/catch.hpp>
#include <array>
#include <iomanip>
#include <iostream>
#include <typeinfo>
#include <boost/type_index.hpp>
/*
Unit test for testing all Process types and their arrangement in
containers ProcessSequence and SwitchProcessSequence
*/
using namespace corsika;
using namespace std;
struct DummyRNG {
int max() const { return 10; }
int min() const { return 0; }
double operator()() const { return 0.5; }
};
static int const nData = 10;
// DummyNode is only needed for BoundaryCrossingProcess
struct DummyNode {
DummyNode(int v)
: data_(v) {}
int data_ = 0;
};
// our data object (particle) is a simple arrary of doubles
struct DummyData {
double data_[nData] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
typedef DummyNode node_type; // for BoundaryCrossingProcess
Code getPID() const { return Code::Proton; }
MomentumVector getMomentum() const {
// only need the coordinate system
return MomentumVector{get_root_CoordinateSystem(), 0_eV, 0_eV, 0_eV};
}
HEPEnergyType getEnergy() const { return 10_GeV; }
Point getPosition() const { return Point(get_root_CoordinateSystem(), 0_m, 0_m, 0_m); }
DirectionVector getDirection() const { return DirectionVector{get_root_CoordinateSystem(), {0, 0, 0} }; }
};
// The stack is non-existent for this example
struct DummyStack {};