aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@gmail.com>2020-01-02 15:46:27 +0100
committerFelix Morgner <felix.morgner@gmail.com>2020-01-02 15:46:27 +0100
commit6998183b580b60ac72f79b3ebc4f206fa35937ac (patch)
tree239ed951133baa1c0b6345f32f844d296d7a5a83 /test
parent05abaa3d00393165e7794a150ad6c4b5ac5dd37e (diff)
downloadnewtype-6998183b580b60ac72f79b3ebc4f206fa35937ac.tar.xz
newtype-6998183b580b60ac72f79b3ebc4f206fa35937ac.zip
new_type: implement divide-assignment
Diffstat (limited to 'test')
-rw-r--r--test/src/arithmetic_suite.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/src/arithmetic_suite.cpp b/test/src/arithmetic_suite.cpp
index c7051e2..f831b98 100644
--- a/test/src/arithmetic_suite.cpp
+++ b/test/src/arithmetic_suite.cpp
@@ -256,6 +256,23 @@ inline namespace compound_arithmetic
ASSERT_EQUAL(elhs *= erhs, (lhs *= rhs).decay());
}
+ auto division_assignment_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 &>() /= std::declval<type_alias const &>())>));
+ }
+
+ auto division_assignment_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 elhs = 42;
+ auto erhs = 18;
+ auto lhs = type_alias{elhs};
+ auto rhs = type_alias{erhs};
+ ASSERT_EQUAL(elhs /= erhs, (lhs /= rhs).decay());
+ }
+
} // namespace compound_arithmetic
auto arithmetic_suite() -> std::pair<cute::suite, std::string>
@@ -303,6 +320,8 @@ auto arithmetic_suite() -> std::pair<cute::suite, std::string>
KAWAII(subtraction_assignment_of_two_instances_of_a_new__type_deriving_arithmetic_produces_the_correct_value_with_respect_to_the_base_type),
KAWAII(multiplication_assignment_of_two_instances_of_a_new__type_deriving_arithmetic_produces_an_instance_of_the_same_new__type),
KAWAII(multiplication_assignment_of_two_instances_of_a_new__type_deriving_arithmetic_produces_the_correct_value_with_respect_to_the_base_type),
+ KAWAII(division_assignment_of_two_instances_of_a_new__type_deriving_arithmetic_produces_an_instance_of_the_same_new__type),
+ KAWAII(division_assignment_of_two_instances_of_a_new__type_deriving_arithmetic_produces_the_correct_value_with_respect_to_the_base_type),
// clang-format on
},