Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanMabille committed Apr 5, 2024
1 parent deaf51f commit 35e20e5
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/test_iterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "doctest/doctest.h"

#include <array>
#include <cstddef>
#include <numeric>

Expand Down Expand Up @@ -241,4 +242,28 @@ namespace sparrow
CHECK(valid);
}
}

TEST_SUITE("pointer_iterator")
{
TEST_CASE("make_pointer_iterator")
{
std::array<int, 3> a = { 2, 4, 6 };
auto iter = make_pointer_iterator(a.begin());
CHECK_EQ(*iter, a[0]);
++iter;
CHECK_EQ(*iter, a[1]);
++iter;
CHECK_EQ(*iter, a[2]);
}

TEST_CASE("const conversion")
{
std::array<int, 3> a = { 2, 4, 6 };
using iterator = pointer_iterator<int*>;
using const_iterator = pointer_iterator<const int*>;

const_iterator iter{a.begin()};
CHECK_EQ(*iter, a[0]);
}
}
}

0 comments on commit 35e20e5

Please sign in to comment.