Skip to content

Commit

Permalink
qvec: allow gtest to print
Browse files Browse the repository at this point in the history
  • Loading branch information
ericwa committed Sep 19, 2024
1 parent ed62ec1 commit f5d105b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/common/qvec.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions tests/test_light.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f5d105b

Please sign in to comment.