]> git.lizzy.rs Git - micro.git/blob - cmd/micro/stack_test.go
Start refactor
[micro.git] / cmd / micro / stack_test.go
1 package main
2
3 import (
4         "testing"
5         "time"
6
7         "github.com/stretchr/testify/assert"
8 )
9
10 func TestStack(t *testing.T) {
11         s := new(TEStack)
12         e1 := &TextEvent{
13                 EventType: TextEventReplace,
14                 Time:      time.Now(),
15         }
16         e2 := &TextEvent{
17                 EventType: TextEventInsert,
18                 Time:      time.Now(),
19         }
20         s.Push(e1)
21         s.Push(e2)
22
23         p := s.Peek()
24         assert.Equal(t, p.EventType, TextEventInsert)
25         p = s.Pop()
26         assert.Equal(t, p.EventType, TextEventInsert)
27         p = s.Peek()
28         assert.Equal(t, p.EventType, TextEventReplace)
29         p = s.Pop()
30         assert.Equal(t, p.EventType, TextEventReplace)
31         p = s.Pop()
32         assert.Nil(t, p)
33         p = s.Peek()
34         assert.Nil(t, p)
35 }