def test_mergeIntervals(self): ## testing intervals: int1 = interval('[2,6]') int2 = interval('[4,9]') int3 = interval('[7,12]') int4 = interval('[8,10]') mergedInt = interval('[2,9]') adjInt = interval('[2,12]') ## test overlap merge: self.assertEqual(interval.mergeIntervals(int1, int2), mergedInt) ## test adjacent merge: self.assertEqual(interval.mergeIntervals(int1, int3), adjInt) ## test interval that does not merge: with self.assertRaises(IntervalError): interval.mergeIntervals(int1, int4)
def test_mergeIntervals(self): ## testing intervals: int1 = interval('[2,6]') int2 = interval('[4,9]') int3 = interval('[7,12]') int4 = interval('[8,10]') mergedInt = interval('[2,9]') adjInt = interval('[2,12]') ## test overlap merge: self.assertEqual(interval.mergeIntervals(int1,int2), mergedInt) ## test adjacent merge: self.assertEqual(interval.mergeIntervals(int1,int3), adjInt) ## test interval that does not merge: with self.assertRaises(IntervalError): interval.mergeIntervals(int1,int4)
def test_merge_interval(self): self.assertEqual(interval.mergeIntervals(interval("[2,6]"), interval("[3,8]")).interval2str(), "[2,8]") self.assertEqual(interval.mergeIntervals(interval("(0,12]"), interval("[3,13]")).interval2str(), "(0,13]") self.assertEqual(interval.mergeIntervals(interval("(0,12]"), interval("[3,4]")).interval2str(), "(0,12]") self.assertEqual(interval.mergeIntervals(interval("(0,3]"), interval("(3,4]")).interval2str(), "(0,4]") self.assertEqual(interval.mergeIntervals(interval("[1,3]"), interval("[2,5]")).interval2str(), "[1,5]") self.assertEqual(interval.mergeIntervals(interval("(1,13)"), interval("[2,25]")).interval2str(), "(1,25]")
def test_merge_interval(self): self.assertEqual( interval.mergeIntervals(interval('[2,6]'), interval('[3,8]')).interval2str(), '[2,8]') self.assertEqual( interval.mergeIntervals(interval('(0,12]'), interval('[3,13]')).interval2str(), '(0,13]') self.assertEqual( interval.mergeIntervals(interval('(0,12]'), interval('[3,4]')).interval2str(), '(0,12]') self.assertEqual( interval.mergeIntervals(interval('(0,3]'), interval('(3,4]')).interval2str(), '(0,4]') self.assertEqual( interval.mergeIntervals(interval('[1,3]'), interval('[2,5]')).interval2str(), '[1,5]') self.assertEqual( interval.mergeIntervals(interval('(1,13)'), interval('[2,25]')).interval2str(), '(1,25]')
def test_merge(self): # test for merge self.assertTrue(interval.mergeIntervals(self.interval1,self.interval2) == self.interval3)