Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
garsoft
test
CoreUtils
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
37
(!
std::is_copy_constructible<gar::UncopiableAndUnmovableClass>::value
);
38
BOOST_CHECK
39
(!
std::is_copy_assignable<gar::UncopiableAndUnmovableClass>::value
);
40
BOOST_CHECK
41
(!
std::is_move_constructible<gar::UncopiableAndUnmovableClass>::value
);
42
BOOST_CHECK
43
(!
std::is_move_assignable<gar::UncopiableAndUnmovableClass>::value
);
44
45
46
// check a class derived from gar::UncopiableAndUnmovableClass class
47
struct
Derived
:
protected
gar::UncopiableAndUnmovableClass
{};
48
49
BOOST_CHECK(!
std::is_copy_constructible<Derived>::value
);
50
BOOST_CHECK(!
std::is_copy_assignable <Derived>::value
);
51
BOOST_CHECK(!
std::is_move_constructible<Derived>::value
);
52
BOOST_CHECK(!
std::is_move_assignable <Derived>::value
);
53
54
55
// check a class derived from gar::UncopiableAndUnmovableClass class
56
// and made movable
57
struct
MovableDerived:
protected
gar::UncopiableAndUnmovableClass
{
58
MovableDerived(MovableDerived&&):
59
gar::UncopiableAndUnmovableClass
() {}
60
};
61
62
BOOST_CHECK(!
std::is_copy_constructible<MovableDerived>::value
);
63
BOOST_CHECK(!
std::is_copy_assignable <MovableDerived>::value
);
64
BOOST_CHECK(
std::is_move_constructible<MovableDerived>::value
);
65
BOOST_CHECK(!
std::is_move_assignable <MovableDerived>::value
);
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
75
BOOST_CHECK(!
std::is_copy_constructible<AssignableDerived>::value
);
76
BOOST_CHECK(
std::is_copy_assignable <AssignableDerived>::value
);
77
BOOST_CHECK(!
std::is_move_constructible<AssignableDerived>::value
);
78
BOOST_CHECK(
std::is_move_assignable <AssignableDerived>::value
);
79
80
}
// BOOST_AUTO_TEST_CASE(larProviderFromTest)
81
82
83
//------------------------------------------------------------------------------
Derived
Definition:
value_ptr_test.cc:35
quiet_unit_test.hpp
gar::UncopiableAndUnmovableClass
An empty class that can't be copied nor moved.
Definition:
UncopiableAndUnmovableClass.h:43
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(UncopiableAndUnmovableClassTest)
Definition:
UncopiableAndUnmovableClass_test.cc:33
submit_mcc.value
value
Definition:
submit_mcc.py:159
Generated by
1.8.11