1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-07-08 13:54:52 +02:00
openrw/tests/test_GameWorld.cpp
2019-01-21 20:31:31 +00:00

71 lines
2.0 KiB
C++

#include <boost/test/unit_test.hpp>
#include <engine/GameData.hpp>
#include <engine/GameWorld.hpp>
#include <objects/InstanceObject.hpp>
#include "test_Globals.hpp"
BOOST_AUTO_TEST_SUITE(GameWorldTests, DATA_TEST_PREDICATE)
BOOST_AUTO_TEST_CASE(test_gameobject_id) {
auto& gw = *Global::get().e;
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());
}
BOOST_AUTO_TEST_CASE(test_offsetgametime) {
auto& gw = *Global::get().e;
gw.state = new GameState();
BOOST_CHECK_EQUAL(0, gw.getHour());
BOOST_CHECK_EQUAL(0, gw.getMinute());
gw.offsetGameTime(30);
BOOST_CHECK_EQUAL(0, gw.getHour());
BOOST_CHECK_EQUAL(30, gw.getMinute());
gw.offsetGameTime(30);
BOOST_CHECK_EQUAL(1, gw.getHour());
BOOST_CHECK_EQUAL(0, gw.getMinute());
gw.offsetGameTime(-30);
BOOST_CHECK_EQUAL(0, gw.getHour());
BOOST_CHECK_EQUAL(30, gw.getMinute());
gw.offsetGameTime(-60);
BOOST_CHECK_EQUAL(23, gw.getHour());
BOOST_CHECK_EQUAL(30, gw.getMinute());
gw.offsetGameTime(30);
BOOST_CHECK_EQUAL(0, gw.getHour());
BOOST_CHECK_EQUAL(0, gw.getMinute());
gw.offsetGameTime(24 * 60);
BOOST_CHECK_EQUAL(0, gw.getHour());
BOOST_CHECK_EQUAL(0, gw.getMinute());
gw.offsetGameTime(8 * 60 + 25);
BOOST_CHECK_EQUAL(8, gw.getHour());
BOOST_CHECK_EQUAL(25, gw.getMinute());
gw.offsetGameTime(-30);
BOOST_CHECK_EQUAL(7, gw.getHour());
BOOST_CHECK_EQUAL(55, gw.getMinute());
gw.offsetGameTime(-24 * 60);
BOOST_CHECK_EQUAL(7, gw.getHour());
BOOST_CHECK_EQUAL(55, gw.getMinute());
gw.offsetGameTime(0);
BOOST_CHECK_EQUAL(7, gw.getHour());
BOOST_CHECK_EQUAL(55, gw.getMinute());
gw.offsetGameTime(30 * 24 * 60 + 90);
BOOST_CHECK_EQUAL(9, gw.getHour());
BOOST_CHECK_EQUAL(25, gw.getMinute());
}
BOOST_AUTO_TEST_SUITE_END()