diff options
Diffstat (limited to 'asl/base/utility_tests.cpp')
-rw-r--r-- | asl/base/utility_tests.cpp | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/asl/base/utility_tests.cpp b/asl/base/utility_tests.cpp index 20cdf97..7e54bb2 100644 --- a/asl/base/utility_tests.cpp +++ b/asl/base/utility_tests.cpp @@ -12,28 +12,28 @@ template<typename T> static constexpr int identify(T&&) { return 4; } struct IdentifySelf { - constexpr int get(this auto&& self) { return identify(ASL_FWD(self)); } + constexpr int get(this auto&& self) { return identify(std::forward<decltype(self)>(self)); } }; -static int get_const_lref(const IdentifySelf& i) { return ASL_FWD(i).get(); } -static int get_const_rref(const IdentifySelf&& i) { return ASL_FWD(i).get(); } -static int get_lref(IdentifySelf& i) { return ASL_FWD(i).get(); } -static int get_rref(IdentifySelf&& i) { return ASL_FWD(i).get(); } +static int get_const_lref(const IdentifySelf& i) { return i.get(); } +static int get_const_rref(const IdentifySelf&& i) { return std::move(i).get(); } // NOLINT +static int get_lref(IdentifySelf& i) { return i.get(); } +static int get_rref(IdentifySelf&& i) { return std::move(i).get(); } // NOLINT ASL_TEST(forward) { - IdentifySelf id; - ASL_TEST_EXPECT(get_const_lref(id) == 1); + IdentifySelf id{}; + ASL_TEST_EXPECT(get_const_lref(IdentifySelf{}) == 1); ASL_TEST_EXPECT(get_lref(id) == 3); - ASL_TEST_EXPECT(get_const_rref(ASL_MOVE(id)) == 2); - ASL_TEST_EXPECT(get_rref(ASL_MOVE(id)) == 4); + ASL_TEST_EXPECT(get_const_rref(IdentifySelf{}) == 2); + ASL_TEST_EXPECT(get_rref(IdentifySelf{}) == 4); } ASL_TEST(move) { IdentifySelf id; ASL_TEST_EXPECT(id.get() == 3); - ASL_TEST_EXPECT(ASL_MOVE(id).get() == 4); + ASL_TEST_EXPECT(IdentifySelf{}.get() == 4); } struct Level1 @@ -51,33 +51,33 @@ struct Level3 Level2 deeper; }; -static int get_const_lref(const Level3& i) { return ASL_FWD(i).deeper.deeper.id.get(); } -static int get_const_rref(const Level3&& i) { return ASL_FWD(i).deeper.deeper.id.get(); } -static int get_lref(Level3& i) { return ASL_FWD(i).deeper.deeper.id.get(); } -static int get_rref(Level3&& i) { return ASL_FWD(i).deeper.deeper.id.get(); } +static int get_const_lref(const Level3& i) { return i.deeper.deeper.id.get(); } +static int get_const_rref(const Level3&& i) { return std::move(i).deeper.deeper.id.get(); } +static int get_lref(Level3& i) { return i.deeper.deeper.id.get(); } +static int get_rref(Level3&& i) { return std::move(i).deeper.deeper.id.get(); } ASL_TEST(forward2) { Level3 id{}; ASL_TEST_EXPECT(get_const_lref(id) == 1); ASL_TEST_EXPECT(get_lref(id) == 3); - ASL_TEST_EXPECT(get_const_rref(ASL_MOVE(id)) == 2); - ASL_TEST_EXPECT(get_rref(ASL_MOVE(id)) == 4); + ASL_TEST_EXPECT(get_const_rref(Level3{}) == 2); + ASL_TEST_EXPECT(get_rref(Level3{}) == 4); } template<typename T> -static int test_fwd_like(T&& t) +static int test_fwd_like(T) // NOLINT { - IdentifySelf id; - return ASL_FWD_LIKE(decltype(t), id).get(); + const IdentifySelf id; + return std::forward_like<T>(id).get(); } ASL_TEST(forward_like) { int x{}; - ASL_TEST_EXPECT(test_fwd_like<const int&>(x) == 1); + ASL_TEST_EXPECT(test_fwd_like<const int&>(7) == 1); ASL_TEST_EXPECT(test_fwd_like<int&>(x) == 3); - ASL_TEST_EXPECT(test_fwd_like<const int&&>(ASL_MOVE(x)) == 2); - ASL_TEST_EXPECT(test_fwd_like<int&&>(ASL_MOVE(x)) == 4); + ASL_TEST_EXPECT(test_fwd_like<const int&&>(8) == 2); + ASL_TEST_EXPECT(test_fwd_like<int&&>(9) == 4); } |