diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2020-01-02 13:15:53 +0100 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2020-01-02 13:15:53 +0100 |
| commit | 9a5d11d4c5701c8ad2e6aa1213cc9fd2937ccbc4 (patch) | |
| tree | c5fab3249e9b6c22cc4e4f03a9ac9f2d3c80e78d /test | |
| parent | b34cbb0fa7dcd783245d2d2b2352846579bbb77b (diff) | |
| download | newtype-9a5d11d4c5701c8ad2e6aa1213cc9fd2937ccbc4.tar.xz newtype-9a5d11d4c5701c8ad2e6aa1213cc9fd2937ccbc4.zip | |
new_type: implement add-assign
Diffstat (limited to 'test')
| -rw-r--r-- | test/src/arithmetic_suite.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/src/arithmetic_suite.cpp b/test/src/arithmetic_suite.cpp index 7c2b617..5d760d2 100644 --- a/test/src/arithmetic_suite.cpp +++ b/test/src/arithmetic_suite.cpp @@ -202,6 +202,28 @@ inline namespace division_tests } // namespace division_tests +inline namespace compound_addition +{ + + auto addition_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 addition_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 lhs = type_alias{24}; + auto rhs = type_alias{18}; + auto elhs = 42; + auto erhs = 18; + ASSERT_EQUAL(elhs += erhs, (lhs += rhs).decay()); + } + +} // namespace compound_addition + auto arithmetic_suite() -> std::pair<cute::suite, std::string> { return { |
