Skip to content
Snippets Groups Projects
Commit 12a880e0 authored by Duncan Holmes's avatar Duncan Holmes
Browse files

Upload New File

parent 9cf67a6d
Branches
No related tags found
No related merge requests found
from unittest import TestCase
from linked_list_example import Stack, LinkedStack
class TestStacksDifferentially(TestCase):
def test_lifo_with_no_interleaving(self):
# Set up one unit under test.
array_based = Stack()
array_based.push(14)
array_based.push(29)
# Set up the other unit under test.
link_based = LinkedStack()
link_based.push(14)
link_based.push(29)
# Assert that the behaviors match and include messages describing what could go wrong.
self.assertEqual( link_based.pop(), array_based.pop(), 'values of first pops did not agree')
self.assertEqual( link_based.pop(), array_based.pop(), 'values of second pops did not agree')
"""
Write an additional test case where the setup code interleaves
both push and pop calls. Verify that the array-based stack and
your link-based stack agree on that test case.
kiond've just sounds like what we had previously
WHATEVER
this is 6 test cases in one test case
"""
def test_compare_array_ADT_and_linked_ADT(self):
array_stack = Stack()
linked_stack = LinkedStack()
self.assertEqual( array_stack.is_empty() , linked_stack.is_empty() )
array_stack.push(1)
linked_stack.push(1)
self.assertEqual( array_stack.is_empty() , linked_stack.is_empty() )
self.assertEqual( array_stack.pop(), linked_stack.pop() )
array_stack.push(2)
linked_stack.push(2)
self.assertEqual(array_stack.is_empty(), linked_stack.is_empty())
self.assertEqual(array_stack.pop(), linked_stack.pop())
array_stack.push('a')
linked_stack.push('a')
self.assertEqual(array_stack.is_empty(), linked_stack.is_empty())
self.assertEqual(array_stack.pop(), linked_stack.pop())
array_stack.push(1)
linked_stack.push('a')
self.assertEqual(array_stack.is_empty(), linked_stack.is_empty())
self.assertNotEqual(array_stack.pop(), linked_stack.pop())
#array_stack.push(1)
linked_stack.push(1)
self.assertNotEqual(array_stack.is_empty(), linked_stack.is_empty())
self.assertNotEqual(array_stack.pop(), linked_stack.pop())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment