qvec: allow gtest to print

This commit is contained in:
Eric Wasylishen 2024-09-18 22:57:42 -06:00
parent ed62ec1040
commit f5d105b34d
2 changed files with 20 additions and 0 deletions

View File

@ -296,6 +296,12 @@ public:
constexpr auto end() const { return v.end(); }
constexpr auto cbegin() const { return v.cbegin(); }
constexpr auto cend() const { return v.cend(); }
// gtest support
friend std::ostream& operator<<(std::ostream& os, const qvec& point) {
os << fmt::format("{}", point);
return os;
}
};
// Fmt support

View File

@ -717,6 +717,20 @@ TEST(mathlib, qvecConstructorExtra)
EXPECT_EQ(2, test[1]);
}
TEST(mathlib, qvecGTestPrint)
{
const qvec2f test(1, 2);
EXPECT_EQ(testing::PrintToString(test), "1 2");
}
TEST(mathlib, qvecFmtFormat)
{
const qvec2f test(1, 2);
EXPECT_EQ("1 2", fmt::format("{}", test));
}
// aabb3f
TEST(mathlib, aabbBasic)