Add unit test for backwards iteration.
This commit is contained in:
parent
221f236f40
commit
c1b6bd0500
1 changed files with 26 additions and 9 deletions
|
@ -26,9 +26,6 @@ TEST(vwr, vector_iterator) {
|
|||
|
||||
ivec3 from(100, 200, 300);
|
||||
ivec3 to(102, 203, 304);
|
||||
auto seq = increasing_sequence_range<ivec3>(from, to);
|
||||
auto it = seq.begin();
|
||||
auto it_end = seq.end();
|
||||
|
||||
std::array<ivec3, 24> expected{
|
||||
ivec3(100, 200, 300),
|
||||
|
@ -56,6 +53,12 @@ TEST(vwr, vector_iterator) {
|
|||
ivec3(100, 202, 303),
|
||||
ivec3(101, 202, 303)
|
||||
};
|
||||
|
||||
{
|
||||
auto seq = increasing_sequence_range<ivec3>(from, to);
|
||||
auto it = seq.begin();
|
||||
auto it_end = seq.end();
|
||||
|
||||
std::vector<ivec3> results;
|
||||
for (; it != it_end; ++it) {
|
||||
results.push_back(*it);
|
||||
|
@ -65,4 +68,18 @@ TEST(vwr, vector_iterator) {
|
|||
for (std::size_t z = 0; z < expected.size(); ++z) {
|
||||
EXPECT_EQ(expected[z], results[z]);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
using dec_sequence_range = sequence_range<ivec3, op::dec<int64_t>, std::greater<int64_t>, 0, 1, 2>;
|
||||
std::vector<ivec3> results;
|
||||
for (auto& itm : dec_sequence_range(to, from)) {
|
||||
results.push_back(itm);
|
||||
}
|
||||
|
||||
EXPECT_EQ(expected.size(), results.size());
|
||||
for (std::size_t z = 0; z < expected.size(); ++z) {
|
||||
EXPECT_EQ(expected[z] + 1, results[results.size() - 1 - z]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue