diff --git a/include/common/qvec.hh b/include/common/qvec.hh index c4f72fc1..33f3ee67 100644 --- a/include/common/qvec.hh +++ b/include/common/qvec.hh @@ -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 diff --git a/tests/test_light.cc b/tests/test_light.cc index a8b742e9..ed3995df 100644 --- a/tests/test_light.cc +++ b/tests/test_light.cc @@ -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)