forked from wufenggirl/LeetCode-in-Golang
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmin-stack_test.go
More file actions
executable file
·50 lines (43 loc) · 852 Bytes
/
min-stack_test.go
File metadata and controls
executable file
·50 lines (43 loc) · 852 Bytes
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
package problem0155
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_Problem155_1(t *testing.T) {
ast := assert.New(t)
s := Constructor()
s.Push(-2)
// [-2]
s.Push(0)
// [-2, 0]
s.Push(-3)
// [-2, 0, -3]
ast.Equal(-3, s.GetMin(), "get min from [-2, 0, -3]")
// [-2, 0, -3]
s.Pop()
// [-2, 0]
ast.Equal(0, s.Top(), "get top from [-2, 0]")
// [-2, 0]
ast.Equal(-2, s.GetMin(), "get min from [-2, 0]")
// [-2, 0]
}
func Test_Problem155_2(t *testing.T) {
ast := assert.New(t)
s := Constructor()
s.Push(-2)
// [-2]
s.Push(0)
// [-2, 0]
s.Push(-1)
// [-2, 0, -1]
ast.Equal(-2, s.GetMin(), "get min from [-2, -1, 0]")
// [-2, 0, -1]
ast.Equal(-1, s.Top(), "get top from [-2, -1, 0]")
// [-2, 0, -1]
s.Pop()
// [-2, 0]
ast.Equal(-2, s.GetMin(), "get top from [0, -1]")
// [-2, 0]
s.Pop()
// [-2]
}