From 35e20e54f68425d0e7f2387bb3f5e6e694326474 Mon Sep 17 00:00:00 2001 From: Johan Mabille Date: Fri, 5 Apr 2024 14:47:38 +0200 Subject: [PATCH] Added tests --- test/test_iterator.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/test_iterator.cpp b/test/test_iterator.cpp index a1aab8ea..1f6cc1e6 100644 --- a/test/test_iterator.cpp +++ b/test/test_iterator.cpp @@ -14,6 +14,7 @@ #include "doctest/doctest.h" +#include #include #include @@ -241,4 +242,28 @@ namespace sparrow CHECK(valid); } } + + TEST_SUITE("pointer_iterator") + { + TEST_CASE("make_pointer_iterator") + { + std::array 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 a = { 2, 4, 6 }; + using iterator = pointer_iterator; + using const_iterator = pointer_iterator; + + const_iterator iter{a.begin()}; + CHECK_EQ(*iter, a[0]); + } + } }