mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-14 07:23:26 +00:00
updated unit test
This commit is contained in:
@@ -5,7 +5,7 @@ project(unit-tests)
|
||||
file(GLOB TEST_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
|
||||
|
||||
include(GoogleTest)
|
||||
add_executable(unit-tests UnitTestColor.cpp UnitTestMatrix.cpp)
|
||||
add_executable(unit-tests UnitTestPrediction.cpp UnitTestMatrix.cpp)
|
||||
|
||||
target_link_libraries(unit-tests PRIVATE gtest gtest_main omath)
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <omath/prediction/Engine.h>
|
||||
|
||||
TEST(x,x)
|
||||
{
|
||||
omath::prediction::Target target{.m_origin = {100, 0, 60}, .m_velocity = {0, 0, 0}, .m_isAirborne = false};
|
||||
omath::prediction::Projectile proj = {.m_origin = {3,2,1}, .m_launchSpeed = 5000, .m_gravityScale= 0.4};
|
||||
auto vel = omath::prediction::Engine(400, 1.f / 1000.f, 50, 5.f).MaybeCalculateAimPoint(proj, target);
|
||||
|
||||
auto pitch = proj.m_origin.ViewAngleTo(vel.value()).x;
|
||||
|
||||
printf("pitch: %f", pitch);
|
||||
}
|
||||
14
tests/UnitTestPrediction.cpp
Normal file
14
tests/UnitTestPrediction.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <omath/prediction/Engine.h>
|
||||
|
||||
TEST(UnitTestPrediction, PredictionTest)
|
||||
{
|
||||
const omath::prediction::Target target{.m_origin = {100, 0, 90}, .m_velocity = {0, 0, 0}, .m_isAirborne = false};
|
||||
const omath::prediction::Projectile proj = {.m_origin = {3,2,1}, .m_launchSpeed = 5000, .m_gravityScale= 0.4};
|
||||
const auto viewPoint = omath::prediction::Engine(400, 1.f / 1000.f, 50, 5.f).MaybeCalculateAimPoint(proj, target);
|
||||
|
||||
const auto [pitch, yaw, _] = proj.m_origin.ViewAngleTo(viewPoint.value());
|
||||
|
||||
EXPECT_NEAR(42.547142, pitch, 0.0001f);
|
||||
EXPECT_NEAR(-1.181189, yaw, 0.0001f);
|
||||
}
|
||||
Reference in New Issue
Block a user