Tests
This commit is contained in:
parent
626927fba4
commit
18f1213985
17618
tests/catch.hpp
Normal file
17618
tests/catch.hpp
Normal file
File diff suppressed because it is too large
Load Diff
44
tests/test.cpp
Normal file
44
tests/test.cpp
Normal 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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user