mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[wpimath] Move struct/proto classes to separate files (#5918)
Also add unit tests.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "frc/geometry/Transform3d.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
namespace {
|
||||
|
||||
using StructType = wpi::Struct<frc::Transform3d>;
|
||||
const Transform3d kExpectedData{
|
||||
Transform3d{Translation3d{0.3504_m, 22.9_m, 3.504_m},
|
||||
Rotation3d{Quaternion{0.3504, 35.04, 2.29, 0.3504}}}};
|
||||
} // namespace
|
||||
|
||||
TEST(Transform3dStructTest, Roundtrip) {
|
||||
uint8_t buffer[StructType::kSize];
|
||||
std::memset(buffer, 0, StructType::kSize);
|
||||
StructType::Pack(buffer, kExpectedData);
|
||||
|
||||
Transform3d unpacked_data = StructType::Unpack(buffer);
|
||||
|
||||
EXPECT_EQ(kExpectedData.Translation(), unpacked_data.Translation());
|
||||
EXPECT_EQ(kExpectedData.Rotation(), unpacked_data.Rotation());
|
||||
}
|
||||
Reference in New Issue
Block a user