Use references for cleaner self move tests

This commit is contained in:
Dmitry Marakasov 2016-02-17 04:00:28 +03:00
parent e37245b7e1
commit fcfe258550
3 changed files with 6 additions and 7 deletions

View File

@ -33,10 +33,6 @@ IF(SDL2PP_WITH_TTF)
)
ENDIF(SDL2PP_WITH_TTF)
# disable self-move warning: it's deliberately used in tests
INCLUDE(AppendCXXFlagIfSupported)
APPEND_CXX_FLAG_IF_SUPPORTED(-Wno-self-move CMAKE_CXX_FLAGS)
ADD_DEFINITIONS(-DTESTDATA_DIR="${PROJECT_SOURCE_DIR}/testdata")
# header tests: these just include specific headers to check if

View File

@ -10,6 +10,7 @@
EXPECT_EQUAL(obj.getmethod(), ptr); \
EXPECT_TRUE(obj1.getmethod() == nullval); \
\
obj = std::move(obj); \
cl& obj_ref = obj; \
obj = std::move(obj_ref); \
EXPECT_EQUAL(obj.getmethod(), ptr); \
}

View File

@ -50,7 +50,8 @@ BEGIN_TEST(int, char*[])
Point p(12,13);
p = Point(14,15);
p = std::move(p);
Point& pref = p;
p = std::move(pref);
EXPECT_TRUE(p.GetX() == 14 && p.GetY() == 15);
}
@ -144,7 +145,8 @@ BEGIN_TEST(int, char*[])
Rect r(21,22,23,24);
r = Rect(25,26,27,28);
r = std::move(r);
Rect& rref = r;
r = std::move(rref);
EXPECT_TRUE(r.GetX() == 25 && r.GetY() == 26 && r.GetW() == 27 && r.GetH() == 28);
}