diff --git a/lab - linked list lab/TestStacksDifferentially.py b/lab - linked list lab/TestStacksDifferentially.py new file mode 100644 index 0000000000000000000000000000000000000000..378f5cdb2c73417c79e93957b5a1c492f03c5a08 --- /dev/null +++ b/lab - linked list lab/TestStacksDifferentially.py @@ -0,0 +1,66 @@ +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()) + + + + + +