Changeset 10555 for code/branches/core7/test/core
- Timestamp:
- Aug 29, 2015, 5:35:59 PM (9 years ago)
- Location:
- code/branches/core7/test/core
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core7/test/core/CMakeLists.txt
r10407 r10555 26 26 object/ObjectListBaseTest.cc 27 27 object/ObjectListIteratorTest.cc 28 object/S martPtrTest.cc28 object/StrongPtrTest.cc 29 29 object/WeakPtrTest.cc 30 30 singleton/ScopeTest.cc -
code/branches/core7/test/core/object/StrongPtrTest.cc
r10553 r10555 1 1 #include <gtest/gtest.h> 2 #include "core/object/S martPtr.h"2 #include "core/object/StrongPtr.h" 3 3 4 4 namespace orxonox … … 17 17 } 18 18 19 TEST(S martPtrTest, CanReferenceObject)19 TEST(StrongPtrTest, CanReferenceObject) 20 20 { 21 21 bool bla; 22 22 DestroyableTest* test = new DestroyableTest(bla); 23 S martPtr<DestroyableTest> smartPtr = test;24 EXPECT_EQ(test, s martPtr.get());23 StrongPtr<DestroyableTest> strongPtr = test; 24 EXPECT_EQ(test, strongPtr.get()); 25 25 test->destroy(); 26 26 } 27 27 28 TEST(S martPtrTest, IncreasesReferenceCount)28 TEST(StrongPtrTest, IncreasesReferenceCount) 29 29 { 30 30 bool bla; … … 32 32 EXPECT_EQ(0u, test->getReferenceCount()); 33 33 { 34 S martPtr<DestroyableTest> smartPtr = test;34 StrongPtr<DestroyableTest> strongPtr = test; 35 35 EXPECT_EQ(1u, test->getReferenceCount()); 36 36 } … … 39 39 } 40 40 41 TEST(S martPtrTest, DestroyDeletesInstance)41 TEST(StrongPtrTest, DestroyDeletesInstance) 42 42 { 43 43 bool destroyed = false; … … 48 48 } 49 49 50 TEST(S martPtrTest, PreventsDestruction)50 TEST(StrongPtrTest, PreventsDestruction) 51 51 { 52 52 bool destroyed = false; 53 53 DestroyableTest* test = new DestroyableTest(destroyed); 54 54 EXPECT_FALSE(destroyed); 55 S martPtr<DestroyableTest> smartPtr = test;55 StrongPtr<DestroyableTest> strongPtr = test; 56 56 test->destroy(); 57 57 EXPECT_FALSE(destroyed); 58 58 } 59 59 60 TEST(S martPtrTest, DestroysIfSmartPtrRemoved)60 TEST(StrongPtrTest, DestroysIfStrongPtrRemoved) 61 61 { 62 62 bool destroyed = false; … … 64 64 EXPECT_FALSE(destroyed); 65 65 { 66 S martPtr<DestroyableTest> smartPtr = test;66 StrongPtr<DestroyableTest> strongPtr = test; 67 67 test->destroy(); 68 68 EXPECT_FALSE(destroyed); … … 71 71 } 72 72 73 TEST(S martPtrTest, DestroysIfAllSmartPtrsRemoved)73 TEST(StrongPtrTest, DestroysIfAllStrongPtrsRemoved) 74 74 { 75 75 bool destroyed = false; … … 77 77 EXPECT_FALSE(destroyed); 78 78 { 79 S martPtr<DestroyableTest> smartPtr1 = test;79 StrongPtr<DestroyableTest> strongPtr1 = test; 80 80 { 81 S martPtr<DestroyableTest> smartPtr2 = test;81 StrongPtr<DestroyableTest> strongPtr2 = test; 82 82 { 83 S martPtr<DestroyableTest> smartPtr3 = test;83 StrongPtr<DestroyableTest> strongPtr3 = test; 84 84 test->destroy(); 85 85 EXPECT_FALSE(destroyed); … … 92 92 } 93 93 94 void isNull(const S martPtr<DestroyableTest> smartPtr)94 void isNull(const StrongPtr<DestroyableTest> strongPtr) 95 95 { 96 EXPECT_TRUE(s martPtr == NULL);97 EXPECT_TRUE(s martPtr == 0);98 EXPECT_TRUE(!s martPtr);99 EXPECT_FALSE(s martPtr != NULL);100 EXPECT_FALSE(s martPtr != 0);101 EXPECT_FALSE(s martPtr);96 EXPECT_TRUE(strongPtr == NULL); 97 EXPECT_TRUE(strongPtr == 0); 98 EXPECT_TRUE(!strongPtr); 99 EXPECT_FALSE(strongPtr != NULL); 100 EXPECT_FALSE(strongPtr != 0); 101 EXPECT_FALSE(strongPtr); 102 102 } 103 103 104 TEST(S martPtrTest, IsNull)104 TEST(StrongPtrTest, IsNull) 105 105 { 106 106 { 107 S martPtr<DestroyableTest> smartPtr;108 isNull(s martPtr);107 StrongPtr<DestroyableTest> strongPtr; 108 isNull(strongPtr); 109 109 } 110 110 { 111 S martPtr<DestroyableTest> smartPtr = NULL;112 isNull(s martPtr);111 StrongPtr<DestroyableTest> strongPtr = NULL; 112 isNull(strongPtr); 113 113 } 114 114 { 115 S martPtr<DestroyableTest> smartPtr;116 s martPtr = NULL;117 isNull(s martPtr);115 StrongPtr<DestroyableTest> strongPtr; 116 strongPtr = NULL; 117 isNull(strongPtr); 118 118 } 119 119 { 120 S martPtr<DestroyableTest> smartPtr = 0;121 isNull(s martPtr);120 StrongPtr<DestroyableTest> strongPtr = 0; 121 isNull(strongPtr); 122 122 } 123 123 { 124 S martPtr<DestroyableTest> smartPtr;125 s martPtr = 0;126 isNull(s martPtr);124 StrongPtr<DestroyableTest> strongPtr; 125 strongPtr = 0; 126 isNull(strongPtr); 127 127 } 128 128 } 129 129 130 TEST(S martPtrTest, IsNotNull)130 TEST(StrongPtrTest, IsNotNull) 131 131 { 132 132 bool destroyed = false; 133 133 DestroyableTest* test = new DestroyableTest(destroyed); 134 S martPtr<DestroyableTest> smartPtr = test;135 EXPECT_FALSE(s martPtr == NULL);136 EXPECT_FALSE(s martPtr == 0);137 EXPECT_FALSE(!s martPtr);138 EXPECT_TRUE(s martPtr != NULL);139 EXPECT_TRUE(s martPtr != 0);140 EXPECT_TRUE(s martPtr);134 StrongPtr<DestroyableTest> strongPtr = test; 135 EXPECT_FALSE(strongPtr == NULL); 136 EXPECT_FALSE(strongPtr == 0); 137 EXPECT_FALSE(!strongPtr); 138 EXPECT_TRUE(strongPtr != NULL); 139 EXPECT_TRUE(strongPtr != 0); 140 EXPECT_TRUE(strongPtr); 141 141 test->destroy(); 142 142 }
Note: See TracChangeset
for help on using the changeset viewer.