2015-04-29 22:03:53 +02:00
|
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
#include <engine/GameData.hpp>
|
2016-09-09 22:13:22 +02:00
|
|
|
#include <engine/GameWorld.hpp>
|
2015-05-01 03:04:23 +02:00
|
|
|
#include <objects/InstanceObject.hpp>
|
2017-10-26 03:51:24 +02:00
|
|
|
#include "test_Globals.hpp"
|
2015-04-29 22:03:53 +02:00
|
|
|
|
2019-01-18 02:29:59 +01:00
|
|
|
BOOST_AUTO_TEST_SUITE(GameWorldTests, DATA_TEST_PREDICATE)
|
2015-04-29 22:03:53 +02:00
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
BOOST_AUTO_TEST_CASE(test_gameobject_id) {
|
2018-09-05 00:14:27 +02:00
|
|
|
auto& gw = *Global::get().e;
|
2016-09-09 22:13:22 +02:00
|
|
|
|
|
|
|
auto object1 = gw.createInstance(1337, glm::vec3(100.f, 0.f, 0.f));
|
|
|
|
auto object2 = gw.createInstance(1337, glm::vec3(100.f, 0.f, 100.f));
|
|
|
|
|
|
|
|
BOOST_CHECK_NE(object1->getGameObjectID(), object2->getGameObjectID());
|
2015-04-29 22:03:53 +02:00
|
|
|
}
|
2016-08-10 17:22:47 +02:00
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
BOOST_AUTO_TEST_CASE(test_offsetgametime) {
|
2018-09-05 00:14:27 +02:00
|
|
|
auto& gw = *Global::get().e;
|
2016-09-09 22:13:22 +02:00
|
|
|
gw.state = new GameState();
|
2016-08-10 17:22:47 +02:00
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
BOOST_CHECK_EQUAL(0, gw.getHour());
|
|
|
|
BOOST_CHECK_EQUAL(0, gw.getMinute());
|
2016-08-10 17:22:47 +02:00
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
gw.offsetGameTime(30);
|
|
|
|
BOOST_CHECK_EQUAL(0, gw.getHour());
|
|
|
|
BOOST_CHECK_EQUAL(30, gw.getMinute());
|
2016-08-10 17:22:47 +02:00
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
gw.offsetGameTime(30);
|
|
|
|
BOOST_CHECK_EQUAL(1, gw.getHour());
|
|
|
|
BOOST_CHECK_EQUAL(0, gw.getMinute());
|
2016-08-10 17:22:47 +02:00
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
gw.offsetGameTime(-30);
|
|
|
|
BOOST_CHECK_EQUAL(0, gw.getHour());
|
|
|
|
BOOST_CHECK_EQUAL(30, gw.getMinute());
|
2016-08-10 17:22:47 +02:00
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
gw.offsetGameTime(-60);
|
|
|
|
BOOST_CHECK_EQUAL(23, gw.getHour());
|
|
|
|
BOOST_CHECK_EQUAL(30, gw.getMinute());
|
2016-08-10 17:22:47 +02:00
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
gw.offsetGameTime(30);
|
|
|
|
BOOST_CHECK_EQUAL(0, gw.getHour());
|
|
|
|
BOOST_CHECK_EQUAL(0, gw.getMinute());
|
2016-08-10 17:22:47 +02:00
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
gw.offsetGameTime(24 * 60);
|
|
|
|
BOOST_CHECK_EQUAL(0, gw.getHour());
|
|
|
|
BOOST_CHECK_EQUAL(0, gw.getMinute());
|
2016-08-10 17:22:47 +02:00
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
gw.offsetGameTime(8 * 60 + 25);
|
|
|
|
BOOST_CHECK_EQUAL(8, gw.getHour());
|
|
|
|
BOOST_CHECK_EQUAL(25, gw.getMinute());
|
2016-08-10 17:22:47 +02:00
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
gw.offsetGameTime(-30);
|
|
|
|
BOOST_CHECK_EQUAL(7, gw.getHour());
|
|
|
|
BOOST_CHECK_EQUAL(55, gw.getMinute());
|
2016-08-10 17:22:47 +02:00
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
gw.offsetGameTime(-24 * 60);
|
|
|
|
BOOST_CHECK_EQUAL(7, gw.getHour());
|
|
|
|
BOOST_CHECK_EQUAL(55, gw.getMinute());
|
2016-08-10 17:22:47 +02:00
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
gw.offsetGameTime(0);
|
|
|
|
BOOST_CHECK_EQUAL(7, gw.getHour());
|
|
|
|
BOOST_CHECK_EQUAL(55, gw.getMinute());
|
2016-08-10 17:22:47 +02:00
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
gw.offsetGameTime(30 * 24 * 60 + 90);
|
|
|
|
BOOST_CHECK_EQUAL(9, gw.getHour());
|
|
|
|
BOOST_CHECK_EQUAL(25, gw.getMinute());
|
2016-08-10 17:22:47 +02:00
|
|
|
}
|
2015-04-29 22:03:53 +02:00
|
|
|
|
2016-06-16 22:11:55 +02:00
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|