All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Macros | Functions
DetectorTimingTypes_test.cc File Reference

Test of detinfo::DetectorTimings with DetectorClocksStandard. More...

#include <boost/test/unit_test.hpp>
#include "lardataalg/DetectorInfo/DetectorTimingTypes.h"
#include "lardataalg/Utilities/quantities/electronics.h"
#include "lardataalg/Utilities/quantities/spacetime.h"
#include "larcorealg/CoreUtils/DebugUtils.h"
#include "larcorealg/CoreUtils/MetaUtils.h"
#include "test/Utilities/disable_boost_fpc_tolerance.hpp"
#include <type_traits>

Go to the source code of this file.

Macros

#define BOOST_TEST_MODULE   ( DetectorTimingTypes_test )
 

Functions

void test_time_operations ()
 
void test_integral_tick_operations ()
 
void test_real_tick_operations ()
 
 BOOST_AUTO_TEST_CASE (OpticalTime_testcase)
 

Detailed Description

Test of detinfo::DetectorTimings with DetectorClocksStandard.

Author
Gianluca Petrillo (petri.nosp@m.llo@.nosp@m.slac..nosp@m.stan.nosp@m.ford..nosp@m.edu)
Date
June 27, 2019

Definition in file DetectorTimingTypes_test.cc.

Macro Definition Documentation

#define BOOST_TEST_MODULE   ( DetectorTimingTypes_test )

Definition at line 9 of file DetectorTimingTypes_test.cc.

Function Documentation

BOOST_AUTO_TEST_CASE ( OpticalTime_testcase  )

Definition at line 235 of file DetectorTimingTypes_test.cc.

236 {
240 }
void test_time_operations()
void test_real_tick_operations()
void test_integral_tick_operations()
void test_integral_tick_operations ( )

Definition at line 148 of file DetectorTimingTypes_test.cc.

149 {
150  using namespace util::quantities::electronics_literals;
151  using namespace detinfo::timescales;
152 
153  using traits_t = timescale_traits<OpticalTimeCategory>;
154 
155  BOOST_TEST_MESSAGE("Testing category: " << traits_t::name());
156 
157  using tick_t = traits_t::tick_t;
158  using tick_interval_t = traits_t::tick_interval_t;
159 
160  //
161  // ticks
162  //
163  tick_t tick { 100.0_tick };
164  tick_t tick2 { 50.0_tick };
165 
166  tick_interval_t dtick { 30_tick };
167 
168  static_assert(util::is_same_decay_v<decltype(tick + dtick), tick_t>);
169  BOOST_TEST(tick + dtick == 130.0_tick);
170  static_assert(util::is_same_decay_v<decltype(tick + 30.0_tick), tick_t>);
171  BOOST_TEST(tick + 30.0_tick == 130.0_tick);
172 
173  static_assert(util::is_same_decay_v<decltype(tick - dtick), tick_t>);
174  BOOST_TEST(tick - dtick == 70.0_tick);
175  static_assert(util::is_same_decay_v<decltype(tick - 30.0_tick), tick_t>);
176  BOOST_TEST(tick - 30.0_tick == 70.0_tick);
177 
178  static_assert(util::is_same_decay_v<decltype(tick - tick2), tick_interval_t>);
179  BOOST_TEST(tick - tick2 == 50_tick);
180 } // test_integral_tick_operations()
constexpr auto is_same_decay_v
Whether T and U are the same type, after being applied std::decay.
Definition: MetaUtils.h:263
Timing types for optical detector time scale.
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:75
then echo fcl name
void test_real_tick_operations ( )

Type of a point in time, measured in ticks.

Type of a time interval, measured in ticks.

Definition at line 184 of file DetectorTimingTypes_test.cc.

185 {
186  using namespace util::quantities::electronics_literals;
187  using namespace detinfo::timescales;
188  using traits_t = timescale_traits<OpticalTimeCategory>;
189 
190  BOOST_TEST_MESSAGE("Testing category: " << traits_t::name());
191 
192  using tick_d_t = traits_t::tick_d_t;
193  using tick_interval_d_t = traits_t::tick_interval_d_t;
194 
195  //
196  // ticks
197  //
198  tick_d_t tick { 100.5_tickd };
199  tick_d_t tick2 { 50.0_tickd };
200 
201  tick_interval_d_t dtick { 30_tickd };
202 
203  static_assert(util::is_same_decay_v<decltype(tick + dtick), tick_d_t>);
204  BOOST_TEST(tick + dtick == 130.5_tickd);
205  static_assert(util::is_same_decay_v<decltype(tick + 30.0_tickd), tick_d_t>);
206  BOOST_TEST(tick + 30.0_tickd == 130.5_tickd);
207 
208  static_assert(util::is_same_decay_v<decltype(tick - dtick), tick_d_t>);
209  BOOST_TEST(tick - dtick == 70.5_tickd);
210  static_assert(util::is_same_decay_v<decltype(tick - 30.0_tickd), tick_d_t>);
211  BOOST_TEST(tick - 30.0_tickd == 70.5_tickd);
212 
213  static_assert
214  (util::is_same_decay_v<decltype(tick - tick2), tick_interval_d_t>);
215  BOOST_TEST(tick - tick2 == 50.5_tickd);
216 
217 
218  /// Type of a point in time, measured in ticks.
219  using ClockTick_t = optical_tick;
220 
221  /// Type of a time interval, measured in ticks.
222  using ClockTicks_t = optical_time_ticks;
223 
224  ClockTick_t mytick { 10_tick };
225  ClockTicks_t mydelay { 5_tick };
226 
227  ClockTick_t delayedTick = mytick + mydelay;
228  BOOST_TEST(delayedTick == 15_tick);
229 } // test_real_tick_operations()
constexpr auto is_same_decay_v
Whether T and U are the same type, after being applied std::decay.
Definition: MetaUtils.h:263
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.
Definition: electronics.h:75
timescale_traits< OpticalTimeCategory >::tick_t optical_tick
then echo fcl name
void test_time_operations ( )

Definition at line 112 of file DetectorTimingTypes_test.cc.

113 {
114  using namespace util::quantities::time_literals;
115  using namespace detinfo::timescales;
116 
117  using traits_t = timescale_traits<OpticalTimeCategory>;
118 
119  BOOST_TEST_MESSAGE("Testing category: " << traits_t::name());
120 
121  using time_point_t = traits_t::time_point_t;
122  using time_interval_t = traits_t::time_interval_t;
123 
124  //
125  // time points and intervals
126  //
127  time_point_t p { 10.0_us };
128  time_point_t p2 { 5.0_us };
129 
130  time_interval_t dt { 500_ns };
131 
132  static_assert(util::is_same_decay_v<decltype(p + dt), time_point_t>);
133  BOOST_TEST(p + dt == 10.5_us);
134  static_assert(util::is_same_decay_v<decltype(p + 500_ns), time_point_t>);
135  BOOST_TEST(p + 500_ns == 10.5_us);
136 
137  static_assert(util::is_same_decay_v<decltype(p - dt), time_point_t>);
138  BOOST_TEST(p - dt == 9.5_us);
139  static_assert(util::is_same_decay_v<decltype(p - 500_ns), time_point_t>);
140  BOOST_TEST(p - 500_ns == 9.5_us);
141 
142  static_assert(util::is_same_decay_v<decltype(p - p2), time_interval_t>);
143  BOOST_TEST(p - p2 == 5.0_us);
144 } // test_time_operations()
constexpr auto is_same_decay_v
Whether T and U are the same type, after being applied std::decay.
Definition: MetaUtils.h:263
pdgs p
Definition: selectors.fcl:22
Timing types for optical detector time scale.
then echo fcl name