8 #include <framework/gearbox/Unit.h>
10 #include <framework/utilities/TestHelpers.h>
12 #include <gtest/gtest.h>
20 TEST(UnitTest, MultiplyDivide)
23 double length = 10.0 * Unit::mm;
25 EXPECT_DOUBLE_EQ(1.0, length);
27 EXPECT_DOUBLE_EQ(10.0, length / Unit::mm);
28 EXPECT_DOUBLE_EQ(10000.0, length / Unit::um);
30 EXPECT_DOUBLE_EQ(1e9, 1 * Unit::s);
34 TEST(UnitTest, ConvertValue)
37 EXPECT_DOUBLE_EQ(1.0, Unit::convertValue(1.0,
"cm"));
38 EXPECT_DOUBLE_EQ(1.0, Unit::convertValue(1.0,
"ns"));
39 EXPECT_DOUBLE_EQ(1.0, Unit::convertValue(1.0,
"rad"));
40 EXPECT_DOUBLE_EQ(1.0, Unit::convertValue(1.0,
"GeV"));
41 EXPECT_DOUBLE_EQ(1.0, Unit::convertValue(1.0,
"K"));
42 EXPECT_DOUBLE_EQ(1e-4, Unit::convertValue(1.0,
"T"));
43 EXPECT_DOUBLE_EQ(1.0, Unit::convertValue(1.0,
"e"));
44 EXPECT_DOUBLE_EQ(1.0, Unit::convertValue(1.0,
"g/cm3"));
47 EXPECT_DOUBLE_EQ(1e2, Unit::convertValue(1.0,
"m"));
48 EXPECT_DOUBLE_EQ(1e5, Unit::convertValue(1.0,
"km"));
49 EXPECT_DOUBLE_EQ(1e-1, Unit::convertValue(1.0,
"mm"));
50 EXPECT_DOUBLE_EQ(1e-4, Unit::convertValue(1.0,
"um"));
51 EXPECT_DOUBLE_EQ(1e-7, Unit::convertValue(1.0,
"nm"));
54 EXPECT_DOUBLE_EQ(5e3 * 1e2, Unit::convertValue(5e3,
"m"));
55 EXPECT_DOUBLE_EQ(5e-3 * 1e2, Unit::convertValue(5e-3,
"m"));
56 EXPECT_DOUBLE_EQ(M_PI, Unit::convertValue(180.0,
"deg"));
59 EXPECT_B2ERROR(EXPECT_DOUBLE_EQ(5e3, Unit::convertValue(5e3,
"nonexistingunit")));
63 TEST(UnitTest, ConvertValueToUnit)
66 EXPECT_DOUBLE_EQ(1.0, Unit::convertValueToUnit(1.0,
"cm"));
67 EXPECT_DOUBLE_EQ(1.0, Unit::convertValueToUnit(1.0,
"ns"));
68 EXPECT_DOUBLE_EQ(1.0, Unit::convertValueToUnit(1.0,
"rad"));
69 EXPECT_DOUBLE_EQ(1.0, Unit::convertValueToUnit(1.0,
"GeV"));
70 EXPECT_DOUBLE_EQ(1.0, Unit::convertValueToUnit(1.0,
"K"));
71 EXPECT_DOUBLE_EQ(1.0, Unit::convertValueToUnit(1e-4,
"T"));
72 EXPECT_DOUBLE_EQ(1.0, Unit::convertValueToUnit(1.0,
"e"));
73 EXPECT_DOUBLE_EQ(1.0, Unit::convertValueToUnit(1.0,
"g/cm3"));
76 EXPECT_DOUBLE_EQ(1e-2, Unit::convertValueToUnit(1.0,
"m"));
77 EXPECT_DOUBLE_EQ(1e-5, Unit::convertValueToUnit(1.0,
"km"));
78 EXPECT_DOUBLE_EQ(1e1, Unit::convertValueToUnit(1.0,
"mm"));
79 EXPECT_DOUBLE_EQ(1e4, Unit::convertValueToUnit(1.0,
"um"));
80 EXPECT_DOUBLE_EQ(1e7, Unit::convertValueToUnit(1.0,
"nm"));
83 EXPECT_DOUBLE_EQ(5e3 * 1e-2, Unit::convertValueToUnit(5e3,
"m"));
84 EXPECT_DOUBLE_EQ(5e-3 * 1e-2, Unit::convertValueToUnit(5e-3,
"m"));
85 EXPECT_DOUBLE_EQ(180.0, Unit::convertValueToUnit(M_PI,
"deg"));
88 EXPECT_B2ERROR(EXPECT_DOUBLE_EQ(5e3, Unit::convertValueToUnit(5e3,
"nonexistingunit")));
TEST(TestgetDetectorRegion, TestgetDetectorRegion)
Test Constructors.
Abstract base class for different kinds of events.