9 #define BOOST_TEST_MODULE ( DetectorTimingTypes_test ) 10 #include <boost/test/unit_test.hpp> 21 #include <type_traits> 28 static_assert(!detinfo::timescales::is_tick_v<double>);
30 (!detinfo::timescales::is_tick_v<util::quantities::second>);
32 ( detinfo::timescales::is_tick_v<util::quantities::tick>);
34 ( detinfo::timescales::is_tick_v<util::quantities::tick_d>);
36 (!detinfo::timescales::is_tick_v<detinfo::timescales::optical_time>);
38 ( detinfo::timescales::is_tick_v<detinfo::timescales::optical_tick>);
40 ( detinfo::timescales::is_tick_v<detinfo::timescales::optical_time_ticks>);
45 ::same_category_as<detinfo::timescales::optical_time>
49 ::category_compatible_with<detinfo::timescales::optical_time>
53 ::same_category_as<detinfo::timescales::optical_tick>
57 ::category_compatible_with<detinfo::timescales::optical_tick>
63 detinfo::timescales::optical_time::category_compatible_with
67 detinfo::timescales::optical_time::category_compatible_with
71 detinfo::timescales::optical_time::category_compatible_with
75 detinfo::timescales::optical_time::category_compatible_with
79 detinfo::timescales::optical_time::category_compatible_with
83 detinfo::timescales::optical_time::category_compatible_with
87 detinfo::timescales::optical_time::category_compatible_with
91 !detinfo::timescales::optical_time::category_compatible_with
99 static_assert(std::is_same_v<
104 static_assert(std::is_same_v<
121 using time_point_t = traits_t::time_point_t;
122 using time_interval_t = traits_t::time_interval_t;
127 time_point_t
p { 10.0_us };
128 time_point_t p2 { 5.0_us };
130 time_interval_t dt { 500_ns };
133 BOOST_TEST(
p + dt == 10.5_us);
135 BOOST_TEST(
p + 500_ns == 10.5_us);
138 BOOST_TEST(
p - dt == 9.5_us);
140 BOOST_TEST(
p - 500_ns == 9.5_us);
143 BOOST_TEST(
p - p2 == 5.0_us);
157 using tick_t = traits_t::tick_t;
158 using tick_interval_t = traits_t::tick_interval_t;
163 tick_t
tick { 100.0_tick };
164 tick_t tick2 { 50.0_tick };
166 tick_interval_t dtick { 30_tick };
169 BOOST_TEST(
tick + dtick == 130.0_tick);
171 BOOST_TEST(
tick + 30.0_tick == 130.0_tick);
174 BOOST_TEST(
tick - dtick == 70.0_tick);
176 BOOST_TEST(
tick - 30.0_tick == 70.0_tick);
179 BOOST_TEST(
tick - tick2 == 50_tick);
192 using tick_d_t = traits_t::tick_d_t;
193 using tick_interval_d_t = traits_t::tick_interval_d_t;
198 tick_d_t
tick { 100.5_tickd };
199 tick_d_t tick2 { 50.0_tickd };
201 tick_interval_d_t dtick { 30_tickd };
204 BOOST_TEST(
tick + dtick == 130.5_tickd);
206 BOOST_TEST(
tick + 30.0_tickd == 130.5_tickd);
209 BOOST_TEST(
tick - dtick == 70.5_tickd);
211 BOOST_TEST(
tick - 30.0_tickd == 70.5_tickd);
215 BOOST_TEST(
tick - tick2 == 50.5_tickd);
224 ClockTick_t mytick { 10_tick };
225 ClockTicks_t mydelay { 5_tick };
227 ClockTick_t delayedTick = mytick + mydelay;
228 BOOST_TEST(delayedTick == 15_tick);
233 BOOST_AUTO_TEST_SUITE(DetectorTimingTypes_test)
242 BOOST_AUTO_TEST_SUITE_END()
Literal constants for electronics quantities.
void test_time_operations()
A collection of traits for a time scale.
BOOST_AUTO_TEST_CASE(OpticalTime_testcase)
Functions to help debugging by instrumenting code.
timescale_traits< OpticalTimeCategory >::tick_interval_d_t optical_time_ticks_d
timescale_traits< OpticalTimeCategory >::tick_interval_t optical_time_ticks
Timing types for optical detector time scale.
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
timescale_traits< OpticalTimeCategory >::time_point_t optical_time
A point in time on the optical detector electronics time scale.
An interval (duration, length, distance) between two quantity points.
Literal constants for time quantities.
Category for electronics time scale.
Dimensioned variables related to electronics.
timescale_traits< OpticalTimeCategory >::tick_t optical_tick
void test_real_tick_operations()
Dimensioned variables representing space or time quantities.
Data types for detinfo::DetectorTimings.
timescale_traits< OpticalTimeCategory >::tick_d_t optical_tick_d
void test_integral_tick_operations()
Namespace including different time scales as defined in LArSoft.
timescale_traits< ElectronicsTimeCategory >::time_point_t electronics_time
A point in time on the electronics time scale.