Macros | Functions
datasize_test.cc File Reference

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

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

Go to the source code of this file.

Macros

#define BOOST_TEST_MODULE   ( datasize_test )
 

Functions

void test_datasize_literals ()
 
 BOOST_AUTO_TEST_CASE (datasize_testcase)
 

Detailed Description

Unit test for lardataalg/Utilities/quantities/datasize.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 datasize_test.cc.

Macro Definition Documentation

#define BOOST_TEST_MODULE   ( datasize_test )

Definition at line 11 of file datasize_test.cc.

Function Documentation

BOOST_AUTO_TEST_CASE ( datasize_testcase  )

Definition at line 87 of file datasize_test.cc.

87  {
88 
90 
91 } // BOOST_AUTO_TEST_CASE(datasize_testcase)
void test_datasize_literals()
void test_datasize_literals ( )

Definition at line 23 of file datasize_test.cc.

23  {
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()
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)