Ejemplo n.º 1
0
 def test_03_03(self):
     """OaS.indexMatch() - correct match on range(3)"""
     self.assertEqual(-1, OaS.indexMatch(list(range(3)), -1))
     self.assertEqual(0, OaS.indexMatch(list(range(3)), 0))
     self.assertEqual(1, OaS.indexMatch(list(range(3)), 1))
     self.assertEqual(2, OaS.indexMatch(list(range(3)), 2))
     self.assertEqual(-1, OaS.indexMatch(list(range(3)), 3))
Ejemplo n.º 2
0
 def test_04(self):
     """OaS.indexMatch() - 100 random ranges -10,000 to 10,000"""
     random.seed()
     for i in range(1):
         start = random.randint(-10000, 10000)
         end = random.randint(-10000, 10000)
         if start > end:
             start, end = end, start
         myR = list(range(start, end))
         self.assertEqual(-1, OaS.indexMatch(myR, start - 1))
         for j, aVal in enumerate(myR):
             self.assertEqual(j, OaS.indexMatch(myR, aVal))
         self.assertEqual(-1, OaS.indexMatch(myR, end))
Ejemplo n.º 3
0
 def test_02(self):
     """OaS.indexMatch() - missing returns -1"""
     self.assertEqual(-1, OaS.indexMatch(list(range(4)), 23))
     self.assertEqual(-1, OaS.indexMatch(list(range(4)), -1))
     self.assertEqual(-1, OaS.indexMatch(list(range(4)), 4))
Ejemplo n.º 4
0
 def test_01(self):
     """OaS.indexMatch() - empty list returns -1"""
     self.assertEqual(-1, OaS.indexMatch([], 23))