mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-07 03:12:36 +01:00
Make unit tests work again, fixing tests & code
This commit is contained in:
parent
9bc535d243
commit
e7faa60926
@ -41,6 +41,8 @@ void Animator::tick(float dt)
|
||||
}
|
||||
}
|
||||
|
||||
state.time = state.time + dt;
|
||||
|
||||
float animTime = state.time;
|
||||
if (! state.repeat)
|
||||
{
|
||||
@ -84,7 +86,6 @@ void Animator::tick(float dt)
|
||||
blendFrames[b.second.frameIndex] = xform;
|
||||
#endif
|
||||
}
|
||||
state.time = state.time + dt;
|
||||
}
|
||||
|
||||
for (auto& p : blendFrames)
|
||||
|
@ -34,7 +34,7 @@ BOOST_AUTO_TEST_CASE(test_matrix)
|
||||
}
|
||||
};
|
||||
|
||||
animator.playAnimation(0, &animation, 1.f, true);
|
||||
animator.playAnimation(0, &animation, 1.f, false);
|
||||
|
||||
animator.tick(0.0f);
|
||||
|
||||
|
@ -34,7 +34,7 @@ BOOST_AUTO_TEST_CASE(test_create)
|
||||
BOOST_AUTO_TEST_CASE(test_activities)
|
||||
{
|
||||
{
|
||||
auto character = Global::get().e->createPedestrian(1, {0.f, 0.f, 0.f});
|
||||
auto character = Global::get().e->createPedestrian(1, {0.f, 0.f, 225.6f});
|
||||
|
||||
BOOST_REQUIRE( character != nullptr );
|
||||
|
||||
|
@ -45,13 +45,15 @@ public:
|
||||
Global() {
|
||||
wnd.create(sf::VideoMode(640, 360), "Testing");
|
||||
d = new GameData(&log, &work, getGamePath());
|
||||
|
||||
d->loadIMG("/models/gta3");
|
||||
d->loadIMG("/anim/cuts");
|
||||
d->load();
|
||||
|
||||
e = new GameWorld(&log, &work, d);
|
||||
s = new GameState;
|
||||
e->state = s;
|
||||
|
||||
e->data->loadIMG("/models/gta3");
|
||||
e->data->loadIMG("/anim/cuts");
|
||||
e->data->load();
|
||||
for(std::map<std::string, std::string>::iterator it = e->data->ideLocations.begin();
|
||||
it != e->data->ideLocations.end();
|
||||
++it) {
|
||||
|
@ -11,18 +11,23 @@ BOOST_AUTO_TEST_CASE(test_character_inventory)
|
||||
BOOST_REQUIRE( character != nullptr );
|
||||
|
||||
auto item = Global::get().e->getInventoryItem(4);
|
||||
auto fist = Global::get().e->getInventoryItem(0);
|
||||
|
||||
BOOST_REQUIRE(item != nullptr);
|
||||
BOOST_REQUIRE(fist != nullptr );
|
||||
BOOST_CHECK_NE( fist, item );
|
||||
|
||||
character->addToInventory(item);
|
||||
|
||||
BOOST_CHECK_EQUAL( character->getActiveItem(), fist );
|
||||
|
||||
character->setActiveItem( item->getInventorySlot() );
|
||||
|
||||
BOOST_CHECK_EQUAL( character->getActiveItem(), item );
|
||||
|
||||
character->removeFromInventory( item->getInventorySlot() );
|
||||
|
||||
BOOST_CHECK_EQUAL( character->getActiveItem(), nullptr );
|
||||
BOOST_CHECK_EQUAL( character->getActiveItem(), fist );
|
||||
|
||||
Global::get().e->destroyObject(character);
|
||||
}
|
||||
|
@ -11,13 +11,17 @@ BOOST_AUTO_TEST_CASE(frustum_test_visible)
|
||||
|
||||
f.update(f.projection());
|
||||
|
||||
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({ 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({10.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,-10.f}, 1.f ) );
|
||||
BOOST_CHECK( f.intersects({-10.f, 0.f,-10.f}, 1.f ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,13 +76,12 @@ BOOST_AUTO_TEST_CASE(test_available_nodes)
|
||||
{-10.f, 0.f, 0.f }
|
||||
};
|
||||
|
||||
BOOST_REQUIRE(expected.size() == 3);
|
||||
BOOST_ASSERT( expected.size() == open.size() );
|
||||
|
||||
auto left = open.begin();
|
||||
auto right = expected.begin();
|
||||
for ( ; left != open.end() && right != expected.end(); ++left, ++right )
|
||||
{
|
||||
BOOST_CHECK( ! ( *left != *right ) );
|
||||
for (auto& v : expected) {
|
||||
BOOST_CHECK(std::find_if(open.begin(), open.end(),
|
||||
[v](AIGraphNode* n) { return n->position == v; }) != open.end());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,8 @@ BOOST_AUTO_TEST_CASE(TestProjectile)
|
||||
projectile->tick(0.016f);
|
||||
}
|
||||
|
||||
BOOST_CHECK_LT( glm::distance(character->getPosition(), projectile->getPosition()), 1.f );
|
||||
BOOST_CHECK_LT( 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
|
||||
BOOST_CHECK( character->getCurrentState().health < 100.f );
|
||||
|
Loading…
Reference in New Issue
Block a user