| 51 | } |
| 52 | |
| 53 | void algorithm_test::test_non_modifying() |
| 54 | { |
| 55 | auto data1 = {1, 2, 3, 4, 5}; |
| 56 | auto res1 = std::all_of( |
| 57 | data1.begin(), data1.end(), |
| 58 | [](auto x){ return x > 0; } |
| 59 | ); |
| 60 | auto res2 = std::all_of( |
| 61 | data1.begin(), data1.end(), |
| 62 | [](auto x){ return x < 4; } |
| 63 | ); |
| 64 | |
| 65 | test("all_of pt1", res1); |
| 66 | test("all_of pt2", !res2); |
| 67 | |
| 68 | auto res3 = std::any_of( |
| 69 | data1.begin(), data1.end(), |
| 70 | [](auto x){ return x > 4; } |
| 71 | ); |
| 72 | auto res4 = std::any_of( |
| 73 | data1.begin(), data1.end(), |
| 74 | [](auto x){ return x == 10; } |
| 75 | ); |
| 76 | |
| 77 | test("any_of pt1", res3); |
| 78 | test("any_of pt2", !res4); |
| 79 | |
| 80 | auto res5 = std::none_of( |
| 81 | data1.begin(), data1.end(), |
| 82 | [](auto x){ return x < 0; } |
| 83 | ); |
| 84 | auto res6 = std::none_of( |
| 85 | data1.begin(), data1.end(), |
| 86 | [](auto x){ return x == 4; } |
| 87 | ); |
| 88 | |
| 89 | test("none_of pt1", res5); |
| 90 | test("none_of pt2", !res6); |
| 91 | |
| 92 | std::array<int, 5> data2{1, 2, 3, 4, 5}; |
| 93 | auto check1 = {1, 20, 3, 40, 5}; |
| 94 | std::for_each( |
| 95 | data2.begin(), data2.end(), |
| 96 | [](auto& x){ |
| 97 | if (x % 2 == 0) |
| 98 | x *= 10; |
| 99 | } |
| 100 | ); |
| 101 | |
| 102 | test_eq( |
| 103 | "for_each", check1.begin(), check1.end(), |
| 104 | data2.begin(), data2.end() |
| 105 | ); |
| 106 | |
| 107 | auto res7 = std::find(data2.begin(), data2.end(), 40); |
| 108 | test_eq("find", res7, &data2[3]); |
| 109 | |
| 110 | auto res8 = std::find_if( |
nothing calls this directly
no test coverage detected