Changeset 10736 for code/branches/cpp11_v2/test/core
- Timestamp:
- Oct 31, 2015, 11:50:17 PM (9 years ago)
- Location:
- code/branches/cpp11_v2/test/core
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v2/test/core/CMakeLists.txt
r10624 r10736 25 25 object/ListableTest.cc 26 26 object/ObjectListBaseTest.cc 27 object/ObjectListTest.cc 27 28 object/ObjectListIteratorTest.cc 28 29 object/StrongPtrTest.cc -
code/branches/cpp11_v2/test/core/object/IteratorTest.cc
r10624 r10736 80 80 it->test(); 81 81 } 82 83 TEST_F(IteratorTest, CanIterateOverInterfaceListWithInterfaceIterator) 84 { 85 TestClass testClass; 86 TestInterface testInterface; 87 88 size_t i = 0; 89 for (Iterator<TestInterface> it = ObjectList<TestInterface>::begin(); it != ObjectList<TestInterface>::end(); ++it) 90 { 91 ++i; 92 if (i == 1u) EXPECT_EQ(&testClass, *it); 93 if (i == 2u) EXPECT_EQ(&testInterface, *it); 94 } 95 EXPECT_EQ(2u, i); 96 } 97 98 TEST_F(IteratorTest, CanIterateOverClassListWithClassIterator) 99 { 100 TestClass testClass; 101 TestInterface testInterface; 102 103 size_t i = 0; 104 for (Iterator<TestClass> it = ObjectList<TestClass>::begin(); it != ObjectList<TestClass>::end(); ++it) 105 { 106 ++i; 107 if (i == 1u) EXPECT_EQ(&testClass, *it); 108 } 109 EXPECT_EQ(1u, i); 110 } 111 112 TEST_F(IteratorTest, CanIterateOverInterfaceListWithClassIterator) 113 { 114 TestClass testClass; 115 TestInterface testInterface; 116 117 size_t i = 0; 118 for (Iterator<TestClass> it = ObjectList<TestInterface>::begin(); it != ObjectList<TestInterface>::end(); ++it) 119 { 120 ++i; 121 if (i == 1u) EXPECT_EQ(&testClass, *it); 122 if (i == 2u) EXPECT_EQ(NULL, *it); 123 } 124 EXPECT_EQ(2u, i); 125 } 126 127 TEST_F(IteratorTest, CanIterateOverClassListWithInterfaceIterator) 128 { 129 TestClass testClass; 130 TestInterface testInterface; 131 132 size_t i = 0; 133 for (Iterator<TestInterface> it = ObjectList<TestClass>::begin(); it != ObjectList<TestClass>::end(); ++it) 134 { 135 ++i; 136 if (i == 1u) EXPECT_EQ(&testClass, *it); 137 } 138 EXPECT_EQ(1u, i); 139 } 82 140 } -
code/branches/cpp11_v2/test/core/object/ObjectListIteratorTest.cc
r10624 r10736 3 3 4 4 #include "core/object/ObjectListIterator.h" 5 #include "core/object/Listable.h" 5 #include "core/class/OrxonoxClass.h" 6 #include "core/class/OrxonoxInterface.h" 6 7 #include "core/CoreIncludes.h" 7 8 #include "core/module/ModuleInstance.h" … … 11 12 namespace 12 13 { 13 class ListableTest : public Listable14 class TestInterface : virtual public OrxonoxInterface 14 15 { 15 16 public: 16 ListableTest() { RegisterObject(ListableTest); } 17 TestInterface() { RegisterObject(TestInterface); } 18 }; 19 20 class TestClass : public OrxonoxClass, public TestInterface 21 { 22 public: 23 TestClass() { RegisterObject(TestClass); } 17 24 MOCK_METHOD0(test, void()); 18 25 }; 19 26 20 RegisterClassNoArgs(ListableTest); 27 RegisterClassNoArgs(TestInterface); 28 RegisterClassNoArgs(TestClass); 21 29 22 30 // Fixture … … 42 50 TEST_F(ObjectListIteratorTest, CanCreateIterator) 43 51 { 44 ObjectListIterator< ListableTest> it;52 ObjectListIterator<TestClass> it; 45 53 } 46 54 47 55 TEST_F(ObjectListIteratorTest, CanAssignIterator) 48 56 { 49 ObjectListIterator< ListableTest> it = ObjectList<ListableTest>::begin();57 ObjectListIterator<TestClass> it = ObjectList<TestClass>::begin(); 50 58 } 51 59 … … 53 61 { 54 62 size_t i = 0; 55 for (ObjectListIterator< ListableTest> it = ObjectList<ListableTest>::begin(); it != ObjectList<ListableTest>::end(); ++it)63 for (ObjectListIterator<TestClass> it = ObjectList<TestClass>::begin(); it != ObjectList<TestClass>::end(); ++it) 56 64 ++i; 57 65 EXPECT_EQ(0u, i); … … 60 68 TEST_F(ObjectListIteratorTest, CanIterateOverFullList) 61 69 { 62 ListableTest test1; 63 ListableTest test2; 64 ListableTest test3; 70 TestClass test1; 71 TestClass test2; 72 TestClass test3; 73 TestInterface interface; 65 74 66 75 size_t i = 0; 67 for (ObjectListIterator< ListableTest> it = ObjectList<ListableTest>::begin(); it != ObjectList<ListableTest>::end(); ++it)76 for (ObjectListIterator<TestClass> it = ObjectList<TestClass>::begin(); it != ObjectList<TestClass>::end(); ++it) 68 77 { 69 78 ++i; … … 77 86 TEST_F(ObjectListIteratorTest, CanIterateReverseOverFullList) 78 87 { 79 ListableTest test1; 80 ListableTest test2; 81 ListableTest test3; 88 TestClass test1; 89 TestClass test2; 90 TestClass test3; 91 TestInterface interface; 82 92 83 93 size_t i = 0; 84 for (ObjectListIterator< ListableTest> it = ObjectList<ListableTest>::rbegin(); it != ObjectList<ListableTest>::rend(); --it)94 for (ObjectListIterator<TestClass> it = ObjectList<TestClass>::rbegin(); it != ObjectList<TestClass>::rend(); --it) 85 95 { 86 96 ++i; … … 94 104 TEST_F(ObjectListIteratorTest, CanCallObjects) 95 105 { 96 ListableTest test1; 97 ListableTest test2; 98 ListableTest test3; 106 TestClass test1; 107 TestClass test2; 108 TestClass test3; 109 TestInterface interface; 99 110 100 111 EXPECT_CALL(test1, test()); … … 102 113 EXPECT_CALL(test3, test()); 103 114 104 for (ObjectListIterator< ListableTest> it = ObjectList<ListableTest>::begin(); it != ObjectList<ListableTest>::end(); ++it)115 for (ObjectListIterator<TestClass> it = ObjectList<TestClass>::begin(); it != ObjectList<TestClass>::end(); ++it) 105 116 it->test(); 106 117 }
Note: See TracChangeset
for help on using the changeset viewer.