Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Miscellaneous
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
practice problem folder
Miscellaneous
Commits
12a880e0
Commit
12a880e0
authored
1 month ago
by
Duncan Holmes
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
9cf67a6d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lab - linked list lab/TestStacksDifferentially.py
+66
-0
66 additions, 0 deletions
lab - linked list lab/TestStacksDifferentially.py
with
66 additions
and
0 deletions
lab - linked list lab/TestStacksDifferentially.py
0 → 100644
+
66
−
0
View file @
12a880e0
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
())
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment