9 #include <boost/test/unit_test.hpp>
28 constexpr
auto eps = std::numeric_limits<float>::epsilon();
32 BOOST_AUTO_TEST_SUITE(MaterialAccumulatedMaterialSlab)
35 AccumulatedMaterialSlab
a;
36 auto [average, trackCount] = a.totalAverage();
38 BOOST_CHECK(not(average));
39 BOOST_CHECK_EQUAL(trackCount, 0
u);
44 AccumulatedMaterialSlab
a;
48 auto [average, trackCount] = a.totalAverage();
49 BOOST_CHECK(not(average));
50 BOOST_CHECK_EQUAL(trackCount, 0
u);
55 AccumulatedMaterialSlab
a;
59 auto [average, trackCount] = a.totalAverage();
60 BOOST_CHECK(not(average));
61 BOOST_CHECK_EQUAL(trackCount, 3
u);
66 AccumulatedMaterialSlab
a;
73 auto [average, trackCount] = a.totalAverage();
74 BOOST_CHECK_EQUAL(trackCount, 1
u);
75 BOOST_CHECK_EQUAL(average.material(), unit.material());
76 BOOST_CHECK_EQUAL(average.thickness(), 3 * unit.thickness());
77 BOOST_CHECK_EQUAL(average.thicknessInX0(), 3.0f);
78 BOOST_CHECK_EQUAL(average.thicknessInL0(), 3.0f);
86 auto [average, trackCount] = a.totalAverage();
87 BOOST_CHECK_EQUAL(trackCount, 2
u);
89 BOOST_CHECK_EQUAL(average.material(), unit.material());
90 BOOST_CHECK_EQUAL(average.thickness(), 3 * unit.thickness());
91 BOOST_CHECK_EQUAL(average.thicknessInX0(), 3.0f);
92 BOOST_CHECK_EQUAL(average.thicknessInL0(), 3.0f);
100 AccumulatedMaterialSlab
a;
107 auto [average, trackCount] = a.totalAverage();
108 BOOST_CHECK_EQUAL(trackCount, 1
u);
109 BOOST_CHECK_EQUAL(average.material(), unit.material());
110 BOOST_CHECK_EQUAL(average.thickness(), 3 * unit.thickness());
111 BOOST_CHECK_EQUAL(average.thicknessInX0(), 3.0f);
112 BOOST_CHECK_EQUAL(average.thicknessInL0(), 3.0f);
116 MaterialSlab twice = unit;
117 twice.scaleThickness(2);
121 auto [average, trackCount] = a.totalAverage();
122 BOOST_CHECK_EQUAL(trackCount, 2
u);
124 BOOST_CHECK_EQUAL(average.material(), unit.material());
125 BOOST_CHECK_EQUAL(average.thickness(), 3 * unit.thickness());
126 BOOST_CHECK_EQUAL(average.thicknessInX0(), 3.0f);
127 BOOST_CHECK_EQUAL(average.thicknessInL0(), 3.0f);
131 MaterialSlab thrice = unit;
132 thrice.scaleThickness(3);
133 a.accumulate(thrice);
135 auto [average, trackCount] = a.totalAverage();
136 BOOST_CHECK_EQUAL(trackCount, 3
u);
138 BOOST_CHECK_EQUAL(average.material(), unit.material());
139 BOOST_CHECK_EQUAL(average.thickness(), 3 * unit.thickness());
140 BOOST_CHECK_EQUAL(average.thicknessInX0(), 3.0f);
141 BOOST_CHECK_EQUAL(average.thicknessInL0(), 3.0f);
148 AccumulatedMaterialSlab
a;
153 auto [average, trackCount] = a.totalAverage();
154 BOOST_CHECK_EQUAL(trackCount, 1
u);
155 BOOST_CHECK_EQUAL(average.material(), unit.material());
156 BOOST_CHECK_EQUAL(average.thickness(), unit.thickness());
157 BOOST_CHECK_EQUAL(average.thicknessInX0(), unit.thicknessInX0());
158 BOOST_CHECK_EQUAL(average.thicknessInL0(), unit.thicknessInL0());
162 MaterialSlab three = unit;
163 three.scaleThickness(3);
166 auto [average, trackCount] = a.totalAverage();
167 BOOST_CHECK_EQUAL(trackCount, 2);
169 BOOST_CHECK_EQUAL(average.material(), unit.material());
170 BOOST_CHECK_EQUAL(average.thickness(), 2 * unit.thickness());
171 BOOST_CHECK_EQUAL(average.thicknessInX0(), 2 * unit.thicknessInX0());
172 BOOST_CHECK_EQUAL(average.thicknessInL0(), 2 * unit.thicknessInL0());
176 MaterialSlab vac(2 * unit.thickness());
182 auto [average, trackCount] = a.totalAverage();
183 BOOST_CHECK_EQUAL(trackCount, 4
u);
188 0.5f * unit.material().molarDensity(),
eps);
194 BOOST_CHECK_EQUAL(average.thicknessInX0(), 1 * unit.thicknessInX0());
195 BOOST_CHECK_EQUAL(average.thicknessInL0(), 1 * unit.thicknessInL0());
197 BOOST_CHECK_EQUAL(average.thickness(), 2 * unit.thickness());
201 BOOST_AUTO_TEST_SUITE_END()