-
Notifications
You must be signed in to change notification settings - Fork 38
/
ioc_test.go
54 lines (41 loc) · 932 Bytes
/
ioc_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
package idiom
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_Undo(t *testing.T) {
set := NewIntSet()
assert.False(t, set.Contains(1))
set.Add(1)
assert.True(t, set.Contains(1))
set.Delete(1)
assert.False(t, set.Contains(1))
}
func Test_UndoableSet(t *testing.T) {
set := NewUndoableIntSet()
assert.False(t, set.Contains(1))
set.Add(1)
set.Add(2)
assert.True(t, set.Contains(1))
assert.True(t, set.Contains(2))
err := set.Undo()
assert.Nil(t, err)
assert.False(t, set.Contains(2))
err = set.Undo()
assert.Nil(t, err)
assert.False(t, set.Contains(1))
}
func Test_UndoIOC(t *testing.T) {
set := NewFloatSet()
assert.False(t, set.Contains(1))
set.Add(1)
set.Add(2)
assert.True(t, set.Contains(1))
assert.True(t, set.Contains(2))
err := set.Undo()
assert.Nil(t, err)
assert.False(t, set.Contains(2))
err = set.Undo()
assert.Nil(t, err)
assert.False(t, set.Contains(1))
}