MCPcopy Create free account
hub / github.com/HelenOS/helenos / test_mutating

Method test_mutating

uspace/lib/cpp/src/__bits/test/algorithm.cpp:190–295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

188 }
189
190 void algorithm_test::test_mutating()
191 {
192 auto check1 = {1, 2, 3, 10, 20, 30, 40};
193 std::array<int, 4> data1{10, 20, 30, 40};
194 std::array<int, 7> data2{1, 2, 3, 4, 5, 6, 7};
195
196 auto res1 = std::copy(
197 data1.begin(), data1.end(), data2.begin() + 3
198 );
199
200 test_eq(
201 "copy pt1", check1.begin(), check1.end(),
202 data2.begin(), data2.end()
203 );
204 test_eq("copy pt2", res1, data2.end());
205
206 auto check2 = {1, 2, 3, 10, 20, 30, 7, 8};
207 std::array<int, 8> data3{1, 2, 3, 4, 5, 6, 7, 8};
208
209 auto res2 = std::copy_n(
210 data1.begin(), 3, data3.begin() + 3
211 );
212 test_eq(
213 "copy_n pt1", check2.begin(), check2.end(),
214 data3.begin(), data3.end()
215 );
216 test_eq("copy_n pt2", res2, &data3[6]);
217
218 auto check3 = {2, 4, 6, 8};
219 std::array<int, 4> data4{0, 0, 0, 0};
220 std::array<int, 9> data5{1, 2, 3, 4, 5, 6, 7, 8, 9};
221
222 auto res3 = std::copy_if(
223 data5.begin(), data5.end(), data4.begin(),
224 [](auto x){ return x % 2 == 0; }
225 );
226
227 test_eq(
228 "copy_if pt1", check3.begin(), check3.end(),
229 data4.begin(), data4.end()
230 );
231 test_eq("copy_if pt2", res3, data4.end());
232
233 /**
234 * Note: Not testing copy_backwards as it isn't
235 * really easy to test, but since it is
236 * widely used in the rest of the library
237 * (mainly right shifting in sequence
238 * containers) it's tested by other tests.
239 */
240
241 auto check4 = {std::string{"A"}, std::string{"B"}, std::string{"C"}};
242 std::array<std::string, 3> data6{"A", "B", "C"};
243 std::array<std::string, 3> data7{"", "", ""};
244
245 auto res4 = std::move(
246 data6.begin(), data6.end(), data7.begin()
247 );

Callers

nothing calls this directly

Calls 10

copyFunction · 0.85
copy_nFunction · 0.85
copy_ifFunction · 0.85
moveFunction · 0.85
swap_rangesFunction · 0.85
iter_swapFunction · 0.85
transformFunction · 0.85
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected