Changeset 10920 for code/branches/cpp11_v2/test
- Timestamp:
- Dec 6, 2015, 2:51:14 PM (9 years ago)
- Location:
- code/branches/cpp11_v2/test/core/object
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v2/test/core/object/IteratorTest.cc
r10846 r10920 55 55 TEST_F(IteratorTest, CanAssignIterator) 56 56 { 57 Iterator<TestInterface> it = ObjectList<TestInterface>::begin(); 57 ObjectList<TestInterface> list; 58 Iterator<TestInterface> it = list.begin(); 58 59 } 59 60 … … 61 62 { 62 63 size_t i = 0; 63 for (Iterator<TestInterface> it = ObjectList<TestInterface>::begin(); it != ObjectList<TestInterface>::end(); ++it) 64 ObjectList<TestInterface> list; 65 for (Iterator<TestInterface> it = list.begin(); it != list.end(); ++it) 64 66 ++i; 65 67 EXPECT_EQ(0u, i); … … 77 79 78 80 // iterate over interfaces but use a TestClass iterator - now we can call TestClass::test() 79 for (Iterator<TestClass> it = ObjectList<TestInterface>::begin(); it != ObjectList<TestInterface>::end(); ++it) 81 ObjectList<TestInterface> list; 82 for (Iterator<TestClass> it = list.begin(); it != list.end(); ++it) 80 83 it->test(); 81 84 } … … 87 90 88 91 size_t i = 0; 89 for (Iterator<TestInterface> it = ObjectList<TestInterface>::begin(); it != ObjectList<TestInterface>::end(); ++it) 92 ObjectList<TestInterface> list; 93 for (Iterator<TestInterface> it = list.begin(); it != list.end(); ++it) 90 94 { 91 95 ++i; … … 102 106 103 107 size_t i = 0; 104 for (Iterator<TestClass> it = ObjectList<TestClass>::begin(); it != ObjectList<TestClass>::end(); ++it) 108 ObjectList<TestClass> list; 109 for (Iterator<TestClass> it = list.begin(); it != list.end(); ++it) 105 110 { 106 111 ++i; … … 116 121 117 122 size_t i = 0; 118 for (Iterator<TestClass> it = ObjectList<TestInterface>::begin(); it != ObjectList<TestInterface>::end(); ++it) 123 ObjectList<TestInterface> list; 124 for (Iterator<TestClass> it = list.begin(); it != list.end(); ++it) 119 125 { 120 126 ++i; … … 131 137 132 138 size_t i = 0; 133 for (Iterator<TestInterface> it = ObjectList<TestClass>::begin(); it != ObjectList<TestClass>::end(); ++it) 139 ObjectList<TestClass> list; 140 for (Iterator<TestInterface> it = list.begin(); it != list.end(); ++it) 134 141 { 135 142 ++i; -
code/branches/cpp11_v2/test/core/object/ListableTest.cc
r10846 r10920 63 63 { 64 64 ListableClassTest test; 65 EXPECT_EQ(1u, ObjectList<ListableClassTest> ::size());65 EXPECT_EQ(1u, ObjectList<ListableClassTest>().size()); 66 66 EXPECT_TRUE(objectListContains<ListableClassTest>(&test)); 67 67 } … … 70 70 { 71 71 ListableSubclassTest test; 72 EXPECT_EQ(1u, ObjectList<ListableClassTest> ::size());72 EXPECT_EQ(1u, ObjectList<ListableClassTest>().size()); 73 73 EXPECT_TRUE(objectListContains<ListableClassTest>(&test)); 74 EXPECT_EQ(1u, ObjectList<ListableSubclassTest> ::size());74 EXPECT_EQ(1u, ObjectList<ListableSubclassTest>().size()); 75 75 EXPECT_TRUE(objectListContains<ListableSubclassTest>(&test)); 76 76 } … … 78 78 TEST_F(ListableTest, RemovesFromObjectList) 79 79 { 80 EXPECT_EQ(0u, ObjectList<ListableClassTest> ::size());80 EXPECT_EQ(0u, ObjectList<ListableClassTest>().size()); 81 81 { 82 82 ListableClassTest test; 83 EXPECT_EQ(1u, ObjectList<ListableClassTest> ::size());83 EXPECT_EQ(1u, ObjectList<ListableClassTest>().size()); 84 84 EXPECT_TRUE(objectListContains<ListableClassTest>(&test)); 85 85 } 86 EXPECT_EQ(0u, ObjectList<ListableClassTest> ::size());86 EXPECT_EQ(0u, ObjectList<ListableClassTest>().size()); 87 87 } 88 88 89 89 TEST_F(ListableTest, RemovesFromAllObjectLists) 90 90 { 91 EXPECT_EQ(0u, ObjectList<ListableClassTest> ::size());92 EXPECT_EQ(0u, ObjectList<ListableSubclassTest> ::size());91 EXPECT_EQ(0u, ObjectList<ListableClassTest>().size()); 92 EXPECT_EQ(0u, ObjectList<ListableSubclassTest>().size()); 93 93 { 94 94 ListableSubclassTest test; 95 EXPECT_EQ(1u, ObjectList<ListableClassTest> ::size());95 EXPECT_EQ(1u, ObjectList<ListableClassTest>().size()); 96 96 EXPECT_TRUE(objectListContains<ListableClassTest>(&test)); 97 EXPECT_EQ(1u, ObjectList<ListableSubclassTest> ::size());97 EXPECT_EQ(1u, ObjectList<ListableSubclassTest>().size()); 98 98 EXPECT_TRUE(objectListContains<ListableSubclassTest>(&test)); 99 99 } 100 EXPECT_EQ(0u, ObjectList<ListableClassTest> ::size());101 EXPECT_EQ(0u, ObjectList<ListableSubclassTest> ::size());100 EXPECT_EQ(0u, ObjectList<ListableClassTest>().size()); 101 EXPECT_EQ(0u, ObjectList<ListableSubclassTest>().size()); 102 102 } 103 103 -
code/branches/cpp11_v2/test/core/object/ObjectListIteratorTest.cc
r10846 r10920 55 55 TEST_F(ObjectListIteratorTest, CanAssignIterator) 56 56 { 57 ObjectListIterator<TestClass> it = ObjectList<TestClass>::begin(); 57 ObjectList<TestClass> list; 58 ObjectListIterator<TestClass> it = list.begin(); 58 59 } 59 60 … … 61 62 { 62 63 size_t i = 0; 63 for (ObjectListIterator<TestClass> it = ObjectList<TestClass>::begin(); it != ObjectList<TestClass>::end(); ++it) 64 ObjectList<TestClass> list; 65 for (ObjectListIterator<TestClass> it = list.begin(); it != list.end(); ++it) 64 66 ++i; 65 67 EXPECT_EQ(0u, i); … … 74 76 75 77 size_t i = 0; 76 for (ObjectListIterator<TestClass> it = ObjectList<TestClass>::begin(); it != ObjectList<TestClass>::end(); ++it) 78 ObjectList<TestClass> list; 79 for (ObjectListIterator<TestClass> it = list.begin(); it != list.end(); ++it) 77 80 { 78 81 ++i; … … 92 95 93 96 size_t i = 0; 94 for (ObjectListIterator<TestClass> it = ObjectList<TestClass>::rbegin(); it != ObjectList<TestClass>::rend(); --it) 97 ObjectList<TestClass> list; 98 for (ObjectListIterator<TestClass> it = list.rbegin(); it != list.rend(); --it) 95 99 { 96 100 ++i; … … 113 117 EXPECT_CALL(test3, test()); 114 118 115 for (ObjectListIterator<TestClass> it = ObjectList<TestClass>::begin(); it != ObjectList<TestClass>::end(); ++it) 119 ObjectList<TestClass> list; 120 for (ObjectListIterator<TestClass> it = list.begin(); it != list.end(); ++it) 116 121 it->test(); 117 122 } -
code/branches/cpp11_v2/test/core/object/ObjectListTest.cc
r10846 r10920 15 15 public: 16 16 ListableTest() { RegisterObject(ListableTest); } 17 ListableTest(Context* context) : Listable(context) { RegisterObject(ListableTest); } 17 18 MOCK_METHOD0(test, void()); 18 19 }; … … 103 104 object->test(); 104 105 } 106 107 TEST_F(ObjectListTest, UsesCorrectContext) 108 { 109 Context context1(Context::getRootContext()); 110 Context context2(Context::getRootContext()); 111 112 ListableTest test1(&context1); 113 ListableTest test2(&context1); 114 ListableTest test3(&context2); 115 116 EXPECT_EQ(3, ObjectList<ListableTest>().size()); 117 EXPECT_EQ(2, ObjectList<ListableTest>(&context1).size()); 118 EXPECT_EQ(1, ObjectList<ListableTest>(&context2).size()); 119 } 120 121 TEST_F(ObjectListTest, CanIterateOverCorrectContext) 122 { 123 Context context1(Context::getRootContext()); 124 Context context2(Context::getRootContext()); 125 126 ListableTest test1(&context1); 127 ListableTest test2(&context1); 128 ListableTest test3(&context2); 129 130 { 131 size_t i = 0; 132 for (ListableTest* object : ObjectList<ListableTest>(&context1)) 133 { 134 ++i; 135 if (i == 1u) EXPECT_EQ(&test1, object); 136 if (i == 2u) EXPECT_EQ(&test2, object); 137 } 138 EXPECT_EQ(2u, i); 139 } 140 { 141 size_t i = 0; 142 for (ListableTest* object : ObjectList<ListableTest>(&context2)) 143 { 144 ++i; 145 if (i == 1u) EXPECT_EQ(&test3, object); 146 } 147 EXPECT_EQ(1u, i); 148 } 149 } 105 150 }
Note: See TracChangeset
for help on using the changeset viewer.