service_internal_test.go 565 字节
Newer Older
1 2 3 4 5 6
package master

import "testing"

func TestPartitionCount(t *testing.T) {
	cs := make([]Chunk, 100)
H
Helin Wang 已提交
7
	ts := partition(cs, 5)
8 9 10 11 12
	if len(ts) != 20 {
		t.Error(len(ts))
	}

	cs = make([]Chunk, 101)
H
Helin Wang 已提交
13
	ts = partition(cs, 5)
14 15 16 17
	if len(ts) != 21 {
		t.Error(len(ts))
	}

H
Helin Wang 已提交
18 19 20 21 22 23
	ts = partition(cs, 1)
	if len(ts) != 101 {
		t.Error(len(ts))
	}

	ts = partition(cs, 0)
24 25 26 27 28 29 30 31 32
	if len(ts) != 101 {
		t.Error(len(ts))
	}
}

func TestPartionIndex(t *testing.T) {
	cs := make([]Chunk, 100)
	ts := partition(cs, 20)
	for i := range ts {
G
gongweibao 已提交
33
		if ts[i].Task.Meta.ID != i {
34 35 36 37
			t.Error(ts[i], i)
		}
	}
}