aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/include/iterable_suite.hpp11
-rw-r--r--test/src/driver.cpp2
-rw-r--r--test/src/iterable_suite.cpp61
3 files changed, 74 insertions, 0 deletions
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 <cute/cute_suite.h>
+
+#include <string>
+#include <utility>
+
+auto iterable_suite() -> std::pair<cute::suite, std::string>;
+
+#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 <cute/cute.h>
+
+#include <array>
+#include <iterator>
+
+namespace
+{
+
+}
+
+inline namespace begin_tests
+{
+
+ auto a_new__type_not_deriving_iterable_has_no_begin() -> void
+ {
+ using type_alias = nt::new_type<int, struct tag>;
+ ASSERT(!(nt::impl::has_begin_v<type_alias>));
+ }
+
+ auto a_new__type_based_on_a_non_iterable_type_deriving_iterable_has_no_begin() -> void
+ {
+ static_assert(!nt::impl::has_begin_v<int>);
+ using type_alias = nt::new_type<int, struct tag, deriving(nt::Iterable)>;
+ ASSERT(!(nt::impl::has_begin_v<type_alias>));
+ }
+
+ 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<std::array<int, 3>>);
+ using type_alias = nt::new_type<std::array<int, 3>, struct tag, deriving(nt::Iterable)>;
+ ASSERT(nt::impl::has_member_begin_v<type_alias>);
+ }
+
+ 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<std::array<int const, 3>>);
+ using type_alias = nt::new_type<std::array<int, 3>, struct tag, deriving(nt::Iterable)>;
+ ASSERT(nt::impl::has_member_begin_v<type_alias const>);
+ }
+
+} // namespace begin_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),
+ },
+ "Iterable Tests"};
+} \ No newline at end of file