This commit is contained in:
zvon 2020-07-27 18:59:00 +02:00
parent 626927fba4
commit 18f1213985
2 changed files with 17662 additions and 0 deletions

17618
tests/catch.hpp Normal file

File diff suppressed because it is too large Load Diff

44
tests/test.cpp Normal file
View File

@ -0,0 +1,44 @@
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
#include "../sdlpp.hpp"
// sdlpp.hpp
TEST_CASE( "Rect collisions" ) {
SDLPP::Rect r(0,0,10,10);
REQUIRE(r.colidesWith(r));
SDLPP::Rect r2(100,100,10,10);
REQUIRE_FALSE(r.colidesWith(r2));
SDLPP::Rect r3(10,10,90,90);
REQUIRE(r.colidesWith(r3));
}
TEST_CASE( "Circle collisions" ) {
SDLPP::Circle c(0,0,10);
REQUIRE(c.colidesWith(c));
SDLPP::Circle c2(10,10,10);
REQUIRE(c.colidesWith(c2));
SDLPP::Circle c3(100,100,10);
REQUIRE_FALSE(c.colidesWith(c3));
SDLPP::Circle c4(5,5,2);
REQUIRE(c.colidesWith(c4));
SDLPP::Circle c5(10,0,5);
REQUIRE(c.colidesWith(c5));
}
TEST_CASE( "Multiple collisions" ) {
SDLPP::RectangleRender r(0,0,10,10);
r.addCollision(SDLPP::Circle(0,0,5));
r.addCollision(SDLPP::Circle(10,10,5));
SDLPP::RectangleRender r1(0,0,5,5);
r1.addCollision(SDLPP::Rect(0,0,5,5));
SDLPP::RectangleRender r2(5,5,5,5);
r2.addCollision(SDLPP::Rect(0,0,5,5));
SDLPP::RectangleRender r3(0,6,3,3);
r3.addCollision(SDLPP::Rect(0,0,3,3));
REQUIRE(r.colidesWith(r1));
REQUIRE(r.colidesWith(r2));
REQUIRE_FALSE(r.colidesWith(r3));
}