Skip to content

Commit

Permalink
unit test for AAboveBSidebar method is_strictly_increasing
Browse files Browse the repository at this point in the history
  • Loading branch information
lhaibach committed Jan 27, 2025
1 parent f7a0d33 commit c6ab8b6
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions tests/test_aabovebsidebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,52 @@ def test(in_values, out_values):

# ensure a "noise" value "0.0" does not influence the result
test([1.0, 2.0, 3.0, 0.0, 4.0], [1.0, 2.0, 3.0, 0.0, 4.0])


def test_aabovebsidebar_isstrictlyincreasing(): # noqa: D103
"""Test the is_strictly_increasing method of the AAboveBSidebar class."""
# Case 1: Strictly increasing values
sidebar = AAboveBSidebar(
[
DepthColumnEntry(fitz.Rect(), value=1),
DepthColumnEntry(fitz.Rect(), value=2),
DepthColumnEntry(fitz.Rect(), value=3),
DepthColumnEntry(fitz.Rect(), value=4),
DepthColumnEntry(fitz.Rect(), value=5),
]
)
assert sidebar.is_strictly_increasing(), "The sidebar should be strictly increasing"

# Case 2: Not strictly increasing (equal values)
sidebar = AAboveBSidebar(
[
DepthColumnEntry(fitz.Rect(), value=1),
DepthColumnEntry(fitz.Rect(), value=2),
DepthColumnEntry(fitz.Rect(), value=2),
DepthColumnEntry(fitz.Rect(), value=4),
]
)
assert not sidebar.is_strictly_increasing(), "The sidebar should not be strictly increasing"

# Case 3: Not strictly increasing (decreasing)
sidebar = AAboveBSidebar(
[
DepthColumnEntry(fitz.Rect(), value=5),
DepthColumnEntry(fitz.Rect(), value=4),
DepthColumnEntry(fitz.Rect(), value=3),
DepthColumnEntry(fitz.Rect(), value=2),
]
)
assert not sidebar.is_strictly_increasing(), "The sidebar should not be strictly increasing"

# Case 4: Single entry (trivial)
sidebar = AAboveBSidebar(
[
DepthColumnEntry(fitz.Rect(), value=1),
]
)
assert sidebar.is_strictly_increasing(), "A single entry should be considered strictly increasing"

# Case 5: Empty
sidebar = AAboveBSidebar([])
assert sidebar.is_strictly_increasing(), "An empty list should be considered strictly increasing"

0 comments on commit c6ab8b6

Please sign in to comment.