mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-22 02:12:45 +01:00
Provide tests for ViewCamera
This commit is contained in:
parent
35c90d1ebc
commit
e759101a47
@ -34,6 +34,7 @@ set(TESTS
|
||||
Text
|
||||
TrafficDirector
|
||||
Vehicle
|
||||
ViewCamera
|
||||
VisualFX
|
||||
Weapon
|
||||
World
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
26
tests/test_ViewCamera.cpp
Normal 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()
|
Loading…
Reference in New Issue
Block a user