diff --git a/include/ddc/discrete_vector.hpp b/include/ddc/discrete_vector.hpp index 446f98f2c..d563032f9 100644 --- a/include/ddc/discrete_vector.hpp +++ b/include/ddc/discrete_vector.hpp @@ -381,7 +381,7 @@ class DiscreteVector : public detail::DiscreteVectorConversionOperators> KOKKOS_FUNCTION constexpr DiscreteVector& operator--() { - ++m_values[0]; + --m_values[0]; return *this; } @@ -389,7 +389,7 @@ class DiscreteVector : public detail::DiscreteVectorConversionOperators(), dv_z); } +TEST(DiscreteVectorXTest, PreIncrement) +{ + DVectX const ix0(3); + DVectX ix1(ix0); + DVectX const ix2 = ++ix1; + EXPECT_EQ(ix1, ix0 + 1); + EXPECT_EQ(ix2, ix0 + 1); +} + +TEST(DiscreteVectorXTest, PostIncrement) +{ + DVectX const ix0(3); + DVectX ix1(ix0); + DVectX const ix2 = ix1++; + EXPECT_EQ(ix1, ix0 + 1); + EXPECT_EQ(ix2, ix0); +} + +TEST(DiscreteVectorXTest, PreDecrement) +{ + DVectX const ix0(3); + DVectX ix1(ix0); + DVectX const ix2 = --ix1; + EXPECT_EQ(ix1, ix0 - 1); + EXPECT_EQ(ix2, ix0 - 1); +} + +TEST(DiscreteVectorXTest, PostDecrement) +{ + DVectX const ix0(3); + DVectX ix1(ix0); + DVectX const ix2 = ix1--; + EXPECT_EQ(ix1, ix0 - 1); + EXPECT_EQ(ix2, ix0); +} + TEST(DiscreteVectorTest, ExternalBinaryOperatorPlus) { std::size_t const dv_x = 7;