소스 검색

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):


불러오는 중...
취소
저장