mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Upgrade to C++20 (#4239)
* Use explicit this capture required by C++20 * Use C++20 span * Replace wpi::numbers with std::numbers * Fix C++20 clang-tidy warning false positive in fmt * Remove ciso646 include since C++20 removed that header * Fix global-buffer-overflow asan warnings in ntcore tests * Add DIOSetProxy constructor to HAL * Upgrade MSVC compiler to 2022 * Bump native-utils to 2023.2.7 (changes to std=c++20) Co-authored-by: Peter Johnson <johnson.peter@gmail.com>
This commit is contained in:
@@ -3,8 +3,7 @@
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include <wpi/numbers>
|
||||
#include <numbers>
|
||||
|
||||
#include "frc/geometry/Rotation2d.h"
|
||||
#include "gtest/gtest.h"
|
||||
@@ -12,8 +11,8 @@
|
||||
using namespace frc;
|
||||
|
||||
TEST(Rotation2dTest, RadiansToDegrees) {
|
||||
const Rotation2d rot1{units::radian_t{wpi::numbers::pi / 3.0}};
|
||||
const Rotation2d rot2{units::radian_t{wpi::numbers::pi / 4.0}};
|
||||
const Rotation2d rot1{units::radian_t{std::numbers::pi / 3.0}};
|
||||
const Rotation2d rot2{units::radian_t{std::numbers::pi / 4.0}};
|
||||
|
||||
EXPECT_DOUBLE_EQ(60.0, rot1.Degrees().value());
|
||||
EXPECT_DOUBLE_EQ(45.0, rot2.Degrees().value());
|
||||
@@ -23,15 +22,15 @@ TEST(Rotation2dTest, DegreesToRadians) {
|
||||
const auto rot1 = Rotation2d{45_deg};
|
||||
const auto rot2 = Rotation2d{30_deg};
|
||||
|
||||
EXPECT_DOUBLE_EQ(wpi::numbers::pi / 4.0, rot1.Radians().value());
|
||||
EXPECT_DOUBLE_EQ(wpi::numbers::pi / 6.0, rot2.Radians().value());
|
||||
EXPECT_DOUBLE_EQ(std::numbers::pi / 4.0, rot1.Radians().value());
|
||||
EXPECT_DOUBLE_EQ(std::numbers::pi / 6.0, rot2.Radians().value());
|
||||
}
|
||||
|
||||
TEST(Rotation2dTest, RotateByFromZero) {
|
||||
const Rotation2d zero;
|
||||
auto rotated = zero + Rotation2d{90_deg};
|
||||
|
||||
EXPECT_DOUBLE_EQ(wpi::numbers::pi / 2.0, rotated.Radians().value());
|
||||
EXPECT_DOUBLE_EQ(std::numbers::pi / 2.0, rotated.Radians().value());
|
||||
EXPECT_DOUBLE_EQ(90.0, rotated.Degrees().value());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user