Exemplo n.º 1
0
 def test_add_equal_down(self):
     l = OrderedList(False)
     n1 = 1
     n2 = 1
     n3 = 1
     sequence_list = []
     l.add(n1)
     sequence_list.append(l.get_index(0))
     l.add(n2)
     sequence_list.append(l.get_index(1))
     l.add(n3)
     sequence_list.append(l.get_index(2))
     data = l.get_all()
     res = sequence_list
     self.assertEqual(data, res)
Exemplo n.º 2
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)
Exemplo 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)