$search
00001 00009 /***************************************************************************** 00010 ** Includes 00011 *****************************************************************************/ 00012 00013 #include <gtest/gtest.h> 00014 #include "../../include/ecl/utilities/singleton.hpp" 00015 00020 /***************************************************************************** 00021 * Classes 00022 ****************************************************************************/ 00023 00024 namespace ecl { 00025 namespace utilities { 00026 namespace tests { 00027 00028 class TestSingleton : public ecl::Singleton<TestSingleton> { 00029 00030 friend class ecl::Singleton<TestSingleton>; 00031 00032 public: 00033 int value() { return data; } 00034 00035 protected: 00036 TestSingleton() : data(32) {} 00037 00038 private: 00039 int data; 00040 }; 00041 00042 }}} 00043 00044 00045 /***************************************************************************** 00046 ** Convenience Macro 00047 *****************************************************************************/ 00048 00049 #define TestInstance ecl::utilities::tests::TestSingleton::instance() 00050 00051 /***************************************************************************** 00052 ** Tests 00053 *****************************************************************************/ 00054 00055 TEST(Singleton,instantiation) { 00056 int i = TestInstance.value(); 00057 EXPECT_EQ(32,i); 00058 } 00059 00060 /***************************************************************************** 00061 ** Main program 00062 *****************************************************************************/ 00063 00064 int main(int argc, char **argv) { 00065 testing::InitGoogleTest(&argc,argv); 00066 return RUN_ALL_TESTS(); 00067 } 00068