Exemplo n.º 1
0
func BenchmarkUnique(b *testing.B) {
	for i := 0; i < b.N; i++ {
		sample := sudoku.Block{Val: 0, Possible: []int{6, 9, 8, 7, 1}}
		have := []int{5, 6, 9, 8}
		sample.Unique(have)
	}
}
Exemplo n.º 2
0
func TestUnique(t *testing.T) {
	sample := sudoku.Block{Val: 0, Possible: []int{6, 9, 8, 7, 1}}
	have := []int{5, 6, 9, 8}
	expect := sudoku.Block{Val: 0, Possible: []int{1, 7}}
	sample.Unique(have)
	if len(sample.Possible) != len(expect.Possible) {
		t.Errorf("Wrong length")
	}
	sort.Ints(sample.Possible)
	sort.Ints(expect.Possible)
	for i, e := range expect.Possible {
		if sample.Possible[i] != e {
			t.Errorf("Wrong Calculation, expect %v, but got %v", expect, sample)
		}
	}
}