mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-09-09 07:18:45 -04:00
Use references for cleaner self move tests
This commit is contained in:
parent
e37245b7e1
commit
fcfe258550
@ -33,10 +33,6 @@ IF(SDL2PP_WITH_TTF)
|
|||||||
)
|
)
|
||||||
ENDIF(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")
|
ADD_DEFINITIONS(-DTESTDATA_DIR="${PROJECT_SOURCE_DIR}/testdata")
|
||||||
|
|
||||||
# header tests: these just include specific headers to check if
|
# header tests: these just include specific headers to check if
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
EXPECT_EQUAL(obj.getmethod(), ptr); \
|
EXPECT_EQUAL(obj.getmethod(), ptr); \
|
||||||
EXPECT_TRUE(obj1.getmethod() == nullval); \
|
EXPECT_TRUE(obj1.getmethod() == nullval); \
|
||||||
\
|
\
|
||||||
obj = std::move(obj); \
|
cl& obj_ref = obj; \
|
||||||
|
obj = std::move(obj_ref); \
|
||||||
EXPECT_EQUAL(obj.getmethod(), ptr); \
|
EXPECT_EQUAL(obj.getmethod(), ptr); \
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,8 @@ BEGIN_TEST(int, char*[])
|
|||||||
Point p(12,13);
|
Point p(12,13);
|
||||||
p = Point(14,15);
|
p = Point(14,15);
|
||||||
|
|
||||||
p = std::move(p);
|
Point& pref = p;
|
||||||
|
p = std::move(pref);
|
||||||
|
|
||||||
EXPECT_TRUE(p.GetX() == 14 && p.GetY() == 15);
|
EXPECT_TRUE(p.GetX() == 14 && p.GetY() == 15);
|
||||||
}
|
}
|
||||||
@ -144,7 +145,8 @@ BEGIN_TEST(int, char*[])
|
|||||||
Rect r(21,22,23,24);
|
Rect r(21,22,23,24);
|
||||||
r = Rect(25,26,27,28);
|
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);
|
EXPECT_TRUE(r.GetX() == 25 && r.GetY() == 26 && r.GetW() == 27 && r.GetH() == 28);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user