From b3934ef4038a48c4bbce22fdc313b408fea6b7c3 Mon Sep 17 00:00:00 2001 From: ralfulrich <ralf.ulrich@kit.edu> Date: Tue, 11 Jun 2019 14:43:46 +0200 Subject: [PATCH] added a few more basic unit-tests for Examples. This is supposed to catch future failures of this type. --- Documentation/Examples/boundary_example.cc | 4 ++++ Documentation/Examples/cascade_example.cc | 4 ++++ Documentation/Examples/vertical_EAS.cc | 4 ++++ Processes/ParticleCut/ParticleCut.h | 6 ++++-- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Documentation/Examples/boundary_example.cc b/Documentation/Examples/boundary_example.cc index f9839a7b2..ff4885b37 100644 --- a/Documentation/Examples/boundary_example.cc +++ b/Documentation/Examples/boundary_example.cc @@ -178,4 +178,8 @@ int main() { cut.GetCutEnergy() + cut.GetInvEnergy() + cut.GetEmEnergy(); cout << "total energy (GeV): " << Efinal / 1_GeV << endl << "relative difference (%): " << (Efinal / E0 - 1.) * 100 << endl; + + // basic check for unit-tests + assert(cut.GetNumberEmParticles() == 29785); + assert(cut.GetNumberInvParticles() == 26697); } diff --git a/Documentation/Examples/cascade_example.cc b/Documentation/Examples/cascade_example.cc index 3b5d56100..c2cc3c4f4 100644 --- a/Documentation/Examples/cascade_example.cc +++ b/Documentation/Examples/cascade_example.cc @@ -158,4 +158,8 @@ int main() { << "relative difference (%): " << (Efinal / E0 - 1) * 100 << endl; cout << "total dEdX energy (GeV): " << eLoss.GetTotal() / 1_GeV << endl << "relative difference (%): " << eLoss.GetTotal() / E0 * 100 << endl; + + // basic check for unit-tests + assert(cut.GetNumberEmParticles() == 127); + assert(cut.GetNumberInvParticles() == 116); } diff --git a/Documentation/Examples/vertical_EAS.cc b/Documentation/Examples/vertical_EAS.cc index 0b3d4641a..7745c1628 100644 --- a/Documentation/Examples/vertical_EAS.cc +++ b/Documentation/Examples/vertical_EAS.cc @@ -151,4 +151,8 @@ int main() { << "relative difference (%): " << (Efinal / E0 - 1) * 100 << endl; cout << "total dEdX energy (GeV): " << eLoss.GetTotal() / 1_GeV << endl << "relative difference (%): " << eLoss.GetTotal() / E0 * 100 << endl; + + // basic check for unit-tests + assert(cut.GetNumberEmParticles() == 526); + assert(cut.GetNumberInvParticles() == 645); } diff --git a/Processes/ParticleCut/ParticleCut.h b/Processes/ParticleCut/ParticleCut.h index 6d5f7a685..739a1919e 100644 --- a/Processes/ParticleCut/ParticleCut.h +++ b/Processes/ParticleCut/ParticleCut.h @@ -24,9 +24,9 @@ namespace corsika::process { units::si::HEPEnergyType fEnergy = 0 * units::si::electronvolt; units::si::HEPEnergyType fEmEnergy = 0 * units::si::electronvolt; - int fEmCount = 0; + unsigned int fEmCount = 0; units::si::HEPEnergyType fInvEnergy = 0 * units::si::electronvolt; - int fInvCount = 0; + unsigned int fInvCount = 0; public: ParticleCut(const units::si::HEPEnergyType vCut) @@ -46,6 +46,8 @@ namespace corsika::process { units::si::HEPEnergyType GetInvEnergy() const { return fInvEnergy; } units::si::HEPEnergyType GetCutEnergy() const { return fEnergy; } units::si::HEPEnergyType GetEmEnergy() const { return fEmEnergy; } + unsigned int GetNumberEmParticles() const { return fEmCount; } + unsigned int GetNumberInvParticles() const { return fInvCount; } }; } // namespace particle_cut } // namespace corsika::process -- GitLab