From 328a781040f76b571ecb478bf80e6946c9493486 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Thu, 31 Oct 2024 20:40:14 -0700 Subject: [PATCH] [wpimath] Port Rotation2d Java tests to C++ (#7318) --- .../src/test/native/cpp/geometry/Rotation2dTest.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/wpimath/src/test/native/cpp/geometry/Rotation2dTest.cpp b/wpimath/src/test/native/cpp/geometry/Rotation2dTest.cpp index de2fc1741e..65d3016d18 100644 --- a/wpimath/src/test/native/cpp/geometry/Rotation2dTest.cpp +++ b/wpimath/src/test/native/cpp/geometry/Rotation2dTest.cpp @@ -49,6 +49,19 @@ TEST(Rotation2dTest, Minus) { EXPECT_DOUBLE_EQ(40.0, (rot1 - rot2).Degrees().value()); } +TEST(Rotation2dTest, UnaryMinus) { + const auto rot = Rotation2d{20_deg}; + + EXPECT_DOUBLE_EQ(-20.0, (-rot).Degrees().value()); +} + +TEST(Rotation2dTest, Multiply) { + const auto rot = Rotation2d{10_deg}; + + EXPECT_DOUBLE_EQ(30.0, (rot * 3.0).Degrees().value()); + EXPECT_DOUBLE_EQ(410.0, (rot * 41.0).Degrees().value()); +} + TEST(Rotation2dTest, Equality) { auto rot1 = Rotation2d{43_deg}; auto rot2 = Rotation2d{43_deg};