From 05abaa3d00393165e7794a150ad6c4b5ac5dd37e Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Thu, 2 Jan 2020 15:42:12 +0100 Subject: new_type: implement multiply-assignment --- test/src/arithmetic_suite.cpp | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/src/arithmetic_suite.cpp b/test/src/arithmetic_suite.cpp index 75a7f46..c7051e2 100644 --- a/test/src/arithmetic_suite.cpp +++ b/test/src/arithmetic_suite.cpp @@ -202,7 +202,7 @@ inline namespace division_tests } // namespace division_tests -inline namespace compound_addition +inline namespace compound_arithmetic { auto addition_assignment_of_two_instances_of_a_new__type_deriving_arithmetic_produces_an_instance_of_the_same_new__type() -> void @@ -239,7 +239,24 @@ inline namespace compound_addition ASSERT_EQUAL(elhs -= erhs, (lhs -= rhs).decay()); } -} // namespace compound_addition + auto multiplication_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; + ASSERT((std::is_same_v() *= std::declval())>)); + } + + auto multiplication_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; + 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 { @@ -279,13 +296,13 @@ auto arithmetic_suite() -> std::pair 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), - /// Compound Addition Tests + /// Compound Arithmetic Tests KAWAII(addition_assignment_of_two_instances_of_a_new__type_deriving_arithmetic_produces_an_instance_of_the_same_new__type), KAWAII(addition_assignment_of_two_instances_of_a_new__type_deriving_arithmetic_produces_the_correct_value_with_respect_to_the_base_type), - - /// Compound Addition Tests KAWAII(subtraction_assignment_of_two_instances_of_a_new__type_deriving_arithmetic_produces_an_instance_of_the_same_new__type), 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), // clang-format on }, -- cgit v1.2.3