mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-08-03 19:05:59 -04:00
Added PollAllEvents()
This commit is contained in:
parent
78cc589fc9
commit
c10ffbb867
@ -28,4 +28,12 @@ namespace SDL2pp {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int PollAllEvents() {
|
||||
int result;
|
||||
|
||||
for (result = 0; PollEvent(); result++);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,8 @@ namespace SDL2pp {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int PollAllEvents();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -111,4 +111,21 @@ BEGIN_TEST(int, char*[])
|
||||
EXPECT_TRUE(PollEvent(eventHandler) == false);
|
||||
EXPECT_TRUE(eventHandler.events.size() == 1);
|
||||
}
|
||||
|
||||
// With no callback and no polled events
|
||||
{
|
||||
EXPECT_TRUE(PollAllEvents() == 0);
|
||||
}
|
||||
|
||||
// With no callback and several polled events
|
||||
{
|
||||
constexpr int totalEvents = 5;
|
||||
for (int n = 0; n < totalEvents; ++n) {
|
||||
PushUserEvent();
|
||||
}
|
||||
|
||||
EXPECT_TRUE(PollAllEvents() == totalEvents);
|
||||
// Verify no further events
|
||||
EXPECT_TRUE(PollEvent() == false);
|
||||
}
|
||||
END_TEST()
|
||||
|
Loading…
x
Reference in New Issue
Block a user