Exemple #1
0
    def test_iterate_with_iterator(self):
        l = DoubleLinkedList.from_list([1, 2, 3, 4, 5])

        accumulator = []
        it = l.iterator_first()
        while it is not None:
            accumulator.append(it.value)
            it = it.next

        self.assertEqual(accumulator, [1, 2, 3, 4, 5])
Exemple #2
0
    def test_pop_first_few_elements(self):
        l = DoubleLinkedList().from_list([1, 2, 3, 4, 5])
        l.pop_first()
        l.pop_first()
        l.pop_first()

        self.assertEqual(list(l), [4, 5])
Exemple #3
0
    def test_push_first_a_few_elements(self):
        l = DoubleLinkedList()
        l.push_first(1)
        l.push_first(2)
        l.push_first(3)

        self.assertEqual(list(l), [3, 2, 1])
Exemple #4
0
    def __init__(self, config, initial_frame):
        """
        Konstruktor klasy. Przekazywane do niego są: konfiguracja oraz pierwsza klatka
        """

        self.scene_rectangle = Rectangle(0, 0, config['width'],
                                         config['height'])

        self.config = config
        self.initial_frame = initial_frame

        self.frames = DoubleLinkedList.from_list([initial_frame])
        self.current_frame_iterator = self.frames.iterator_first()
        self.frames_counter = 0
Exemple #5
0
    def test_5_len(self):
        l = DoubleLinkedList.from_list([1, 2, 3, 4, 5])

        self.assertEqual(len(l), 5)
Exemple #6
0
    def test_0_len(self):
        l = DoubleLinkedList()

        self.assertEqual(len(l), 0)
Exemple #7
0
    def test_empty(self):
        l = DoubleLinkedList()

        self.assertTrue(l.empty())
Exemple #8
0
    def test_non_empty(self):
        l = DoubleLinkedList.from_list([1, 2, 3, 4, 5])

        self.assertFalse(l.empty())
Exemple #9
0
    def test_reverse(self):
        l = DoubleLinkedList.from_list([1, 2, 3, 4, 5])

        self.assertEqual(list(reversed(l)), [5, 4, 3, 2, 1])
Exemple #10
0
    def test_push_last_one_element(self):
        l = DoubleLinkedList()
        l.push_last(1)

        self.assertEqual(list(l), [1])
Exemple #11
0
    def test_pop_last_one_element(self):
        l = DoubleLinkedList().from_list([1, 2, 3, 4, 5])
        l.pop_last()

        self.assertEqual(list(l), [1, 2, 3, 4])
Exemple #12
0
    def test_creating_list_from_static_method(self):
        l = DoubleLinkedList.from_list([1, 2, 3, 4, 5])

        self.assertEqual(list(l), [1, 2, 3, 4, 5])