Skip to content

Commit

Permalink
Add xfailing tests for remaining bounds handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
mlojek committed Feb 7, 2025
1 parent c7c0963 commit 307ad87
Show file tree
Hide file tree
Showing 3 changed files with 165 additions and 0 deletions.
68 changes: 68 additions & 0 deletions tests/data_classes/bounds_handle/test_bounds_reflect.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
"""
Unit tests for Bounds.reflect method.
"""

import pytest


@pytest.mark.xfail
class TestBoundsReflect:
"""
Unit tests for Bounds.reflect method.
"""

def test_point_in_bounds(self, example_bounds, point_in_bounds):
"""
Test if reflection works as expected when the point lies within bounds.
"""
handled_point = example_bounds.reflect(point_in_bounds)
assert handled_point.x == [14]

def test_point_equal_lower_bound(self, example_bounds, point_equal_lower_bound):
"""
Test if reflection works as expected when the point lies on the lower bound.
"""
handled_point = example_bounds.reflect(point_equal_lower_bound)
assert handled_point.x == [10]

def test_point_equal_upper_bound(self, example_bounds, point_equal_upper_bound):
"""
Test if reflection works as expected when the point lies on the upper bound.
"""
handled_point = example_bounds.reflect(point_equal_upper_bound)
assert handled_point.x == [20]

def test_point_below_bounds(self, example_bounds, point_below_bounds):
"""
Test if reflection works as expected when the point lies below the lower bound.
"""
handled_point = example_bounds.reflect(point_below_bounds)
assert handled_point.x == [18]

def test_point_above_bounds(self, example_bounds, point_above_bounds):
"""
Test if reflection works as expected when the point lies above the upper bound.
"""
handled_point = example_bounds.reflect(point_above_bounds)
assert handled_point.x == [17]

def test_point_twice_below_bounds(self, example_bounds, point_twice_below_bounds):
"""
Test if reflection works as expected when the point lies far below the lower bound.
"""
handled_point = example_bounds.reflect(point_twice_below_bounds)
assert handled_point.x == [16]

def test_point_twice_above_bounds(self, example_bounds, point_twice_above_bounds):
"""
Test if reflection works as expected when the point lies far above the upper bound.
"""
handled_point = example_bounds.reflect(point_twice_above_bounds)
assert handled_point.x == [12]

def test_multidimensional(self, example_bounds, point_multidimensional):
"""
Test if reflection works as expected for a multidimensional point.
"""
handled_point = example_bounds.reflect(point_multidimensional)
assert handled_point.x == [14, 10, 20, 18, 17, 16, 12]
68 changes: 68 additions & 0 deletions tests/data_classes/bounds_handle/test_bounds_wrap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
"""
Unit tests for Bounds.wrap method.
"""

import pytest


@pytest.mark.xfail
class TestBoundswrap:
"""
Unit tests for Bounds.wrap method.
"""

def test_point_in_bounds(self, example_bounds, point_in_bounds):
"""
Test if wrapping works as expected when the point lies within bounds.
"""
handled_point = example_bounds.wrap(point_in_bounds)
assert handled_point.x == [14]

def test_point_equal_lower_bound(self, example_bounds, point_equal_lower_bound):
"""
Test if wrapping works as expected when the point lies on the lower bound.
"""
handled_point = example_bounds.wrap(point_equal_lower_bound)
assert handled_point.x == [10]

def test_point_equal_upper_bound(self, example_bounds, point_equal_upper_bound):
"""
Test if wrapping works as expected when the point lies on the upper bound.
"""
handled_point = example_bounds.wrap(point_equal_upper_bound)
assert handled_point.x == [20]

def test_point_below_bounds(self, example_bounds, point_below_bounds):
"""
Test if wrapping works as expected when the point lies below the lower bound.
"""
handled_point = example_bounds.wrap(point_below_bounds)
assert handled_point.x == [2]

def test_point_above_bounds(self, example_bounds, point_above_bounds):
"""
Test if wrapping works as expected when the point lies above the upper bound.
"""
handled_point = example_bounds.wrap(point_above_bounds)
assert handled_point.x == [14]

def test_point_twice_below_bounds(self, example_bounds, point_twice_below_bounds):
"""
Test if wrapping works as expected when the point lies far below the lower bound.
"""
handled_point = example_bounds.wrap(point_twice_below_bounds)
assert handled_point.x == [16]

def test_point_twice_above_bounds(self, example_bounds, point_twice_above_bounds):
"""
Test if wrapping works as expected when the point lies far above the upper bound.
"""
handled_point = example_bounds.wrap(point_twice_above_bounds)
assert handled_point.x == [12]

def test_multidimensional(self, example_bounds, point_multidimensional):
"""
Test if wrapping works as expected for a multidimensional point.
"""
handled_point = example_bounds.wrap(point_multidimensional)
assert handled_point.x == [14, 10, 20, 2, 14, 16, 12]
29 changes: 29 additions & 0 deletions tests/data_classes/bounds_handle/test_handle_bounds.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""
Unit tests for Bounds.handle_bounds method.
"""

import pytest


class TestBoundsHandleBounds:
"""
Unit tests for Bounds.handle_bounds method.
"""

def test_project(self, example_bounds, point_multidimensional):
handled_point = example_bounds.handle_bounds(point_multidimensional, "project")
assert handled_point.x == [14, 10, 20, 10, 20, 10, 20]

@pytest.mark.xfail()
def test_reflect(self, example_bounds, point_multidimensional):
handled_point = example_bounds.handle_bounds(point_multidimensional, "reflect")
assert handled_point.x == [14, 10, 20, 18, 17, 16, 12]

@pytest.mark.xfail()
def test_wrap(self, example_bounds, point_multidimensional):
handled_point = example_bounds.handle_bounds(point_multidimensional, "wrap")
assert handled_point.x == [14, 10, 20, 2, 14, 16, 12]

def test_invalid_mode(self, example_bounds, point_multidimensional):
with pytest.raises(ValueError, match="Invalid mode"):
example_bounds.handle_bounds(point_multidimensional, "invalid")

0 comments on commit 307ad87

Please sign in to comment.