Преглед изворни кода

test: test Interval.overlaps()

main
Rob Hallam пре 2 месеци
родитељ
комит
4cf406935b
1 измењених фајлова са 16 додато и 0 уклоњено
  1. +16
    -0
      test/test_utils.py

+ 16
- 0
test/test_utils.py Прегледај датотеку

@@ -225,6 +225,22 @@ class TestInterval(unittest.TestCase):
interval.update_duration(5, relative=True)
self.assertEqual(interval.start, 0)

def test_overlaps(self):
"""Test the overlaps method - returns True if the interval overlaps with another interval"""
interval1 = utils.Interval(start=0, end=10)
interval2 = utils.Interval(start=5, end=15) # overlaps with interval1
interval3 = utils.Interval(start=15, end=20) # does not overlap with interval1
interval4 = utils.Interval(start=10, end=15) # touch overlap with interval1
# test with overlapping interval
self.assertTrue(interval1.overlaps(interval2))
self.assertTrue(interval2.overlaps(interval1))
# test with non-overlapping interval
self.assertFalse(interval1.overlaps(interval3))
self.assertFalse(interval3.overlaps(interval1))
# test with touching interval
self.assertTrue(interval1.overlaps(interval4))
self.assertTrue(interval4.overlaps(interval1))

# Unhappy path tests

def test_init_no_start_end(self):


Loading…
Откажи
Сачувај