diff --git a/include/heyoka/number.hpp b/include/heyoka/number.hpp index 478e846f6..8c3d9d17f 100644 --- a/include/heyoka/number.hpp +++ b/include/heyoka/number.hpp @@ -105,6 +105,7 @@ HEYOKA_DLL_PUBLIC bool is_negative_one(const number &); HEYOKA_DLL_PUBLIC bool is_negative(const number &); HEYOKA_DLL_PUBLIC bool is_integer(const number &); +HEYOKA_DLL_PUBLIC number operator+(number); HEYOKA_DLL_PUBLIC number operator-(const number &); HEYOKA_DLL_PUBLIC number operator+(const number &, const number &); diff --git a/test/number.cpp b/test/number.cpp index 7323dffaf..d998917bd 100644 --- a/test/number.cpp +++ b/test/number.cpp @@ -928,3 +928,34 @@ TEST_CASE("move semantics") REQUIRE(x3 == number{3.}); REQUIRE(x2 == number{0.}); } + +TEST_CASE("basic arith") +{ + number n{42.}; + + REQUIRE(+n == n); + REQUIRE(-n == number{-42.}); +} + +TEST_CASE("copy assignment") +{ + number n1{42.}; + number n2{42.f}; + + n2 = n1; + + REQUIRE(n2 == number{42.}); +} + +TEST_CASE("swap") +{ + REQUIRE(std::is_nothrow_swappable_v); + + number n1{42.}; + number n2{42.f}; + + swap(n1, n2); + + REQUIRE(n2 == number{42.}); + REQUIRE(n1 == number{42.f}); +}