IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 8bd09d1c authored by ralfulrich's avatar ralfulrich
Browse files

futher tests, coverage

parent c9b72fb6
No related branches found
No related tags found
1 merge request!337Resolve "Add kinetic energy getter for particles"
Pipeline #4351 passed with warnings
......@@ -334,6 +334,8 @@ TEST_CASE("Distance between points") {
CHECK(distance(p5, p6) / 1_m == Approx(1));
}
TEST_CASE("Geometry Tree") {}
TEST_CASE("Path") {
// define a known CS
CoordinateSystemPtr root = get_root_CoordinateSystem();
......
......@@ -38,10 +38,43 @@ CoordinateSystemPtr const& gCS = get_root_CoordinateSystem();
Point const gOrigin(gCS, {0_m, 0_m, 0_m});
TEST_CASE("VolumeTree") {
logging::set_level(logging::level::info);
Environment<IEmpty> env;
auto& universe = *(env.getUniverse());
auto world = Environment<IEmpty>::createNode<Sphere>(Point{gCS, 0_m, 0_m, 0_m}, 150_km);
// volume cut partly by "world"
auto vol1 =
Environment<IEmpty>::createNode<Sphere>(Point{gCS, 0_m, 0_m, 140_km}, 20_km);
// partly overlap with "vol1"
auto vol2 = Environment<IEmpty>::createNode<Sphere>(Point{gCS, 0_m, 0_m, 120_km}, 5_km);
vol1->excludeOverlapWith(vol2);
world->addChild(std::move(vol1));
world->addChild(std::move(vol2));
// in world
CHECK(dynamic_cast<Sphere const&>(
world->getContainingNode(Point(gCS, 0_m, 0_m, 0_m))->getVolume())
.getRadius() == 150_km);
// in vol1
CHECK(dynamic_cast<Sphere const&>(
world->getContainingNode(Point(gCS, 0_m, 0_m, 149_km))->getVolume())
.getRadius() == 20_km);
// outside world, in universe
CHECK(world->getContainingNode(Point(gCS, 0_m, 151_km, 0_m)) == nullptr);
// in vol2
CHECK(dynamic_cast<Sphere const&>(
world->getContainingNode(Point(gCS, 0_m, 0_km, 119_km))->getVolume())
.getRadius() == 5_km);
CHECK(dynamic_cast<Sphere const&>(
world->getContainingNode(Point(gCS, 0_m, 0_km, 121_km))->getVolume())
.getRadius() == 5_km);
universe.addChild(std::move(world));
}
TEST_CASE("HomogeneousMedium") {
logging::set_level(logging::level::info);
corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v");
NuclearComposition const protonComposition(std::vector<Code>{Code::Proton},
std::vector<float>{1.f});
......@@ -54,7 +87,6 @@ TEST_CASE("HomogeneousMedium") {
TEST_CASE("FlatExponential") {
logging::set_level(logging::level::info);
corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v");
NuclearComposition const protonComposition(std::vector<Code>{Code::Proton},
std::vector<float>{1.f});
......@@ -117,7 +149,6 @@ TEST_CASE("FlatExponential") {
TEST_CASE("SlidingPlanarExponential") {
logging::set_level(logging::level::info);
corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v");
NuclearComposition const protonComposition(std::vector<Code>{Code::Proton},
std::vector<float>{1.f});
......@@ -178,7 +209,6 @@ struct Exponential {
TEST_CASE("InhomogeneousMedium") {
logging::set_level(logging::level::info);
corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v");
Vector direction(gCS, QuantityVector<dimensionless_d>(1, 0, 0));
......@@ -227,7 +257,6 @@ TEST_CASE("InhomogeneousMedium") {
TEST_CASE("LayeredSphericalAtmosphereBuilder") {
logging::set_level(logging::level::info);
corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v");
LayeredSphericalAtmosphereBuilder builder =
make_layered_spherical_atmosphere_builder<>::create(gOrigin,
......@@ -267,7 +296,6 @@ TEST_CASE("LayeredSphericalAtmosphereBuilder") {
TEST_CASE("LayeredSphericalAtmosphereBuilder w/ magnetic field") {
logging::set_level(logging::level::info);
corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v");
// setup our interface types
using ModelInterface = IMagneticFieldModel<IMediumModel>;
......
......@@ -27,7 +27,6 @@ using namespace corsika;
TEST_CASE("MediumProperties") {
logging::set_level(logging::level::info);
corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v");
// test access of medium properties via enum and class types
......@@ -45,7 +44,6 @@ TEST_CASE("MediumProperties") {
TEST_CASE("MediumPropertyModel w/ Homogeneous") {
logging::set_level(logging::level::info);
corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v");
CoordinateSystemPtr gCS = get_root_CoordinateSystem();
......
......@@ -48,7 +48,6 @@ auto setupEnvironment(Code vTargetCode) {
TEST_CASE("Homogeneous Density") {
logging::set_level(logging::level::info);
corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v");
auto [env, csPtr, nodePtr] = setupEnvironment(Code::Nitrogen);
auto const& cs = *csPtr;
......@@ -62,7 +61,7 @@ TEST_CASE("Homogeneous Density") {
Point const injectionPos = showerCore + Vector<dimensionless_d>{cs, {0, 0, 1}} * t;
ShowerAxis const showerAxis{injectionPos, (showerCore - injectionPos), *env,
true, // -> do not throw exceptions
true, // -> throw exceptions
20}; // -> number of bins
CHECK(showerAxis.getSteplength() == 500_m);
......@@ -83,4 +82,11 @@ TEST_CASE("Homogeneous Density") {
CHECK_THROWS(showerAxis.getX(-1_m));
CHECK_THROWS(showerAxis.getX((injectionPos - showerCore).getNorm() + 1_m));
ShowerAxis const showerAxisNoThrow{injectionPos, (showerCore - injectionPos), *env,
false, // -> do not throw exceptions
20}; // -> number of bins
CHECK(showerAxisNoThrow.getX(-1_m) == showerAxis.getMinimumX());
CHECK(showerAxisNoThrow.getX((injectionPos - showerCore).getNorm() + 1_m) ==
showerAxis.getMaximumX());
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment