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 larcorealg/CoreUtils/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 // LArSoft libraries
23 
24 // Boost libraries
25 #include <boost/test/unit_test.hpp>
26 
27 // C/C++ standard libraries
28 #include <type_traits>
29 
30 
31 //------------------------------------------------------------------------------
32 // static checks
33 static_assert( std::is_copy_constructible_v<lar::PolymorphicClass>);
34 static_assert( std::is_copy_assignable_v <lar::PolymorphicClass>);
35 static_assert( std::is_move_constructible_v<lar::PolymorphicClass>);
36 static_assert( std::is_move_assignable_v <lar::PolymorphicClass>);
37 
38 static_assert(!std::is_copy_constructible_v<lar::PolymorphicUncopiableClass>);
39 static_assert(!std::is_copy_assignable_v <lar::PolymorphicUncopiableClass>);
40 static_assert( std::is_move_constructible_v<lar::PolymorphicUncopiableClass>);
41 static_assert( std::is_move_assignable_v <lar::PolymorphicUncopiableClass>);
42 
43 static_assert( std::is_copy_constructible_v<lar::PolymorphicUnmovableClass>);
44 static_assert( std::is_copy_assignable_v <lar::PolymorphicUnmovableClass>);
45 static_assert(!std::is_move_constructible_v<lar::PolymorphicUnmovableClass>);
46 static_assert(!std::is_move_assignable_v <lar::PolymorphicUnmovableClass>);
47 
48 static_assert(!std::is_copy_constructible_v<lar::PolymorphicUncopiableAndUnmovableClass>);
49 static_assert(!std::is_copy_assignable_v <lar::PolymorphicUncopiableAndUnmovableClass>);
50 static_assert(!std::is_move_constructible_v<lar::PolymorphicUncopiableAndUnmovableClass>);
51 static_assert(!std::is_move_assignable_v <lar::PolymorphicUncopiableAndUnmovableClass>);
52 
53 
54 //------------------------------------------------------------------------------
55 BOOST_AUTO_TEST_CASE(UncopiableAndUnmovableClassTest) {
56 
57  // check lar::UncopiableAndUnmovableClass class itself
58  BOOST_TEST
60  BOOST_TEST
62  BOOST_TEST
64  BOOST_TEST
66 
67 
68  // check a class derived from lar::UncopiableAndUnmovableClass class
69  struct Derived: protected lar::UncopiableAndUnmovableClass {};
70 
75 
76 
77  // check a class derived from lar::UncopiableAndUnmovableClass class
78  // and made movable
79  struct MovableDerived: protected lar::UncopiableAndUnmovableClass {
80  MovableDerived(MovableDerived&&):
82  };
83 
88 
89 
90  // check a class derived from lar::UncopiableAndUnmovableClass class
91  // and made both copy- and move-assignable
92  struct AssignableDerived: protected lar::UncopiableAndUnmovableClass {
93  AssignableDerived& operator=(AssignableDerived const&) { return *this; }
94  AssignableDerived& operator=(AssignableDerived&&) { return *this; }
95  };
96 
101 
102 } // BOOST_AUTO_TEST_CASE(UncopiableAndUnmovableClassTest)
103 
104 
105 //------------------------------------------------------------------------------
An empty class that can&#39;t be copied nor moved.
Defines classes that can&#39;t be copied nor moved.
BOOST_AUTO_TEST_CASE(UncopiableAndUnmovableClassTest)