Changeset c300bb5 in mainline
- Timestamp:
- 2018-07-05T21:41:24Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7452b155
- Parents:
- bb1d15c
- git-author:
- Dzejrou <dzejrou@…> (2018-05-17 00:49:32)
- git-committer:
- Dzejrou <dzejrou@…> (2018-07-05 21:41:24)
- Location:
- uspace/lib/cpp
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/include/__bits/test/tests.hpp
rbb1d15c rc300bb5 265 265 private: 266 266 void test_construction_and_assignment(); 267 void test_modifiers(); 267 268 }; 268 269 } -
uspace/lib/cpp/include/impl/list.hpp
rbb1d15c rc300bb5 71 71 72 72 list_const_iterator(const list_iterator<T>& other) 73 : current_{other. current_}, head_{other.head_}73 : current_{other.node()}, head_{other.head()} 74 74 { /* DUMMY BODY */ } 75 75 … … 125 125 list_node<value_type>* node() 126 126 { 127 return const_cast<list_node<value_type>*>(current_); 128 } 129 130 const list_node<value_type>* node() const 131 { 127 132 return current_; 128 133 } 129 134 130 const list_node<value_type>* node() const 131 { 132 return current_; 135 list_node<value_type>* head() 136 { 137 return const_cast<list_node<value_type>*>(head_); 138 } 139 140 const list_node<value_type>* head() const 141 { 142 return head_; 133 143 } 134 144 … … 154 164 155 165 private: 156 list_node<value_type>* current_;157 list_node<value_type>* head_;166 const list_node<value_type>* current_; 167 const list_node<value_type>* head_; 158 168 bool end_; 159 169 }; … … 253 263 } 254 264 255 operator list_const_iterator<T>() const 256 { 257 return list_const_iterator<T>{current_}; 265 list_node<value_type>* head() 266 { 267 return head_; 268 } 269 270 const list_node<value_type>* head() const 271 { 272 return head_; 258 273 } 259 274 … … 746 761 747 762 auto first_node = first.node(); 748 auto last_node = last.node() ;763 auto last_node = last.node()->prev; 749 764 auto prev = first_node->prev; 750 765 auto next = last_node->next; 751 766 752 prev->append(next); 753 754 while (first_node != next) 755 { 756 // TODO: test with head in the range 757 /* if (first_node == head_) */ 758 /* head_ = last.node()->next; */ 767 first_node->prev = nullptr; 768 last_node->next = nullptr; 769 prev->next = next; 770 next->prev = prev; 771 772 while (first_node) 773 { 774 if (first_node == head_) 775 { 776 head_ = next; 777 head_->prev = prev; 778 } 759 779 760 780 auto tmp = first_node; -
uspace/lib/cpp/src/__bits/test/list.cpp
rbb1d15c rc300bb5 40 40 41 41 test_construction_and_assignment(); 42 test_modifiers(); 42 43 43 44 return end(); … … 152 153 test_eq("back", l5.back(), 1); 153 154 } 155 156 void list_test::test_modifiers() 157 { 158 std::list<int> l1{}; 159 test_eq("empty list", l1.empty(), true); 160 161 l1.push_back(1); 162 test_eq("empty list push_back pt1", l1.size(), 1U); 163 test_eq("empty list push_back pt2", l1.empty(), false); 164 test_eq("empty list push_back pt3", l1.front(), 1); 165 test_eq("empty list push_back pt4", l1.back(), 1); 166 167 l1.push_front(2); 168 test_eq("push_front pt1", l1.size(), 2U); 169 test_eq("push_front pt2", l1.front(), 2); 170 test_eq("push_front pt3", l1.back(), 1); 171 172 l1.pop_back(); 173 test_eq("pop_back pt1", l1.size(), 1U); 174 test_eq("pop_back pt2", l1.back(), 2); 175 176 l1.push_front(3); 177 test_eq("size", l1.size(), 2U); 178 179 l1.pop_front(); 180 test_eq("pop_front", l1.front(), 2); 181 182 auto check1 = {2, 42, 42, 42, 42, 42}; 183 l1.insert(l1.begin(), 5U, 42); 184 test_eq( 185 "insert n*value", 186 check1.begin(), check1.end(), 187 l1.begin(), l1.end() 188 ); 189 190 auto data1 = {33, 34}; 191 auto check2 = {2, 42, 33, 34, 42, 42, 42, 42}; 192 auto it1 = l1.begin(); 193 std::advance(it1, 2); 194 195 l1.insert(it1, data1.begin(), data1.end()); 196 test_eq( 197 "insert iterator range", 198 check2.begin(), check2.end(), 199 l1.begin(), l1.end() 200 ); 201 202 auto check3 = {2, 42, 33, 34, 42, 33, 34, 42, 42, 42}; 203 auto it2 = l1.begin(); 204 std::advance(it2, 5); 205 206 l1.insert(it2, data1); 207 test_eq( 208 "insert initializer_list", 209 check3.begin(), check3.end(), 210 l1.begin(), l1.end() 211 ); 212 213 auto check4 = {2, 42, 33, 34, 33, 34, 42, 42, 42}; 214 auto it3 = l1.begin(); 215 std::advance(it3, 4); 216 217 l1.erase(it3); 218 test_eq( 219 "erase iterator", 220 check4.begin(), check4.end(), 221 l1.begin(), l1.end() 222 ); 223 224 auto check5 = {33, 34, 42, 42, 42}; 225 auto it4 = l1.begin(); 226 auto it5 = l1.begin(); 227 std::advance(it5, 4); 228 229 l1.erase(it4, it5); 230 test_eq( 231 "erase iterator range", 232 check5.begin(), check5.end(), 233 l1.begin(), l1.end() 234 ); 235 236 l1.clear(); 237 test_eq("clear empty", l1.empty(), true); 238 test_eq("clear size", l1.size(), 0U); 239 } 154 240 } 155 241
Note:
See TracChangeset
for help on using the changeset viewer.