Example #1
0
 def test_push_front(self):
     q = LinkedDeque()
     q.push_front("A")
     assert q.length() == 1
     q.push_front("B")
     assert q.length() == 2
     assert q.front() == "B"
     assert q.back() == "A"
Example #2
0
 def test_pop_front(self):
     q = LinkedDeque()
     with self.assertRaises(ValueError):
         q.pop_front()
     q.push_front("A")
     assert q.length() == 1
     assert q.pop_front() == "A"
     assert q.is_empty() is True
     q.push_front("one")
     q.push_back("two")
     assert q.pop_front() == "one"
     assert q.pop_front() == "two"
     with self.assertRaises(ValueError):
         q.pop_front()
     assert q.is_empty() is True
 def test_push_front(self):
     dq = LinkedDeque()
     dq.push_front('A')
     assert dq.length() == 1
     assert dq.front() == 'A'
     dq.push_front('B')
     assert dq.length() == 2
     assert dq.front() == 'B'
     dq.push_front('C')
     assert dq.length() == 3
     assert dq.front() == 'C'
     assert dq.is_empty() == False