IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 625fa33d authored by Felix Riehn's avatar Felix Riehn
Browse files

added unit tests for momentum and cross section unit, fixed

parent 869844f2
No related branches found
No related tags found
No related merge requests found
......@@ -24,17 +24,6 @@ namespace phys {
} // namespace units
} // namespace phys
namespace phys {
namespace units {
namespace literals {
QUANTITY_DEFINE_SCALING_LITERALS(barn, area_d,
magnitude(corsika::units::si::constants::barn))
// phys::units::quantity<energy_d/mass_d> Joule2Kg = c2; // 1_Joule / 1_kg;
} // namespace literals
} // namespace units
}
namespace phys {
namespace units {
......@@ -49,6 +38,7 @@ namespace phys {
}
namespace corsika::units::si {
using namespace phys::units;
using namespace phys::units::literals;
......@@ -78,6 +68,30 @@ namespace corsika::units::si {
} // end namespace corsika::units::si
namespace phys {
namespace units {
namespace literals {
QUANTITY_DEFINE_SCALING_LITERALS(barn, corsika::units::si::sigma_d,
magnitude(corsika::units::si::constants::barn))
// phys::units::quantity<energy_d/mass_d> Joule2Kg = c2; // 1_Joule / 1_kg;
} // namespace literals
} // namespace units
}
namespace phys {
namespace units {
namespace literals {
QUANTITY_DEFINE_SCALING_LITERALS(newton_second, corsika::units::si::momentum_d,
magnitude(corsika::units::si::newton_second))
// phys::units::quantity<energy_d/mass_d> Joule2Kg = c2; // 1_Joule / 1_kg;
} // namespace literals
} // namespace units
}
// we want to call the operator<< without namespace... I think
using namespace phys::units::io;
......
......@@ -32,7 +32,7 @@ TEST_CASE("PhysicalUnits", "[Units]") {
LengthType l1 = 10_nm;
l1 = l1;
LengthType arr0[5];
arr0[0] = 5_m;
......@@ -41,6 +41,9 @@ TEST_CASE("PhysicalUnits", "[Units]") {
std::array<EnergyType, 4> arr2; // empty array
[[maybe_unused]] std::array<EnergyType, 4> arr3 = {1_GeV, 1_eV, 5_MeV};
[[maybe_unused]] auto p1 = 10_newton_second;
REQUIRE(p1 == 10_newton_second);
}
SECTION("Powers in literal units") {
......@@ -77,6 +80,10 @@ TEST_CASE("PhysicalUnits", "[Units]") {
REQUIRE(E2 == 40_GeV);
REQUIRE(E2 / 1_GeV == Approx(40));
const MassType m = 1_kg;
const SpeedType v = 1_m / 1_s;
REQUIRE( m*v == 1_newton_second);
const double lgE = log10(E2 / 1_GeV);
REQUIRE(lgE == Approx(log10(40.)));
......
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