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

Unit test for lardataalg/Utilities/quantities/frequency.h header. More...

#include <boost/test/unit_test.hpp>
#include "lardataalg/Utilities/quantities/frequency.h"
#include <type_traits>

Go to the source code of this file.

Macros

#define BOOST_TEST_MODULE   ( frequency_test )
 

Functions

void test_frequency_literals ()
 
void test_frequency_special_operations ()
 
 BOOST_AUTO_TEST_CASE (frequency_testcase)
 

Detailed Description

Unit test for lardataalg/Utilities/quantities/frequency.h header.

Author
Gianluca Petrillo (petri.nosp@m.llo@.nosp@m.slac..nosp@m.stan.nosp@m.ford..nosp@m.edu)
Date
November 2, 2018
See Also
lardataalg/Utilities/quantities.h

Definition in file frequency_test.cc.

Macro Definition Documentation

#define BOOST_TEST_MODULE   ( frequency_test )

Definition at line 11 of file frequency_test.cc.

Function Documentation

BOOST_AUTO_TEST_CASE ( frequency_testcase  )

Definition at line 90 of file frequency_test.cc.

90  {
91 
94 
95 } // BOOST_AUTO_TEST_CASE(frequency_testcase)
void test_frequency_literals()
void test_frequency_special_operations()
void test_frequency_literals ( )

Definition at line 22 of file frequency_test.cc.

22  {
23 
24  using namespace util::quantities::frequency_literals;
25 
26  constexpr auto f_Hz = 2_Hz;
27  static_assert(std::is_same<decltype(f_Hz), util::quantities::hertz const>());
28  static_assert(double(f_Hz) == 2.0);
29  static_assert(f_Hz == 2.0_Hz);
30 
31  constexpr auto f_kHz = 20_kHz;
32  static_assert
33  (std::is_same<decltype(f_kHz), util::quantities::kilohertz const>());
34  static_assert(double(f_kHz) == 20.0);
35  static_assert(f_kHz == 20.0_kHz);
36 
37  constexpr auto f_MHz = 200_MHz;
38  static_assert
39  (std::is_same<decltype(f_MHz), util::quantities::megahertz const>());
40  static_assert(double(f_MHz) == 200.0);
41  static_assert(f_MHz == 200.0_MHz);
42 
43  constexpr auto f_GHz = 5_GHz;
44  static_assert
45  (std::is_same<decltype(f_GHz), util::quantities::gigahertz const>());
46  static_assert(double(f_GHz) == 5.0);
47  static_assert(f_GHz == 5.0_GHz);
48 
49 } // test_frequency_literals()
A value measured in the specified unit.
Definition: quantities.h:566
void test_frequency_special_operations ( )

Definition at line 53 of file frequency_test.cc.

53  {
54 
55  using namespace util::quantities::time_literals;
56  using namespace util::quantities::frequency_literals;
57 
58  // ---------------------------------------------------------------------------
59 
60  static_assert(std::is_same<decltype(5_us * 2_MHz), double>());
61  static_assert(5_us * 2_MHz == 10.0);
62  static_assert(5_ms * 2_MHz == 10'000.0);
63 
64  static_assert(std::is_same<decltype(2_MHz * 5_us), double>());
65  static_assert(2_MHz * 5_us == 10.0);
66  static_assert(2_MHz * 5_ms == 10'000.0);
67 
68  // ---------------------------------------------------------------------------
69 
70  static_assert
71  (std::is_same<decltype(10 / 5_us), util::quantities::megahertz>());
72  static_assert(10 / 5_us == 2_MHz);
73  static_assert(10'000.0 / 5_ms == 2_MHz);
74 
75  // ---------------------------------------------------------------------------
76 
77  static_assert
78  (std::is_same<decltype(10 / 2_MHz), util::quantities::microsecond>());
79  static_assert(10 / 2_MHz == 5_us);
80  static_assert(10'000.0 / 2_MHz == 5_ms);
81 
82  // ---------------------------------------------------------------------------
83 
84 } // test_constexpr_operations()
A value measured in the specified unit.
Definition: quantities.h:566