From 60a3e2aedda225591f10a360575250b201aadd53 Mon Sep 17 00:00:00 2001 From: Keuin Date: Tue, 12 Apr 2022 13:03:05 +0800 Subject: Add vec3::mod2. --- test.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test.cpp') diff --git a/test.cpp b/test.cpp index 8c450f9..1b765aa 100644 --- a/test.cpp +++ b/test.cpp @@ -67,4 +67,11 @@ TEST(Vec, Norm) { TEST(Vec, UnitVec) { vec3d a{1, 2, 2}, b{1.0 / 3, 2.0 / 3, 2.0 / 3}; ASSERT_EQ(a.unit_vec(), b); +} + +TEST(Vec, Mod2) { + vec3i a{1, 2, 3}; + vec3d b{2.5, 3, 1.2}; + ASSERT_EQ(a.mod2(), 14); + ASSERT_LE(abs(b.mod2() - (2.5 * 2.5 + 3 * 3 + 1.2 * 1.2)), 1e-10); } \ No newline at end of file -- cgit v1.2.3