| 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}; |
nothing calls this directly
no test coverage detected