diff --git a/tests/requirements.txt b/tests/requirements.txt index 55b033e..9a54149 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1 +1,2 @@ -pytest \ No newline at end of file +hypothesis +pytest diff --git a/tests/test_interpolation.py b/tests/test_interpolation.py index e15c05e..03dd864 100644 --- a/tests/test_interpolation.py +++ b/tests/test_interpolation.py @@ -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 ( @@ -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)