Esempio n. 1
0
 def test_find_first_1(self):
     n1 = 2
     n2 = 2
     n3 = 3
     ls = OrderedList(True)
     ls.add(n1)
     ls.add(n2)
     ls.add(n3)
     data = ls.find(2)
     res = ls.get_index(0)
     self.assertEqual(data, res)
Esempio n. 2
0
 def test_find_none(self):
     n1 = 2
     n2 = 2
     n3 = 3
     ls = OrderedList(False)
     ls.add(n1)
     ls.add(n2)
     ls.add(n3)
     data = ls.find(1)
     res = None
     self.assertEqual(data, res)
Esempio n. 3
0
 def test_find_random(self):
     for t in range(1000):
         l = []
         nodes_count = random.randint(0, 10)
         ls = OrderedList(True)
         for i in range(nodes_count):
             r = random.randint(0, 10)
             ls.add(r)
             l.append(r)
         l = sorted(l)
         data = ls.find(5)
         try:
             res = ls.get_index(l.index(5))
         except:
             res = None
         self.assertEqual(data, res)