-
Notifications
You must be signed in to change notification settings - Fork 0
/
stack_test.go
62 lines (46 loc) · 1017 Bytes
/
stack_test.go
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
50
51
52
53
54
55
56
57
58
59
60
61
62
package adt_test
import (
"adt"
"testing"
"github.com/stretchr/testify/suite"
)
func (s *StackSuite) SetupTest() {
s.stack = adt.NewStack()
}
func (s *StackSuite) TestEmpty() {
s.True(s.stack.IsEmpty())
}
func (s *StackSuite) TestNotEmpty() {
s.stack.Bury("red")
s.False(s.stack.IsEmpty())
}
func (s *StackSuite) TestEmptySizeZero() {
s.Zero(s.stack.Size())
}
func (s *StackSuite) TestTwoSize() {
s.stack.Bury("red")
s.stack.Bury("blue")
s.Equal(2, s.stack.Size())
}
func (s *StackSuite) TestUnburySingleItem() {
s.stack.Bury("red")
s.Equal("red", s.stack.Unbury())
s.Zero(s.stack.Size())
s.True(s.stack.IsEmpty())
}
func (s *StackSuite) TestUnburyMutlipleItems() {
s.stack.Bury("red")
s.stack.Bury("blue")
s.Equal("blue", s.stack.Unbury())
s.Equal(1, s.stack.Size())
s.Equal("red", s.stack.Unbury())
s.Zero(s.stack.Size())
s.True(s.stack.IsEmpty())
}
type StackSuite struct {
suite.Suite
stack *adt.Stack
}
func TestStackSuite(t *testing.T) {
suite.Run(t, new(StackSuite))
}