Beispiel #1
0
 def test_query_pos(self):
     test_cnt = 1000
     for t in range(test_cnt):
         i = randint(0, len(self.array) - 2)
         j = randint(i + 1, len(self.array) - 1)
         self.assertEqual(self.rmq.query_pos(i, j),
                          i + argmin(self.array[i:j]))
 def test_first(self):
     self.assertEqual(argmin(3, 4, 7, 4), 0)
     self.assertEqual(argmin(3, 4, 7, 3), 0)
 def test_last(self):
     self.assertEqual(argmin(3, 4, 7, 4, 1), 4)
     self.assertEqual(argmin(3, 4, 7, 3, 1), 4)
 def test_middle(self):
     self.assertEqual(argmin(3, 4, 0, 4), 2)
     self.assertEqual(argmin(3, 0, 7, 3), 1)
 def test_array(self):
     self.assertEqual(argmin([3, 4, 0, 4]), 2)
     self.assertEqual(argmin([3, 0, 7, 3]), 1)
 def test_two(self):
     self.assertEqual(argmin(0, 1), 0)
     self.assertEqual(argmin(0, 0), 0)
     self.assertEqual(argmin(1, 0), 1)
Beispiel #7
0
 def test_query_pos(self):
     test_cnt = 1000
     for t in range(test_cnt):
         i = randint(0, len(self.array) - 2)
         j = randint(i + 1, len(self.array) - 1)
         self.assertEqual(self.rmq.query_pos(i, j), i + argmin(self.array[i:j]))