Bring float quaternion tests to parity.

This commit is contained in:
Kyle Isom 2019-08-05 09:47:47 -07:00
parent de1c4e6109
commit a3c815daca
1 changed files with 22 additions and 1 deletions

View File

@ -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) TEST(Quaternionf, Norm)
{ {
geom::Quaternionf p(geom::Vector3f {0.9899139811480784, 9.387110042325054, 6.161341707794767}, geom::Quaternionf p(geom::Vector3f {0.9899139811480784, 9.387110042325054, 6.161341707794767},
5.563199889674063); 5.563199889674063);
float norm = 12.57016663729933; 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) TEST(QuaternionMiscellaneous, SanityChecks)
{ {
geom::Vector3d v {1.0, 2.0, 3.0}; geom::Vector3d v {1.0, 2.0, 3.0};