IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 4ff6f2fb authored by ralfulrich's avatar ralfulrich
Browse files

coverage

parent ea7b3832
No related branches found
No related tags found
1 merge request!337Resolve "Add kinetic energy getter for particles"
......@@ -146,12 +146,12 @@ namespace corsika::nuclear_stack {
* Overwrite normal setMomentum function with nuclear version
*/
void setMomentum(MomentumVector const& v);
/**
* Overwrite normal getMomentum function with nuclear version
*/
MomentumVector getMomentum() const;
/**
* Overwrite normal getEnergy function with nuclear version
*/
......
......@@ -87,7 +87,8 @@ namespace corsika {
///! Set energy
void setEnergy(HEPEnergyType const& e) {
super_type::getStackData().setKineticEnergy(super_type::getIndex(), e - this->getMass());
super_type::getStackData().setKineticEnergy(super_type::getIndex(),
e - this->getMass());
}
///! Set kinetic energy
......@@ -107,7 +108,8 @@ namespace corsika {
super_type::getIndex(), DirectionVector(v.getCoordinateSystem(), {0, 0, 0}));
} else {
super_type::getStackData().setKineticEnergy(
super_type::getIndex(), sqrt(square(getMass()) + square(P)) - this->getMass());
super_type::getIndex(),
sqrt(square(getMass()) + square(P)) - this->getMass());
super_type::getStackData().setDirection(super_type::getIndex(), v / P);
}
}
......
......@@ -76,6 +76,7 @@ TEST_CASE("SecondaryStack", "[stack]") {
CHECK(view.getSize() == 0);
CHECK(view.getEntries() == 0);
CHECK(view.isEmpty());
CHECK_THROWS(view.erase(view.begin())); // nothing to delete yet
{
auto proj = view.getProjectile();
......@@ -112,6 +113,7 @@ TEST_CASE("SecondaryStack", "[stack]") {
auto pDel = view.getNextParticle();
view.erase(pDel);
CHECK_THROWS(view.erase(pDel)); // already erased
CHECK(view.getSize() == 2);
CHECK(stack.getSize() == 4);
......
......@@ -71,6 +71,9 @@ TEST_CASE("Stack", "[Stack]") {
SECTION("delete from stack") {
StackTest stack;
CHECK_THROWS(stack.erase(stack.begin())); // nothing to delete
CHECK(stack.getSize() == 0);
StackTest::stack_iterator_type p =
stack.addParticle(std::tuple{0.}); // valid way to access particle data
......@@ -80,6 +83,7 @@ TEST_CASE("Stack", "[Stack]") {
stack.erase(p);
CHECK(stack.getSize() == 1);
CHECK(stack.getEntries() == 0);
CHECK_THROWS(stack.erase(p)); // already deleted
}
SECTION("delete particle") {
......
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