From cdb0bdfc60481708ab1a9707c0e1e4458e6396bf Mon Sep 17 00:00:00 2001 From: Keuin Date: Mon, 11 Apr 2022 10:24:03 +0800 Subject: Test vec3 minus and cross product. Fix missing const qualifier in overloaded operators. --- test.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test.cpp') diff --git a/test.cpp b/test.cpp index b1e5199..8f413f3 100644 --- a/test.cpp +++ b/test.cpp @@ -12,4 +12,23 @@ TEST(Vec, VecAdd) { vec3d d{1.1, 2.2, 3.3}, e{4.4, 5.5, 6.6}, f{5.5, 7.7, 9.9}; ASSERT_EQ(d + e, f); +} + +TEST(Vec, VecMin) { + vec3i a{1, 1, 1}, b{2, 2, 2}, c{-1, -1, -1}; + ASSERT_EQ(a - b, c); + ASSERT_EQ(-a, c); + + vec3d d{1.1, 2.2, 3.3}, e{-4.4, -5.5, -6.6}, f{5.5, 7.7, 9.9}; + ASSERT_EQ(d - e, f); + ASSERT_EQ(d + (-e), f); +} + +TEST(Vec, VecCrossProduct) { + vec3i a{1, 1, 1}, b{2, 2, 2}, c{3, 4, 5}, d{6, 7, 8}, e{-3, -6, -3}; + ASSERT_EQ(a * b, vec3i{}); + ASSERT_EQ(c * d, e); + + vec3d f{3.0, 4.0, 5.0}, g{6.0, 7.0, 8.0}, h{-3, -6, -3}; + ASSERT_EQ(f * g, h); } \ No newline at end of file -- cgit v1.2.3