1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-10-04 08:07:17 +02:00

Provide tests for ViewCamera

This commit is contained in:
Daniel Evans 2019-05-23 23:38:35 +01:00
parent 35c90d1ebc
commit e759101a47
4 changed files with 34 additions and 1 deletions

View File

@ -34,6 +34,7 @@ set(TESTS
Text
TrafficDirector
Vehicle
ViewCamera
VisualFX
Weapon
World

View File

@ -3,6 +3,6 @@
#include "test_Globals.hpp"
std::ostream& operator<<(std::ostream& stream, const glm::vec3& v) {
stream << v.x << " " << v.y << " " << v.z;
stream << glm::to_string(v);
return stream;
}

View File

@ -45,6 +45,12 @@ struct print_log_value<glm::vec3> {
s << glm::to_string(v);
}
};
template <>
struct print_log_value<glm::vec4> {
void operator()(std::ostream& s, glm::vec4 const& v) {
s << glm::to_string(v);
}
};
BOOST_NS_MAGIC_CLOSING
}
}

26
tests/test_ViewCamera.cpp Normal file
View File

@ -0,0 +1,26 @@
#include <boost/test/unit_test.hpp>
#include "test_Globals.hpp"
#include <render/ViewCamera.hpp>
namespace {
struct CameraFixture {
ViewCamera camera_ {
{1.f, 2.f, 3.f}
};
};
}
BOOST_AUTO_TEST_SUITE(ViewCameraTests)
BOOST_FIXTURE_TEST_CASE(test_creation, CameraFixture) {
BOOST_CHECK_EQUAL(camera_.position, glm::vec3(1.f, 2.f, 3.f));
}
BOOST_FIXTURE_TEST_CASE(test_view_matrix, CameraFixture) {
const auto& view = camera_.getView();
BOOST_CHECK_EQUAL(view[3], glm::vec4(2.f, -3.f, 1.f, 1.f));
}
BOOST_AUTO_TEST_SUITE_END()