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);
59  EXPECT_FALSE(is_reference_wrapper<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 
TEST
TEST(TypeTests, fundamentals)
ecl::cref
ReferenceWrapper< T const > cref(T const &wrapped_object)
Definition: references.hpp:163
ecl::ReferenceWrapper
Provides a wrapper which allows the original object to be passed like a reference.
Definition: references.hpp:91
ecl::ref
ReferenceWrapper< T > ref(T &wrapped_object)
Definition: references.hpp:151
ecl::is_reference_wrapper
Default action for detection of the reference wrapper type trait (false).
Definition: references.hpp:176
main
int main(int argc, char **argv)
ecl
Embedded control libraries.


ecl_utilities
Author(s): Daniel Stonier
autogenerated on Wed Mar 2 2022 00:16:32