mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
[wpiutil] Change Struct to allow non-constexpr implementation (#5992)
This required changing the constant values (e.g. kSize) into functions (e.g. GetSize()). Fixed implementations of ForEachNested to be inline (as these are actually templates). Also added a ntcore Struct test.
This commit is contained in:
@@ -16,8 +16,8 @@ const ChassisSpeeds kExpectedData{
|
||||
} // namespace
|
||||
|
||||
TEST(ChassisSpeedsStructTest, Roundtrip) {
|
||||
uint8_t buffer[StructType::kSize];
|
||||
std::memset(buffer, 0, StructType::kSize);
|
||||
uint8_t buffer[StructType::GetSize()];
|
||||
std::memset(buffer, 0, StructType::GetSize());
|
||||
StructType::Pack(buffer, kExpectedData);
|
||||
|
||||
ChassisSpeeds unpacked_data = StructType::Unpack(buffer);
|
||||
|
||||
@@ -16,8 +16,8 @@ const DifferentialDriveKinematics kExpectedData{
|
||||
} // namespace
|
||||
|
||||
TEST(DifferentialDriveKinematicsStructTest, Roundtrip) {
|
||||
uint8_t buffer[StructType::kSize];
|
||||
std::memset(buffer, 0, StructType::kSize);
|
||||
uint8_t buffer[StructType::GetSize()];
|
||||
std::memset(buffer, 0, StructType::GetSize());
|
||||
StructType::Pack(buffer, kExpectedData);
|
||||
|
||||
DifferentialDriveKinematics unpacked_data = StructType::Unpack(buffer);
|
||||
|
||||
@@ -16,8 +16,8 @@ const DifferentialDriveWheelSpeeds kExpectedData{
|
||||
} // namespace
|
||||
|
||||
TEST(DifferentialDriveWheelSpeedsStructTest, Roundtrip) {
|
||||
uint8_t buffer[StructType::kSize];
|
||||
std::memset(buffer, 0, StructType::kSize);
|
||||
uint8_t buffer[StructType::GetSize()];
|
||||
std::memset(buffer, 0, StructType::GetSize());
|
||||
StructType::Pack(buffer, kExpectedData);
|
||||
|
||||
DifferentialDriveWheelSpeeds unpacked_data = StructType::Unpack(buffer);
|
||||
|
||||
@@ -17,8 +17,8 @@ const MecanumDriveKinematics kExpectedData{MecanumDriveKinematics{
|
||||
} // namespace
|
||||
|
||||
TEST(MecanumDriveKinematicsStructTest, Roundtrip) {
|
||||
uint8_t buffer[StructType::kSize];
|
||||
std::memset(buffer, 0, StructType::kSize);
|
||||
uint8_t buffer[StructType::GetSize()];
|
||||
std::memset(buffer, 0, StructType::GetSize());
|
||||
StructType::Pack(buffer, kExpectedData);
|
||||
|
||||
MecanumDriveKinematics unpacked_data = StructType::Unpack(buffer);
|
||||
|
||||
@@ -16,8 +16,8 @@ const MecanumDriveWheelPositions kExpectedData{
|
||||
} // namespace
|
||||
|
||||
TEST(MecanumDriveWheelPositionsStructTest, Roundtrip) {
|
||||
uint8_t buffer[StructType::kSize];
|
||||
std::memset(buffer, 0, StructType::kSize);
|
||||
uint8_t buffer[StructType::GetSize()];
|
||||
std::memset(buffer, 0, StructType::GetSize());
|
||||
StructType::Pack(buffer, kExpectedData);
|
||||
|
||||
MecanumDriveWheelPositions unpacked_data = StructType::Unpack(buffer);
|
||||
|
||||
@@ -16,8 +16,8 @@ const MecanumDriveWheelSpeeds kExpectedData{
|
||||
} // namespace
|
||||
|
||||
TEST(MecanumDriveWheelSpeedsStructTest, Roundtrip) {
|
||||
uint8_t buffer[StructType::kSize];
|
||||
std::memset(buffer, 0, StructType::kSize);
|
||||
uint8_t buffer[StructType::GetSize()];
|
||||
std::memset(buffer, 0, StructType::GetSize());
|
||||
StructType::Pack(buffer, kExpectedData);
|
||||
|
||||
MecanumDriveWheelSpeeds unpacked_data = StructType::Unpack(buffer);
|
||||
|
||||
@@ -16,8 +16,8 @@ const SwerveModulePosition kExpectedData{
|
||||
} // namespace
|
||||
|
||||
TEST(SwerveModulePositionStructTest, Roundtrip) {
|
||||
uint8_t buffer[StructType::kSize];
|
||||
std::memset(buffer, 0, StructType::kSize);
|
||||
uint8_t buffer[StructType::GetSize()];
|
||||
std::memset(buffer, 0, StructType::GetSize());
|
||||
StructType::Pack(buffer, kExpectedData);
|
||||
|
||||
SwerveModulePosition unpacked_data = StructType::Unpack(buffer);
|
||||
|
||||
@@ -16,8 +16,8 @@ const SwerveModuleState kExpectedData{
|
||||
} // namespace
|
||||
|
||||
TEST(SwerveModuleStateStructTest, Roundtrip) {
|
||||
uint8_t buffer[StructType::kSize];
|
||||
std::memset(buffer, 0, StructType::kSize);
|
||||
uint8_t buffer[StructType::GetSize()];
|
||||
std::memset(buffer, 0, StructType::GetSize());
|
||||
StructType::Pack(buffer, kExpectedData);
|
||||
|
||||
SwerveModuleState unpacked_data = StructType::Unpack(buffer);
|
||||
|
||||
Reference in New Issue
Block a user