Simplified unit test for BigMin.

This commit is contained in:
Sascha L. Teichmann 2014-09-07 10:12:39 +02:00
parent a8c2a4c55d
commit 45ec5ccd3e

View File

@ -162,12 +162,8 @@ func TestCoordInterleaving(t *testing.T) {
})
}
func outsiders(zmin, zmax int64) chan int64 {
func outsiders(zmin, zmax int64, fn func(int64)) {
outs := make(chan int64)
go func() {
defer close(outs)
c1 := InterleavedToCoord(zmin)
c2 := InterleavedToCoord(zmax)
cub := Cuboid{P1: c1, P2: c2}
@ -175,19 +171,13 @@ func outsiders(zmin, zmax int64) chan int64 {
for c.X = c1.X; c.X <= c2.X; c.X++ {
for c.Y = c1.Y; c.Y <= c2.Y; c.Y++ {
for c.Z = c1.Z; c.Z <= c2.Z; c.Z++ {
code := CoordToInterleaved(c) + 1
if code < zmin || code > zmax {
continue
}
c3 := InterleavedToCoord(code)
if !cub.Contains(c3) {
outs <- code
zn := CoordToInterleaved(c) + 1
if zn > zmin && zn < zmax && !cub.Contains(InterleavedToCoord(zn)) {
fn(zn)
}
}
}
}
}()
return outs
}
func TestBigMin(t *testing.T) {
@ -214,7 +204,7 @@ func TestBigMin(t *testing.T) {
}
errors, success := 0, 0
for zcode := range outsiders(zmin, zmax) {
outsiders(zmin, zmax, func(zcode int64) {
nbm := NaiveBigMin(zmin, zmax, zcode)
cbm := BigMin(zmin, zmax, zcode)
//fmt.Printf("nbm: %b\n", nbm)
@ -224,7 +214,7 @@ func TestBigMin(t *testing.T) {
} else {
success++
}
}
})
if errors > 0 {
cub := Cuboid{P1: c1, P2: c2}
t.Errorf("BigMin: %s (%d %d) %d errors out of %d (%f)\n",