mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
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.
29 lines
901 B
C++
29 lines
901 B
C++
// 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::GetSize()];
|
|
std::memset(buffer, 0, StructType::GetSize());
|
|
StructType::Pack(buffer, kExpectedData);
|
|
|
|
Transform3d unpacked_data = StructType::Unpack(buffer);
|
|
|
|
EXPECT_EQ(kExpectedData.Translation(), unpacked_data.Translation());
|
|
EXPECT_EQ(kExpectedData.Rotation(), unpacked_data.Rotation());
|
|
}
|