Changeset 11054 for code/branches/cpp11_v3/test/core/object/IteratorTest.cc
- Timestamp:
- Jan 10, 2016, 1:54:11 PM (9 years ago)
- Location:
- code/branches/cpp11_v3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v3
- Property svn:mergeinfo changed
-
code/branches/cpp11_v3/test/core/object/IteratorTest.cc
r10624 r11054 15 15 { 16 16 public: 17 TestInterface() { RegisterObject(TestInterface); }17 TestInterface() { RegisterObject(TestInterface); } 18 18 }; 19 19 … … 32 32 { 33 33 public: 34 virtual void SetUp() 34 virtual void SetUp() override 35 35 { 36 36 new IdentifierManager(); 37 37 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER); 38 Context::setRootContext(new Context( NULL));38 Context::setRootContext(new Context(nullptr)); 39 39 } 40 40 41 virtual void TearDown() 41 virtual void TearDown() override 42 42 { 43 43 Context::destroyRootContext(); … … 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 } 85 86 TEST_F(IteratorTest, CanIterateOverInterfaceListWithInterfaceIterator) 87 { 88 TestClass testClass; 89 TestInterface testInterface; 90 91 size_t i = 0; 92 ObjectList<TestInterface> list; 93 for (Iterator<TestInterface> it = list.begin(); it != list.end(); ++it) 94 { 95 ++i; 96 if (i == 1u) EXPECT_EQ(&testClass, *it); 97 if (i == 2u) EXPECT_EQ(&testInterface, *it); 98 } 99 EXPECT_EQ(2u, i); 100 } 101 102 TEST_F(IteratorTest, CanIterateOverClassListWithClassIterator) 103 { 104 TestClass testClass; 105 TestInterface testInterface; 106 107 size_t i = 0; 108 ObjectList<TestClass> list; 109 for (Iterator<TestClass> it = list.begin(); it != list.end(); ++it) 110 { 111 ++i; 112 if (i == 1u) EXPECT_EQ(&testClass, *it); 113 } 114 EXPECT_EQ(1u, i); 115 } 116 117 TEST_F(IteratorTest, CanIterateOverInterfaceListWithClassIterator) 118 { 119 TestClass testClass; 120 TestInterface testInterface; 121 122 size_t i = 0; 123 ObjectList<TestInterface> list; 124 for (Iterator<TestClass> it = list.begin(); it != list.end(); ++it) 125 { 126 ++i; 127 if (i == 1u) EXPECT_EQ(&testClass, *it); 128 if (i == 2u) EXPECT_EQ(nullptr, *it); 129 } 130 EXPECT_EQ(2u, i); 131 } 132 133 TEST_F(IteratorTest, CanIterateOverClassListWithInterfaceIterator) 134 { 135 TestClass testClass; 136 TestInterface testInterface; 137 138 size_t i = 0; 139 ObjectList<TestClass> list; 140 for (Iterator<TestInterface> it = list.begin(); it != list.end(); ++it) 141 { 142 ++i; 143 if (i == 1u) EXPECT_EQ(&testClass, *it); 144 } 145 EXPECT_EQ(1u, i); 146 } 82 147 }
Note: See TracChangeset
for help on using the changeset viewer.