mirror of
https://github.com/rwengine/openrw.git
synced 2024-09-15 06:52:34 +02:00
clang-format files in tests
This commit is contained in:
parent
11a9907f07
commit
3015b7f3e0
@ -2,7 +2,7 @@
|
|||||||
#include <boost/test/included/unit_test.hpp>
|
#include <boost/test/included/unit_test.hpp>
|
||||||
#include "test_globals.hpp"
|
#include "test_globals.hpp"
|
||||||
|
|
||||||
std::ostream& operator<<( std::ostream& stream, const glm::vec3& v ) {
|
std::ostream& operator<<(std::ostream& stream, const glm::vec3& v) {
|
||||||
stream << v.x << " " << v.y << " " << v.z;
|
stream << v.x << " " << v.y << " " << v.z;
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
@ -5,50 +5,47 @@
|
|||||||
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());
|
||||||
|
|
||||||
{
|
{
|
||||||
std::string upperpath { "DATA/CULLZONE.DAT" };
|
std::string upperpath{"DATA/CULLZONE.DAT"};
|
||||||
auto truepath = index.findFilePath(upperpath);
|
auto truepath = index.findFilePath(upperpath);
|
||||||
BOOST_ASSERT(! truepath.empty());
|
BOOST_ASSERT(!truepath.empty());
|
||||||
BOOST_CHECK(upperpath != truepath);
|
BOOST_CHECK(upperpath != truepath);
|
||||||
fs::path expected {Global::getGamePath()};
|
fs::path expected{Global::getGamePath()};
|
||||||
expected /= "data/CULLZONE.DAT";
|
expected /= "data/CULLZONE.DAT";
|
||||||
BOOST_CHECK_EQUAL(truepath.native(), expected.native());
|
BOOST_CHECK_EQUAL(truepath.native(), expected.native());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::string upperpath { "DATA/MAPS/COMNBTM/COMNBTM.IPL" };
|
std::string upperpath{"DATA/MAPS/COMNBTM/COMNBTM.IPL"};
|
||||||
auto truepath = index.findFilePath(upperpath);
|
auto truepath = index.findFilePath(upperpath);
|
||||||
BOOST_ASSERT(! truepath.empty());
|
BOOST_ASSERT(!truepath.empty());
|
||||||
BOOST_CHECK(upperpath != truepath);
|
BOOST_CHECK(upperpath != truepath);
|
||||||
fs::path expected {Global::getGamePath()};
|
fs::path expected{Global::getGamePath()};
|
||||||
expected /= "data/maps/comnbtm/comNbtm.ipl";
|
expected /= "data/maps/comnbtm/comNbtm.ipl";
|
||||||
BOOST_CHECK_EQUAL(truepath.native(), expected.native());
|
BOOST_CHECK_EQUAL(truepath.native(), expected.native());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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");
|
||||||
|
|
||||||
auto handle = index.openFile("cullzone.dat");
|
auto handle = index.openFile("cullzone.dat");
|
||||||
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");
|
|
||||||
|
auto handle = index.openFile("landstal.dff");
|
||||||
auto handle = index.openFile("landstal.dff");
|
BOOST_CHECK(handle != nullptr);
|
||||||
BOOST_CHECK( handle != nullptr );
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -5,26 +5,25 @@
|
|||||||
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);
|
|
||||||
|
|
||||||
gd.load();
|
gd.load();
|
||||||
|
|
||||||
{
|
{
|
||||||
auto def = gd.findObjectType<ObjectData>(1100);
|
auto def = gd.findObjectType<ObjectData>(1100);
|
||||||
|
|
||||||
BOOST_REQUIRE( def );
|
BOOST_REQUIRE(def);
|
||||||
|
|
||||||
BOOST_ASSERT(def->class_type == ObjectInformation::_class("OBJS"));
|
BOOST_ASSERT(def->class_type == ObjectInformation::_class("OBJS"));
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL( def->modelName, "rd_Corner1" );
|
BOOST_CHECK_EQUAL(def->modelName, "rd_Corner1");
|
||||||
BOOST_CHECK_EQUAL( def->textureName, "generic" );
|
BOOST_CHECK_EQUAL(def->textureName, "generic");
|
||||||
BOOST_CHECK_EQUAL( def->numClumps, 1 );
|
BOOST_CHECK_EQUAL(def->numClumps, 1);
|
||||||
BOOST_CHECK_EQUAL( def->drawDistance[0], 220 );
|
BOOST_CHECK_EQUAL(def->drawDistance[0], 220);
|
||||||
BOOST_CHECK_EQUAL( def->flags, 0 );
|
BOOST_CHECK_EQUAL(def->flags, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,73 +1,71 @@
|
|||||||
#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 object2 = gw.createInstance(1337, glm::vec3(100.f, 0.f, 100.f));
|
|
||||||
|
|
||||||
BOOST_CHECK_NE( object1->getGameObjectID(), object2->getGameObjectID() );
|
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)
|
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();
|
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL(0, gw.getHour());
|
BOOST_CHECK_EQUAL(0, gw.getHour());
|
||||||
BOOST_CHECK_EQUAL(0, gw.getMinute());
|
BOOST_CHECK_EQUAL(0, gw.getMinute());
|
||||||
|
|
||||||
gw.offsetGameTime(30);
|
gw.offsetGameTime(30);
|
||||||
BOOST_CHECK_EQUAL(0, gw.getHour());
|
BOOST_CHECK_EQUAL(0, gw.getHour());
|
||||||
BOOST_CHECK_EQUAL(30, gw.getMinute());
|
BOOST_CHECK_EQUAL(30, gw.getMinute());
|
||||||
|
|
||||||
gw.offsetGameTime(30);
|
gw.offsetGameTime(30);
|
||||||
BOOST_CHECK_EQUAL(1, gw.getHour());
|
BOOST_CHECK_EQUAL(1, gw.getHour());
|
||||||
BOOST_CHECK_EQUAL(0, gw.getMinute());
|
BOOST_CHECK_EQUAL(0, gw.getMinute());
|
||||||
|
|
||||||
gw.offsetGameTime(-30);
|
gw.offsetGameTime(-30);
|
||||||
BOOST_CHECK_EQUAL(0, gw.getHour());
|
BOOST_CHECK_EQUAL(0, gw.getHour());
|
||||||
BOOST_CHECK_EQUAL(30, gw.getMinute());
|
BOOST_CHECK_EQUAL(30, gw.getMinute());
|
||||||
|
|
||||||
gw.offsetGameTime(-60);
|
gw.offsetGameTime(-60);
|
||||||
BOOST_CHECK_EQUAL(23, gw.getHour());
|
BOOST_CHECK_EQUAL(23, gw.getHour());
|
||||||
BOOST_CHECK_EQUAL(30, gw.getMinute());
|
BOOST_CHECK_EQUAL(30, gw.getMinute());
|
||||||
|
|
||||||
gw.offsetGameTime(30);
|
gw.offsetGameTime(30);
|
||||||
BOOST_CHECK_EQUAL(0, gw.getHour());
|
BOOST_CHECK_EQUAL(0, gw.getHour());
|
||||||
BOOST_CHECK_EQUAL(0, gw.getMinute());
|
BOOST_CHECK_EQUAL(0, gw.getMinute());
|
||||||
|
|
||||||
gw.offsetGameTime(24*60);
|
gw.offsetGameTime(24 * 60);
|
||||||
BOOST_CHECK_EQUAL(0, gw.getHour());
|
BOOST_CHECK_EQUAL(0, gw.getHour());
|
||||||
BOOST_CHECK_EQUAL(0, gw.getMinute());
|
BOOST_CHECK_EQUAL(0, gw.getMinute());
|
||||||
|
|
||||||
gw.offsetGameTime(8*60 + 25);
|
gw.offsetGameTime(8 * 60 + 25);
|
||||||
BOOST_CHECK_EQUAL(8, gw.getHour());
|
BOOST_CHECK_EQUAL(8, gw.getHour());
|
||||||
BOOST_CHECK_EQUAL(25, gw.getMinute());
|
BOOST_CHECK_EQUAL(25, gw.getMinute());
|
||||||
|
|
||||||
gw.offsetGameTime(-30);
|
gw.offsetGameTime(-30);
|
||||||
BOOST_CHECK_EQUAL(7, gw.getHour());
|
BOOST_CHECK_EQUAL(7, gw.getHour());
|
||||||
BOOST_CHECK_EQUAL(55, gw.getMinute());
|
BOOST_CHECK_EQUAL(55, gw.getMinute());
|
||||||
|
|
||||||
gw.offsetGameTime(-24*60);
|
gw.offsetGameTime(-24 * 60);
|
||||||
BOOST_CHECK_EQUAL(7, gw.getHour());
|
BOOST_CHECK_EQUAL(7, gw.getHour());
|
||||||
BOOST_CHECK_EQUAL(55, gw.getMinute());
|
BOOST_CHECK_EQUAL(55, gw.getMinute());
|
||||||
|
|
||||||
gw.offsetGameTime(0);
|
gw.offsetGameTime(0);
|
||||||
BOOST_CHECK_EQUAL(7, gw.getHour());
|
BOOST_CHECK_EQUAL(7, gw.getHour());
|
||||||
BOOST_CHECK_EQUAL(55, gw.getMinute());
|
BOOST_CHECK_EQUAL(55, gw.getMinute());
|
||||||
|
|
||||||
gw.offsetGameTime(30*24*60 + 90);
|
gw.offsetGameTime(30 * 24 * 60 + 90);
|
||||||
BOOST_CHECK_EQUAL(9, gw.getHour());
|
BOOST_CHECK_EQUAL(9, gw.getHour());
|
||||||
BOOST_CHECK_EQUAL(25, gw.getMinute());
|
BOOST_CHECK_EQUAL(25, gw.getMinute());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2,37 +2,36 @@
|
|||||||
#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(
|
||||||
CallbackReceiver reciever([&](const Logger::LogMessage& m) { lastMessage = m; });
|
[&](const Logger::LogMessage& m) { lastMessage = m; });
|
||||||
|
|
||||||
log.addReciever(&reciever);
|
log.addReciever(&reciever);
|
||||||
|
|
||||||
log.info("Tests", "Test");
|
log.info("Tests", "Test");
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL( lastMessage.component, "Tests" );
|
BOOST_CHECK_EQUAL(lastMessage.component, "Tests");
|
||||||
BOOST_CHECK_EQUAL( lastMessage.severity, Logger::Info );
|
BOOST_CHECK_EQUAL(lastMessage.severity, Logger::Info);
|
||||||
BOOST_CHECK_EQUAL( lastMessage.message, "Test" );
|
BOOST_CHECK_EQUAL(lastMessage.message, "Test");
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
@ -6,19 +6,18 @@ 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>("") };
|
|
||||||
|
BOOST_CHECK_EQUAL(ref->resource, nullptr);
|
||||||
BOOST_CHECK_EQUAL( ref->resource, nullptr );
|
BOOST_CHECK_EQUAL(ref->state, RW::Loading);
|
||||||
BOOST_CHECK_EQUAL( ref->state, RW::Loading );
|
|
||||||
|
ref->state = RW::Loaded;
|
||||||
ref->state = RW::Loaded;
|
ref->resource = &resource;
|
||||||
ref->resource = &resource;
|
|
||||||
|
BOOST_CHECK_EQUAL(ref->resource, &resource);
|
||||||
BOOST_CHECK_EQUAL( ref->resource, &resource );
|
BOOST_CHECK_EQUAL(ref->state, RW::Loaded);
|
||||||
BOOST_CHECK_EQUAL( ref->state, RW::Loaded );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
@ -4,7 +4,7 @@
|
|||||||
#include <script/ScriptMachine.hpp>
|
#include <script/ScriptMachine.hpp>
|
||||||
#include <test_globals.hpp>
|
#include <test_globals.hpp>
|
||||||
|
|
||||||
#if 0 // Disabled until we make a start on saving the game
|
#if 0 // Disabled until we make a start on saving the game
|
||||||
BOOST_AUTO_TEST_SUITE(SaveGameTests)
|
BOOST_AUTO_TEST_SUITE(SaveGameTests)
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(test_write_state)
|
BOOST_AUTO_TEST_CASE(test_write_state)
|
||||||
|
@ -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()
|
||||||
|
|
||||||
|
@ -1,54 +1,54 @@
|
|||||||
#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. */
|
|
||||||
Global::get().e->data->loadDFF("player.dff");
|
|
||||||
ModelRef& test_model = Global::get().e->data->models["player"];
|
|
||||||
|
|
||||||
Animator animator(test_model->resource, &skeleton);
|
|
||||||
|
|
||||||
animation.duration = 1.f;
|
/** Models are currently needed to relate animation bones <=> model
|
||||||
animation.bones["player"] = new AnimationBone{
|
* frame #s. */
|
||||||
"player",
|
Global::get().e->data->loadDFF("player.dff");
|
||||||
0, 0, 1.0f,
|
ModelRef& test_model = Global::get().e->data->models["player"];
|
||||||
AnimationBone::RT0,
|
|
||||||
{
|
Animator animator(test_model->resource, &skeleton);
|
||||||
{
|
|
||||||
glm::quat(), glm::vec3(0.f, 0.f, 0.f), glm::vec3(), 0.f, 0
|
animation.duration = 1.f;
|
||||||
},
|
animation.bones["player"] = new AnimationBone{
|
||||||
{
|
"player",
|
||||||
glm::quat(), glm::vec3(0.f, 1.f, 0.f), glm::vec3(), 1.0f, 1
|
0,
|
||||||
},
|
0,
|
||||||
}
|
1.0f,
|
||||||
};
|
AnimationBone::RT0,
|
||||||
|
{
|
||||||
animator.playAnimation(0, &animation, 1.f, false);
|
{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},
|
||||||
animator.tick(0.0f);
|
}};
|
||||||
|
|
||||||
BOOST_CHECK( skeleton.getData(0).a.translation == glm::vec3(0.f, 0.f, 0.f) );
|
animator.playAnimation(0, &animation, 1.f, false);
|
||||||
BOOST_CHECK( skeleton.getData(0).b.translation == glm::vec3(0.f, 0.f, 0.f) );
|
|
||||||
|
animator.tick(0.0f);
|
||||||
animator.tick(1.0f);
|
|
||||||
|
BOOST_CHECK(skeleton.getData(0).a.translation ==
|
||||||
BOOST_CHECK( skeleton.getData(0).a.translation == glm::vec3(0.f, 1.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) );
|
BOOST_CHECK(skeleton.getData(0).b.translation ==
|
||||||
}
|
glm::vec3(0.f, 0.f, 0.f));
|
||||||
|
|
||||||
|
animator.tick(1.0f);
|
||||||
|
|
||||||
|
BOOST_CHECK(skeleton.getData(0).a.translation ==
|
||||||
|
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()
|
||||||
|
|
||||||
|
@ -1,33 +1,32 @@
|
|||||||
#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_CHECK( archive.getAssetCount() > 0 );
|
|
||||||
|
|
||||||
LoaderIMGFile f, f2;
|
BOOST_REQUIRE(archive.load(Global::getGamePath() + "/models/gta3"));
|
||||||
|
|
||||||
f = archive.getAssetInfoByIndex(0);
|
BOOST_CHECK(archive.getAssetCount() > 0);
|
||||||
|
|
||||||
// A few assumptions..
|
LoaderIMGFile f, f2;
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL( f.name, "radar00.txd" );
|
f = archive.getAssetInfoByIndex(0);
|
||||||
BOOST_CHECK_EQUAL( f.offset, 0);
|
|
||||||
BOOST_CHECK_EQUAL( f.size, 33);
|
// A few assumptions..
|
||||||
|
|
||||||
BOOST_CHECK( archive.findAssetInfo("radar00.txd", f2) );
|
BOOST_CHECK_EQUAL(f.name, "radar00.txd");
|
||||||
|
BOOST_CHECK_EQUAL(f.offset, 0);
|
||||||
BOOST_CHECK_EQUAL( f2.name, f.name );
|
BOOST_CHECK_EQUAL(f.size, 33);
|
||||||
BOOST_CHECK_EQUAL( f2.offset, f.offset );
|
|
||||||
BOOST_CHECK_EQUAL( f2.size, f.size );
|
BOOST_CHECK(archive.findAssetInfo("radar00.txd", f2));
|
||||||
|
|
||||||
|
BOOST_CHECK_EQUAL(f2.name, f.name);
|
||||||
|
BOOST_CHECK_EQUAL(f2.offset, f.offset);
|
||||||
|
BOOST_CHECK_EQUAL(f2.size, f.size);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,63 +1,62 @@
|
|||||||
#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(
|
||||||
VehicleObject* vehicle = Global::get().e->createVehicle(90u, glm::vec3(tpos, 100.f), glm::quat());
|
90u, glm::vec3(tpos, 100.f), glm::quat());
|
||||||
|
|
||||||
BOOST_REQUIRE(vehicle != nullptr);
|
BOOST_REQUIRE(vehicle != nullptr);
|
||||||
|
|
||||||
BOOST_REQUIRE(vehicle->info != nullptr);
|
BOOST_REQUIRE(vehicle->info != nullptr);
|
||||||
BOOST_REQUIRE(vehicle->vehicle != nullptr);
|
BOOST_REQUIRE(vehicle->vehicle != nullptr);
|
||||||
|
|
||||||
// Relies on tile 0,0 being watered...
|
// Relies on tile 0,0 being watered...
|
||||||
|
|
||||||
BOOST_CHECK( ! vehicle->isInWater() );
|
BOOST_CHECK(!vehicle->isInWater());
|
||||||
|
|
||||||
// Move it under the water
|
// Move it under the water
|
||||||
vehicle->setPosition(glm::vec3(tpos, -5.f));
|
vehicle->setPosition(glm::vec3(tpos, -5.f));
|
||||||
|
|
||||||
// Allow the object to update
|
// Allow the object to update
|
||||||
vehicle->tickPhysics(0.0016f);
|
vehicle->tickPhysics(0.0016f);
|
||||||
|
|
||||||
BOOST_CHECK( vehicle->isInWater() );
|
BOOST_CHECK(vehicle->isInWater());
|
||||||
|
|
||||||
// Ensure that the in water state sticks
|
// Ensure that the in water state sticks
|
||||||
vehicle->tickPhysics(0.0016f);
|
vehicle->tickPhysics(0.0016f);
|
||||||
|
|
||||||
BOOST_CHECK( vehicle->isInWater() );
|
BOOST_CHECK(vehicle->isInWater());
|
||||||
|
|
||||||
vehicle->setPosition(glm::vec3(tpos, 5.f));
|
vehicle->setPosition(glm::vec3(tpos, 5.f));
|
||||||
vehicle->tickPhysics(0.0016f);
|
vehicle->tickPhysics(0.0016f);
|
||||||
BOOST_CHECK( ! vehicle->isInWater() );
|
BOOST_CHECK(!vehicle->isInWater());
|
||||||
|
|
||||||
// TODO: fix magic numbers
|
// TODO: fix magic numbers
|
||||||
auto orgval = Global::get().e->data->realWater[0];
|
auto orgval = Global::get().e->data->realWater[0];
|
||||||
Global::get().e->data->realWater[0] = NO_WATER_INDEX;
|
Global::get().e->data->realWater[0] = NO_WATER_INDEX;
|
||||||
|
|
||||||
vehicle->tickPhysics(0.0016f);
|
vehicle->tickPhysics(0.0016f);
|
||||||
BOOST_CHECK( ! vehicle->isInWater() );
|
BOOST_CHECK(!vehicle->isInWater());
|
||||||
|
|
||||||
vehicle->setPosition(glm::vec3(tpos, -5.f));
|
vehicle->setPosition(glm::vec3(tpos, -5.f));
|
||||||
|
|
||||||
vehicle->tickPhysics(0.0016f);
|
vehicle->tickPhysics(0.0016f);
|
||||||
BOOST_CHECK( ! vehicle->isInWater() );
|
BOOST_CHECK(!vehicle->isInWater());
|
||||||
|
|
||||||
Global::get().e->data->realWater[0] = orgval;
|
Global::get().e->data->realWater[0] = orgval;
|
||||||
|
|
||||||
vehicle->tickPhysics(0.0016f);
|
vehicle->tickPhysics(0.0016f);
|
||||||
BOOST_CHECK( ! vehicle->isInWater() );
|
BOOST_CHECK(!vehicle->isInWater());
|
||||||
|
|
||||||
Global::get().e->destroyObject(vehicle);
|
Global::get().e->destroyObject(vehicle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
|
@ -1,150 +1,151 @@
|
|||||||
|
#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.
|
||||||
|
BOOST_CHECK_EQUAL(controller->getCurrentActivity(), nullptr);
|
||||||
|
|
||||||
// Check the initial activity is Idle.
|
// Check that Idle activities are instantly displaced.
|
||||||
BOOST_CHECK_EQUAL( controller->getCurrentActivity(), nullptr );
|
controller->setNextActivity(
|
||||||
|
new Activities::GoTo(glm::vec3{1000.f, 0.f, 0.f}));
|
||||||
|
|
||||||
// Check that Idle activities are instantly displaced.
|
BOOST_CHECK_EQUAL(controller->getCurrentActivity()->name(), "GoTo");
|
||||||
controller->setNextActivity( new Activities::GoTo( glm::vec3{ 1000.f, 0.f, 0.f } ) );
|
BOOST_CHECK_EQUAL(controller->getNextActivity(), nullptr);
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL( controller->getCurrentActivity()->name(), "GoTo" );
|
Global::get().e->destroyObject(character);
|
||||||
BOOST_CHECK_EQUAL( controller->getNextActivity(), nullptr );
|
delete controller;
|
||||||
|
}
|
||||||
Global::get().e->destroyObject(character);
|
|
||||||
delete controller;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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");
|
||||||
|
|
||||||
for(float t = 0.f; t < 11.5f; t+=(1.f/60.f)) {
|
for (float t = 0.f; t < 11.5f; t += (1.f / 60.f)) {
|
||||||
controller->update(1.f/60.f);
|
controller->update(1.f / 60.f);
|
||||||
character->tick(1.f/60.f);
|
character->tick(1.f / 60.f);
|
||||||
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(
|
||||||
BOOST_REQUIRE(vehicle != nullptr);
|
90u, glm::vec3(10.f, 0.f, 0.f), glm::quat());
|
||||||
BOOST_REQUIRE(vehicle->model != nullptr);
|
BOOST_REQUIRE(vehicle != nullptr);
|
||||||
|
BOOST_REQUIRE(vehicle->model != nullptr);
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
auto controller = new DefaultAIController(character);
|
auto controller = new DefaultAIController(character);
|
||||||
|
|
||||||
controller->setNextActivity( new Activities::EnterVehicle( vehicle, 0 ) );
|
controller->setNextActivity(new Activities::EnterVehicle(vehicle, 0));
|
||||||
|
|
||||||
for(float t = 0.f; t < 0.5f; t+=(1.f/60.f)) {
|
for (float t = 0.f; t < 0.5f; t += (1.f / 60.f)) {
|
||||||
character->tick(1.f/60.f);
|
character->tick(1.f / 60.f);
|
||||||
Global::get().e->dynamicsWorld->stepSimulation(1.f/60.f);
|
Global::get().e->dynamicsWorld->stepSimulation(1.f / 60.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL( nullptr, character->getCurrentVehicle() );
|
BOOST_CHECK_EQUAL(nullptr, character->getCurrentVehicle());
|
||||||
|
|
||||||
for(float t = 0.f; t < 9.0f; t+=(1.f/60.f)) {
|
for (float t = 0.f; t < 9.0f; t += (1.f / 60.f)) {
|
||||||
character->tick(1.f/60.f);
|
character->tick(1.f / 60.f);
|
||||||
Global::get().e->dynamicsWorld->stepSimulation(1.f/60.f);
|
Global::get().e->dynamicsWorld->stepSimulation(1.f / 60.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL( vehicle, character->getCurrentVehicle() );
|
BOOST_CHECK_EQUAL(vehicle, character->getCurrentVehicle());
|
||||||
|
|
||||||
controller->setNextActivity( new Activities::ExitVehicle( ) );
|
controller->setNextActivity(new Activities::ExitVehicle());
|
||||||
|
|
||||||
for(float t = 0.f; t < 9.0f; t+=(1.f/60.f)) {
|
for (float t = 0.f; t < 9.0f; t += (1.f / 60.f)) {
|
||||||
character->tick(1.f/60.f);
|
character->tick(1.f / 60.f);
|
||||||
Global::get().e->dynamicsWorld->stepSimulation(1.f/60.f);
|
Global::get().e->dynamicsWorld->stepSimulation(1.f / 60.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL( nullptr, character->getCurrentVehicle() );
|
BOOST_CHECK_EQUAL(nullptr, character->getCurrentVehicle());
|
||||||
|
|
||||||
character->setPosition(glm::vec3(5.f, 0.f, 0.f));
|
character->setPosition(glm::vec3(5.f, 0.f, 0.f));
|
||||||
controller->setNextActivity( new Activities::EnterVehicle( vehicle, 0 ) );
|
controller->setNextActivity(new Activities::EnterVehicle(vehicle, 0));
|
||||||
|
|
||||||
for(float t = 0.f; t < 0.5f; t+=(1.f/60.f)) {
|
for (float t = 0.f; t < 0.5f; t += (1.f / 60.f)) {
|
||||||
character->tick(1.f/60.f);
|
character->tick(1.f / 60.f);
|
||||||
Global::get().e->dynamicsWorld->stepSimulation(1.f/60.f);
|
Global::get().e->dynamicsWorld->stepSimulation(1.f / 60.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL( nullptr, character->getCurrentVehicle() );
|
BOOST_CHECK_EQUAL(nullptr, character->getCurrentVehicle());
|
||||||
controller->skipActivity();
|
controller->skipActivity();
|
||||||
|
|
||||||
for(float t = 0.f; t < 5.0f; t+=(1.f/60.f)) {
|
for (float t = 0.f; t < 5.0f; t += (1.f / 60.f)) {
|
||||||
character->tick(1.f/60.f);
|
character->tick(1.f / 60.f);
|
||||||
Global::get().e->dynamicsWorld->stepSimulation(1.f/60.f);
|
Global::get().e->dynamicsWorld->stepSimulation(1.f / 60.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL( nullptr, character->getCurrentVehicle() );
|
BOOST_CHECK_EQUAL(nullptr, character->getCurrentVehicle());
|
||||||
|
|
||||||
Global::get().e->destroyObject(character);
|
Global::get().e->destroyObject(character);
|
||||||
delete controller;
|
delete controller;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL( character->getCurrentState().health, 100.f );
|
BOOST_CHECK_EQUAL(character->getCurrentState().health, 100.f);
|
||||||
BOOST_CHECK( character->isAlive() );
|
BOOST_CHECK(character->isAlive());
|
||||||
|
|
||||||
GameObject::DamageInfo dmg;
|
GameObject::DamageInfo dmg;
|
||||||
dmg.type = GameObject::DamageInfo::Bullet;
|
dmg.type = GameObject::DamageInfo::Bullet;
|
||||||
dmg.hitpoints = character->getCurrentState().health + 1.f;
|
dmg.hitpoints = character->getCurrentState().health + 1.f;
|
||||||
|
|
||||||
// Do some damage
|
// Do some damage
|
||||||
BOOST_CHECK(character->takeDamage(dmg));
|
BOOST_CHECK(character->takeDamage(dmg));
|
||||||
|
|
||||||
BOOST_CHECK( ! character->isAlive() );
|
BOOST_CHECK(!character->isAlive());
|
||||||
|
|
||||||
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);
|
||||||
delete controller;
|
delete controller;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
#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(
|
||||||
BOOST_REQUIRE(ChaseKeyframe::load(Global::getGamePath() + "/data/paths/CHASE0.DAT", keyframes));
|
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);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,21 +1,20 @@
|
|||||||
#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"
|
<< "path=/dev/test" << std::endl;
|
||||||
<< "path=/dev/test" << std::endl;
|
|
||||||
|
|
||||||
GameConfig config("openrw_test.ini", "/tmp");
|
GameConfig config("openrw_test.ini", "/tmp");
|
||||||
|
|
||||||
BOOST_CHECK(config.isValid());
|
BOOST_CHECK(config.isValid());
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL(config.getGameDataPath(), "/dev/test");
|
BOOST_CHECK_EQUAL(config.getGameDataPath(), "/dev/test");
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
@ -6,28 +6,27 @@
|
|||||||
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");
|
|
||||||
|
|
||||||
CutsceneTracks tracks;
|
CutsceneTracks tracks;
|
||||||
|
|
||||||
LoaderCutsceneDAT loader;
|
LoaderCutsceneDAT loader;
|
||||||
|
|
||||||
loader.load( tracks, d );
|
loader.load(tracks, d);
|
||||||
|
|
||||||
BOOST_CHECK( tracks.position.find(0.f) != tracks.position.end() );
|
BOOST_CHECK(tracks.position.find(0.f) != tracks.position.end());
|
||||||
BOOST_CHECK( tracks.position.find(64.8f) != tracks.position.end() );
|
BOOST_CHECK(tracks.position.find(64.8f) != tracks.position.end());
|
||||||
|
|
||||||
BOOST_CHECK( tracks.zoom.find(64.8f) != tracks.zoom.end() );
|
BOOST_CHECK(tracks.zoom.find(64.8f) != tracks.zoom.end());
|
||||||
|
|
||||||
BOOST_CHECK( tracks.zoom.find(64.8f) != tracks.zoom.end() );
|
BOOST_CHECK(tracks.zoom.find(64.8f) != tracks.zoom.end());
|
||||||
|
|
||||||
BOOST_CHECK( tracks.target.find(64.8f) != tracks.target.end() );
|
BOOST_CHECK(tracks.target.find(64.8f) != tracks.target.end());
|
||||||
|
|
||||||
BOOST_CHECK( tracks.duration == 64.8f );
|
BOOST_CHECK(tracks.duration == 64.8f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -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,84 +9,80 @@
|
|||||||
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;
|
|
||||||
|
|
||||||
l.loadWeapons(Global::get().getGamePath() + "/data/weapon.dat", weaponData);
|
l.loadWeapons(Global::get().getGamePath() + "/data/weapon.dat", weaponData);
|
||||||
|
|
||||||
BOOST_ASSERT( weaponData.size() > 0 );
|
BOOST_ASSERT(weaponData.size() > 0);
|
||||||
|
|
||||||
WeaponDataPtr data = weaponData[0];
|
WeaponDataPtr data = weaponData[0];
|
||||||
|
|
||||||
BOOST_CHECK( data->fireType == WeaponData::MELEE );
|
|
||||||
BOOST_CHECK( data->hitRange == 2.8f );
|
|
||||||
BOOST_CHECK( data->fireRate == 750 );
|
|
||||||
BOOST_CHECK( data->reloadMS == 300 );
|
|
||||||
BOOST_CHECK( data->clipSize == 1000 );
|
|
||||||
BOOST_CHECK( data->damage == 8);
|
|
||||||
BOOST_CHECK( data->speed == -1.f);
|
|
||||||
BOOST_CHECK( data->meleeRadius == 0.5f );
|
|
||||||
BOOST_CHECK( data->lifeSpan == -1.0f );
|
|
||||||
BOOST_CHECK( data->spread == -1.0f );
|
|
||||||
BOOST_CHECK( data->fireOffset == glm::vec3(0.1f, 0.65f, 0.2f) );
|
|
||||||
BOOST_CHECK( data->animation1 == "fightppunch" );
|
|
||||||
BOOST_CHECK( data->animation2 == "kick_floor");
|
|
||||||
BOOST_CHECK( data->animLoopStart == 0 );
|
|
||||||
BOOST_CHECK( data->animLoopEnd == 99 );
|
|
||||||
BOOST_CHECK( data->animFirePoint == 12 );
|
|
||||||
BOOST_CHECK( data->animCrouchFirePoint == 12 );
|
|
||||||
BOOST_CHECK( data->modelID == -1 );
|
|
||||||
BOOST_CHECK( data->flags == 0) ;
|
|
||||||
|
|
||||||
|
BOOST_CHECK(data->fireType == WeaponData::MELEE);
|
||||||
|
BOOST_CHECK(data->hitRange == 2.8f);
|
||||||
|
BOOST_CHECK(data->fireRate == 750);
|
||||||
|
BOOST_CHECK(data->reloadMS == 300);
|
||||||
|
BOOST_CHECK(data->clipSize == 1000);
|
||||||
|
BOOST_CHECK(data->damage == 8);
|
||||||
|
BOOST_CHECK(data->speed == -1.f);
|
||||||
|
BOOST_CHECK(data->meleeRadius == 0.5f);
|
||||||
|
BOOST_CHECK(data->lifeSpan == -1.0f);
|
||||||
|
BOOST_CHECK(data->spread == -1.0f);
|
||||||
|
BOOST_CHECK(data->fireOffset == glm::vec3(0.1f, 0.65f, 0.2f));
|
||||||
|
BOOST_CHECK(data->animation1 == "fightppunch");
|
||||||
|
BOOST_CHECK(data->animation2 == "kick_floor");
|
||||||
|
BOOST_CHECK(data->animLoopStart == 0);
|
||||||
|
BOOST_CHECK(data->animLoopEnd == 99);
|
||||||
|
BOOST_CHECK(data->animFirePoint == 12);
|
||||||
|
BOOST_CHECK(data->animCrouchFirePoint == 12);
|
||||||
|
BOOST_CHECK(data->modelID == -1);
|
||||||
|
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);
|
||||||
|
|
||||||
BOOST_ASSERT( loaded.find("wastebin") != loaded.end() );
|
BOOST_ASSERT(loaded.find("wastebin") != loaded.end());
|
||||||
BOOST_ASSERT( loaded.find("lamppost1") != loaded.end() );
|
BOOST_ASSERT(loaded.find("lamppost1") != loaded.end());
|
||||||
|
|
||||||
DynamicObjectDataPtr lamp = loaded["lamppost1"];
|
DynamicObjectDataPtr lamp = loaded["lamppost1"];
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL( lamp->mass, 600.0);
|
BOOST_CHECK_EQUAL(lamp->mass, 600.0);
|
||||||
BOOST_CHECK_EQUAL( lamp->turnMass, 4000.0);
|
BOOST_CHECK_EQUAL(lamp->turnMass, 4000.0);
|
||||||
BOOST_CHECK_CLOSE( lamp->airRes, 0.99, 1.0);
|
BOOST_CHECK_CLOSE(lamp->airRes, 0.99, 1.0);
|
||||||
BOOST_CHECK_CLOSE( lamp->elacticity, 0.05, 0.01);
|
BOOST_CHECK_CLOSE(lamp->elacticity, 0.05, 0.01);
|
||||||
BOOST_CHECK_EQUAL( lamp->bouancy, 50.0);
|
BOOST_CHECK_EQUAL(lamp->bouancy, 50.0);
|
||||||
BOOST_CHECK_EQUAL( lamp->uprootForce, 400);
|
BOOST_CHECK_EQUAL(lamp->uprootForce, 400);
|
||||||
BOOST_CHECK_EQUAL( lamp->collDamageMulti, 1.0);
|
BOOST_CHECK_EQUAL(lamp->collDamageMulti, 1.0);
|
||||||
BOOST_CHECK_EQUAL( lamp->collDamageFlags, 1);
|
BOOST_CHECK_EQUAL(lamp->collDamageFlags, 1);
|
||||||
BOOST_CHECK_EQUAL( lamp->collResponseFlags, 1);
|
BOOST_CHECK_EQUAL(lamp->collResponseFlags, 1);
|
||||||
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;
|
|
||||||
|
|
||||||
l.loadHandling(Global::get().getGamePath() + "/data/handling.cfg", loaded);
|
l.loadHandling(Global::get().getGamePath() + "/data/handling.cfg", loaded);
|
||||||
|
|
||||||
BOOST_ASSERT( loaded.size() > 0 );
|
BOOST_ASSERT(loaded.size() > 0);
|
||||||
BOOST_ASSERT( loaded.find("STINGER") != loaded.end() );
|
BOOST_ASSERT(loaded.find("STINGER") != loaded.end());
|
||||||
|
|
||||||
VehicleInfoPtr info = loaded["STINGER"];
|
VehicleInfoPtr info = loaded["STINGER"];
|
||||||
VehicleHandlingInfo& handling = info->handling;
|
VehicleHandlingInfo& handling = info->handling;
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL( handling.mass, 1000.0 );
|
BOOST_CHECK_EQUAL(handling.mass, 1000.0);
|
||||||
BOOST_CHECK_EQUAL( handling.flags, 0xA182 );
|
BOOST_CHECK_EQUAL(handling.flags, 0xA182);
|
||||||
BOOST_CHECK_EQUAL( handling.driveType, VehicleHandlingInfo::All );
|
BOOST_CHECK_EQUAL(handling.driveType, VehicleHandlingInfo::All);
|
||||||
BOOST_CHECK_EQUAL( handling.engineType, VehicleHandlingInfo::Petrol );
|
BOOST_CHECK_EQUAL(handling.engineType, VehicleHandlingInfo::Petrol);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
|
@ -1,117 +1,123 @@
|
|||||||
#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);
|
||||||
|
|
||||||
// Boost moved the print_log_value struct in version 1.59
|
// Boost moved the print_log_value struct in version 1.59
|
||||||
// TODO: use another testing library
|
// TODO: use another testing library
|
||||||
#if BOOST_VERSION >= 105900
|
#if BOOST_VERSION >= 105900
|
||||||
#define BOOST_NS_MAGIC namespace tt_detail {
|
#define BOOST_NS_MAGIC namespace tt_detail {
|
||||||
#define BOOST_NS_MAGIC_CLOSING }
|
#define BOOST_NS_MAGIC_CLOSING }
|
||||||
#else
|
#else
|
||||||
#define BOOST_NS_MAGIC
|
#define BOOST_NS_MAGIC
|
||||||
#define BOOST_NS_MAGIC_CLOSING
|
#define BOOST_NS_MAGIC_CLOSING
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace boost { namespace test_tools { BOOST_NS_MAGIC
|
namespace boost {
|
||||||
template<>
|
namespace test_tools {
|
||||||
|
BOOST_NS_MAGIC
|
||||||
|
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 {
|
||||||
template<>
|
namespace test_tools {
|
||||||
|
BOOST_NS_MAGIC
|
||||||
|
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 {
|
||||||
template<>
|
namespace test_tools {
|
||||||
|
BOOST_NS_MAGIC
|
||||||
|
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
|
||||||
GameData* d;
|
GameData* d;
|
||||||
GameWorld* e;
|
GameWorld* e;
|
||||||
GameState* s;
|
GameState* s;
|
||||||
Logger log;
|
Logger log;
|
||||||
WorkContext work;
|
WorkContext work;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Global() {
|
Global() {
|
||||||
if (SDL_Init(SDL_INIT_VIDEO) < 0)
|
if (SDL_Init(SDL_INIT_VIDEO) < 0)
|
||||||
throw std::runtime_error("Failed to initialize SDL2!");
|
throw std::runtime_error("Failed to initialize SDL2!");
|
||||||
|
|
||||||
window.create("Tests", 800, 600, false);
|
window.create("Tests", 800, 600, false);
|
||||||
window.hideCursor();
|
window.hideCursor();
|
||||||
|
|
||||||
#if RW_TEST_WITH_DATA
|
#if RW_TEST_WITH_DATA
|
||||||
d = new GameData(&log, &work, getGamePath());
|
d = new GameData(&log, &work, getGamePath());
|
||||||
|
|
||||||
d->load();
|
d->load();
|
||||||
|
|
||||||
e = new GameWorld(&log, &work, d);
|
e = new GameWorld(&log, &work, d);
|
||||||
s = new GameState;
|
s = new GameState;
|
||||||
e->state = s;
|
e->state = s;
|
||||||
|
|
||||||
e->dynamicsWorld->setGravity(btVector3(0.f, 0.f, 0.f));
|
e->dynamicsWorld->setGravity(btVector3(0.f, 0.f, 0.f));
|
||||||
|
|
||||||
while( ! e->_work->isEmpty() ) {
|
while (!e->_work->isEmpty()) {
|
||||||
std::this_thread::yield();
|
std::this_thread::yield();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
~Global() {
|
~Global() {
|
||||||
window.close();
|
window.close();
|
||||||
#if RW_TEST_WITH_DATA
|
#if RW_TEST_WITH_DATA
|
||||||
delete e;
|
delete e;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#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;
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -6,35 +6,33 @@
|
|||||||
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 );
|
|
||||||
|
|
||||||
auto item = Global::get().e->getInventoryItem(4);
|
auto item = Global::get().e->getInventoryItem(4);
|
||||||
auto fist = Global::get().e->getInventoryItem(0);
|
auto fist = Global::get().e->getInventoryItem(0);
|
||||||
|
|
||||||
BOOST_REQUIRE(item != nullptr);
|
BOOST_REQUIRE(item != nullptr);
|
||||||
BOOST_REQUIRE(fist != nullptr );
|
BOOST_REQUIRE(fist != nullptr);
|
||||||
BOOST_CHECK_NE( fist, item );
|
BOOST_CHECK_NE(fist, item);
|
||||||
|
|
||||||
character->addToInventory(item);
|
character->addToInventory(item);
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL( character->getActiveItem(), fist );
|
BOOST_CHECK_EQUAL(character->getActiveItem(), fist);
|
||||||
|
|
||||||
character->setActiveItem( item->getInventorySlot() );
|
character->setActiveItem(item->getInventorySlot());
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL( character->getActiveItem(), item );
|
BOOST_CHECK_EQUAL(character->getActiveItem(), item);
|
||||||
|
|
||||||
character->removeFromInventory( item->getInventorySlot() );
|
character->removeFromInventory(item->getInventorySlot());
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL( character->getActiveItem(), fist );
|
BOOST_CHECK_EQUAL(character->getActiveItem(), fist);
|
||||||
|
|
||||||
Global::get().e->destroyObject(character);
|
Global::get().e->destroyObject(character);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
|
@ -7,27 +7,27 @@
|
|||||||
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;
|
||||||
|
|
||||||
f->setLifetime(GameObject::TrafficLifetime);
|
f->setLifetime(GameObject::TrafficLifetime);
|
||||||
|
|
||||||
{
|
{
|
||||||
auto search = objects.find(id);
|
auto search = objects.find(id);
|
||||||
BOOST_CHECK( search != objects.end() );
|
BOOST_CHECK(search != objects.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewCamera testCamera;
|
ViewCamera testCamera;
|
||||||
testCamera.position = glm::vec3(0.f, 0.f, 0.f);
|
testCamera.position = glm::vec3(0.f, 0.f, 0.f);
|
||||||
Global::get().e->cleanupTraffic(testCamera);
|
Global::get().e->cleanupTraffic(testCamera);
|
||||||
|
|
||||||
{
|
{
|
||||||
auto search = objects.find(id);
|
auto search = objects.find(id);
|
||||||
BOOST_CHECK( search != objects.end() );
|
BOOST_CHECK(search != objects.end());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,69 +1,67 @@
|
|||||||
#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");
|
|
||||||
|
|
||||||
LoaderDFF loader;
|
LoaderDFF loader;
|
||||||
|
|
||||||
Model* m = loader.loadFromMemory(d);
|
Model* m = loader.loadFromMemory(d);
|
||||||
|
|
||||||
BOOST_REQUIRE( m != nullptr );
|
BOOST_REQUIRE(m != nullptr);
|
||||||
|
|
||||||
BOOST_REQUIRE_EQUAL( m->frames.size(), 40 );
|
BOOST_REQUIRE_EQUAL(m->frames.size(), 40);
|
||||||
|
|
||||||
BOOST_REQUIRE_EQUAL( m->geometries.size(), 16 );
|
BOOST_REQUIRE_EQUAL(m->geometries.size(), 16);
|
||||||
|
|
||||||
BOOST_REQUIRE_EQUAL( m->geometries[0]->subgeom.size(), 5 );
|
BOOST_REQUIRE_EQUAL(m->geometries[0]->subgeom.size(), 5);
|
||||||
|
|
||||||
for(auto& g : m->geometries) {
|
for (auto& g : m->geometries) {
|
||||||
BOOST_CHECK_GT( g->geometryBounds.radius, 0.f );
|
BOOST_CHECK_GT(g->geometryBounds.radius, 0.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_REQUIRE( m->atomics.size() > 0 );
|
BOOST_REQUIRE(m->atomics.size() > 0);
|
||||||
|
|
||||||
for(Model::Atomic& a : m->atomics) {
|
for (Model::Atomic& a : m->atomics) {
|
||||||
BOOST_CHECK( a.frame < m->frames.size() );
|
BOOST_CHECK(a.frame < m->frames.size());
|
||||||
BOOST_CHECK( a.geometry < m->geometries.size() );
|
BOOST_CHECK(a.geometry < m->geometries.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
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 job = new BackgroundLoaderJob<Model, LoaderDFF>{ &ctx, index, "landstal.dff", modelRef };
|
|
||||||
|
|
||||||
ctx.queueJob(job);
|
auto index = &Global::get().e->data->index;
|
||||||
|
auto job = new BackgroundLoaderJob<Model, LoaderDFF>{
|
||||||
|
&ctx, index, "landstal.dff", modelRef};
|
||||||
|
|
||||||
while( modelRef->state == RW::Loading ) {
|
ctx.queueJob(job);
|
||||||
ctx.update();
|
|
||||||
std::this_thread::yield();
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_REQUIRE( modelRef->resource != nullptr );
|
while (modelRef->state == RW::Loading) {
|
||||||
|
ctx.update();
|
||||||
|
std::this_thread::yield();
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_CHECK( modelRef->resource->frames.size() > 0 );
|
BOOST_REQUIRE(modelRef->resource != nullptr);
|
||||||
|
|
||||||
delete modelRef->resource;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
BOOST_CHECK(modelRef->resource->frames.size() > 0);
|
||||||
|
|
||||||
|
delete modelRef->resource;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,97 +1,93 @@
|
|||||||
|
#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; }));
|
|
||||||
|
BOOST_CHECK(!clickered);
|
||||||
BOOST_CHECK(! clickered );
|
|
||||||
|
// Click underneath the menu item.
|
||||||
// Click underneath the menu item.
|
test.click(0.f, -1.f);
|
||||||
test.click(0.f, -1.f);
|
|
||||||
|
BOOST_CHECK(!clickered);
|
||||||
BOOST_CHECK(! clickered );
|
|
||||||
|
float h = test.entries.at(0)->getHeight();
|
||||||
float h = test.entries.at(0)->getHeight();
|
|
||||||
|
test.click(0.f, h + 1.f);
|
||||||
test.click(0.f, h + 1.f);
|
|
||||||
|
BOOST_CHECK(!clickered);
|
||||||
BOOST_CHECK(! clickered );
|
|
||||||
|
test.click(0.f, h / 2.f);
|
||||||
test.click(0.f, h / 2.f);
|
|
||||||
|
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);
|
test.addEntry(Menu::lambda("Test", [&] { clickered = true; }));
|
||||||
test.addEntry(Menu::lambda("Test", [&]{ clickered = true; }));
|
|
||||||
|
BOOST_CHECK(!clickered);
|
||||||
BOOST_CHECK(! clickered );
|
|
||||||
|
// Click underneath the menu item.
|
||||||
// Click underneath the menu item.
|
test.click(201.f, -1.f);
|
||||||
test.click(201.f, -1.f);
|
|
||||||
|
BOOST_CHECK(!clickered);
|
||||||
BOOST_CHECK(! clickered );
|
|
||||||
|
float h = test.entries.at(0)->getHeight();
|
||||||
float h = test.entries.at(0)->getHeight();
|
|
||||||
|
test.click(201.f, 200.f + h + 1.f);
|
||||||
test.click(201.f, 200.f + h + 1.f);
|
|
||||||
|
BOOST_CHECK(!clickered);
|
||||||
BOOST_CHECK(! clickered );
|
|
||||||
|
test.click(201.f, 200.f + h / 2.f);
|
||||||
test.click(201.f, 200.f + h / 2.f);
|
|
||||||
|
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; }));
|
test.addEntry(Menu::lambda("Test2", [&] { clickindex = 1; }));
|
||||||
test.addEntry(Menu::lambda("Test2", [&]{ clickindex = 1; }));
|
|
||||||
|
test.activate();
|
||||||
test.activate();
|
|
||||||
|
BOOST_CHECK(clickindex == -1);
|
||||||
BOOST_CHECK( clickindex == -1 );
|
|
||||||
|
test.move(1);
|
||||||
test.move( 1);
|
test.activate();
|
||||||
test.activate();
|
|
||||||
|
BOOST_CHECK(clickindex == 0);
|
||||||
BOOST_CHECK( clickindex == 0 );
|
|
||||||
|
test.move(1);
|
||||||
test.move( 1);
|
test.activate();
|
||||||
test.activate();
|
|
||||||
|
BOOST_CHECK(clickindex == 1);
|
||||||
BOOST_CHECK( clickindex == 1 );
|
|
||||||
|
test.move(-1);
|
||||||
test.move(-1);
|
test.activate();
|
||||||
test.activate();
|
|
||||||
|
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; }));
|
test.addEntry(Menu::lambda("Test2", [&] { clickindex = 1; }));
|
||||||
test.addEntry(Menu::lambda("Test2", [&]{ clickindex = 1; }));
|
|
||||||
|
test.hover(0.f, test.entries[0]->getHeight() - 0.1f);
|
||||||
test.hover(0.f, test.entries[0]->getHeight() - 0.1f);
|
BOOST_CHECK(test.activeEntry == 0);
|
||||||
BOOST_CHECK( test.activeEntry == 0 );
|
|
||||||
|
test.hover(0.f, test.entries[0]->getHeight() + 0.1f);
|
||||||
test.hover(0.f, test.entries[0]->getHeight() + 0.1f);
|
BOOST_CHECK(test.activeEntry == 1);
|
||||||
BOOST_CHECK( test.activeEntry == 1 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#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)
|
||||||
|
|
||||||
#if 0 // Tests disabled as object damage logic is unclear
|
#if 0 // Tests disabled as object damage logic is unclear
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(instance_test_damage)
|
BOOST_AUTO_TEST_CASE(instance_test_damage)
|
||||||
{
|
{
|
||||||
|
@ -5,55 +5,52 @@
|
|||||||
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;
|
|
||||||
|
|
||||||
l.load(Global::get().getGamePath() + "/data/maps/generic.ide");
|
l.load(Global::get().getGamePath() + "/data/maps/generic.ide");
|
||||||
|
|
||||||
BOOST_ASSERT( l.objects.find(1100) != l.objects.end() );
|
BOOST_ASSERT(l.objects.find(1100) != l.objects.end());
|
||||||
|
|
||||||
auto obj = l.objects[1100];
|
auto obj = l.objects[1100];
|
||||||
|
|
||||||
auto def = std::dynamic_pointer_cast<ObjectData>(obj);
|
auto def = std::dynamic_pointer_cast<ObjectData>(obj);
|
||||||
|
|
||||||
BOOST_ASSERT(def->class_type == ObjectInformation::_class("OBJS"));
|
BOOST_ASSERT(def->class_type == ObjectInformation::_class("OBJS"));
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL( def->modelName, "rd_Corner1" );
|
BOOST_CHECK_EQUAL(def->modelName, "rd_Corner1");
|
||||||
BOOST_CHECK_EQUAL( def->textureName, "generic" );
|
BOOST_CHECK_EQUAL(def->textureName, "generic");
|
||||||
BOOST_CHECK_EQUAL( def->numClumps, 1 );
|
BOOST_CHECK_EQUAL(def->numClumps, 1);
|
||||||
BOOST_CHECK_EQUAL( def->drawDistance[0], 220 );
|
BOOST_CHECK_EQUAL(def->drawDistance[0], 220);
|
||||||
BOOST_CHECK_EQUAL( def->flags, 0 );
|
BOOST_CHECK_EQUAL(def->flags, 0);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
LoaderIDE l;
|
LoaderIDE l;
|
||||||
|
|
||||||
l.load(Global::get().getGamePath() + "/data/default.ide");
|
l.load(Global::get().getGamePath() + "/data/default.ide");
|
||||||
|
|
||||||
BOOST_ASSERT( l.objects.find(90) != l.objects.end() );
|
BOOST_ASSERT(l.objects.find(90) != l.objects.end());
|
||||||
|
|
||||||
auto obj = l.objects[90];
|
auto obj = l.objects[90];
|
||||||
|
|
||||||
auto def = std::dynamic_pointer_cast<VehicleData>(obj);
|
auto def = std::dynamic_pointer_cast<VehicleData>(obj);
|
||||||
|
|
||||||
BOOST_ASSERT(def->class_type == ObjectInformation::_class("CARS"));
|
BOOST_ASSERT(def->class_type == ObjectInformation::_class("CARS"));
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL( def->modelName, "landstal");
|
BOOST_CHECK_EQUAL(def->modelName, "landstal");
|
||||||
BOOST_CHECK_EQUAL( def->textureName, "landstal" );
|
BOOST_CHECK_EQUAL(def->textureName, "landstal");
|
||||||
BOOST_CHECK_EQUAL( def->type, VehicleData::CAR );
|
BOOST_CHECK_EQUAL(def->type, VehicleData::CAR);
|
||||||
BOOST_CHECK_EQUAL( def->handlingID, "LANDSTAL" );
|
BOOST_CHECK_EQUAL(def->handlingID, "LANDSTAL");
|
||||||
BOOST_CHECK_EQUAL( def->gameName, "LANDSTK" );
|
BOOST_CHECK_EQUAL(def->gameName, "LANDSTK");
|
||||||
BOOST_CHECK_EQUAL( def->classType, VehicleData::RICHFAMILY );
|
BOOST_CHECK_EQUAL(def->classType, VehicleData::RICHFAMILY);
|
||||||
BOOST_CHECK_EQUAL( def->frequency, 10 );
|
BOOST_CHECK_EQUAL(def->frequency, 10);
|
||||||
BOOST_CHECK_EQUAL( def->wheelModelID, 164 );
|
BOOST_CHECK_EQUAL(def->wheelModelID, 164);
|
||||||
BOOST_CHECK_CLOSE( def->wheelScale, 0.8f, 0.01f);
|
BOOST_CHECK_CLOSE(def->wheelScale, 0.8f, 0.01f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(test_gamedata_data)
|
BOOST_AUTO_TEST_CASE(test_gamedata_data) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,97 +1,97 @@
|
|||||||
#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;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
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});
|
||||||
|
|
||||||
//Global::get().e->insertObject(p);
|
// Global::get().e->insertObject(p);
|
||||||
|
|
||||||
BOOST_CHECK( ! p->picked_up );
|
BOOST_CHECK(!p->picked_up);
|
||||||
|
|
||||||
Global::get().e->dynamicsWorld->stepSimulation(0.016f);
|
Global::get().e->dynamicsWorld->stepSimulation(0.016f);
|
||||||
p->tick(0.f);
|
p->tick(0.f);
|
||||||
|
|
||||||
BOOST_CHECK( p->picked_up );
|
BOOST_CHECK(p->picked_up);
|
||||||
|
|
||||||
p->picked_up = false;
|
p->picked_up = false;
|
||||||
|
|
||||||
BOOST_CHECK( ! p->picked_up );
|
BOOST_CHECK(!p->picked_up);
|
||||||
|
|
||||||
Global::get().e->dynamicsWorld->stepSimulation(0.016f);
|
Global::get().e->dynamicsWorld->stepSimulation(0.016f);
|
||||||
p->tick(0.f);
|
p->tick(0.f);
|
||||||
|
|
||||||
BOOST_CHECK( ! p->picked_up );
|
BOOST_CHECK(!p->picked_up);
|
||||||
|
|
||||||
Global::get().e->dynamicsWorld->stepSimulation(0.016f);
|
Global::get().e->dynamicsWorld->stepSimulation(0.016f);
|
||||||
p->tick(60.5f);
|
p->tick(60.5f);
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
// Check the characters inventory is empty.
|
// Check the characters inventory is empty.
|
||||||
for (int i = 0; i < maxInventorySlots; ++i) {
|
for (int i = 0; i < maxInventorySlots; ++i) {
|
||||||
BOOST_CHECK( character->getCurrentState().weapons[i].weaponId == 0 );
|
BOOST_CHECK(character->getCurrentState().weapons[i].weaponId == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Global::get().e->dynamicsWorld->stepSimulation(0.016f);
|
Global::get().e->dynamicsWorld->stepSimulation(0.016f);
|
||||||
p->tick(0.f);
|
p->tick(0.f);
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
|
@ -1,28 +1,27 @@
|
|||||||
#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);
|
|
||||||
|
|
||||||
f.update(f.projection());
|
f.update(f.projection());
|
||||||
|
|
||||||
BOOST_CHECK( f.intersects({10.f, 0.f,-10.f}, 1.f ) );
|
BOOST_CHECK(f.intersects({10.f, 0.f, -10.f}, 1.f));
|
||||||
BOOST_CHECK(!f.intersects({ 0.f, 0.f, 10.f}, 1.f ) );
|
BOOST_CHECK(!f.intersects({0.f, 0.f, 10.f}, 1.f));
|
||||||
|
|
||||||
BOOST_CHECK(!f.intersects({0.f, 10.f, 0.f}, 1.f ) );
|
BOOST_CHECK(!f.intersects({0.f, 10.f, 0.f}, 1.f));
|
||||||
BOOST_CHECK(!f.intersects({0.f,-10.f, 0.f}, 1.f ) );
|
BOOST_CHECK(!f.intersects({0.f, -10.f, 0.f}, 1.f));
|
||||||
|
|
||||||
BOOST_CHECK(!f.intersects({ 10.f, 0.f, 0.f}, 1.f ) );
|
BOOST_CHECK(!f.intersects({10.f, 0.f, 0.f}, 1.f));
|
||||||
BOOST_CHECK(!f.intersects({-10.f, 0.f, 0.f}, 1.f ) );
|
BOOST_CHECK(!f.intersects({-10.f, 0.f, 0.f}, 1.f));
|
||||||
|
|
||||||
BOOST_CHECK( f.intersects({ 10.f, 0.f,-10.f}, 1.f ) );
|
BOOST_CHECK(f.intersects({10.f, 0.f, -10.f}, 1.f));
|
||||||
BOOST_CHECK( f.intersects({-10.f, 0.f,-10.f}, 1.f ) );
|
BOOST_CHECK(f.intersects({-10.f, 0.f, -10.f}, 1.f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
@ -1,32 +1,31 @@
|
|||||||
#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");
|
|
||||||
|
|
||||||
RWBStream stream(d->data, d->length);
|
|
||||||
|
|
||||||
RWBStream::ChunkID id = stream.getNextChunk();
|
|
||||||
|
|
||||||
BOOST_REQUIRE_EQUAL( id, 0x0010 );
|
RWBStream stream(d->data, d->length);
|
||||||
|
|
||||||
auto inner = stream.getInnerStream();
|
RWBStream::ChunkID id = stream.getNextChunk();
|
||||||
|
|
||||||
auto inner1 = inner.getNextChunk();
|
BOOST_REQUIRE_EQUAL(id, 0x0010);
|
||||||
|
|
||||||
BOOST_REQUIRE_EQUAL( inner1, 0x0001 );
|
auto inner = stream.getInnerStream();
|
||||||
|
|
||||||
auto innerCursor = inner.getCursor();
|
auto inner1 = inner.getNextChunk();
|
||||||
|
|
||||||
// This is a value inside in the Clump's struct header section.
|
BOOST_REQUIRE_EQUAL(inner1, 0x0001);
|
||||||
BOOST_CHECK_EQUAL( *(std::uint32_t*)innerCursor, 0x10 );
|
|
||||||
}
|
auto innerCursor = inner.getCursor();
|
||||||
|
|
||||||
|
// This is a value inside in the Clump's struct header section.
|
||||||
|
BOOST_CHECK_EQUAL(*(std::uint32_t*)innerCursor, 0x10);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,29 +1,23 @@
|
|||||||
#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) {
|
||||||
|
SCMFile f;
|
||||||
|
f.loadFile(data, sizeof(data));
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(scmfile_test)
|
BOOST_CHECK_EQUAL(f.getModelSection(), 0x10);
|
||||||
{
|
BOOST_CHECK_EQUAL(f.getMissionSection(), 0x20);
|
||||||
SCMFile f;
|
BOOST_CHECK_EQUAL(f.getCodeSection(), 0x28);
|
||||||
f.loadFile(data, sizeof(data));
|
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL( f.getModelSection(), 0x10 );
|
|
||||||
BOOST_CHECK_EQUAL( f.getMissionSection(), 0x20 );
|
|
||||||
BOOST_CHECK_EQUAL( f.getCodeSection(), 0x28 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
@ -4,61 +4,60 @@
|
|||||||
|
|
||||||
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({
|
|
||||||
{0, { t1, t2, true }}
|
skeleton.setAllData({{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);
|
|
||||||
|
BOOST_CHECK(skeleton.getData(0).b.translation == t2.translation);
|
||||||
BOOST_CHECK(skeleton.getData(0).b.translation == t2.translation);
|
BOOST_CHECK(skeleton.getData(0).b.rotation == t2.rotation);
|
||||||
BOOST_CHECK(skeleton.getData(0).b.rotation == t2.rotation);
|
|
||||||
|
BOOST_CHECK(skeleton.getData(0).enabled);
|
||||||
BOOST_CHECK(skeleton.getData(0).enabled);
|
|
||||||
|
skeleton.setData(0, {t2, t1, false});
|
||||||
skeleton.setData(0, {t2, t1, false});
|
|
||||||
|
BOOST_CHECK(skeleton.getData(0).a.translation == t2.translation);
|
||||||
BOOST_CHECK(skeleton.getData(0).a.translation == t2.translation);
|
BOOST_CHECK(skeleton.getData(0).a.rotation == t2.rotation);
|
||||||
BOOST_CHECK(skeleton.getData(0).a.rotation == t2.rotation);
|
|
||||||
|
BOOST_CHECK(skeleton.getData(0).b.translation == t1.translation);
|
||||||
BOOST_CHECK(skeleton.getData(0).b.translation == t1.translation);
|
BOOST_CHECK(skeleton.getData(0).b.rotation == t1.rotation);
|
||||||
BOOST_CHECK(skeleton.getData(0).b.rotation == t1.rotation);
|
|
||||||
|
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({
|
|
||||||
{0, { t2, t1, true }}
|
skeleton.setAllData({{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 ==
|
||||||
BOOST_CHECK(skeleton.getInterpolated(0).translation == Skeleton::IdentityTransform.translation);
|
Skeleton::IdentityTransform.translation);
|
||||||
BOOST_CHECK(skeleton.getInterpolated(0).rotation == Skeleton::IdentityTransform.rotation);
|
BOOST_CHECK(skeleton.getInterpolated(0).rotation ==
|
||||||
|
Skeleton::IdentityTransform.rotation);
|
||||||
skeleton.interpolate(0.f);
|
|
||||||
|
skeleton.interpolate(0.f);
|
||||||
BOOST_CHECK(skeleton.getInterpolated(0).translation == t1.translation);
|
|
||||||
BOOST_CHECK(skeleton.getInterpolated(0).rotation == t1.rotation);
|
BOOST_CHECK(skeleton.getInterpolated(0).translation == t1.translation);
|
||||||
|
BOOST_CHECK(skeleton.getInterpolated(0).rotation == t1.rotation);
|
||||||
skeleton.interpolate(1.f);
|
|
||||||
|
skeleton.interpolate(1.f);
|
||||||
BOOST_CHECK(skeleton.getInterpolated(0).translation == t2.translation);
|
|
||||||
BOOST_CHECK(skeleton.getInterpolated(0).rotation == t2.rotation);
|
BOOST_CHECK(skeleton.getInterpolated(0).translation == t2.translation);
|
||||||
|
BOOST_CHECK(skeleton.getInterpolated(0).rotation == t2.rotation);
|
||||||
}
|
}
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
|
@ -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)
|
||||||
|
|
||||||
|
@ -1,173 +1,136 @@
|
|||||||
#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");
|
|
||||||
|
|
||||||
GameTexts texts;
|
GameTexts texts;
|
||||||
|
|
||||||
LoaderGXT loader;
|
LoaderGXT loader;
|
||||||
|
|
||||||
loader.load( texts, d );
|
loader.load(texts, d);
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL( texts.text("1008"), T("BUSTED") );
|
BOOST_CHECK_EQUAL(texts.text("1008"), T("BUSTED"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 =
|
||||||
auto big = ScreenTextEntry::makeBig(
|
ScreenTextEntry::makeBig("TEST_1", T("Test String"), 1, 5000);
|
||||||
"TEST_1",
|
|
||||||
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);
|
||||||
BOOST_CHECK_EQUAL(5000, big.durationMS);
|
BOOST_CHECK_EQUAL(5000, big.durationMS);
|
||||||
BOOST_CHECK_EQUAL(0, big.displayedMS);
|
BOOST_CHECK_EQUAL(0, big.displayedMS);
|
||||||
BOOST_CHECK_EQUAL(1, big.alignment);
|
BOOST_CHECK_EQUAL(1, big.alignment);
|
||||||
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);
|
||||||
BOOST_CHECK_EQUAL(0, big.displayedMS);
|
BOOST_CHECK_EQUAL(0, big.displayedMS);
|
||||||
BOOST_CHECK_EQUAL(2, big.alignment);
|
BOOST_CHECK_EQUAL(2, big.alignment);
|
||||||
BOOST_CHECK_EQUAL(30, big.size);
|
BOOST_CHECK_EQUAL(30, big.size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
BOOST_CHECK_EQUAL(0, help.displayedMS);
|
BOOST_CHECK_EQUAL(0, help.displayedMS);
|
||||||
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",
|
st.addText<ScreenTextType::HighPriority>(
|
||||||
T("Test String"),
|
ScreenTextEntry::makeHighPriority("TEST_1", T("Test String"), 5000));
|
||||||
2,
|
|
||||||
5000));
|
|
||||||
st.addText<ScreenTextType::HighPriority>(
|
|
||||||
ScreenTextEntry::makeHighPriority(
|
|
||||||
"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"),
|
||||||
BOOST_CHECK_EQUAL(5000, st.getText<ScreenTextType::Big>()[0].durationMS);
|
st.getText<ScreenTextType::Big>()[0].text);
|
||||||
BOOST_CHECK_EQUAL(0, st.getText<ScreenTextType::Big>()[0].displayedMS);
|
BOOST_CHECK_EQUAL(5000, st.getText<ScreenTextType::Big>()[0].durationMS);
|
||||||
|
BOOST_CHECK_EQUAL(0, st.getText<ScreenTextType::Big>()[0].displayedMS);
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL(1, st.getText<ScreenTextType::HighPriority>().size());
|
BOOST_CHECK_EQUAL(1, st.getText<ScreenTextType::HighPriority>().size());
|
||||||
|
|
||||||
st.tick(6.f);
|
st.tick(6.f);
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL(0, st.getText<ScreenTextType::Big>().size());
|
BOOST_CHECK_EQUAL(0, st.getText<ScreenTextType::Big>().size());
|
||||||
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());
|
||||||
|
|
||||||
st.clear<ScreenTextType::Big>();
|
st.clear<ScreenTextType::Big>();
|
||||||
|
|
||||||
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~");
|
const auto codeStr3 = T("Hello world~1~");
|
||||||
const auto codeStr3 = T("Hello world~1~");
|
|
||||||
|
|
||||||
auto f1 = ScreenText::format(codeStr1, T("r"));
|
auto f1 = ScreenText::format(codeStr1, T("r"));
|
||||||
BOOST_CHECK_EQUAL(f1, T("Hello r world"));
|
BOOST_CHECK_EQUAL(f1, T("Hello r world"));
|
||||||
|
|
||||||
auto f2 = ScreenText::format(codeStr2, T("k"), T("h"));
|
auto f2 = ScreenText::format(codeStr2, T("k"), T("h"));
|
||||||
BOOST_CHECK_EQUAL(f2, T("kHello h world~1~"));
|
BOOST_CHECK_EQUAL(f2, T("kHello h world~1~"));
|
||||||
|
|
||||||
auto f3 = ScreenText::format(codeStr3, T("x"));
|
auto f3 = ScreenText::format(codeStr3, T("x"));
|
||||||
BOOST_CHECK_EQUAL(f3, T("Hello worldx"));
|
BOOST_CHECK_EQUAL(f3, T("Hello worldx"));
|
||||||
|
|
||||||
auto f4 = ScreenText::format(codeStr3, T("x"), T("k"));
|
auto f4 = ScreenText::format(codeStr3, T("x"), T("k"));
|
||||||
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());
|
||||||
|
|
||||||
st.remove<ScreenTextType::Big>("TEST_1");
|
st.remove<ScreenTextType::Big>("TEST_1");
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL(1, st.getText<ScreenTextType::Big>().size());
|
BOOST_CHECK_EQUAL(1, st.getText<ScreenTextType::Big>().size());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,222 +1,168 @@
|
|||||||
#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_PED,
|
|
||||||
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);
|
|
||||||
|
|
||||||
TrafficDirector director(&graph, Global::get().e);
|
|
||||||
|
|
||||||
ViewCamera testCamera(glm::vec3(-5.f, -5.f, 0.f));
|
PathData path{PathData::PATH_PED,
|
||||||
|
0,
|
||||||
auto open = director.findAvailableNodes(AIGraphNode::Pedestrian, testCamera, 10.f);
|
"",
|
||||||
|
{
|
||||||
std::vector<glm::vec3> expected {
|
{PathNode::EXTERNAL, 1, {10.f, 10.f, 0.f}, 1.f, 0, 0},
|
||||||
{ 0.f,-10.f, 0.f },
|
{PathNode::EXTERNAL, 2, {10.f, 0.f, 0.f}, 1.f, 0, 0},
|
||||||
{-10.f,-10.f, 0.f },
|
{PathNode::EXTERNAL, 3, {10.f, -10.f, 0.f}, 1.f, 0, 0},
|
||||||
{-10.f, 0.f, 0.f }
|
{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},
|
||||||
BOOST_REQUIRE(expected.size() == 3);
|
{PathNode::EXTERNAL, -1, {-10.f, 10.f, 0.f}, 1.f, 0, 0},
|
||||||
BOOST_ASSERT( expected.size() == open.size() );
|
}};
|
||||||
|
|
||||||
for (auto& v : expected) {
|
graph.createPathNodes(glm::vec3(), glm::quat(), path);
|
||||||
BOOST_CHECK(std::find_if(open.begin(), open.end(),
|
|
||||||
[v](AIGraphNode* n) { return n->position == v; }) != open.end());
|
TrafficDirector director(&graph, Global::get().e);
|
||||||
}
|
|
||||||
|
ViewCamera testCamera(glm::vec3(-5.f, -5.f, 0.f));
|
||||||
|
|
||||||
|
auto open =
|
||||||
|
director.findAvailableNodes(AIGraphNode::Pedestrian, testCamera, 10.f);
|
||||||
|
|
||||||
|
std::vector<glm::vec3> expected{
|
||||||
|
{0.f, -10.f, 0.f}, {-10.f, -10.f, 0.f}, {-10.f, 0.f, 0.f}};
|
||||||
|
|
||||||
|
BOOST_REQUIRE(expected.size() == 3);
|
||||||
|
BOOST_ASSERT(expected.size() == open.size());
|
||||||
|
|
||||||
|
for (auto& v : expected) {
|
||||||
|
BOOST_CHECK(std::find_if(open.begin(), open.end(), [v](AIGraphNode* n) {
|
||||||
|
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_PED,
|
||||||
PathData path {
|
0,
|
||||||
PathData::PATH_PED,
|
"",
|
||||||
0, "",
|
{
|
||||||
{
|
{PathNode::EXTERNAL, 1, {10.f, 10.f, 0.f}, 1.f, 0, 0},
|
||||||
{
|
}};
|
||||||
PathNode::EXTERNAL,
|
|
||||||
1,
|
graph.createPathNodes(glm::vec3(), glm::quat(), path);
|
||||||
{ 10.f, 10.f, 0.f },
|
|
||||||
1.f, 0, 0
|
TrafficDirector director(&graph, Global::get().e);
|
||||||
},
|
|
||||||
}
|
// Create something that isn't a pedestrian
|
||||||
};
|
InstanceObject* box =
|
||||||
|
Global::get().e->createInstance(1337, glm::vec3(10.f, 10.f, 0.f));
|
||||||
graph.createPathNodes(glm::vec3(), glm::quat(), path);
|
|
||||||
|
{
|
||||||
TrafficDirector director(&graph, Global::get().e);
|
auto open = director.findAvailableNodes(AIGraphNode::Pedestrian,
|
||||||
|
glm::vec3(5.f, 5.f, 0.f), 10.f);
|
||||||
// Create something that isn't a pedestrian
|
BOOST_CHECK(open.size() == 1);
|
||||||
InstanceObject* box = Global::get().e->createInstance(1337, glm::vec3(10.f, 10.f, 0.f));
|
}
|
||||||
|
|
||||||
{
|
Global::get().e->destroyObject(box);
|
||||||
auto open = director.findAvailableNodes(AIGraphNode::Pedestrian, glm::vec3( 5.f, 5.f, 0.f), 10.f);
|
|
||||||
BOOST_CHECK( open.size() == 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
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_PED,
|
||||||
PathData path {
|
0,
|
||||||
PathData::PATH_PED,
|
"",
|
||||||
0, "",
|
{
|
||||||
{
|
{PathNode::EXTERNAL, 1, {10.f, 10.f, 0.f}, 1.f, 0, 0},
|
||||||
{
|
}};
|
||||||
PathNode::EXTERNAL,
|
|
||||||
1,
|
graph.createPathNodes(glm::vec3(), glm::quat(), path);
|
||||||
{ 10.f, 10.f, 0.f },
|
|
||||||
1.f, 0, 0
|
TrafficDirector director(&graph, Global::get().e);
|
||||||
},
|
|
||||||
}
|
// create something that should block the spawn point
|
||||||
};
|
CharacterObject* ped =
|
||||||
|
Global::get().e->createPedestrian(1, glm::vec3(10.f, 10.f, 0.f));
|
||||||
graph.createPathNodes(glm::vec3(), glm::quat(), path);
|
|
||||||
|
{
|
||||||
TrafficDirector director(&graph, Global::get().e);
|
auto open = director.findAvailableNodes(AIGraphNode::Pedestrian,
|
||||||
|
glm::vec3(5.f, 5.f, 0.f), 10.f);
|
||||||
// create something that should block the spawn point
|
BOOST_CHECK(open.size() == 0);
|
||||||
CharacterObject* ped = Global::get().e->createPedestrian(1, glm::vec3(10.f, 10.f, 0.f));
|
}
|
||||||
|
|
||||||
{
|
Global::get().e->destroyObject(ped);
|
||||||
auto open = director.findAvailableNodes(AIGraphNode::Pedestrian, glm::vec3( 5.f, 5.f, 0.f), 10.f);
|
|
||||||
BOOST_CHECK( open.size() == 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
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_PED,
|
||||||
PathData path {
|
0,
|
||||||
PathData::PATH_PED,
|
"",
|
||||||
0, "",
|
{
|
||||||
{
|
{PathNode::EXTERNAL, 1, {10.f, 10.f, 0.f}, 1.f, 0, 0},
|
||||||
{
|
}};
|
||||||
PathNode::EXTERNAL,
|
|
||||||
1,
|
graph.createPathNodes(glm::vec3(), glm::quat(), path);
|
||||||
{ 10.f, 10.f, 0.f },
|
|
||||||
1.f, 0, 0
|
TrafficDirector director(&graph, Global::get().e);
|
||||||
},
|
|
||||||
}
|
CharacterObject* ped =
|
||||||
};
|
Global::get().e->createPedestrian(1, glm::vec3(5.f, 5.f, 0.f));
|
||||||
|
|
||||||
graph.createPathNodes(glm::vec3(), glm::quat(), path);
|
{
|
||||||
|
director.setDensity(AIGraphNode::Pedestrian, 1.f);
|
||||||
TrafficDirector director(&graph, Global::get().e);
|
auto open = director.findAvailableNodes(AIGraphNode::Pedestrian,
|
||||||
|
glm::vec3(5.f, 5.f, 0.f), 10.f);
|
||||||
CharacterObject* ped = Global::get().e->createPedestrian(1, glm::vec3(5.f, 5.f, 0.f));
|
BOOST_CHECK(open.size() == 0);
|
||||||
|
}
|
||||||
{
|
|
||||||
director.setDensity(AIGraphNode::Pedestrian, 1.f);
|
{
|
||||||
auto open = director.findAvailableNodes(AIGraphNode::Pedestrian, glm::vec3( 5.f, 5.f, 0.f), 10.f);
|
director.setDensity(AIGraphNode::Pedestrian, 2.f);
|
||||||
BOOST_CHECK( open.size() == 0 );
|
auto open = director.findAvailableNodes(AIGraphNode::Pedestrian,
|
||||||
}
|
glm::vec3(5.f, 5.f, 0.f), 10.f);
|
||||||
|
BOOST_CHECK(open.size() == 1);
|
||||||
{
|
}
|
||||||
director.setDensity(AIGraphNode::Pedestrian, 2.f);
|
|
||||||
auto open = director.findAvailableNodes(AIGraphNode::Pedestrian, glm::vec3( 5.f, 5.f, 0.f), 10.f);
|
Global::get().e->destroyObject(ped);
|
||||||
BOOST_CHECK( open.size() == 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
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_PED,
|
||||||
PathData path {
|
0,
|
||||||
PathData::PATH_PED,
|
"",
|
||||||
0, "",
|
{
|
||||||
{
|
{PathNode::EXTERNAL, 1, {10.f, 10.f, 0.f}, 1.f, 0, 0},
|
||||||
{
|
}};
|
||||||
PathNode::EXTERNAL,
|
|
||||||
1,
|
graph.createPathNodes(glm::vec3(), glm::quat(), path);
|
||||||
{ 10.f, 10.f, 0.f },
|
|
||||||
1.f, 0, 0
|
TrafficDirector director(&graph, Global::get().e);
|
||||||
},
|
|
||||||
}
|
auto created = director.populateNearby(glm::vec3(0.f, 0.f, 0.f), 20.f);
|
||||||
};
|
|
||||||
|
BOOST_CHECK(created.size() == 1);
|
||||||
graph.createPathNodes(glm::vec3(), glm::quat(), path);
|
|
||||||
|
// Global::get().e->destroyObject(created[0]);
|
||||||
TrafficDirector director(&graph, Global::get().e);
|
|
||||||
|
|
||||||
auto created = director.populateNearby(glm::vec3(0.f, 0.f, 0.f), 20.f);
|
|
||||||
|
|
||||||
BOOST_CHECK( created.size() == 1 );
|
|
||||||
|
|
||||||
//Global::get().e->destroyObject(created[0]);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,135 +1,133 @@
|
|||||||
#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);
|
||||||
|
|
||||||
BOOST_REQUIRE(vehicle->info != nullptr);
|
BOOST_REQUIRE(vehicle->info != nullptr);
|
||||||
BOOST_REQUIRE(vehicle->vehicle != nullptr);
|
BOOST_REQUIRE(vehicle->vehicle != nullptr);
|
||||||
|
|
||||||
// Hardcoded values for the moment
|
// Hardcoded values for the moment
|
||||||
BOOST_CHECK_EQUAL(vehicle->vehicle->type, VehicleData::CAR);
|
BOOST_CHECK_EQUAL(vehicle->vehicle->type, VehicleData::CAR);
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL(vehicle->info->wheels.size(), 4);
|
BOOST_CHECK_EQUAL(vehicle->info->wheels.size(), 4);
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL(vehicle->info->seats.size(), 4);
|
BOOST_CHECK_EQUAL(vehicle->info->seats.size(), 4);
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
VehicleObject::Part* part = vehicle->getPart("bonnet_dummy");
|
VehicleObject::Part* part = vehicle->getPart("bonnet_dummy");
|
||||||
|
|
||||||
BOOST_REQUIRE( part != nullptr );
|
BOOST_REQUIRE(part != nullptr);
|
||||||
|
|
||||||
BOOST_REQUIRE( part->normal != nullptr );
|
BOOST_REQUIRE(part->normal != nullptr);
|
||||||
BOOST_REQUIRE( part->damaged != nullptr );
|
BOOST_REQUIRE(part->damaged != nullptr);
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL( part->normal->getName(), "bonnet_hi_ok");
|
BOOST_CHECK_EQUAL(part->normal->getName(), "bonnet_hi_ok");
|
||||||
BOOST_CHECK_EQUAL( part->damaged->getName(), "bonnet_hi_dam");
|
BOOST_CHECK_EQUAL(part->damaged->getName(), "bonnet_hi_dam");
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
VehicleObject::Part* bonnetpart = vehicle->getPart("bonnet_dummy");
|
|
||||||
auto skel = vehicle->skeleton;
|
|
||||||
|
|
||||||
vehicle->setPartState(bonnetpart, VehicleObject::DAM);
|
|
||||||
|
|
||||||
BOOST_CHECK(!skel->getData(bonnetpart->normal->getIndex()).enabled );
|
|
||||||
BOOST_CHECK( skel->getData(bonnetpart->damaged->getIndex()).enabled );
|
|
||||||
|
|
||||||
vehicle->setPartState(bonnetpart, VehicleObject::OK);
|
|
||||||
|
|
||||||
BOOST_CHECK( skel->getData(bonnetpart->normal->getIndex()).enabled );
|
|
||||||
BOOST_CHECK(!skel->getData(bonnetpart->damaged->getIndex()).enabled );
|
|
||||||
|
|
||||||
Global::get().e->destroyObject(vehicle);
|
VehicleObject::Part* bonnetpart = vehicle->getPart("bonnet_dummy");
|
||||||
|
auto skel = vehicle->skeleton;
|
||||||
|
|
||||||
|
vehicle->setPartState(bonnetpart, VehicleObject::DAM);
|
||||||
|
|
||||||
|
BOOST_CHECK(!skel->getData(bonnetpart->normal->getIndex()).enabled);
|
||||||
|
BOOST_CHECK(skel->getData(bonnetpart->damaged->getIndex()).enabled);
|
||||||
|
|
||||||
|
vehicle->setPartState(bonnetpart, VehicleObject::OK);
|
||||||
|
|
||||||
|
BOOST_CHECK(skel->getData(bonnetpart->normal->getIndex()).enabled);
|
||||||
|
BOOST_CHECK(!skel->getData(bonnetpart->damaged->getIndex()).enabled);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
BOOST_REQUIRE(vehicle->info != nullptr);
|
BOOST_REQUIRE(vehicle->info != nullptr);
|
||||||
BOOST_REQUIRE(vehicle->vehicle != nullptr);
|
BOOST_REQUIRE(vehicle->vehicle != nullptr);
|
||||||
|
|
||||||
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 );
|
|
||||||
|
|
||||||
VehicleObject::Part* part = vehicle->getPart("door_lf_dummy");
|
BOOST_REQUIRE(vehicle != nullptr);
|
||||||
|
|
||||||
BOOST_REQUIRE( part != nullptr );
|
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL( part->constraint, nullptr );
|
|
||||||
BOOST_CHECK_EQUAL( part->body, nullptr );
|
|
||||||
|
|
||||||
vehicle->setPartLocked(part, false);
|
|
||||||
|
|
||||||
BOOST_CHECK_NE( part->body, nullptr );
|
|
||||||
BOOST_CHECK_NE( part->constraint, nullptr );
|
|
||||||
|
|
||||||
vehicle->setPartLocked(part, true);
|
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL( part->constraint, nullptr );
|
VehicleObject::Part* part = vehicle->getPart("door_lf_dummy");
|
||||||
BOOST_CHECK_EQUAL( part->body, nullptr );
|
|
||||||
|
BOOST_REQUIRE(part != nullptr);
|
||||||
Global::get().e->destroyObject(vehicle);
|
|
||||||
|
BOOST_CHECK_EQUAL(part->constraint, nullptr);
|
||||||
|
BOOST_CHECK_EQUAL(part->body, nullptr);
|
||||||
|
|
||||||
|
vehicle->setPartLocked(part, false);
|
||||||
|
|
||||||
|
BOOST_CHECK_NE(part->body, nullptr);
|
||||||
|
BOOST_CHECK_NE(part->constraint, nullptr);
|
||||||
|
|
||||||
|
vehicle->setPartLocked(part, true);
|
||||||
|
|
||||||
|
BOOST_CHECK_EQUAL(part->constraint, nullptr);
|
||||||
|
BOOST_CHECK_EQUAL(part->body, nullptr);
|
||||||
|
|
||||||
|
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 );
|
|
||||||
|
|
||||||
VehicleObject::Part* part = vehicle->getPart("door_lf_dummy");
|
BOOST_REQUIRE(vehicle != nullptr);
|
||||||
|
|
||||||
BOOST_REQUIRE( part != nullptr );
|
VehicleObject::Part* part = vehicle->getPart("door_lf_dummy");
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL( part->body, nullptr );
|
BOOST_REQUIRE(part != nullptr);
|
||||||
|
|
||||||
vehicle->setPartLocked(part, true);
|
BOOST_CHECK_EQUAL(part->body, nullptr);
|
||||||
vehicle->setPartTarget(part, true, 1.f);
|
|
||||||
|
vehicle->setPartLocked(part, true);
|
||||||
/// @todo a reasonable test
|
vehicle->setPartTarget(part, true, 1.f);
|
||||||
|
|
||||||
Global::get().e->destroyObject(vehicle);
|
/// @todo a reasonable test
|
||||||
|
|
||||||
|
Global::get().e->destroyObject(vehicle);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
|
@ -1,130 +1,117 @@
|
|||||||
#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});
|
BOOST_REQUIRE(character != nullptr);
|
||||||
BOOST_REQUIRE( character != nullptr );
|
BOOST_REQUIRE(character->model != nullptr);
|
||||||
BOOST_REQUIRE( character->model != nullptr);
|
BOOST_REQUIRE(character->physObject != nullptr);
|
||||||
BOOST_REQUIRE( character->physObject != nullptr);
|
|
||||||
|
|
||||||
WeaponScan scan( 10.f, {0.f, 0.f, 10.f}, {0.f,0.f, -10.f} );
|
WeaponScan scan(10.f, {0.f, 0.f, 10.f}, {0.f, 0.f, -10.f});
|
||||||
|
|
||||||
Global::get().e->doWeaponScan( scan );
|
Global::get().e->doWeaponScan(scan);
|
||||||
|
|
||||||
BOOST_CHECK( character->getCurrentState().health < 100.f );
|
BOOST_CHECK(character->getCurrentState().health < 100.f);
|
||||||
|
|
||||||
Global::get().e->destroyObject(character);
|
Global::get().e->destroyObject(character);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
BOOST_CHECK( character->getCurrentState().health == 100.f );
|
BOOST_CHECK(character->getCurrentState().health == 100.f);
|
||||||
|
|
||||||
for(float t = 0.f; t <= 5.f; t += 0.016f) {
|
for (float t = 0.f; t <= 5.f; t += 0.016f) {
|
||||||
Global::get().e->dynamicsWorld->stepSimulation(0.016f, 0, 0);
|
Global::get().e->dynamicsWorld->stepSimulation(0.016f, 0, 0);
|
||||||
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);
|
||||||
|
|
||||||
Global::get().e->destroyObjectQueued(character);
|
Global::get().e->destroyObjectQueued(character);
|
||||||
Global::get().e->destroyQueuedObjects();
|
Global::get().e->destroyQueuedObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
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[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);
|
||||||
|
|
||||||
BOOST_CHECK( character->getCurrentState().health == 100.f );
|
BOOST_CHECK(character->getCurrentState().health == 100.f);
|
||||||
|
|
||||||
for(float t = 0.f; t <= 9.0f; t += 0.016f) {
|
for (float t = 0.f; t <= 9.0f; t += 0.016f) {
|
||||||
Global::get().e->dynamicsWorld->stepSimulation(0.016f, 0, 0);
|
Global::get().e->dynamicsWorld->stepSimulation(0.016f, 0, 0);
|
||||||
projectile->tick(0.016f);
|
projectile->tick(0.016f);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_CHECK( projectile->getPosition().z < 10.f );
|
BOOST_CHECK(projectile->getPosition().z < 10.f);
|
||||||
BOOST_CHECK( projectile->getPosition().z > 0.f );
|
BOOST_CHECK(projectile->getPosition().z > 0.f);
|
||||||
|
|
||||||
BOOST_CHECK( character->getCurrentState().health < 100.f );
|
BOOST_CHECK(character->getCurrentState().health < 100.f);
|
||||||
|
|
||||||
Global::get().e->destroyObjectQueued(character);
|
Global::get().e->destroyObjectQueued(character);
|
||||||
Global::get().e->destroyQueuedObjects();
|
Global::get().e->destroyQueuedObjects();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
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[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);
|
||||||
|
|
||||||
BOOST_CHECK( character->getCurrentState().health == 100.f );
|
BOOST_CHECK(character->getCurrentState().health == 100.f);
|
||||||
|
|
||||||
for(float t = 0.f; t <= 9.f; t += 0.016f) {
|
for (float t = 0.f; t <= 9.f; t += 0.016f) {
|
||||||
Global::get().e->dynamicsWorld->stepSimulation(0.016f, 0, 0);
|
Global::get().e->dynamicsWorld->stepSimulation(0.016f, 0, 0);
|
||||||
projectile->tick(0.016f);
|
projectile->tick(0.016f);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_CHECK( projectile->getPosition().z < 10.f );
|
BOOST_CHECK(projectile->getPosition().z < 10.f);
|
||||||
|
|
||||||
BOOST_CHECK( character->getCurrentState().health < 100.f );
|
BOOST_CHECK(character->getCurrentState().health < 100.f);
|
||||||
|
|
||||||
Global::get().e->destroyObjectQueued(character);
|
Global::get().e->destroyObjectQueued(character);
|
||||||
Global::get().e->destroyQueuedObjects();
|
Global::get().e->destroyQueuedObjects();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,48 +1,49 @@
|
|||||||
#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;
|
|
||||||
|
|
||||||
bool worked = false, completed = false;
|
bool worked = false, completed = false;
|
||||||
|
|
||||||
TestJob* job = new TestJob(&context, &worked, &completed);
|
TestJob *job = new TestJob(&context, &worked, &completed);
|
||||||
|
|
||||||
BOOST_CHECK( ! worked );
|
BOOST_CHECK(!worked);
|
||||||
BOOST_CHECK( ! completed );
|
BOOST_CHECK(!completed);
|
||||||
|
|
||||||
context.queueJob(job);
|
context.queueJob(job);
|
||||||
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
|
@ -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()
|
||||||
|
Loading…
Reference in New Issue
Block a user