From a3c815dacad1406be213e81c0eef76dfd8b3c56c Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Mon, 5 Aug 2019 09:47:47 -0700 Subject: [PATCH] Bring float quaternion tests to parity. --- test/quaternion_test.cc | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/test/quaternion_test.cc b/test/quaternion_test.cc index 94713aa..4bcd967 100644 --- a/test/quaternion_test.cc +++ b/test/quaternion_test.cc @@ -47,13 +47,25 @@ TEST(Quaterniond, Identity) } +TEST(Quaternionf, Addition) +{ + geom::Quaternionf p(geom::Vector3f {1.0, -2.0, 1.0}, 3.0); + geom::Quaternionf q(geom::Vector3f {-1.0, 2.0, 3.0}, 2.0); + geom::Quaternionf expected(geom::Vector3f{0.0, 0.0, 4.0}, 5.0); + + EXPECT_EQ(p + q, expected); + EXPECT_EQ(expected - q, p); + EXPECT_NE(expected - q, q); // exercise != +} + + TEST(Quaternionf, Norm) { geom::Quaternionf p(geom::Vector3f {0.9899139811480784, 9.387110042325054, 6.161341707794767}, 5.563199889674063); float norm = 12.57016663729933; - EXPECT_DOUBLE_EQ(p.norm(), norm); + EXPECT_FLOAT_EQ(p.norm(), norm); } @@ -67,6 +79,15 @@ TEST(Quaternionf, Product) } +TEST(Quaternionf, Identity) +{ + geom::Quaternionf p(geom::Vector3f {1.0, -2.0, 1.0}, 3.0); + geom::Quaternionf q; + + EXPECT_EQ(p * q, p); +} + + TEST(QuaternionMiscellaneous, SanityChecks) { geom::Vector3d v {1.0, 2.0, 3.0};