mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-29 02:21:44 +00:00
[wpimath] Add structs for TrapezoidProfile.State and ExponentialProfile.State (#8163)
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
// 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.
|
||||
|
||||
package edu.wpi.first.math.trajectory.struct;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import edu.wpi.first.math.trajectory.ExponentialProfile;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class ExponentialProfileStateStructTest {
|
||||
private static final ExponentialProfile.State STATE = new ExponentialProfile.State(4.0, 5.0);
|
||||
|
||||
@Test
|
||||
void testRoundtrip() {
|
||||
ByteBuffer buffer = ByteBuffer.allocate(ExponentialProfile.State.struct.getSize());
|
||||
buffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||
ExponentialProfile.State.struct.pack(buffer, STATE);
|
||||
buffer.rewind();
|
||||
assertEquals(STATE, ExponentialProfile.State.struct.unpack(buffer));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// 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.
|
||||
|
||||
package edu.wpi.first.math.trajectory.struct;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import edu.wpi.first.math.trajectory.TrapezoidProfile;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class TrapezoidProfileStateStructTest {
|
||||
private static final TrapezoidProfile.State STATE = new TrapezoidProfile.State(4.0, 5.0);
|
||||
|
||||
@Test
|
||||
void testRoundtrip() {
|
||||
ByteBuffer buffer = ByteBuffer.allocate(TrapezoidProfile.State.struct.getSize());
|
||||
buffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||
TrapezoidProfile.State.struct.pack(buffer, STATE);
|
||||
buffer.rewind();
|
||||
assertEquals(STATE, TrapezoidProfile.State.struct.unpack(buffer));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user