ArrayStackTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
c 4
b 0
f 0
dl 0
loc 17
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A test_push() 0 16 4
1
import unittest
2
3
from pyalgs.data_structures.commons.stack import LinkedListStack
4
from pyalgs.data_structures.commons.stack import ArrayStack
5
from pyalgs.data_structures.commons.stack import Stack
6
7
8 View Code Duplication
class StackTest(unittest.TestCase):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
9
    def test_push(self):
10
        stack = Stack.create()
11
        stack.push(10)
12
        stack.push(1)
13
14
        print([i for i in stack.iterate()])
15
16
        self.assertFalse(stack.is_empty())
17
        self.assertEqual(2, stack.size())
18
        self.assertEqual(1, stack.pop())
19
        self.assertFalse(stack.is_empty())
20
        self.assertEqual(1, stack.size())
21
        self.assertEqual(10, stack.pop())
22
        self.assertTrue(stack.is_empty())
23
24
        for i in range(100):
25
            stack.push(i)
26
27
28 View Code Duplication
class LinkedListStackTest(unittest.TestCase):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
29
    def test_push(self):
30
        stack = LinkedListStack()
31
        stack.push(10)
32
        stack.push(1)
33
34
        print([i for i in stack.iterate()])
35
36
        self.assertFalse(stack.is_empty())
37
        self.assertEqual(2, stack.size())
38
        self.assertEqual(1, stack.pop())
39
        self.assertFalse(stack.is_empty())
40
        self.assertEqual(1, stack.size())
41
        self.assertEqual(10, stack.pop())
42
        self.assertTrue(stack.is_empty())
43
44
        for i in range(100):
45
            stack.push(i)
46
47
48
class ArrayStackTest(unittest.TestCase):
49
    def test_push(self):
50
        stack = ArrayStack()
51
        stack.push(10)
52
53
        print([i for i in stack.iterate()])
54
55
        self.assertFalse(stack.is_empty())
56
        self.assertEqual(1, stack.size())
57
        self.assertEqual(10, stack.pop())
58
        self.assertTrue(stack.is_empty())
59
60
        for i in range(100):
61
            stack.push(i)
62
63
        for i in range(100):
64
            stack.pop()
65
66
67
if __name__ == '__main__':
68
    unittest.main()
69