1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-09-18 16:32:32 +02:00

clang-format files in tests

This commit is contained in:
Daniel Evans 2016-09-09 21:13:22 +01:00
parent 11a9907f07
commit 3015b7f3e0
35 changed files with 1271 additions and 1409 deletions

View File

@ -5,8 +5,7 @@
BOOST_AUTO_TEST_SUITE(FileIndexTests) BOOST_AUTO_TEST_SUITE(FileIndexTests)
#if RW_TEST_WITH_DATA #if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_directory_paths) BOOST_AUTO_TEST_CASE(test_directory_paths) {
{
FileIndex index; FileIndex index;
index.indexGameDirectory(Global::getGamePath()); index.indexGameDirectory(Global::getGamePath());
@ -31,8 +30,7 @@ BOOST_AUTO_TEST_CASE(test_directory_paths)
} }
} }
BOOST_AUTO_TEST_CASE(test_file) BOOST_AUTO_TEST_CASE(test_file) {
{
FileIndex index; FileIndex index;
index.indexTree(Global::getGamePath() + "/data"); index.indexTree(Global::getGamePath() + "/data");
@ -41,8 +39,7 @@ BOOST_AUTO_TEST_CASE(test_file)
BOOST_CHECK(handle != nullptr); BOOST_CHECK(handle != nullptr);
} }
BOOST_AUTO_TEST_CASE(test_file_archive) BOOST_AUTO_TEST_CASE(test_file_archive) {
{
FileIndex index; FileIndex index;
index.indexArchive(Global::getGamePath() + "/models/gta3.img"); index.indexArchive(Global::getGamePath() + "/models/gta3.img");

View File

@ -5,8 +5,7 @@
BOOST_AUTO_TEST_SUITE(GameDataTests) BOOST_AUTO_TEST_SUITE(GameDataTests)
#if RW_TEST_WITH_DATA #if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_object_data) BOOST_AUTO_TEST_CASE(test_object_data) {
{
GameData gd(&Global::get().log, &Global::get().work, Global::getGamePath()); GameData gd(&Global::get().log, &Global::get().work, Global::getGamePath());
GameWorld gw(&Global::get().log, &Global::get().work, &gd); GameWorld gw(&Global::get().log, &Global::get().work, &gd);

View File

@ -1,14 +1,13 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include <engine/GameWorld.hpp>
#include <engine/GameData.hpp> #include <engine/GameData.hpp>
#include <engine/GameWorld.hpp>
#include <objects/InstanceObject.hpp> #include <objects/InstanceObject.hpp>
#include <test_globals.hpp> #include <test_globals.hpp>
BOOST_AUTO_TEST_SUITE(GameWorldTests) BOOST_AUTO_TEST_SUITE(GameWorldTests)
#if RW_TEST_WITH_DATA #if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_gameobject_id) BOOST_AUTO_TEST_CASE(test_gameobject_id) {
{
GameWorld gw(&Global::get().log, &Global::get().work, Global::get().d); GameWorld gw(&Global::get().log, &Global::get().work, Global::get().d);
auto object1 = gw.createInstance(1337, glm::vec3(100.f, 0.f, 0.f)); auto object1 = gw.createInstance(1337, glm::vec3(100.f, 0.f, 0.f));
@ -17,8 +16,7 @@ BOOST_AUTO_TEST_CASE(test_gameobject_id)
BOOST_CHECK_NE(object1->getGameObjectID(), object2->getGameObjectID()); BOOST_CHECK_NE(object1->getGameObjectID(), object2->getGameObjectID());
} }
BOOST_AUTO_TEST_CASE(test_offsetgametime) BOOST_AUTO_TEST_CASE(test_offsetgametime) {
{
GameWorld gw(&Global::get().log, &Global::get().work, Global::get().d); GameWorld gw(&Global::get().log, &Global::get().work, Global::get().d);
gw.state = new GameState(); gw.state = new GameState();

View File

@ -2,29 +2,28 @@
#include <core/Logger.hpp> #include <core/Logger.hpp>
#include <test_globals.hpp> #include <test_globals.hpp>
class CallbackReceiver : public Logger::MessageReciever class CallbackReceiver : public Logger::MessageReciever {
{
public: public:
std::function<void(const Logger::LogMessage&)> func; std::function<void(const Logger::LogMessage&)> func;
CallbackReceiver(std::function<void(const Logger::LogMessage&)> func) CallbackReceiver(std::function<void(const Logger::LogMessage&)> func)
: func(func) { } : func(func) {
}
virtual void messageRecieved(const Logger::LogMessage& message) virtual void messageRecieved(const Logger::LogMessage& message) {
{
func(message); func(message);
} }
}; };
BOOST_AUTO_TEST_SUITE(LoggerTests) BOOST_AUTO_TEST_SUITE(LoggerTests)
BOOST_AUTO_TEST_CASE(test_reciever) BOOST_AUTO_TEST_CASE(test_reciever) {
{
Logger log; Logger log;
Logger::LogMessage lastMessage("", Logger::Error, ""); Logger::LogMessage lastMessage("", Logger::Error, "");
CallbackReceiver reciever([&](const Logger::LogMessage& m) { lastMessage = m; }); CallbackReceiver reciever(
[&](const Logger::LogMessage& m) { lastMessage = m; });
log.addReciever(&reciever); log.addReciever(&reciever);

View File

@ -6,8 +6,7 @@ typedef ResourceHandle<int>::Ref IntRef;
BOOST_AUTO_TEST_SUITE(ResourceTests) BOOST_AUTO_TEST_SUITE(ResourceTests)
BOOST_AUTO_TEST_CASE(test_ResourceHandle) BOOST_AUTO_TEST_CASE(test_ResourceHandle) {
{
int resource = 42; int resource = 42;
IntRef ref{new ResourceHandle<int>("")}; IntRef ref{new ResourceHandle<int>("")};

View File

@ -1,15 +1,13 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include <test_globals.hpp>
#include <render/VisualFX.hpp> #include <render/VisualFX.hpp>
#include <test_globals.hpp>
BOOST_AUTO_TEST_SUITE(VisualFXTests) BOOST_AUTO_TEST_SUITE(VisualFXTests)
BOOST_AUTO_TEST_CASE(test_light_data) BOOST_AUTO_TEST_CASE(test_light_data) {
{
VisualFX fx(VisualFX::Light); VisualFX fx(VisualFX::Light);
BOOST_CHECK_EQUAL(fx.getType(), VisualFX::Light); BOOST_CHECK_EQUAL(fx.getType(), VisualFX::Light);
} }
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()

View File

@ -1,20 +1,20 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include <engine/Animator.hpp>
#include <data/Skeleton.hpp>
#include <data/Model.hpp> #include <data/Model.hpp>
#include <data/Skeleton.hpp>
#include <engine/Animator.hpp>
#include <glm/gtx/string_cast.hpp> #include <glm/gtx/string_cast.hpp>
#include "test_globals.hpp" #include "test_globals.hpp"
BOOST_AUTO_TEST_SUITE(AnimationTests) BOOST_AUTO_TEST_SUITE(AnimationTests)
#if RW_TEST_WITH_DATA #if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_matrix) BOOST_AUTO_TEST_CASE(test_matrix) {
{
{ {
Skeleton skeleton; Skeleton skeleton;
Animation animation; Animation animation;
/** Models are currently needed to relate animation bones <=> model frame #s. */ /** Models are currently needed to relate animation bones <=> model
* frame #s. */
Global::get().e->data->loadDFF("player.dff"); Global::get().e->data->loadDFF("player.dff");
ModelRef& test_model = Global::get().e->data->models["player"]; ModelRef& test_model = Global::get().e->data->models["player"];
@ -23,32 +23,32 @@ BOOST_AUTO_TEST_CASE(test_matrix)
animation.duration = 1.f; animation.duration = 1.f;
animation.bones["player"] = new AnimationBone{ animation.bones["player"] = new AnimationBone{
"player", "player",
0, 0, 1.0f, 0,
0,
1.0f,
AnimationBone::RT0, AnimationBone::RT0,
{ {
{ {glm::quat(), glm::vec3(0.f, 0.f, 0.f), glm::vec3(), 0.f, 0},
glm::quat(), glm::vec3(0.f, 0.f, 0.f), glm::vec3(), 0.f, 0 {glm::quat(), glm::vec3(0.f, 1.f, 0.f), glm::vec3(), 1.0f, 1},
}, }};
{
glm::quat(), glm::vec3(0.f, 1.f, 0.f), glm::vec3(), 1.0f, 1
},
}
};
animator.playAnimation(0, &animation, 1.f, false); animator.playAnimation(0, &animation, 1.f, false);
animator.tick(0.0f); animator.tick(0.0f);
BOOST_CHECK( skeleton.getData(0).a.translation == glm::vec3(0.f, 0.f, 0.f) ); BOOST_CHECK(skeleton.getData(0).a.translation ==
BOOST_CHECK( skeleton.getData(0).b.translation == glm::vec3(0.f, 0.f, 0.f) ); glm::vec3(0.f, 0.f, 0.f));
BOOST_CHECK(skeleton.getData(0).b.translation ==
glm::vec3(0.f, 0.f, 0.f));
animator.tick(1.0f); animator.tick(1.0f);
BOOST_CHECK( skeleton.getData(0).a.translation == glm::vec3(0.f, 1.f, 0.f) ); BOOST_CHECK(skeleton.getData(0).a.translation ==
BOOST_CHECK( skeleton.getData(0).b.translation == glm::vec3(0.f, 0.f, 0.f) ); glm::vec3(0.f, 1.f, 0.f));
BOOST_CHECK(skeleton.getData(0).b.translation ==
glm::vec3(0.f, 0.f, 0.f));
} }
} }
#endif #endif
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()

View File

@ -1,12 +1,11 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include "test_globals.hpp"
#include <loaders/LoaderIMG.hpp> #include <loaders/LoaderIMG.hpp>
#include "test_globals.hpp"
BOOST_AUTO_TEST_SUITE(ArchiveTests) BOOST_AUTO_TEST_SUITE(ArchiveTests)
#if RW_TEST_WITH_DATA #if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_open_archive) BOOST_AUTO_TEST_CASE(test_open_archive) {
{
LoaderIMG archive; LoaderIMG archive;
BOOST_REQUIRE(archive.load(Global::getGamePath() + "/models/gta3")); BOOST_REQUIRE(archive.load(Global::getGamePath() + "/models/gta3"));

View File

@ -1,15 +1,15 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include "test_globals.hpp"
#include <objects/VehicleObject.hpp> #include <objects/VehicleObject.hpp>
#include "test_globals.hpp"
BOOST_AUTO_TEST_SUITE(BuoyancyTests) BOOST_AUTO_TEST_SUITE(BuoyancyTests)
#if RW_TEST_WITH_DATA #if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_vehicle_buoyancy) BOOST_AUTO_TEST_CASE(test_vehicle_buoyancy) {
{
glm::vec2 tpos(-WATER_WORLD_SIZE / 2.f + 10.f); glm::vec2 tpos(-WATER_WORLD_SIZE / 2.f + 10.f);
{ {
VehicleObject* vehicle = Global::get().e->createVehicle(90u, glm::vec3(tpos, 100.f), glm::quat()); VehicleObject* vehicle = Global::get().e->createVehicle(
90u, glm::vec3(tpos, 100.f), glm::quat());
BOOST_REQUIRE(vehicle != nullptr); BOOST_REQUIRE(vehicle != nullptr);
@ -60,4 +60,3 @@ BOOST_AUTO_TEST_CASE(test_vehicle_buoyancy)
#endif #endif
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()

View File

@ -1,28 +1,28 @@
#include <ai/DefaultAIController.hpp>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include <engine/Animator.hpp>
#include <objects/CharacterObject.hpp> #include <objects/CharacterObject.hpp>
#include <objects/VehicleObject.hpp> #include <objects/VehicleObject.hpp>
#include <ai/DefaultAIController.hpp>
#include "test_globals.hpp" #include "test_globals.hpp"
#include <engine/Animator.hpp>
BOOST_AUTO_TEST_SUITE(CharacterTests) BOOST_AUTO_TEST_SUITE(CharacterTests)
#if RW_TEST_WITH_DATA #if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_create) BOOST_AUTO_TEST_CASE(test_create) {
{ {
{ auto character =
auto character = Global::get().e->createPedestrian(1, {100.f, 100.f, 50.f}); Global::get().e->createPedestrian(1, {100.f, 100.f, 50.f});
BOOST_REQUIRE(character != nullptr); BOOST_REQUIRE(character != nullptr);
auto controller = new DefaultAIController(character); auto controller = new DefaultAIController(character);
// Check the initial activity is Idle. // Check the initial activity is Idle.
BOOST_CHECK_EQUAL(controller->getCurrentActivity(), nullptr); BOOST_CHECK_EQUAL(controller->getCurrentActivity(), nullptr);
// Check that Idle activities are instantly displaced. // Check that Idle activities are instantly displaced.
controller->setNextActivity( new Activities::GoTo( glm::vec3{ 1000.f, 0.f, 0.f } ) ); controller->setNextActivity(
new Activities::GoTo(glm::vec3{1000.f, 0.f, 0.f}));
BOOST_CHECK_EQUAL(controller->getCurrentActivity()->name(), "GoTo"); BOOST_CHECK_EQUAL(controller->getCurrentActivity()->name(), "GoTo");
BOOST_CHECK_EQUAL(controller->getNextActivity(), nullptr); BOOST_CHECK_EQUAL(controller->getNextActivity(), nullptr);
@ -32,16 +32,17 @@ BOOST_AUTO_TEST_CASE(test_create)
} }
} }
BOOST_AUTO_TEST_CASE(test_activities) BOOST_AUTO_TEST_CASE(test_activities) {
{ {
{ auto character =
auto character = Global::get().e->createPedestrian(1, {0.f, 0.f, 225.6f}); Global::get().e->createPedestrian(1, {0.f, 0.f, 225.6f});
BOOST_REQUIRE(character != nullptr); BOOST_REQUIRE(character != nullptr);
auto controller = new DefaultAIController(character); auto controller = new DefaultAIController(character);
controller->setNextActivity( new Activities::GoTo( glm::vec3{ 10.f, 10.f, 0.f } ) ); controller->setNextActivity(
new Activities::GoTo(glm::vec3{10.f, 10.f, 0.f}));
BOOST_CHECK_EQUAL(controller->getCurrentActivity()->name(), "GoTo"); BOOST_CHECK_EQUAL(controller->getCurrentActivity()->name(), "GoTo");
@ -51,13 +52,15 @@ BOOST_AUTO_TEST_CASE(test_activities)
Global::get().e->dynamicsWorld->stepSimulation(1.f / 60.f); Global::get().e->dynamicsWorld->stepSimulation(1.f / 60.f);
} }
BOOST_CHECK_LT( glm::distance(character->getPosition(), {10.f, 10.f, 0.f}), 0.1f); BOOST_CHECK_LT(
glm::distance(character->getPosition(), {10.f, 10.f, 0.f}), 0.1f);
Global::get().e->destroyObject(character); Global::get().e->destroyObject(character);
delete controller; delete controller;
} }
{ {
VehicleObject* vehicle = Global::get().e->createVehicle(90u, glm::vec3(10.f, 0.f, 0.f), glm::quat()); VehicleObject* vehicle = Global::get().e->createVehicle(
90u, glm::vec3(10.f, 0.f, 0.f), glm::quat());
BOOST_REQUIRE(vehicle != nullptr); BOOST_REQUIRE(vehicle != nullptr);
BOOST_REQUIRE(vehicle->model != nullptr); BOOST_REQUIRE(vehicle->model != nullptr);
@ -115,10 +118,10 @@ BOOST_AUTO_TEST_CASE(test_activities)
} }
} }
BOOST_AUTO_TEST_CASE(test_death) BOOST_AUTO_TEST_CASE(test_death) {
{ {
{ auto character =
auto character = Global::get().e->createPedestrian(1, {100.f, 100.f, 50.f}); Global::get().e->createPedestrian(1, {100.f, 100.f, 50.f});
BOOST_REQUIRE(character != nullptr); BOOST_REQUIRE(character != nullptr);
auto controller = new DefaultAIController(character); auto controller = new DefaultAIController(character);
@ -136,8 +139,7 @@ BOOST_AUTO_TEST_CASE(test_death)
character->tick(0.16f); character->tick(0.16f);
BOOST_CHECK_EQUAL( BOOST_CHECK_EQUAL(character->animator->getAnimation(0),
character->animator->getAnimation(0),
character->animations.ko_shot_front); character->animations.ko_shot_front);
Global::get().e->destroyObject(character); Global::get().e->destroyObject(character);
@ -147,4 +149,3 @@ BOOST_AUTO_TEST_CASE(test_death)
#endif #endif
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()

View File

@ -1,14 +1,14 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include "test_globals.hpp"
#include <data/Chase.hpp> #include <data/Chase.hpp>
#include "test_globals.hpp"
BOOST_AUTO_TEST_SUITE(ChaseTests) BOOST_AUTO_TEST_SUITE(ChaseTests)
#if RW_TEST_WITH_DATA #if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_load_keyframes) BOOST_AUTO_TEST_CASE(test_load_keyframes) {
{
std::vector<ChaseKeyframe> keyframes; std::vector<ChaseKeyframe> keyframes;
BOOST_REQUIRE(ChaseKeyframe::load(Global::getGamePath() + "/data/paths/CHASE0.DAT", keyframes)); BOOST_REQUIRE(ChaseKeyframe::load(
Global::getGamePath() + "/data/paths/CHASE0.DAT", keyframes));
BOOST_REQUIRE(keyframes.size() == 5400); BOOST_REQUIRE(keyframes.size() == 5400);
BOOST_CHECK_CLOSE(keyframes[0].position.x, 273.5422, 0.1); BOOST_CHECK_CLOSE(keyframes[0].position.x, 273.5422, 0.1);
} }

View File

@ -1,11 +1,10 @@
#include <boost/test/unit_test.hpp>
#include <GameConfig.hpp> #include <GameConfig.hpp>
#include <boost/test/unit_test.hpp>
#include <fstream> #include <fstream>
BOOST_AUTO_TEST_SUITE(ConfigTests) BOOST_AUTO_TEST_SUITE(ConfigTests)
BOOST_AUTO_TEST_CASE(test_loading) BOOST_AUTO_TEST_CASE(test_loading) {
{
// Write out a temporary file // Write out a temporary file
std::ofstream test_config("/tmp/openrw_test.ini"); std::ofstream test_config("/tmp/openrw_test.ini");
test_config << "[game]\n" test_config << "[game]\n"

View File

@ -6,8 +6,7 @@
BOOST_AUTO_TEST_SUITE(CutsceneTests) BOOST_AUTO_TEST_SUITE(CutsceneTests)
#if RW_TEST_WITH_DATA #if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_load) BOOST_AUTO_TEST_CASE(test_load) {
{
{ {
auto d = Global::get().e->data->index.openFile("intro.dat"); auto d = Global::get().e->data->index.openFile("intro.dat");

View File

@ -1,7 +1,7 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include <data/WeaponData.hpp> #include <data/WeaponData.hpp>
#include "test_globals.hpp"
#include <loaders/GenericDATLoader.hpp> #include <loaders/GenericDATLoader.hpp>
#include "test_globals.hpp"
// Tests against loading various data files // Tests against loading various data files
// These tests are bad but so are the interfaces so it cancels out. // These tests are bad but so are the interfaces so it cancels out.
@ -9,8 +9,7 @@
BOOST_AUTO_TEST_SUITE(DataTests) BOOST_AUTO_TEST_SUITE(DataTests)
#if RW_TEST_WITH_DATA #if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_weapon_dat) BOOST_AUTO_TEST_CASE(test_weapon_dat) {
{
GenericDATLoader l; GenericDATLoader l;
WeaponDataPtrs weaponData; WeaponDataPtrs weaponData;
@ -39,15 +38,14 @@ BOOST_AUTO_TEST_CASE(test_weapon_dat)
BOOST_CHECK(data->animCrouchFirePoint == 12); BOOST_CHECK(data->animCrouchFirePoint == 12);
BOOST_CHECK(data->modelID == -1); BOOST_CHECK(data->modelID == -1);
BOOST_CHECK(data->flags == 0); BOOST_CHECK(data->flags == 0);
} }
BOOST_AUTO_TEST_CASE(test_dynamic_dat_loader) BOOST_AUTO_TEST_CASE(test_dynamic_dat_loader) {
{
GenericDATLoader l; GenericDATLoader l;
DynamicObjectDataPtrs loaded; DynamicObjectDataPtrs loaded;
l.loadDynamicObjects(Global::get().getGamePath() + "/data/object.dat", loaded); l.loadDynamicObjects(Global::get().getGamePath() + "/data/object.dat",
loaded);
BOOST_ASSERT(loaded.size() > 0); BOOST_ASSERT(loaded.size() > 0);
@ -68,8 +66,7 @@ BOOST_AUTO_TEST_CASE(test_dynamic_dat_loader)
BOOST_CHECK_EQUAL(lamp->cameraAvoid, false); BOOST_CHECK_EQUAL(lamp->cameraAvoid, false);
} }
BOOST_AUTO_TEST_CASE(test_handling_data_loader) BOOST_AUTO_TEST_CASE(test_handling_data_loader) {
{
GenericDATLoader l; GenericDATLoader l;
VehicleInfoPtrs loaded; VehicleInfoPtrs loaded;
@ -89,4 +86,3 @@ BOOST_AUTO_TEST_CASE(test_handling_data_loader)
#endif #endif
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()

View File

@ -1,14 +1,14 @@
#ifndef _TESTGLOBABLS_HPP_ #ifndef _TESTGLOBABLS_HPP_
#define _TESTGLOBABLS_HPP_ #define _TESTGLOBABLS_HPP_
#include <engine/GameWorld.hpp> #include <SDL2/SDL.h>
#include <GameConfig.hpp>
#include <GameWindow.hpp>
#include <core/Logger.hpp>
#include <engine/GameData.hpp> #include <engine/GameData.hpp>
#include <engine/GameState.hpp> #include <engine/GameState.hpp>
#include <core/Logger.hpp> #include <engine/GameWorld.hpp>
#include <glm/gtx/string_cast.hpp> #include <glm/gtx/string_cast.hpp>
#include <SDL2/SDL.h>
#include <GameWindow.hpp>
#include <GameConfig.hpp>
std::ostream& operator<<(std::ostream& stream, glm::vec3 const& v); std::ostream& operator<<(std::ostream& stream, glm::vec3 const& v);
@ -22,43 +22,51 @@ std::ostream& operator<<( std::ostream& stream, glm::vec3 const& v );
#define BOOST_NS_MAGIC_CLOSING #define BOOST_NS_MAGIC_CLOSING
#endif #endif
namespace boost { namespace test_tools { BOOST_NS_MAGIC namespace boost {
namespace test_tools {
BOOST_NS_MAGIC
template <> template <>
struct print_log_value<glm::vec3> { struct print_log_value<glm::vec3> {
void operator()( std::ostream& s , glm::vec3 const& v ) void operator()(std::ostream& s, glm::vec3 const& v) {
{
s << glm::to_string(v); s << glm::to_string(v);
} }
}; };
}} BOOST_NS_MAGIC_CLOSING }
}
BOOST_NS_MAGIC_CLOSING
namespace boost { namespace test_tools { BOOST_NS_MAGIC namespace boost {
namespace test_tools {
BOOST_NS_MAGIC
template <> template <>
struct print_log_value<std::nullptr_t> { struct print_log_value<std::nullptr_t> {
void operator()( std::ostream& s , std::nullptr_t ) void operator()(std::ostream& s, std::nullptr_t) {
{
s << "nullptr"; s << "nullptr";
} }
}; };
}} BOOST_NS_MAGIC_CLOSING }
}
BOOST_NS_MAGIC_CLOSING
namespace boost { namespace test_tools { BOOST_NS_MAGIC namespace boost {
namespace test_tools {
BOOST_NS_MAGIC
template <> template <>
struct print_log_value<GameString> { struct print_log_value<GameString> {
void operator()( std::ostream& s , GameString const& v ) void operator()(std::ostream& s, GameString const& v) {
{
for (GameString::size_type i = 0u; i < v.size(); ++i) { for (GameString::size_type i = 0u; i < v.size(); ++i) {
s << (char)v[i]; s << (char)v[i];
} }
} }
}; };
}} BOOST_NS_MAGIC_CLOSING }
}
BOOST_NS_MAGIC_CLOSING
#undef BOOST_NS_MAGIC #undef BOOST_NS_MAGIC
#undef BOOST_NS_MAGIC_CLOSING #undef BOOST_NS_MAGIC_CLOSING
class Global class Global {
{
public: public:
GameWindow window; GameWindow window;
#if RW_TEST_WITH_DATA #if RW_TEST_WITH_DATA
@ -101,14 +109,12 @@ public:
} }
#if RW_TEST_WITH_DATA #if RW_TEST_WITH_DATA
static std::string getGamePath() static std::string getGamePath() {
{
return GameConfig("openrw.ini").getGameDataPath(); return GameConfig("openrw.ini").getGameDataPath();
} }
#endif #endif
static Global& get() static Global& get() {
{
static Global g; static Global g;
return g; return g;
} }

View File

@ -6,8 +6,7 @@
BOOST_AUTO_TEST_SUITE(ItemTests) BOOST_AUTO_TEST_SUITE(ItemTests)
#if RW_TEST_WITH_DATA #if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_character_inventory) BOOST_AUTO_TEST_CASE(test_character_inventory) {
{
{ {
auto character = Global::get().e->createPedestrian(1, {0.f, 0.f, 0.f}); auto character = Global::get().e->createPedestrian(1, {0.f, 0.f, 0.f});
BOOST_REQUIRE(character != nullptr); BOOST_REQUIRE(character != nullptr);
@ -37,4 +36,3 @@ BOOST_AUTO_TEST_CASE(test_character_inventory)
#endif #endif
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()

View File

@ -7,9 +7,9 @@
BOOST_AUTO_TEST_SUITE(LifetimeTests) BOOST_AUTO_TEST_SUITE(LifetimeTests)
#if RW_TEST_WITH_DATA #if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_cleanup) BOOST_AUTO_TEST_CASE(test_cleanup) {
{ GameObject* f =
GameObject* f = Global::get().e->createInstance(1337, glm::vec3(0.f, 0.f, 1000.f)); Global::get().e->createInstance(1337, glm::vec3(0.f, 0.f, 1000.f));
auto id = f->getGameObjectID(); auto id = f->getGameObjectID();
auto& objects = Global::get().e->instancePool.objects; auto& objects = Global::get().e->instancePool.objects;

View File

@ -1,14 +1,13 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include "test_globals.hpp"
#include <data/Model.hpp> #include <data/Model.hpp>
#include <job/WorkContext.hpp> #include <job/WorkContext.hpp>
#include <loaders/BackgroundLoader.hpp> #include <loaders/BackgroundLoader.hpp>
#include "test_globals.hpp"
BOOST_AUTO_TEST_SUITE(LoaderDFFTests) BOOST_AUTO_TEST_SUITE(LoaderDFFTests)
#if RW_TEST_WITH_DATA #if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_load_dff) BOOST_AUTO_TEST_CASE(test_load_dff) {
{
{ {
auto d = Global::get().e->data->index.openFile("landstal.dff"); auto d = Global::get().e->data->index.openFile("landstal.dff");
@ -37,18 +36,18 @@ BOOST_AUTO_TEST_CASE(test_load_dff)
delete m; delete m;
} }
} }
BOOST_AUTO_TEST_CASE(test_loader_job) BOOST_AUTO_TEST_CASE(test_loader_job) {
{
{ {
WorkContext ctx; WorkContext ctx;
ResourceHandle<Model>::Ref modelRef { new ResourceHandle<Model>("landstal.dff") }; ResourceHandle<Model>::Ref modelRef{
new ResourceHandle<Model>("landstal.dff")};
auto index = &Global::get().e->data->index; auto index = &Global::get().e->data->index;
auto job = new BackgroundLoaderJob<Model, LoaderDFF>{ &ctx, index, "landstal.dff", modelRef }; auto job = new BackgroundLoaderJob<Model, LoaderDFF>{
&ctx, index, "landstal.dff", modelRef};
ctx.queueJob(job); ctx.queueJob(job);
@ -63,7 +62,6 @@ BOOST_AUTO_TEST_CASE(test_loader_job)
delete modelRef->resource; delete modelRef->resource;
} }
} }
#endif #endif

View File

@ -1,11 +1,10 @@
#include <MenuSystem.hpp>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include "test_globals.hpp" #include "test_globals.hpp"
#include <MenuSystem.hpp>
BOOST_AUTO_TEST_SUITE(MenuUnitTests) BOOST_AUTO_TEST_SUITE(MenuUnitTests)
BOOST_AUTO_TEST_CASE(menu_test_click) BOOST_AUTO_TEST_CASE(menu_test_click) {
{
bool clickered = false; bool clickered = false;
Menu test(0); Menu test(0);
test.addEntry(Menu::lambda("Test", [&] { clickered = true; })); test.addEntry(Menu::lambda("Test", [&] { clickered = true; }));
@ -28,8 +27,7 @@ BOOST_AUTO_TEST_CASE(menu_test_click)
BOOST_CHECK(clickered); BOOST_CHECK(clickered);
} }
BOOST_AUTO_TEST_CASE(menu_test_click_offset) BOOST_AUTO_TEST_CASE(menu_test_click_offset) {
{
bool clickered = false; bool clickered = false;
Menu test(0); Menu test(0);
test.offset = glm::vec2(200.f, 200.f); test.offset = glm::vec2(200.f, 200.f);
@ -53,8 +51,7 @@ BOOST_AUTO_TEST_CASE(menu_test_click_offset)
BOOST_CHECK(clickered); BOOST_CHECK(clickered);
} }
BOOST_AUTO_TEST_CASE(menu_test_active_index) BOOST_AUTO_TEST_CASE(menu_test_active_index) {
{
int clickindex = -1; int clickindex = -1;
Menu test(0); Menu test(0);
test.addEntry(Menu::lambda("Test1", [&] { clickindex = 0; })); test.addEntry(Menu::lambda("Test1", [&] { clickindex = 0; }));
@ -80,8 +77,7 @@ BOOST_AUTO_TEST_CASE(menu_test_active_index)
BOOST_CHECK(clickindex == 0); BOOST_CHECK(clickindex == 0);
} }
BOOST_AUTO_TEST_CASE(menu_test_hover_index) BOOST_AUTO_TEST_CASE(menu_test_hover_index) {
{
int clickindex = -1; int clickindex = -1;
Menu test(0); Menu test(0);
test.addEntry(Menu::lambda("Test1", [&] { clickindex = 0; })); test.addEntry(Menu::lambda("Test1", [&] { clickindex = 0; }));

View File

@ -1,7 +1,7 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include "test_globals.hpp"
#include <objects/InstanceObject.hpp>
#include <engine/GameWorld.hpp> #include <engine/GameWorld.hpp>
#include <objects/InstanceObject.hpp>
#include "test_globals.hpp"
BOOST_AUTO_TEST_SUITE(ObjectUnitTests) BOOST_AUTO_TEST_SUITE(ObjectUnitTests)

View File

@ -5,8 +5,7 @@
BOOST_AUTO_TEST_SUITE(ObjectDataTests) BOOST_AUTO_TEST_SUITE(ObjectDataTests)
#if RW_TEST_WITH_DATA #if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_object_data) BOOST_AUTO_TEST_CASE(test_object_data) {
{
{ {
LoaderIDE l; LoaderIDE l;
@ -51,9 +50,7 @@ BOOST_AUTO_TEST_CASE(test_object_data)
} }
} }
BOOST_AUTO_TEST_CASE(test_gamedata_data) BOOST_AUTO_TEST_CASE(test_gamedata_data) {
{
} }
#endif #endif

View File

@ -1,19 +1,18 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include <objects/PickupObject.hpp>
#include <objects/ItemPickup.hpp>
#include <items/InventoryItem.hpp>
#include <data/WeaponData.hpp> #include <data/WeaponData.hpp>
#include <items/InventoryItem.hpp>
#include <objects/CharacterObject.hpp> #include <objects/CharacterObject.hpp>
#include <objects/ItemPickup.hpp>
#include <objects/PickupObject.hpp>
#include "test_globals.hpp" #include "test_globals.hpp"
class TestPickup : public PickupObject class TestPickup : public PickupObject {
{
public: public:
bool picked_up = false; bool picked_up = false;
TestPickup(GameWorld* engine, const glm::vec3& position) TestPickup(GameWorld* engine, const glm::vec3& position)
: PickupObject(engine, position, 0, OnStreet) : PickupObject(engine, position, 0, OnStreet) {
{} }
bool onCharacterTouch(CharacterObject* character) { bool onCharacterTouch(CharacterObject* character) {
picked_up = true; picked_up = true;
@ -24,10 +23,10 @@ public:
BOOST_AUTO_TEST_SUITE(PickupTests) BOOST_AUTO_TEST_SUITE(PickupTests)
#if RW_TEST_WITH_DATA #if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_pickup_interaction) BOOST_AUTO_TEST_CASE(test_pickup_interaction) {
{ {
{ auto character =
auto character = Global::get().e->createPedestrian(1, { 30.1f, 0.f, 0.f }); Global::get().e->createPedestrian(1, {30.1f, 0.f, 0.f});
BOOST_REQUIRE(character != nullptr); BOOST_REQUIRE(character != nullptr);
TestPickup* p = new TestPickup(Global::get().e, {30.f, 0.f, 0.f}); TestPickup* p = new TestPickup(Global::get().e, {30.f, 0.f, 0.f});
@ -55,22 +54,22 @@ BOOST_AUTO_TEST_CASE(test_pickup_interaction)
BOOST_CHECK(p->picked_up); BOOST_CHECK(p->picked_up);
Global::get().e->destroyObject(p); Global::get().e->destroyObject(p);
Global::get().e->destroyObject(character); Global::get().e->destroyObject(character);
} }
} }
BOOST_AUTO_TEST_CASE(test_item_pickup) BOOST_AUTO_TEST_CASE(test_item_pickup) {
{ {
{ auto character =
auto character = Global::get().e->createPedestrian(1, { 30.1f, 0.f, 0.f }); Global::get().e->createPedestrian(1, {30.1f, 0.f, 0.f});
BOOST_REQUIRE(character != nullptr); BOOST_REQUIRE(character != nullptr);
auto item = Global::get().e->getInventoryItem(3); auto item = Global::get().e->getInventoryItem(3);
BOOST_REQUIRE(item != nullptr); BOOST_REQUIRE(item != nullptr);
ItemPickup* p = new ItemPickup(Global::get().e, { 30.f, 0.f, 0.f }, PickupObject::OnStreet, item); ItemPickup* p = new ItemPickup(Global::get().e, {30.f, 0.f, 0.f},
PickupObject::OnStreet, item);
Global::get().e->allObjects.push_back(p); Global::get().e->allObjects.push_back(p);
@ -84,8 +83,10 @@ BOOST_AUTO_TEST_CASE(test_item_pickup)
auto& inventory = character->getCurrentState().weapons; auto& inventory = character->getCurrentState().weapons;
BOOST_CHECK(std::any_of(std::begin(inventory), std::end(inventory), BOOST_CHECK(std::any_of(std::begin(inventory), std::end(inventory),
[&](const CharacterWeaponSlot& i) [&](const CharacterWeaponSlot& i) {
{ return i.weaponId == item->getInventorySlot(); }) ); return i.weaponId ==
item->getInventorySlot();
}));
Global::get().e->destroyObject(p); Global::get().e->destroyObject(p);
Global::get().e->destroyObject(character); Global::get().e->destroyObject(character);
@ -94,4 +95,3 @@ BOOST_AUTO_TEST_CASE(test_item_pickup)
#endif #endif
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()

View File

@ -1,11 +1,10 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include "test_globals.hpp"
#include <render/GameRenderer.hpp> #include <render/GameRenderer.hpp>
#include "test_globals.hpp"
BOOST_AUTO_TEST_SUITE(RendererTests) BOOST_AUTO_TEST_SUITE(RendererTests)
BOOST_AUTO_TEST_CASE(frustum_test_visible) BOOST_AUTO_TEST_CASE(frustum_test_visible) {
{
{ {
ViewFrustum f(0.1f, 100.f, glm::half_pi<float>(), 1.f); ViewFrustum f(0.1f, 100.f, glm::half_pi<float>(), 1.f);

View File

@ -1,12 +1,11 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include "test_globals.hpp"
#include <loaders/RWBinaryStream.hpp> #include <loaders/RWBinaryStream.hpp>
#include "test_globals.hpp"
BOOST_AUTO_TEST_SUITE(RWBStreamTests) BOOST_AUTO_TEST_SUITE(RWBStreamTests)
#if RW_TEST_WITH_DATA #if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(iterate_stream_test) BOOST_AUTO_TEST_CASE(iterate_stream_test) {
{
{ {
auto d = Global::get().e->data->index.openFile("landstal.dff"); auto d = Global::get().e->data->index.openFile("landstal.dff");

View File

@ -1,23 +1,17 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include "test_globals.hpp"
#include <script/ScriptMachine.hpp>
#include <script/SCMFile.hpp> #include <script/SCMFile.hpp>
#include <script/ScriptMachine.hpp>
#include "test_globals.hpp"
SCMByte data[] = { SCMByte data[] = {0x02, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
0x02,0x00,0x01,0x08,0x00,0x00,0x00,0x00, 0x01, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x02,0x00,0x01,0x18,0x00,0x00,0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x28, 0x00, 0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x02,0x00,0x01,0x28,0x00,0x00,0x00,0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
BOOST_AUTO_TEST_SUITE(ScriptMachineTests) BOOST_AUTO_TEST_SUITE(ScriptMachineTests)
BOOST_AUTO_TEST_CASE(scmfile_test) {
BOOST_AUTO_TEST_CASE(scmfile_test)
{
SCMFile f; SCMFile f;
f.loadFile(data, sizeof(data)); f.loadFile(data, sizeof(data));

View File

@ -4,16 +4,15 @@
BOOST_AUTO_TEST_SUITE(SkeletonTests) BOOST_AUTO_TEST_SUITE(SkeletonTests)
BOOST_AUTO_TEST_CASE(test_methods) BOOST_AUTO_TEST_CASE(test_methods) {
{ Skeleton::FrameTransform t1{glm::vec3(0.f, 0.f, 0.f),
Skeleton::FrameTransform t1 { glm::vec3(0.f, 0.f, 0.f), glm::quat(0.f, 0.f, 0.f, 0.f) }; glm::quat(0.f, 0.f, 0.f, 0.f)};
Skeleton::FrameTransform t2 { glm::vec3(1.f, 0.f, 0.f), glm::quat(0.f, 0.f, 1.f, 0.f) }; Skeleton::FrameTransform t2{glm::vec3(1.f, 0.f, 0.f),
glm::quat(0.f, 0.f, 1.f, 0.f)};
Skeleton skeleton; Skeleton skeleton;
skeleton.setAllData({ skeleton.setAllData({{0, {t1, t2, true}}});
{0, { t1, t2, true }}
});
BOOST_CHECK(skeleton.getData(0).a.translation == t1.translation); BOOST_CHECK(skeleton.getData(0).a.translation == t1.translation);
BOOST_CHECK(skeleton.getData(0).a.rotation == t1.rotation); BOOST_CHECK(skeleton.getData(0).a.rotation == t1.rotation);
@ -34,21 +33,22 @@ BOOST_AUTO_TEST_CASE(test_methods)
BOOST_CHECK(!skeleton.getData(0).enabled); BOOST_CHECK(!skeleton.getData(0).enabled);
} }
BOOST_AUTO_TEST_CASE(test_interpolate) BOOST_AUTO_TEST_CASE(test_interpolate) {
{ Skeleton::FrameTransform t1{glm::vec3(0.f, 0.f, 0.f),
Skeleton::FrameTransform t1 { glm::vec3(0.f, 0.f, 0.f), glm::quat(0.f, 0.f, 0.f, 0.f) }; glm::quat(0.f, 0.f, 0.f, 0.f)};
Skeleton::FrameTransform t2 { glm::vec3(1.f, 0.f, 0.f), glm::quat(0.f, 0.f, 1.f, 0.f) }; Skeleton::FrameTransform t2{glm::vec3(1.f, 0.f, 0.f),
glm::quat(0.f, 0.f, 1.f, 0.f)};
Skeleton skeleton; Skeleton skeleton;
skeleton.setAllData({ skeleton.setAllData({{0, {t2, t1, true}}});
{0, { t2, t1, true }}
});
/** Without calling Skeleton::interpolate(alpha) the result is identity */ /** Without calling Skeleton::interpolate(alpha) the result is identity */
BOOST_CHECK(skeleton.getInterpolated(0).translation == Skeleton::IdentityTransform.translation); BOOST_CHECK(skeleton.getInterpolated(0).translation ==
BOOST_CHECK(skeleton.getInterpolated(0).rotation == Skeleton::IdentityTransform.rotation); Skeleton::IdentityTransform.translation);
BOOST_CHECK(skeleton.getInterpolated(0).rotation ==
Skeleton::IdentityTransform.rotation);
skeleton.interpolate(0.f); skeleton.interpolate(0.f);
@ -61,4 +61,3 @@ BOOST_AUTO_TEST_CASE(test_interpolate)
BOOST_CHECK(skeleton.getInterpolated(0).rotation == t2.rotation); BOOST_CHECK(skeleton.getInterpolated(0).rotation == t2.rotation);
} }
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()

View File

@ -1,6 +1,6 @@
#include <State.hpp>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include "test_globals.hpp" #include "test_globals.hpp"
#include <State.hpp>
BOOST_AUTO_TEST_SUITE(StateUnitTests) BOOST_AUTO_TEST_SUITE(StateUnitTests)

View File

@ -1,16 +1,15 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include "test_globals.hpp"
#include <data/GameTexts.hpp> #include <data/GameTexts.hpp>
#include <loaders/LoaderGXT.hpp>
#include <engine/ScreenText.hpp> #include <engine/ScreenText.hpp>
#include <loaders/LoaderGXT.hpp>
#include "test_globals.hpp"
#define T(x) GameStringUtil::fromString(x) #define T(x) GameStringUtil::fromString(x)
BOOST_AUTO_TEST_SUITE(TextTests) BOOST_AUTO_TEST_SUITE(TextTests)
#if RW_TEST_WITH_DATA #if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(load_test) BOOST_AUTO_TEST_CASE(load_test) {
{
{ {
auto d = Global::get().e->data->index.openFilePath("text/english.gxt"); auto d = Global::get().e->data->index.openFilePath("text/english.gxt");
@ -24,15 +23,11 @@ BOOST_AUTO_TEST_CASE(load_test)
} }
} }
BOOST_AUTO_TEST_CASE(big_test) BOOST_AUTO_TEST_CASE(big_test) {
{
// Check that makeBig creates a text in the right place // Check that makeBig creates a text in the right place
{ {
auto big = ScreenTextEntry::makeBig( auto big =
"TEST_1", ScreenTextEntry::makeBig("TEST_1", T("Test String"), 1, 5000);
T("Test String"),
1,
5000);
BOOST_CHECK_EQUAL("TEST_1", big.id); BOOST_CHECK_EQUAL("TEST_1", big.id);
BOOST_CHECK_EQUAL(T("Test String"), big.text); BOOST_CHECK_EQUAL(T("Test String"), big.text);
@ -42,11 +37,8 @@ BOOST_AUTO_TEST_CASE(big_test)
BOOST_CHECK_EQUAL(50, big.size); BOOST_CHECK_EQUAL(50, big.size);
} }
{ {
auto big = ScreenTextEntry::makeBig( auto big =
"TEST_1", ScreenTextEntry::makeBig("TEST_1", T("Test String"), 2, 5000);
T("Test String"),
2,
5000);
BOOST_CHECK_EQUAL(T("Test String"), big.text); BOOST_CHECK_EQUAL(T("Test String"), big.text);
BOOST_CHECK_EQUAL(5000, big.durationMS); BOOST_CHECK_EQUAL(5000, big.durationMS);
@ -56,11 +48,8 @@ BOOST_AUTO_TEST_CASE(big_test)
} }
} }
BOOST_AUTO_TEST_CASE(help_test) BOOST_AUTO_TEST_CASE(help_test) {
{ auto help = ScreenTextEntry::makeHelp("TEST_1", T("Test Help"));
auto help = ScreenTextEntry::makeHelp(
"TEST_1",
T("Test Help"));
BOOST_CHECK_EQUAL(T("Test Help"), help.text); BOOST_CHECK_EQUAL(T("Test Help"), help.text);
BOOST_CHECK_EQUAL(5000, help.durationMS); BOOST_CHECK_EQUAL(5000, help.durationMS);
@ -68,26 +57,19 @@ BOOST_AUTO_TEST_CASE(help_test)
BOOST_CHECK_EQUAL(18, help.size); BOOST_CHECK_EQUAL(18, help.size);
} }
BOOST_AUTO_TEST_CASE(queue_test) BOOST_AUTO_TEST_CASE(queue_test) {
{
// Check that creating a test puts it on the right queue. // Check that creating a test puts it on the right queue.
ScreenText st; ScreenText st;
st.addText<ScreenTextType::Big>( st.addText<ScreenTextType::Big>(
ScreenTextEntry::makeBig( ScreenTextEntry::makeBig("TEST_1", T("Test String"), 2, 5000));
"TEST_1",
T("Test String"),
2,
5000));
st.addText<ScreenTextType::HighPriority>( st.addText<ScreenTextType::HighPriority>(
ScreenTextEntry::makeHighPriority( ScreenTextEntry::makeHighPriority("TEST_1", T("Test String"), 5000));
"TEST_1",
T("Test String"),
5000));
BOOST_REQUIRE(st.getText<ScreenTextType::Big>().size() == 1); BOOST_REQUIRE(st.getText<ScreenTextType::Big>().size() == 1);
BOOST_CHECK_EQUAL(T("Test String"), st.getText<ScreenTextType::Big>()[0].text); BOOST_CHECK_EQUAL(T("Test String"),
st.getText<ScreenTextType::Big>()[0].text);
BOOST_CHECK_EQUAL(5000, st.getText<ScreenTextType::Big>()[0].durationMS); BOOST_CHECK_EQUAL(5000, st.getText<ScreenTextType::Big>()[0].durationMS);
BOOST_CHECK_EQUAL(0, st.getText<ScreenTextType::Big>()[0].displayedMS); BOOST_CHECK_EQUAL(0, st.getText<ScreenTextType::Big>()[0].displayedMS);
@ -99,16 +81,11 @@ BOOST_AUTO_TEST_CASE(queue_test)
BOOST_CHECK_EQUAL(0, st.getText<ScreenTextType::HighPriority>().size()); BOOST_CHECK_EQUAL(0, st.getText<ScreenTextType::HighPriority>().size());
} }
BOOST_AUTO_TEST_CASE(clear_test) BOOST_AUTO_TEST_CASE(clear_test) {
{
ScreenText st; ScreenText st;
st.addText<ScreenTextType::Big>( st.addText<ScreenTextType::Big>(
ScreenTextEntry::makeBig( ScreenTextEntry::makeBig("TEST_1", T("Test String"), 2, 5000));
"TEST_1",
T("Test String"),
2,
5000));
BOOST_CHECK_EQUAL(1, st.getText<ScreenTextType::Big>().size()); BOOST_CHECK_EQUAL(1, st.getText<ScreenTextType::Big>().size());
@ -117,8 +94,7 @@ BOOST_AUTO_TEST_CASE(clear_test)
BOOST_CHECK_EQUAL(0, st.getText<ScreenTextType::Big>().size()); BOOST_CHECK_EQUAL(0, st.getText<ScreenTextType::Big>().size());
} }
BOOST_AUTO_TEST_CASE(format_test) BOOST_AUTO_TEST_CASE(format_test) {
{
// Test formating of string codes into strings. // Test formating of string codes into strings.
const auto codeStr1 = T("Hello ~1~ world"); const auto codeStr1 = T("Hello ~1~ world");
const auto codeStr2 = T("~1~Hello ~1~ world~1~"); const auto codeStr2 = T("~1~Hello ~1~ world~1~");
@ -137,31 +113,18 @@ BOOST_AUTO_TEST_CASE(format_test)
BOOST_CHECK_EQUAL(f4, T("Hello worldx")); BOOST_CHECK_EQUAL(f4, T("Hello worldx"));
} }
BOOST_AUTO_TEST_CASE(format_remove) BOOST_AUTO_TEST_CASE(format_remove) {
{
// Test removing an identified string from the list // Test removing an identified string from the list
ScreenText st; ScreenText st;
st.addText<ScreenTextType::Big>( st.addText<ScreenTextType::Big>(
ScreenTextEntry::makeBig( ScreenTextEntry::makeBig("TEST_2", T("Test String"), 2, 5000));
"TEST_2",
T("Test String"),
2,
5000));
st.addText<ScreenTextType::Big>( st.addText<ScreenTextType::Big>(
ScreenTextEntry::makeBig( ScreenTextEntry::makeBig("TEST_1", T("Test String"), 2, 5000));
"TEST_1",
T("Test String"),
2,
5000));
st.addText<ScreenTextType::Big>( st.addText<ScreenTextType::Big>(
ScreenTextEntry::makeBig( ScreenTextEntry::makeBig("TEST_1", T("Test String"), 2, 5000));
"TEST_1",
T("Test String"),
2,
5000));
BOOST_CHECK_EQUAL(3, st.getText<ScreenTextType::Big>().size()); BOOST_CHECK_EQUAL(3, st.getText<ScreenTextType::Big>().size());

View File

@ -1,70 +1,38 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include "test_globals.hpp" #include "test_globals.hpp"
#include <ai/TrafficDirector.hpp>
#include <ai/AIGraph.hpp> #include <ai/AIGraph.hpp>
#include <objects/InstanceObject.hpp> #include <ai/TrafficDirector.hpp>
#include <objects/CharacterObject.hpp> #include <objects/CharacterObject.hpp>
#include <objects/InstanceObject.hpp>
#include <render/ViewCamera.hpp> #include <render/ViewCamera.hpp>
bool operator!=(const AIGraphNode* lhs, const glm::vec3 &rhs) { return lhs->position != rhs; } bool operator!=(const AIGraphNode* lhs, const glm::vec3& rhs) {
std::ostream &operator<<(std::ostream &os, const AIGraphNode* yt) { os << glm::to_string(yt->position); return os; } return lhs->position != rhs;
}
std::ostream& operator<<(std::ostream& os, const AIGraphNode* yt) {
os << glm::to_string(yt->position);
return os;
}
BOOST_AUTO_TEST_SUITE(TrafficDirectorTests) BOOST_AUTO_TEST_SUITE(TrafficDirectorTests)
#if RW_TEST_WITH_DATA #if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_available_nodes) BOOST_AUTO_TEST_CASE(test_available_nodes) {
{
AIGraph graph; AIGraph graph;
PathData path { PathData path{PathData::PATH_PED,
PathData::PATH_PED, 0,
0, "", "",
{ {
{ {PathNode::EXTERNAL, 1, {10.f, 10.f, 0.f}, 1.f, 0, 0},
PathNode::EXTERNAL, {PathNode::EXTERNAL, 2, {10.f, 0.f, 0.f}, 1.f, 0, 0},
1, {PathNode::EXTERNAL, 3, {10.f, -10.f, 0.f}, 1.f, 0, 0},
{ 10.f, 10.f, 0.f }, {PathNode::EXTERNAL, 4, {0.f, -10.f, 0.f}, 1.f, 0, 0},
1.f, 0, 0 {PathNode::EXTERNAL, 5, {-10.f, -10.f, 0.f}, 1.f, 0, 0},
}, {PathNode::EXTERNAL, 6, {-10.f, 0.f, 0.f}, 1.f, 0, 0},
{ {PathNode::EXTERNAL, -1, {-10.f, 10.f, 0.f}, 1.f, 0, 0},
PathNode::EXTERNAL, }};
2,
{ 10.f, 0.f, 0.f },
1.f, 0, 0
},
{
PathNode::EXTERNAL,
3,
{ 10.f,-10.f, 0.f },
1.f, 0, 0
},
{
PathNode::EXTERNAL,
4,
{ 0.f,-10.f, 0.f },
1.f, 0, 0
},
{
PathNode::EXTERNAL,
5,
{-10.f,-10.f, 0.f },
1.f, 0, 0
},
{
PathNode::EXTERNAL,
6,
{-10.f, 0.f, 0.f },
1.f, 0, 0
},
{
PathNode::EXTERNAL,
-1,
{-10.f, 10.f, 0.f },
1.f, 0, 0
},
}
};
graph.createPathNodes(glm::vec3(), glm::quat(), path); graph.createPathNodes(glm::vec3(), glm::quat(), path);
@ -72,141 +40,119 @@ BOOST_AUTO_TEST_CASE(test_available_nodes)
ViewCamera testCamera(glm::vec3(-5.f, -5.f, 0.f)); ViewCamera testCamera(glm::vec3(-5.f, -5.f, 0.f));
auto open = director.findAvailableNodes(AIGraphNode::Pedestrian, testCamera, 10.f); auto open =
director.findAvailableNodes(AIGraphNode::Pedestrian, testCamera, 10.f);
std::vector<glm::vec3> expected{ std::vector<glm::vec3> expected{
{ 0.f,-10.f, 0.f }, {0.f, -10.f, 0.f}, {-10.f, -10.f, 0.f}, {-10.f, 0.f, 0.f}};
{-10.f,-10.f, 0.f },
{-10.f, 0.f, 0.f }
};
BOOST_REQUIRE(expected.size() == 3); BOOST_REQUIRE(expected.size() == 3);
BOOST_ASSERT(expected.size() == open.size()); BOOST_ASSERT(expected.size() == open.size());
for (auto& v : expected) { for (auto& v : expected) {
BOOST_CHECK(std::find_if(open.begin(), open.end(), BOOST_CHECK(std::find_if(open.begin(), open.end(), [v](AIGraphNode* n) {
[v](AIGraphNode* n) { return n->position == v; }) != open.end()); return n->position == v;
}) != open.end());
} }
} }
BOOST_AUTO_TEST_CASE(test_node_not_blocking) BOOST_AUTO_TEST_CASE(test_node_not_blocking) {
{
AIGraph graph; AIGraph graph;
PathData path { PathData path{PathData::PATH_PED,
PathData::PATH_PED, 0,
0, "", "",
{ {
{ {PathNode::EXTERNAL, 1, {10.f, 10.f, 0.f}, 1.f, 0, 0},
PathNode::EXTERNAL, }};
1,
{ 10.f, 10.f, 0.f },
1.f, 0, 0
},
}
};
graph.createPathNodes(glm::vec3(), glm::quat(), path); graph.createPathNodes(glm::vec3(), glm::quat(), path);
TrafficDirector director(&graph, Global::get().e); TrafficDirector director(&graph, Global::get().e);
// Create something that isn't a pedestrian // Create something that isn't a pedestrian
InstanceObject* box = Global::get().e->createInstance(1337, glm::vec3(10.f, 10.f, 0.f)); InstanceObject* box =
Global::get().e->createInstance(1337, glm::vec3(10.f, 10.f, 0.f));
{ {
auto open = director.findAvailableNodes(AIGraphNode::Pedestrian, glm::vec3( 5.f, 5.f, 0.f), 10.f); auto open = director.findAvailableNodes(AIGraphNode::Pedestrian,
glm::vec3(5.f, 5.f, 0.f), 10.f);
BOOST_CHECK(open.size() == 1); BOOST_CHECK(open.size() == 1);
} }
Global::get().e->destroyObject(box); Global::get().e->destroyObject(box);
} }
BOOST_AUTO_TEST_CASE(test_node_blocking) BOOST_AUTO_TEST_CASE(test_node_blocking) {
{
AIGraph graph; AIGraph graph;
PathData path { PathData path{PathData::PATH_PED,
PathData::PATH_PED, 0,
0, "", "",
{ {
{ {PathNode::EXTERNAL, 1, {10.f, 10.f, 0.f}, 1.f, 0, 0},
PathNode::EXTERNAL, }};
1,
{ 10.f, 10.f, 0.f },
1.f, 0, 0
},
}
};
graph.createPathNodes(glm::vec3(), glm::quat(), path); graph.createPathNodes(glm::vec3(), glm::quat(), path);
TrafficDirector director(&graph, Global::get().e); TrafficDirector director(&graph, Global::get().e);
// create something that should block the spawn point // create something that should block the spawn point
CharacterObject* ped = Global::get().e->createPedestrian(1, glm::vec3(10.f, 10.f, 0.f)); CharacterObject* ped =
Global::get().e->createPedestrian(1, glm::vec3(10.f, 10.f, 0.f));
{ {
auto open = director.findAvailableNodes(AIGraphNode::Pedestrian, glm::vec3( 5.f, 5.f, 0.f), 10.f); auto open = director.findAvailableNodes(AIGraphNode::Pedestrian,
glm::vec3(5.f, 5.f, 0.f), 10.f);
BOOST_CHECK(open.size() == 0); BOOST_CHECK(open.size() == 0);
} }
Global::get().e->destroyObject(ped); Global::get().e->destroyObject(ped);
} }
BOOST_AUTO_TEST_CASE(test_node_density) BOOST_AUTO_TEST_CASE(test_node_density) {
{
AIGraph graph; AIGraph graph;
PathData path { PathData path{PathData::PATH_PED,
PathData::PATH_PED, 0,
0, "", "",
{ {
{ {PathNode::EXTERNAL, 1, {10.f, 10.f, 0.f}, 1.f, 0, 0},
PathNode::EXTERNAL, }};
1,
{ 10.f, 10.f, 0.f },
1.f, 0, 0
},
}
};
graph.createPathNodes(glm::vec3(), glm::quat(), path); graph.createPathNodes(glm::vec3(), glm::quat(), path);
TrafficDirector director(&graph, Global::get().e); TrafficDirector director(&graph, Global::get().e);
CharacterObject* ped = Global::get().e->createPedestrian(1, glm::vec3(5.f, 5.f, 0.f)); CharacterObject* ped =
Global::get().e->createPedestrian(1, glm::vec3(5.f, 5.f, 0.f));
{ {
director.setDensity(AIGraphNode::Pedestrian, 1.f); director.setDensity(AIGraphNode::Pedestrian, 1.f);
auto open = director.findAvailableNodes(AIGraphNode::Pedestrian, glm::vec3( 5.f, 5.f, 0.f), 10.f); auto open = director.findAvailableNodes(AIGraphNode::Pedestrian,
glm::vec3(5.f, 5.f, 0.f), 10.f);
BOOST_CHECK(open.size() == 0); BOOST_CHECK(open.size() == 0);
} }
{ {
director.setDensity(AIGraphNode::Pedestrian, 2.f); director.setDensity(AIGraphNode::Pedestrian, 2.f);
auto open = director.findAvailableNodes(AIGraphNode::Pedestrian, glm::vec3( 5.f, 5.f, 0.f), 10.f); auto open = director.findAvailableNodes(AIGraphNode::Pedestrian,
glm::vec3(5.f, 5.f, 0.f), 10.f);
BOOST_CHECK(open.size() == 1); BOOST_CHECK(open.size() == 1);
} }
Global::get().e->destroyObject(ped); Global::get().e->destroyObject(ped);
} }
BOOST_AUTO_TEST_CASE(test_create_traffic) BOOST_AUTO_TEST_CASE(test_create_traffic) {
{
AIGraph graph; AIGraph graph;
PathData path { PathData path{PathData::PATH_PED,
PathData::PATH_PED, 0,
0, "", "",
{ {
{ {PathNode::EXTERNAL, 1, {10.f, 10.f, 0.f}, 1.f, 0, 0},
PathNode::EXTERNAL, }};
1,
{ 10.f, 10.f, 0.f },
1.f, 0, 0
},
}
};
graph.createPathNodes(glm::vec3(), glm::quat(), path); graph.createPathNodes(glm::vec3(), glm::quat(), path);

View File

@ -1,15 +1,15 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include "test_globals.hpp"
#include <objects/VehicleObject.hpp>
#include <data/Model.hpp> #include <data/Model.hpp>
#include <data/Skeleton.hpp> #include <data/Skeleton.hpp>
#include <objects/VehicleObject.hpp>
#include "test_globals.hpp"
BOOST_AUTO_TEST_SUITE(VehicleTests) BOOST_AUTO_TEST_SUITE(VehicleTests)
#if RW_TEST_WITH_DATA #if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(test_create_vehicle) BOOST_AUTO_TEST_CASE(test_create_vehicle) {
{ VehicleObject* vehicle =
VehicleObject* vehicle = Global::get().e->createVehicle(90u, glm::vec3(), glm::quat()); Global::get().e->createVehicle(90u, glm::vec3(), glm::quat());
BOOST_REQUIRE(vehicle != nullptr); BOOST_REQUIRE(vehicle != nullptr);
@ -26,9 +26,9 @@ BOOST_AUTO_TEST_CASE(test_create_vehicle)
Global::get().e->destroyObject(vehicle); Global::get().e->destroyObject(vehicle);
} }
BOOST_AUTO_TEST_CASE(vehicle_parts) BOOST_AUTO_TEST_CASE(vehicle_parts) {
{ VehicleObject* vehicle =
VehicleObject* vehicle = Global::get().e->createVehicle(90u, glm::vec3(), glm::quat()); Global::get().e->createVehicle(90u, glm::vec3(), glm::quat());
BOOST_REQUIRE(vehicle != nullptr); BOOST_REQUIRE(vehicle != nullptr);
BOOST_REQUIRE(vehicle->model != nullptr); BOOST_REQUIRE(vehicle->model != nullptr);
@ -46,9 +46,9 @@ BOOST_AUTO_TEST_CASE(vehicle_parts)
Global::get().e->destroyObject(vehicle); Global::get().e->destroyObject(vehicle);
} }
BOOST_AUTO_TEST_CASE(vehicle_part_vis) BOOST_AUTO_TEST_CASE(vehicle_part_vis) {
{ VehicleObject* vehicle =
VehicleObject* vehicle = Global::get().e->createVehicle(90u, glm::vec3(), glm::quat()); Global::get().e->createVehicle(90u, glm::vec3(), glm::quat());
BOOST_REQUIRE(vehicle != nullptr); BOOST_REQUIRE(vehicle != nullptr);
BOOST_REQUIRE(vehicle->model != nullptr); BOOST_REQUIRE(vehicle->model != nullptr);
@ -69,9 +69,9 @@ BOOST_AUTO_TEST_CASE(vehicle_part_vis)
Global::get().e->destroyObject(vehicle); Global::get().e->destroyObject(vehicle);
} }
BOOST_AUTO_TEST_CASE(test_door_position) BOOST_AUTO_TEST_CASE(test_door_position) {
{ VehicleObject* vehicle = Global::get().e->createVehicle(
VehicleObject* vehicle = Global::get().e->createVehicle(90u, glm::vec3(10.f, 0.f, 0.f), glm::quat()); 90u, glm::vec3(10.f, 0.f, 0.f), glm::quat());
BOOST_REQUIRE(vehicle != nullptr); BOOST_REQUIRE(vehicle != nullptr);
@ -80,13 +80,12 @@ BOOST_AUTO_TEST_CASE(test_door_position)
BOOST_CHECK(vehicle->getSeatEntryPositionWorld(0).x > 5.f); BOOST_CHECK(vehicle->getSeatEntryPositionWorld(0).x > 5.f);
Global::get().e->destroyObject(vehicle); Global::get().e->destroyObject(vehicle);
} }
BOOST_AUTO_TEST_CASE(test_hinges) BOOST_AUTO_TEST_CASE(test_hinges) {
{ VehicleObject* vehicle = Global::get().e->createVehicle(
VehicleObject* vehicle = Global::get().e->createVehicle(90u, glm::vec3(10.f, 0.f, 0.f), glm::quat()); 90u, glm::vec3(10.f, 0.f, 0.f), glm::quat());
BOOST_REQUIRE(vehicle != nullptr); BOOST_REQUIRE(vehicle != nullptr);
@ -110,9 +109,9 @@ BOOST_AUTO_TEST_CASE(test_hinges)
Global::get().e->destroyObject(vehicle); Global::get().e->destroyObject(vehicle);
} }
BOOST_AUTO_TEST_CASE(test_open_part) BOOST_AUTO_TEST_CASE(test_open_part) {
{ VehicleObject* vehicle = Global::get().e->createVehicle(
VehicleObject* vehicle = Global::get().e->createVehicle(90u, glm::vec3(10.f, 0.f, 0.f), glm::quat()); 90u, glm::vec3(10.f, 0.f, 0.f), glm::quat());
BOOST_REQUIRE(vehicle != nullptr); BOOST_REQUIRE(vehicle != nullptr);
@ -132,4 +131,3 @@ BOOST_AUTO_TEST_CASE(test_open_part)
#endif #endif
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()

View File

@ -1,14 +1,13 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include "test_globals.hpp"
#include <objects/CharacterObject.hpp>
#include <data/WeaponData.hpp> #include <data/WeaponData.hpp>
#include <objects/CharacterObject.hpp>
#include <objects/ProjectileObject.hpp> #include <objects/ProjectileObject.hpp>
#include "test_globals.hpp"
BOOST_AUTO_TEST_SUITE(WeaponTests) BOOST_AUTO_TEST_SUITE(WeaponTests)
#if RW_TEST_WITH_DATA #if RW_TEST_WITH_DATA
BOOST_AUTO_TEST_CASE(TestWeaponScan) BOOST_AUTO_TEST_CASE(TestWeaponScan) {
{
{ {
// Test RADIUS scan // Test RADIUS scan
auto character = Global::get().e->createPedestrian(1, {0.f, 0.f, 0.f}); auto character = Global::get().e->createPedestrian(1, {0.f, 0.f, 0.f});
@ -26,22 +25,16 @@ BOOST_AUTO_TEST_CASE(TestWeaponScan)
} }
} }
BOOST_AUTO_TEST_CASE(TestProjectile) BOOST_AUTO_TEST_CASE(TestProjectile) {
{
{ {
auto character = Global::get().e->createPedestrian(1, {25.f, 0.f, 0.f}); auto character = Global::get().e->createPedestrian(1, {25.f, 0.f, 0.f});
BOOST_REQUIRE(character != nullptr); BOOST_REQUIRE(character != nullptr);
auto wepdata = Global::get().e->data->weaponData[5]; auto wepdata = Global::get().e->data->weaponData[5];
auto projectile = new ProjectileObject(Global::get().e, {26.f, 1.f, 10.f}, auto projectile = new ProjectileObject(
{ Global::get().e, {26.f, 1.f, 10.f},
ProjectileObject::Grenade, {ProjectileObject::Grenade, {0.f, 0.f, -1.f}, 2.0f, 5.0f, wepdata});
{0.f, 0.f, -1.f},
2.0f,
5.0f,
wepdata
});
Global::get().e->allObjects.push_back(projectile); Global::get().e->allObjects.push_back(projectile);
@ -52,8 +45,12 @@ BOOST_AUTO_TEST_CASE(TestProjectile)
projectile->tick(0.016f); projectile->tick(0.016f);
} }
BOOST_CHECK_LT( glm::distance(character->getPosition(), projectile->getPosition()), 10.f ); BOOST_CHECK_LT(
BOOST_CHECK_LT( glm::distance(character->getPosition(), projectile->getPosition()), 5.f ); glm::distance(character->getPosition(), projectile->getPosition()),
10.f);
BOOST_CHECK_LT(
glm::distance(character->getPosition(), projectile->getPosition()),
5.f);
// Grenade should have dentonated by this point // Grenade should have dentonated by this point
BOOST_CHECK(character->getCurrentState().health < 100.f); BOOST_CHECK(character->getCurrentState().health < 100.f);
@ -68,14 +65,9 @@ BOOST_AUTO_TEST_CASE(TestProjectile)
auto wepdata = Global::get().e->data->weaponData[6]; auto wepdata = Global::get().e->data->weaponData[6];
auto projectile = new ProjectileObject(Global::get().e, {26.f, 1.f, 10.f}, auto projectile = new ProjectileObject(
{ Global::get().e, {26.f, 1.f, 10.f},
ProjectileObject::Molotov, {ProjectileObject::Molotov, {0.f, 0.f, -1.f}, 2.0f, 10.f, wepdata});
{0.f, 0.f, -1.f},
2.0f,
10.f,
wepdata
});
Global::get().e->allObjects.push_back(projectile); Global::get().e->allObjects.push_back(projectile);
@ -100,14 +92,9 @@ BOOST_AUTO_TEST_CASE(TestProjectile)
auto wepdata = Global::get().e->data->weaponData[7]; auto wepdata = Global::get().e->data->weaponData[7];
auto projectile = new ProjectileObject(Global::get().e, {26.f, 1.f, 10.f}, auto projectile = new ProjectileObject(
{ Global::get().e, {26.f, 1.f, 10.f},
ProjectileObject::RPG, {ProjectileObject::RPG, {0.f, 0.f, -1.f}, 2.0f, 10.f, wepdata});
{0.f, 0.f, -1.f},
2.0f,
10.f,
wepdata
});
Global::get().e->allObjects.push_back(projectile); Global::get().e->allObjects.push_back(projectile);

View File

@ -1,25 +1,26 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include <job/WorkContext.hpp> #include <job/WorkContext.hpp>
class TestJob : public WorkJob class TestJob : public WorkJob {
{
public: public:
bool *_worked, *_completed; bool *_worked, *_completed;
TestJob(WorkContext *context, bool *w, bool *c) TestJob(WorkContext *context, bool *w, bool *c)
: WorkJob(context), _worked(w), _completed(c) : WorkJob(context), _worked(w), _completed(c) {
{} }
void work() { *_worked = true; } void work() {
*_worked = true;
}
void complete() { *_completed = true; } void complete() {
*_completed = true;
}
}; };
BOOST_AUTO_TEST_SUITE(WorkTests) BOOST_AUTO_TEST_SUITE(WorkTests)
BOOST_AUTO_TEST_CASE(test_interface) BOOST_AUTO_TEST_CASE(test_interface) {
{
{ {
WorkContext context; WorkContext context;
@ -37,7 +38,8 @@ BOOST_AUTO_TEST_CASE(test_interface)
BOOST_CHECK(worked); BOOST_CHECK(worked);
BOOST_CHECK(!completed); BOOST_CHECK(!completed);
context.update();; context.update();
;
BOOST_CHECK(worked); BOOST_CHECK(worked);
BOOST_CHECK(completed); BOOST_CHECK(completed);
@ -45,4 +47,3 @@ BOOST_AUTO_TEST_CASE(test_interface)
} }
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()

View File

@ -3,9 +3,7 @@
BOOST_AUTO_TEST_SUITE(WorldTests) BOOST_AUTO_TEST_SUITE(WorldTests)
BOOST_AUTO_TEST_CASE(world_object_destroy) BOOST_AUTO_TEST_CASE(world_object_destroy) {
{
} }
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()