Skip to content

Commit

Permalink
[test] Use const methods for specialization of fill
Browse files Browse the repository at this point in the history
  • Loading branch information
miscco committed Nov 29, 2020
1 parent 9192585 commit 52ed289
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions tests/std/tests/GH_000625_vector_bool_optimization/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,58 +16,58 @@ void test_fill_helper(const size_t length) {
vector<bool> result_true(length, true);
result_true.resize(length + 3, false);
vector<bool> dest_true(length + 3, false);
fill(dest_true.begin(), prev(dest_true.end(), 3), true);
fill(dest_true.cbegin(), prev(dest_true.cend(), 3), true);
assert(dest_true == result_true);

vector<bool> result_false(length, false);
result_false.resize(length + 3, true);
vector<bool> dest_false(length + 3, true);
fill(dest_false.begin(), prev(dest_false.end(), 3), false);
fill(dest_false.cbegin(), prev(dest_false.cend(), 3), false);
assert(dest_false == result_false);

vector<bool> result_true_n(length, true);
result_true_n.resize(length + 3, false);
vector<bool> dest_true_n(length + 3, false);
const auto res_fill_n = fill_n(dest_true_n.begin(), length, true);
const auto res_fill_n = fill_n(dest_true_n.cbegin(), length, true);
assert(dest_true_n == result_true_n);
assert(res_fill_n == prev(dest_true_n.end(), 3));
assert(res_fill_n == prev(dest_true_n.cend(), 3));

vector<bool> result_false_n(length, false);
result_false_n.resize(length + 3, true);
vector<bool> dest_false_n(length + 3, true);
fill_n(dest_false_n.begin(), length, false);
fill_n(dest_false_n.cbegin(), length, false);
assert(dest_false_n == result_false_n);
}

// With offset
{
vector<bool> result_true(length, true);
result_true.resize(length + 3, false);
result_true.insert(result_true.begin(), false);
result_true.insert(result_true.cbegin(), false);
vector<bool> dest_true(length + 4, false);
fill(next(dest_true.begin()), prev(dest_true.end(), 3), true);
fill(next(dest_true.cbegin()), prev(dest_true.cend(), 3), true);
assert(dest_true == result_true);

vector<bool> result_false(length, false);
result_false.resize(length + 3, true);
result_false.insert(result_false.begin(), true);
result_false.insert(result_false.cbegin(), true);
vector<bool> dest_false(length + 4, true);
fill(next(dest_false.begin()), prev(dest_false.end(), 3), false);
fill(next(dest_false.cbegin()), prev(dest_false.cend(), 3), false);
assert(dest_false == result_false);

vector<bool> result_true_n(length, true);
result_true_n.resize(length + 3, false);
result_true_n.insert(result_true_n.begin(), false);
result_true_n.insert(result_true_n.cbegin(), false);
vector<bool> dest_true_n(length + 4, false);
const auto res_fill_n = fill_n(next(dest_true_n.begin()), length, true);
const auto res_fill_n = fill_n(next(dest_true_n.cbegin()), length, true);
assert(dest_true_n == result_true_n);
assert(res_fill_n == prev(dest_true_n.end(), 3));
assert(res_fill_n == prev(dest_true_n.cend(), 3));

vector<bool> result_false_n(length, false);
result_false_n.resize(length + 3, true);
result_false_n.insert(result_false_n.begin(), true);
result_false_n.insert(result_false_n.cbegin(), true);
vector<bool> dest_false_n(length + 4, true);
fill_n(next(dest_false_n.begin()), length, false);
fill_n(next(dest_false_n.cbegin()), length, false);
assert(dest_false_n == result_false_n);
}
}
Expand Down

0 comments on commit 52ed289

Please sign in to comment.