references.cpp
Go to the documentation of this file.
1 
9 /*****************************************************************************
10 ** Includes
11 *****************************************************************************/
12 
13 #include <gtest/gtest.h>
14 #include "../../include/ecl/utilities/references.hpp"
15 
20 /*****************************************************************************
21 ** Classes
22 *****************************************************************************/
23 
24 namespace ecl {
25 namespace utilities {
26 namespace tests {
27 
28 class ReferenceDummy {
29 public:
30  int i;
31 };
32 
33 }}}
34 
35 /*****************************************************************************
36 ** Using
37 *****************************************************************************/
38 
40 using ecl::cref;
41 using ecl::ref;
43 using ecl::utilities::tests::ReferenceDummy;
44 
45 /*****************************************************************************
46 ** Tests
47 *****************************************************************************/
48 
49 TEST(Reference,usage) {
50 
51  int i = 3;
52  ReferenceWrapper<int> wrapper(i);
53  int &j = wrapper;
54  EXPECT_EQ(j,3);
55 }
56 
57 TEST(Reference,traits) {
58  EXPECT_TRUE(is_reference_wrapper< ReferenceWrapper<int> >::value);
60 }
61 
62 TEST(Reference,functions) {
63  int i = 3;
64  ReferenceWrapper<int> refd = ref(i);
65  ReferenceWrapper<int const> crefd = cref(i);
66  EXPECT_EQ(3,refd);
67  EXPECT_EQ(3,crefd);
68 }
69 
70 /*****************************************************************************
71 ** Main
72 *****************************************************************************/
73 
74 int main(int argc, char **argv) {
75  testing::InitGoogleTest(&argc,argv);
76  return RUN_ALL_TESTS();
77 }
78 
Embedded control libraries.
ReferenceWrapper< T const > cref(T const &wrapped_object)
Definition: references.hpp:157
Provides a wrapper which allows the original object to be passed like a reference.
Definition: references.hpp:85
static bool const value
TEST(TypeTests, fundamentals)
int main(int argc, char **argv)
Default action for detection of the reference wrapper type trait (false).
Definition: references.hpp:170
ReferenceWrapper< T > ref(T &wrapped_object)
Definition: references.hpp:145


ecl_utilities
Author(s): Daniel Stonier
autogenerated on Mon Feb 28 2022 22:18:41