We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6284957 commit 9c31495Copy full SHA for 9c31495
shaper_test.go
@@ -0,0 +1,30 @@
1
+package smux
2
+
3
+import (
4
+ "container/heap"
5
+ "testing"
6
+)
7
8
+func TestShaper(t *testing.T) {
9
+ w1 := writeRequest{prio: 10}
10
+ w2 := writeRequest{prio: 10}
11
+ w3 := writeRequest{prio: 20}
12
+ w4 := writeRequest{prio: 100}
13
14
+ var reqs shaperHeap
15
+ heap.Push(&reqs, w4)
16
+ heap.Push(&reqs, w3)
17
+ heap.Push(&reqs, w2)
18
+ heap.Push(&reqs, w1)
19
20
+ var lastPrio uint64
21
+ for len(reqs) > 0 {
22
+ w := heap.Pop(&reqs).(writeRequest)
23
+ if w.prio < lastPrio {
24
+ t.Fatal("incorrect shaper priority")
25
+ }
26
27
+ t.Log("prio:", w.prio)
28
+ lastPrio = w.prio
29
30
+}
0 commit comments