From 52d5330cbb866f050a8f0736c139586c8a22c387 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 21 Feb 2020 21:19:45 +0100 Subject: new_type: begin Iterable implementation --- test/include/iterable_suite.hpp | 11 ++++++++ test/src/driver.cpp | 2 ++ test/src/iterable_suite.cpp | 61 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 test/include/iterable_suite.hpp create mode 100644 test/src/iterable_suite.cpp (limited to 'test') diff --git a/test/include/iterable_suite.hpp b/test/include/iterable_suite.hpp new file mode 100644 index 0000000..c2bbc6e --- /dev/null +++ b/test/include/iterable_suite.hpp @@ -0,0 +1,11 @@ +#ifndef NEWTYPE_TEST_ITERABLE_SUITE_HPP +#define NEWTYPE_TEST_ITERABLE_SUITE_HPP + +#include + +#include +#include + +auto iterable_suite() -> std::pair; + +#endif \ No newline at end of file diff --git a/test/src/driver.cpp b/test/src/driver.cpp index cfd6b90..a0e8904 100644 --- a/test/src/driver.cpp +++ b/test/src/driver.cpp @@ -4,6 +4,7 @@ #include "equality_comparison_suite.hpp" #include "hash_suite.hpp" #include "io_operators_suite.hpp" +#include "iterable_suite.hpp" #include "new_type_constructor_suite.hpp" #include "relational_operators_suite.hpp" @@ -61,6 +62,7 @@ int main(int argc, char ** argv) io_operators_suite(), arithmetic_suite(), hash_suite(), + iterable_suite(), }; auto selectors = get_test_selectors(suites); diff --git a/test/src/iterable_suite.cpp b/test/src/iterable_suite.cpp new file mode 100644 index 0000000..2470571 --- /dev/null +++ b/test/src/iterable_suite.cpp @@ -0,0 +1,61 @@ +#include "iterable_suite.hpp" + +#include "kawaii.hpp" +#include "newtype/derivable.hpp" +#include "newtype/deriving.hpp" +#include "newtype/impl/type_traits_extensions.hpp" +#include "newtype/new_type.hpp" + +#include + +#include +#include + +namespace +{ + +} + +inline namespace begin_tests +{ + + auto a_new__type_not_deriving_iterable_has_no_begin() -> void + { + using type_alias = nt::new_type; + ASSERT(!(nt::impl::has_begin_v)); + } + + auto a_new__type_based_on_a_non_iterable_type_deriving_iterable_has_no_begin() -> void + { + static_assert(!nt::impl::has_begin_v); + using type_alias = nt::new_type; + ASSERT(!(nt::impl::has_begin_v)); + } + + auto a_new__type_based_on_an_iterable_type_with_member_begin_deriving_iterable_has_member_begin() -> void + { + static_assert(nt::impl::has_member_begin_v>); + using type_alias = nt::new_type, struct tag, deriving(nt::Iterable)>; + ASSERT(nt::impl::has_member_begin_v); + } + + auto a_new__type_based_on_an_iterable_type_with_constant_member_begin_deriving_iterable_has_constant_member_begin() -> void + { + static_assert(nt::impl::has_member_begin_v>); + using type_alias = nt::new_type, struct tag, deriving(nt::Iterable)>; + ASSERT(nt::impl::has_member_begin_v); + } + +} // namespace begin_tests + +auto iterable_suite() -> std::pair +{ + 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), + }, + "Iterable Tests"}; +} \ No newline at end of file -- cgit v1.2.3