forked from ericchiang/css
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueue_test.go
39 lines (34 loc) · 1.12 KB
/
queue_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
package css
import "testing"
func TestQueue(t *testing.T) {
t1 := token{tokenDelim, "*", "*", 0, 0, ""}
t2 := token{tokenIdent, "foo", "foo", 0, 0, ""}
t3 := token{tokenIdent, "bar", "bar", 0, 0, ""}
t4 := token{tokenIdent, "spam", "spam", 0, 0, ""}
_, _ = t3, t4
q := newQueue(2)
q.push(t1)
if got := q.get(0); got != t1 {
t.Errorf("get(0) from queue with single element, got%#v, want=%#v", got, t1)
}
q.push(t2)
if got := q.get(0); got != t1 {
t.Errorf("get(0) from queue with two elements, got%#v, want=%#v", got, t1)
}
if got := q.get(1); got != t2 {
t.Errorf("get(1) from queue with two elements, got%#v, want=%#v", got, t2)
}
if got := q.pop(); got != t1 {
t.Errorf("pop() from queue with two elements, got%#v, want=%#v", got, t1)
}
q.push(t3)
if got := q.get(0); got != t2 {
t.Errorf("get(0) from queue with two elements after requeue, got%#v, want=%#v", got, t2)
}
if got := q.get(1); got != t3 {
t.Errorf("get(1) from queue with two elements after requeue, got%#v, want=%#v", got, t3)
}
if got := q.pop(); got != t2 {
t.Errorf("pop() from queue with single element, got%#v, want=%#v", got, t1)
}
}