aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/src/arithmetic_suite.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/src/arithmetic_suite.cpp b/test/src/arithmetic_suite.cpp
index e77c1dd..7c2b617 100644
--- a/test/src/arithmetic_suite.cpp
+++ b/test/src/arithmetic_suite.cpp
@@ -163,6 +163,45 @@ inline namespace multiplication_tests
} // namespace multiplication_tests
+inline namespace division_tests
+{
+
+ auto a_new__type_not_deriving_arithmetic_is_not_dividable_with_instances_of_itself() -> void
+ {
+ using type_alias = nt::new_type<int, struct tag>;
+ ASSERT(!(nt::impl::is_dividable_v<type_alias>));
+ }
+
+ auto a_new__type_deriving_arithmetic_is_dividable_with_instances_of_itself() -> void
+ {
+ using type_alias = nt::new_type<int, struct tag, deriving(nt::Arithmetic)>;
+ ASSERT(nt::impl::is_dividable_v<type_alias>);
+ }
+
+ template<typename T>
+ auto a_new__type_deriving_arithmetic_is_dividable_with_instances_of_itself_if_the_base_type_is_dividable() -> void
+ {
+ static_assert(nt::impl::is_dividable_v<T>, "Sanity Check");
+ using type_alias = nt::new_type<T, struct tag, deriving(nt::Arithmetic)>;
+ ASSERT_EQUAL(nt::impl::is_dividable_v<T>, nt::impl::is_dividable_v<type_alias>);
+ }
+
+ auto division_of_two_instances_of_a_new__type_deriving_arithmetic_produces_an_instance_of_the_same_new__type() -> void
+ {
+ using type_alias = nt::new_type<int, struct tag, deriving(nt::Arithmetic)>;
+ ASSERT((std::is_same_v<type_alias, decltype(std::declval<type_alias const &>() / std::declval<type_alias const &>())>));
+ }
+
+ auto division_of_two_instances_of_a_new__type_deriving_arithmetic_produces_the_correct_value_with_respect_to_the_base_type() -> void
+ {
+ using type_alias = nt::new_type<int, struct tag, deriving(nt::Arithmetic)>;
+ auto lhs = type_alias{24};
+ auto rhs = type_alias{2};
+ ASSERT_EQUAL(24 / 2, (lhs / rhs).decay());
+ }
+
+} // namespace division_tests
+
auto arithmetic_suite() -> std::pair<cute::suite, std::string>
{
return {
@@ -190,6 +229,14 @@ auto arithmetic_suite() -> std::pair<cute::suite, std::string>
KAWAII(a_new__type_deriving_arithmetic_is_multipliable_with_instances_of_itself_if_the_base_type_is_multipliable<multipliable_type>),
KAWAII(multiplication_of_two_instances_of_a_new__type_deriving_arithmetic_produces_an_instance_of_the_same_new__type),
KAWAII(multiplication_of_two_instances_of_a_new__type_deriving_arithmetic_produces_the_correct_value_with_respect_to_the_base_type),
+
+ /// Division Tests
+ KAWAII(a_new__type_not_deriving_arithmetic_is_not_dividable_with_instances_of_itself),
+ KAWAII(a_new__type_deriving_arithmetic_is_dividable_with_instances_of_itself),
+ KAWAII(a_new__type_deriving_arithmetic_is_dividable_with_instances_of_itself_if_the_base_type_is_dividable<int>),
+ KAWAII(a_new__type_deriving_arithmetic_is_dividable_with_instances_of_itself_if_the_base_type_is_dividable<dividable_type>),
+ KAWAII(division_of_two_instances_of_a_new__type_deriving_arithmetic_produces_an_instance_of_the_same_new__type),
+ KAWAII(division_of_two_instances_of_a_new__type_deriving_arithmetic_produces_the_correct_value_with_respect_to_the_base_type),
},
"Arithmetic Operators Tests"};
} \ No newline at end of file