-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain_test.go
35 lines (29 loc) · 834 Bytes
/
main_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
package main
import (
"testing"
"container/heap"
"time"
)
func TestQueue( t *testing.T ) {
q := NewImageCache()
heap.Push( q, NewCacheItem( "item1", nil ) )
time.Sleep( time.Duration(1) * time.Millisecond )
heap.Push( q, NewCacheItem( "item2", nil ) )
time.Sleep( time.Duration(1) * time.Millisecond )
heap.Push( q, NewCacheItem( "item3", nil ) )
time.Sleep( time.Duration(1) * time.Millisecond )
heap.Push( q, NewCacheItem( "item4", nil ) )
time.Sleep( time.Duration(1) * time.Millisecond )
t.Log( q.GetPaths() )
q.Update( "item1" )
t.Log( q.GetPaths() )
t.Log( q.Top().path )
heap.Pop( q )
t.Log( q.GetPaths() )
t.Log( q.Top().path )
heap.Pop( q )
t.Log( q.GetPaths() )
t.Log( q.Top().path )
heap.Pop( q )
t.Log( q.GetPaths() )
}