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.
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.
#define BOOST_TEST_MODULE ( frequency_test ) |
BOOST_AUTO_TEST_CASE |
( |
frequency_testcase |
| ) |
|
Definition at line 90 of file frequency_test.cc.
void test_frequency_literals()
void test_frequency_special_operations()
void test_frequency_literals |
( |
| ) |
|
Definition at line 22 of file frequency_test.cc.
24 using namespace util::quantities::frequency_literals;
26 constexpr
auto f_Hz = 2_Hz;
28 static_assert(
double(f_Hz) == 2.0);
29 static_assert(f_Hz == 2.0_Hz);
31 constexpr
auto f_kHz = 20_kHz;
34 static_assert(
double(f_kHz) == 20.0);
35 static_assert(f_kHz == 20.0_kHz);
37 constexpr
auto f_MHz = 200_MHz;
40 static_assert(
double(f_MHz) == 200.0);
41 static_assert(f_MHz == 200.0_MHz);
43 constexpr
auto f_GHz = 5_GHz;
46 static_assert(
double(f_GHz) == 5.0);
47 static_assert(f_GHz == 5.0_GHz);
A value measured in the specified unit.
void test_frequency_special_operations |
( |
| ) |
|
Definition at line 53 of file frequency_test.cc.
55 using namespace util::quantities::time_literals;
56 using namespace util::quantities::frequency_literals;
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);
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);
72 static_assert(10 / 5_us == 2_MHz);
73 static_assert(10
'000.0 / 5_ms == 2_MHz);
75 // ---------------------------------------------------------------------------
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);
A value measured in the specified unit.