File: skip_test.go

package info (click to toggle)
golang-github-badgerodon-collections 0.0~git20130729.604e922-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 172 kB
  • sloc: makefile: 5
file content (38 lines) | stat: -rw-r--r-- 712 bytes parent folder | download | duplicates (2)
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
package skip

import (
	//"fmt"
	"testing"
)

func Test(t *testing.T) {
	sl := New(func(a,b interface{})bool {
		return a.(int) < b.(int)
	})
	sl.Insert(1, 100)
	if sl.Len() != 1 {
		t.Errorf("expecting len 1")
	}
	sl.Insert(1, 1000)
	if sl.Len() != 1 {
		t.Errorf("expecting len 1")
	}
	if sl.Get(1).(int) != 1000 {
		t.Errorf("expecting sl[1] == 1000")
	}
	sl.Remove(1)
	if sl.Len() != 0 {
		t.Errorf("expecting len 0")
	}
	
	sl.Insert(2, 200)
	sl.Insert(1, 100)
	vs := make([]int, 0)
	sl.Do(func(k, v interface{}) bool {
		vs = append(vs, k.(int))
		return true
	})
	if len(vs) != 2 || vs[0] != 1 || vs[1] != 2 {
		t.Errorf("expecting sorted iteration of all keys")
	}
}