-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack_test.go
More file actions
50 lines (38 loc) · 861 Bytes
/
stack_test.go
File metadata and controls
50 lines (38 loc) · 861 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 main
import (
"testing"
"bytes"
)
func TestStack_Push_Pop(t *testing.T) {
s := NewStack()
s.Push([]byte("1"))
ret := s.Pop()
if !bytes.Equal(ret, []byte("1")) {
t.Errorf("Expected %v, but got: %v", []byte("1"), ret)
}
}
func TestStack_Len(t *testing.T) {
s := NewStack()
s.Push([]byte("1"))
if s.Len() != 1 {
t.Errorf("Expected len of stack is equal 1, but got: %v", s.Len())
}
s.Push([]byte("2"))
if s.Len() != 2 {
t.Errorf("Expected len of stack is equal 2, but got: %v", s.Len())
}
s.Pop()
if s.Len() != 1 {
t.Errorf("Expected len of stack is equal 1, but got: %v", s.Len())
}
}
func TestStack_Pop_LIFO(t *testing.T) {
s := NewStack()
s.Push([]byte("1"))
s.Push([]byte("2"))
s.Push([]byte("3"))
got := s.Pop()
if !bytes.Equal(got, []byte("3")) {
t.Errorf("Expected %v, but got: %v", []byte("3"), got)
}
}