예제 #1
0
    def test_positiveIntegers(self):
        """ Tests from the READ.me """
        # Testing input with only 1 return value
        self.assertEqual(ranges([1, 2]), ["1->2"])

        # Testing input with no return value
        self.assertEqual(ranges([1]), [])

        # Testing input with multiple return values
        self.assertEqual(ranges([1, 2, 3, 4, 5, 8, 9, 10]), ["1->5", "8->10"])
예제 #2
0
 def test_largest(self):
     self.assertEqual(
         ranges([
             1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15, 20, 25, 26, 27, 28, 29,
             30, 33, 34, 35, 36, 37, 40, 41, 42, 43, 44, 77, 78, 79, 80,
             100, 101, 102, 103, 104, 105, 106, 107, 108, 200, 1001, 1002,
             1003, 1234, 1235, 1236, 1237, 1996, 1997, 1998, 1999, 2000,
             2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
             2011, 2012, 2013, 2014, 2015, 2016, 2017, 2080
         ]), [
             '1->5', '10->15', '25->30', '33->37', '40->44', '77->80',
             '100->108', '1001->1003', '1234->1237', '1996->2017'
         ])
예제 #3
0
 def test_single(self):
     self.assertEqual(ranges([1, 2]), ['1->2'])
예제 #4
0
 def test_empty(self):
     self.assertEqual(ranges([]), [])
예제 #5
0
 def test_negatives(self):
     self.assertEqual(
         ranges([
             -20, -19, -18, -17, -16, -3, -2, -1, 0, 1, 2, 3, 10, 11, 12,
             13, 14
         ]), ['-20->-16', '-3->3', '10->14'])
예제 #6
0
 def test_three_ranges(self):
     self.assertEqual(ranges([1, 2, 3, 4, 8, 9, 10, 12, 13, 14]),
                      ['1->4', '8->10', '12->14'])
예제 #7
0
 def test_two_ranges(self):
     self.assertEqual(ranges([1, 2, 3, 4, 7, 8, 9]), ['1->4', '7->9'])
예제 #8
0
 def test_larger(self):
     self.assertEqual(
         ranges([
             0, 1, 2, 3, 4, 5, 7, 8, 9, 11, 12, 13, 20, 21, 22, 23, 24, 25,
             33, 44, 55, 60, 61, 62
         ]), ['0->5', '7->9', '11->13', '20->25', '60->62'])
예제 #9
0
 def test_large(self):
     self.assertEqual(ranges([1, 2, 3, 4, 5, 8, 9, 10]), ['1->5', '8->10'])
예제 #10
0
 def test_single(self):
     self.assertEqual(ranges([1]), [])
예제 #11
0
 def test_small(self):
     self.assertEqual(ranges([1, 2]), ['1->2'])