singleton.cpp
Go to the documentation of this file.
1 
9 /*****************************************************************************
10 ** Includes
11 *****************************************************************************/
12 
13 #include <gtest/gtest.h>
14 #include "../../include/ecl/utilities/singleton.hpp"
15 
20 /*****************************************************************************
21  * Classes
22  ****************************************************************************/
23 
24 namespace ecl {
25 namespace utilities {
26 namespace tests {
27 
28 class TestSingleton : public ecl::Singleton<TestSingleton> {
29 
30  friend class ecl::Singleton<TestSingleton>;
31 
32  public:
33  int value() { return data; }
34 
35  protected:
36  TestSingleton() : data(32) {}
37 
38  private:
39  int data;
40 };
41 
42 }}}
43 
44 
45 /*****************************************************************************
46 ** Convenience Macro
47 *****************************************************************************/
48 
49 #define TestInstance ecl::utilities::tests::TestSingleton::instance()
50 
51 /*****************************************************************************
52 ** Tests
53 *****************************************************************************/
54 
55 TEST(Singleton,instantiation) {
56  int i = TestInstance.value();
57  EXPECT_EQ(32,i);
58 }
59 
60 /*****************************************************************************
61 ** Main program
62 *****************************************************************************/
63 
64 int main(int argc, char **argv) {
65  testing::InitGoogleTest(&argc,argv);
66  return RUN_ALL_TESTS();
67 }
68 
ecl::Singleton
Singleton construction via the curiously recurring template pattern.
Definition: singleton.hpp:55
TEST
TEST(TypeTests, fundamentals)
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