datasize_test.cc
Go to the documentation of this file.
1 /**
2  * @file test/Utilities/datasize_test.cc
3  * @brief Unit test for `lardataalg/Utilities/quantities/datasize.h` header.
4  * @author Gianluca Petrillo (petrillo@slac.stanford.edu)
5  * @date November 2, 2018
6  * @see `lardataalg/Utilities/quantities.h`
7  *
8  */
9 
10 // Boost libraries
11 #define BOOST_TEST_MODULE ( datasize_test )
12 #include <boost/test/unit_test.hpp>
13 
14 // LArSoft libraries
16 
17 // C/C++ standard libraries
18 #include <iostream>
19 #include <type_traits> // std::decay_t<>
20 
21 
22 // -----------------------------------------------------------------------------
24 
26 
27  constexpr auto s_B = 256_B;
28  static_assert(std::is_same<decltype(s_B), util::quantities::byte const>());
29  static_assert(s_B.value() == 256U);
30  static_assert(s_B == 256_B);
31  std::cout << "Tested " << s_B << std::endl;
32 
33  constexpr auto s_kiB = 4_kiB;
34  static_assert
35  (std::is_same<decltype(s_kiB), util::quantities::kibibyte const>());
36  static_assert(s_kiB == 4_kiB);
37  static_assert(s_kiB.value() == 4U);
38  static_assert(s_kiB == 4096_B);
39  std::cout << "Tested " << s_kiB << std::endl;
40 
41  constexpr auto s_MiB = 4_MiB;
42  static_assert
43  (std::is_same<decltype(s_MiB), util::quantities::mebibyte const>());
44  static_assert(s_MiB == 4_MiB);
45  static_assert(s_MiB.value() == 4U);
46  static_assert(s_MiB == 4096_kiB);
47  std::cout << "Tested " << s_MiB << std::endl;
48 
49  constexpr auto s_GiB = 4_GiB;
50  static_assert
51  (std::is_same<decltype(s_GiB), util::quantities::gibibyte const>());
52  static_assert(s_GiB == 4_GiB);
53  static_assert(s_GiB.value() == 4U);
54  static_assert(s_GiB == 4096_MiB);
55  std::cout << "Tested " << s_GiB << std::endl;
56 
57  constexpr auto s_TiB = 4_TiB;
58  static_assert
59  (std::is_same<decltype(s_TiB), util::quantities::tebibyte const>());
60  static_assert(s_TiB == 4_TiB);
61  static_assert(s_TiB.value() == 4U);
62  static_assert(s_TiB == 4096_GiB);
63  std::cout << "Tested " << s_TiB << std::endl;
64 
65  constexpr auto s_PiB = 4_PiB;
66  static_assert
67  (std::is_same<decltype(s_PiB), util::quantities::pebibyte const>());
68  static_assert(s_PiB == 4_PiB);
69  static_assert(s_PiB.value() == 4U);
70  static_assert(s_PiB == 4096_TiB);
71  std::cout << "Tested " << s_PiB << std::endl;
72 
73  constexpr auto s_EiB = 4_EiB;
74  static_assert
75  (std::is_same<decltype(s_EiB), util::quantities::exbibyte const>());
76  static_assert(s_EiB == 4_EiB);
77  static_assert(s_EiB.value() == 4U);
78  static_assert(s_EiB == 4096_PiB);
79  std::cout << "Tested " << s_EiB << std::endl;
80 
81 } // test_datasize_literals()
82 
83 
84 // -----------------------------------------------------------------------------
85 // BEGIN Test cases -----------------------------------------------------------
86 // -----------------------------------------------------------------------------
87 BOOST_AUTO_TEST_CASE(datasize_testcase) {
88 
90 
91 } // BOOST_AUTO_TEST_CASE(datasize_testcase)
92 
93 
94 // -----------------------------------------------------------------------------
95 // END Test cases -------------------------------------------------------------
96 // -----------------------------------------------------------------------------
void test_datasize_literals()
BOOST_AUTO_TEST_CASE(datasize_testcase)
A value measured in the specified unit.
Definition: quantities.h:566
Literal constants for data size quantities.
Definition: datasize.h:224
QTextStream & endl(QTextStream &s)
Dimensioned variables representing data size.