-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesting_stack.py
More file actions
49 lines (40 loc) · 1.4 KB
/
testing_stack.py
File metadata and controls
49 lines (40 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from myLib.datastructures.linear.Stack import Stack
from myLib.datastructures.nodes.DNode import DNode
import random
if __name__ == '__main__':
node = DNode(50)
# Testing Constructors
linked_list = Stack()
print(f"Intializing CircularDoublyLL with a nothing:")
linked_list.print()
linked_list = Stack(0)
print(f"Intializing CircularDoublyLL with an integer:")
linked_list.print()
linked_list = Stack(node)
print(f"Intializing CircularDoublyLL with a node:")
linked_list.print()
print(f"Testing push 5 times:")
for i in range(5):
linked_list.push(random.randint(0, 100))
linked_list.print()
print(f"Testing pop:")
linked_list.pop()
linked_list.print()
print(f"Testing peek:")
print(linked_list.peek(), "\n")
# Testing Inserts,
print(f"Testing insert, delete, and sort (Not available with Stack)")
linked_list.insert_head(DNode(random.randint(0, 100)))
linked_list.insert_tail(DNode(random.randint(0, 100)))
linked_list.insert(DNode(random.randint(0, 100)), 2)
linked_list.sort()
linked_list.delete_head()
linked_list.delete_tail()
linked_list.delete(node)
for i in range (5):
i = random.randint(0, 100)
linked_list.sorted_insert(DNode(i))
linked_list.print()
print(f"Testing Clear:")
linked_list.clear()
linked_list.print()