|
|
@@ -7,7 +7,6 @@
|
|
|
//
|
|
|
|
|
|
#include <gmock/gmock.h>
|
|
|
-#include <cmath>
|
|
|
|
|
|
#include "opaque_typedef/arithmatic.hpp"
|
|
|
#include "opaque_typedef/opaque_typedef.hpp"
|
|
|
@@ -29,6 +28,7 @@ template <typename T> void operator--(T);
|
|
|
using namespace types;
|
|
|
using counter = opaque_typedef<uint32_t, struct counter_tag, Incrementable>;
|
|
|
using countdown = opaque_typedef<uint32_t, struct countdown_tag, Decrementable>;
|
|
|
+using idx = opaque_typedef<uint32_t, struct idx_tag, Incrementable, Decrementable>;
|
|
|
|
|
|
// Actual Test Bodies
|
|
|
TEST(OpaqueTypedefDecrementableTest, CannotDecrement) {
|
|
|
@@ -66,3 +66,11 @@ TEST(OpaqueTypedefDecrementableTest, CanPreDecrement) {
|
|
|
EXPECT_THAT(--c, testing::Eq(countdown{9}));
|
|
|
EXPECT_THAT(c, testing::Eq(countdown{9}));
|
|
|
}
|
|
|
+
|
|
|
+TEST(OpaqueTypedefArithmaticTest, CanMergeIncrementAndDecrement) {
|
|
|
+ idx i{1};
|
|
|
+ EXPECT_TRUE((testing::StaticAssertTypeEq<idx, decltype(i--)>()));
|
|
|
+ EXPECT_TRUE((testing::StaticAssertTypeEq<idx&, decltype(--i)>()));
|
|
|
+ EXPECT_TRUE((testing::StaticAssertTypeEq<idx, decltype(i++)>()));
|
|
|
+ EXPECT_TRUE((testing::StaticAssertTypeEq<idx&, decltype(++i)>()));
|
|
|
+}
|