-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeque_test.go
89 lines (71 loc) · 1.41 KB
/
deque_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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package ds
import (
. "github.com/smartystreets/goconvey/convey"
"testing"
)
func Test_Reg_Deque(t *testing.T) {
Convey("Test Deque", t, func() {
var a Deque_I
a = MakeDeque()
So(a.Size(), ShouldEqual, 0)
a.Push_Back(5)
a.Push_Back(10)
So(a.Front(), ShouldEqual, 5)
So(a.Back(), ShouldEqual, 10)
var b Deque_I
b = MakeDeque()
b.Push_Front(5)
b.Push_Front(10)
So(b.Front(), ShouldEqual, 10)
So(b.Back(), ShouldEqual, 5)
b.Push_Front(15)
b.Push_Front(20)
So(b.Front(), ShouldEqual, 20)
So(b.Back(), ShouldEqual, 5)
So(b.Pop_Front(), ShouldEqual, 20)
So(b.Pop_Back(), ShouldEqual, 5)
b.Print()
So(b.Front(), ShouldEqual, 15)
So(b.Back(), ShouldEqual, 10)
})
}
func BenchmarkDequePushFrontPopFront(b *testing.B) {
var a Deque_I
a = MakeDeque()
for i := 0; i < b.N; i++ {
a.Push_Front(i)
}
for i := 0; i < b.N; i++ {
a.Pop_Front()
}
}
func BenchmarkDequePushBackPopFront(b *testing.B) {
var a Deque_I
a = MakeDeque()
for i := 0; i < b.N; i++ {
a.Push_Back(i)
}
for i := 0; i < b.N; i++ {
a.Pop_Front()
}
}
func BenchmarkDequePushFrontPopBack(b *testing.B) {
var a Deque_I
a = MakeDeque()
for i := 0; i < b.N; i++ {
a.Push_Front(i)
}
for i := 0; i < b.N; i++ {
a.Pop_Back()
}
}
func BenchmarkDequePushBackPopBack(b *testing.B) {
var a Deque_I
a = MakeDeque()
for i := 0; i < b.N; i++ {
a.Push_Back(i)
}
for i := 0; i < b.N; i++ {
a.Pop_Back()
}
}