Skip to content
Closed
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: 3 additions & 0 deletions e2e_toy/tests/test_textops.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def test_inside(self):
def test_below(self):
self.assertEqual(clamp(-3, 0, 10), 0)

def test_at_upper_bound(self):
self.assertEqual(clamp(10, 0, 10), 10)


class ChunkTest(unittest.TestCase):
def test_even(self):
Expand Down
5 changes: 3 additions & 2 deletions e2e_toy/textops.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ def clamp(value, low, high):
"""Limit ``value`` to the closed range [low, high]."""
if value < low:
return low
if value > high:
return value
if value >= high:
# Values at or above the upper bound are handled here.
return max(value, high)
return value


Expand Down
Loading