aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/src/iterable_suite.cpp84
1 files changed, 72 insertions, 12 deletions
diff --git a/test/src/iterable_suite.cpp b/test/src/iterable_suite.cpp
index 8c08a66..3bdb16b 100644
--- a/test/src/iterable_suite.cpp
+++ b/test/src/iterable_suite.cpp
@@ -21,6 +21,7 @@ namespace
auto begin() -> iterator;
auto begin() const -> const_iterator;
+ auto cbegin() const -> const_iterator;
};
} // namespace
@@ -86,18 +87,77 @@ inline namespace begin_tests
} // namespace begin_tests
+inline namespace cbegin_tests
+{
+
+ auto a_new__type_not_deriving_iterable_has_no_cbegin() -> void
+ {
+ using type_alias = nt::new_type<int, struct tag>;
+ ASSERT(!(nt::impl::has_cbegin_v<type_alias>));
+ }
+
+ auto a_new__type_based_on_a_non_iterable_type_deriving_iterable_has_no_cbegin() -> void
+ {
+ static_assert(!nt::impl::has_cbegin_v<int>);
+ using type_alias = nt::new_type<int, struct tag, deriving(nt::Iterable)>;
+ ASSERT(!(nt::impl::has_cbegin_v<type_alias>));
+ }
+
+ auto a_new__type_based_on_an_iterable_type_with_member_cbegin_deriving_iterable_has_member_cbegin() -> void
+ {
+ static_assert(nt::impl::has_member_cbegin_v<with_member>);
+ using type_alias = nt::new_type<with_member, struct tag, deriving(nt::Iterable)>;
+ ASSERT(nt::impl::has_member_cbegin_v<type_alias>);
+ }
+
+ auto a_new__type_based_on_an_iterable_type_without_free_cbegin_deriving_iterable_has_no_free_cbegin() -> void
+ {
+ static_assert(!nt::impl::has_free_cbegin_v<with_member>);
+ using type_alias = nt::new_type<with_member, struct tag, deriving(nt::Iterable)>;
+ ASSERT(!nt::impl::has_free_cbegin_v<type_alias>);
+ }
+
+ auto accessing_the_first_element_of_a_constant_iterator_on_a_new__type_yields_the_same_value_as_accessing_it_through_an_unwrapped_type()
+ -> void
+ {
+ using type_alias = nt::new_type<std::array<int, 3>, struct tag, deriving(nt::Iterable)>;
+ auto weak = std::array{42, 21, 10};
+ auto strong = type_alias{{42, 21, 10}};
+ ASSERT_EQUAL(*weak.cbegin(), *strong.cbegin());
+ }
+
+ auto an_iterator_obtained_via_member_cbegin_compares_equal_to_an_iterator_obtained_via_free_cbegin() -> void
+ {
+ using type_alias = nt::new_type<std::array<int, 3>, struct tag, deriving(nt::Iterable)>;
+ auto instance = type_alias{{42, 21, 10}};
+ ASSERT_EQUAL(cbegin(instance), instance.cbegin());
+ }
+
+} // namespace cbegin_tests
+
auto iterable_suite() -> std::pair<cute::suite, std::string>
{
- return {{
- /// 'begin' Tests
- KAWAII(a_new__type_not_deriving_iterable_has_no_begin),
- KAWAII(a_new__type_based_on_a_non_iterable_type_deriving_iterable_has_no_begin),
- KAWAII(a_new__type_based_on_an_iterable_type_with_member_begin_deriving_iterable_has_member_begin),
- KAWAII(a_new__type_based_on_an_iterable_type_with_constant_member_begin_deriving_iterable_has_constant_member_begin),
- KAWAII(a_new__type_based_on_an_iterable_type_without_free_begin_deriving_iterable_has_no_free_begin),
- KAWAII(a_new__type_based_on_an_iterable_type_without_constant_free_begin_deriving_iterable_has_no_constant_free_begin),
- KAWAII(accessing_the_first_element_of_an_iterator_on_a_new__type_yields_the_same_value_as_accessing_it_through_an_unwrapped_type),
- KAWAII(an_iterator_obtained_via_member_begin_compares_equal_to_an_iterator_obtained_via_free_begin),
- },
- "Iterable Tests"};
+ return {
+ {
+ // clang-format off
+ /// 'begin' Tests
+ KAWAII(a_new__type_not_deriving_iterable_has_no_begin),
+ KAWAII(a_new__type_based_on_a_non_iterable_type_deriving_iterable_has_no_begin),
+ KAWAII(a_new__type_based_on_an_iterable_type_with_member_begin_deriving_iterable_has_member_begin),
+ KAWAII(a_new__type_based_on_an_iterable_type_with_constant_member_begin_deriving_iterable_has_constant_member_begin),
+ KAWAII(a_new__type_based_on_an_iterable_type_without_free_begin_deriving_iterable_has_no_free_begin),
+ KAWAII(a_new__type_based_on_an_iterable_type_without_constant_free_begin_deriving_iterable_has_no_constant_free_begin),
+ KAWAII(accessing_the_first_element_of_an_iterator_on_a_new__type_yields_the_same_value_as_accessing_it_through_an_unwrapped_type),
+ KAWAII(an_iterator_obtained_via_member_begin_compares_equal_to_an_iterator_obtained_via_free_begin),
+
+ /// 'begin' Tests
+ KAWAII(a_new__type_not_deriving_iterable_has_no_cbegin),
+ KAWAII(a_new__type_based_on_a_non_iterable_type_deriving_iterable_has_no_cbegin),
+ KAWAII(a_new__type_based_on_an_iterable_type_with_member_cbegin_deriving_iterable_has_member_cbegin),
+ KAWAII(a_new__type_based_on_an_iterable_type_without_free_cbegin_deriving_iterable_has_no_free_cbegin),
+ KAWAII(accessing_the_first_element_of_a_constant_iterator_on_a_new__type_yields_the_same_value_as_accessing_it_through_an_unwrapped_type),
+ KAWAII(an_iterator_obtained_via_member_cbegin_compares_equal_to_an_iterator_obtained_via_free_cbegin),
+ // clang-format on
+ },
+ "Iterable Tests"};
} \ No newline at end of file