mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-08-03 10:55:57 -04:00
Fix Get() for null Points and Rects, add tests for it
This commit is contained in:
parent
8e6bf5fc2f
commit
5a61a8f51b
@ -51,11 +51,11 @@ bool Point::operator!=(const Point& other) const {
|
||||
}
|
||||
|
||||
SDL_Point* Point::Get() {
|
||||
return &point_;
|
||||
return valid_ ? &point_ : nullptr;
|
||||
}
|
||||
|
||||
const SDL_Point* Point::Get() const {
|
||||
return &point_;
|
||||
return valid_ ? &point_ : nullptr;
|
||||
}
|
||||
|
||||
bool Point::IsNull() const {
|
||||
|
@ -54,11 +54,11 @@ bool Rect::operator!=(const Rect& other) const {
|
||||
}
|
||||
|
||||
SDL_Rect* Rect::Get() {
|
||||
return &rect_;
|
||||
return valid_ ? &rect_ : nullptr;
|
||||
}
|
||||
|
||||
const SDL_Rect* Rect::Get() const {
|
||||
return &rect_;
|
||||
return valid_ ? &rect_ : nullptr;
|
||||
}
|
||||
|
||||
Rect Rect::FromCenter(int cx, int cy, int w, int h) {
|
||||
|
@ -33,6 +33,7 @@ BEGIN_TEST()
|
||||
EXPECT_TRUE(p != Point(1,2));
|
||||
EXPECT_TRUE(p == Point::Null());
|
||||
EXPECT_TRUE(p.IsNull());
|
||||
EXPECT_TRUE(p.Get() == nullptr);
|
||||
}
|
||||
|
||||
{
|
||||
@ -114,6 +115,7 @@ BEGIN_TEST()
|
||||
EXPECT_TRUE(r != Rect(1,2,3,4));
|
||||
EXPECT_TRUE(r == Rect::Null());
|
||||
EXPECT_TRUE(r.IsNull());
|
||||
EXPECT_TRUE(r.Get() == nullptr);
|
||||
}
|
||||
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user