Example #1
0
func TestProcessWeights(t *testing.T) {
	for i, tt := range processTests {
		res := collate.ProcessWeights(tt.opt.alt, tt.opt.top, tt.in)
		if len(res) != len(tt.out) {
			t.Errorf("%d: len(ws) was %d; want %d (%v should be %v)", i, len(res), len(tt.out), res, tt.out)
			continue
		}
		for j, w := range res {
			if w != tt.out[j] {
				t.Errorf("%d: Weights %d was %v; want %v", i, j, w, tt.out[j])
			}
		}
	}
}
Example #2
0
func TestKeyFromElems(t *testing.T) {
	buf := collate.Buffer{}
	for i, tt := range keyFromElemTests {
		buf.ResetKeys()
		ws := collate.ProcessWeights(tt.opt.alt, tt.opt.top, tt.in)
		res := collate.KeyFromElems(tt.opt.collator(), &buf, ws)
		if len(res) != len(tt.out) {
			t.Errorf("%d: len(ws) was %d; want %d (%X should be %X)", i, len(res), len(tt.out), res, tt.out)
		}
		n := len(res)
		if len(tt.out) < n {
			n = len(tt.out)
		}
		for j, c := range res[:n] {
			if c != tt.out[j] {
				t.Errorf("%d: byte %d was %X; want %X", i, j, c, tt.out[j])
			}
		}
	}
}