1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-20 11:23:52 +00:00
openmw/apps/openmw_test_suite/detournavigator/operators.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

90 lines
2.4 KiB
C++
Raw Normal View History

2018-03-13 22:49:08 +00:00
#ifndef OPENMW_TEST_SUITE_DETOURNAVIGATOR_OPERATORS_H
#define OPENMW_TEST_SUITE_DETOURNAVIGATOR_OPERATORS_H
#include <components/bullethelpers/operators.hpp>
#include <components/detournavigator/debug.hpp>
#include <deque>
#include <iomanip>
#include <limits>
#include <gtest/gtest.h>
namespace
{
template <class T>
struct Wrapper
{
const T& mValue;
};
template <class Range>
inline testing::Message& writeRange(testing::Message& message, const Range& range, std::size_t newLine)
{
message << "{";
std::size_t i = 0;
for (const auto& v : range)
{
if (i++ % newLine == 0)
message << "\n";
2022-09-22 18:26:05 +00:00
message << Wrapper<typename std::decay<decltype(v)>::type>{ v } << ", ";
}
return message << "\n}";
}
}
2018-03-13 22:49:08 +00:00
namespace testing
{
template <>
2022-09-22 18:26:05 +00:00
inline testing::Message& Message::operator<<(const osg::Vec3f& value)
{
return (*this) << "Vec3fEq(" << std::setprecision(std::numeric_limits<float>::max_exponent10) << value.x()
2022-09-22 18:26:05 +00:00
<< ", " << std::setprecision(std::numeric_limits<float>::max_exponent10) << value.y() << ", "
<< std::setprecision(std::numeric_limits<float>::max_exponent10) << value.z() << ')';
}
template <>
2022-09-22 18:26:05 +00:00
inline testing::Message& Message::operator<<(const Wrapper<osg::Vec3f>& value)
{
return (*this) << value.mValue;
}
template <>
2022-09-22 18:26:05 +00:00
inline testing::Message& Message::operator<<(const Wrapper<float>& value)
{
return (*this) << std::setprecision(std::numeric_limits<float>::max_exponent10) << value.mValue;
}
template <>
2022-09-22 18:26:05 +00:00
inline testing::Message& Message::operator<<(const Wrapper<int>& value)
{
return (*this) << value.mValue;
}
2018-03-13 22:49:08 +00:00
template <>
2022-09-22 18:26:05 +00:00
inline testing::Message& Message::operator<<(const std::deque<osg::Vec3f>& value)
2018-03-13 22:49:08 +00:00
{
return writeRange(*this, value, 1);
}
template <>
2022-09-22 18:26:05 +00:00
inline testing::Message& Message::operator<<(const std::vector<osg::Vec3f>& value)
{
return writeRange(*this, value, 1);
}
template <>
2022-09-22 18:26:05 +00:00
inline testing::Message& Message::operator<<(const std::vector<float>& value)
{
return writeRange(*this, value, 3);
}
template <>
2022-09-22 18:26:05 +00:00
inline testing::Message& Message::operator<<(const std::vector<int>& value)
{
return writeRange(*this, value, 3);
2018-03-13 22:49:08 +00:00
}
}
#endif