UncopiableAndUnmovableClass_test.cc
Go to the documentation of this file.
1 /**
2  * @file UncopiableAndUnmovableClass_test.cc
3  * @brief Tests the content of UncopiableAndUnmovableClass.h
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  * @date April 28, 2016
6  * @see UncopiableAndUnmovableClass.h
7  *
8  * This test takes no command line argument.
9  *
10  */
11 
12 /*
13  * Boost Magic: define the name of the module;
14  * and do that before the inclusion of Boost unit test headers
15  * because it will change what they provide.
16  * Among the those, there is a main() function and some wrapping catching
17  * unhandled exceptions and considering them test failures, and probably more.
18  */
19 #define BOOST_TEST_MODULE ( UncopiableAndUnmovableClass_test )
20 
21 // GArSoft libraries
22 #include "CoreUtils/UncopiableAndUnmovableClass.h"
23 
24 // Boost libraries
25 #include <cetlib/quiet_unit_test.hpp> // BOOST_AUTO_TEST_CASE()
26 #include <boost/test/test_tools.hpp> // BOOST_CHECK(), BOOST_CHECK_EQUAL()
27 
28 // C/C++ standard libraries
29 #include <type_traits>
30 
31 
32 //------------------------------------------------------------------------------
33 BOOST_AUTO_TEST_CASE(UncopiableAndUnmovableClassTest) {
34 
35  // check gar::UncopiableAndUnmovableClass class itself
36  BOOST_CHECK
38  BOOST_CHECK
40  BOOST_CHECK
42  BOOST_CHECK
44 
45 
46  // check a class derived from gar::UncopiableAndUnmovableClass class
47  struct Derived: protected gar::UncopiableAndUnmovableClass {};
48 
53 
54 
55  // check a class derived from gar::UncopiableAndUnmovableClass class
56  // and made movable
57  struct MovableDerived: protected gar::UncopiableAndUnmovableClass {
58  MovableDerived(MovableDerived&&):
60  };
61 
66 
67 
68  // check a class derived from gar::UncopiableAndUnmovableClass class
69  // and made both copy- and move-assignable
70  struct AssignableDerived: protected gar::UncopiableAndUnmovableClass {
71  AssignableDerived& operator=(AssignableDerived const&) { return *this; }
72  AssignableDerived& operator=(AssignableDerived&&) { return *this; }
73  };
74 
79 
80 } // BOOST_AUTO_TEST_CASE(larProviderFromTest)
81 
82 
83 //------------------------------------------------------------------------------
An empty class that can&#39;t be copied nor moved.
BOOST_AUTO_TEST_CASE(UncopiableAndUnmovableClassTest)