Skip to content
This repository was archived by the owner on Nov 5, 2023. It is now read-only.

Fuzz TimeInterpolatableBuffer #43

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pytest
hypothesis
pytest
19 changes: 19 additions & 0 deletions tests/test_interpolation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import math
from typing import Iterable

from hypothesis import given, strategies as st

from wpimath.geometry import Pose2d, Rotation2d
from wpimath.interpolation import (
Expand All @@ -23,6 +26,22 @@ def test_float():
assert buffer.sample(0) == 1


@given(
st.builds(TimeInterpolatableFloatBuffer, st.floats(1, 10)),
st.iterables(
st.tuples(st.booleans(), st.floats(0, 100))
),
)
def test_float_arbitrary(
buffer: TimeInterpolatableFloatBuffer, instructions: Iterable[tuple[bool, float]]
):
for should_add, time_s in instructions:
if should_add:
buffer.addSample(time_s, 0)
else:
buffer.sample(time_s)


def test_rotation2d():
buffer = TimeInterpolatableRotation2dBuffer(10)

Expand Down