mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-11-17 15:48:17 +01:00
Simplified unit test for BigMin.
This commit is contained in:
parent
a8c2a4c55d
commit
45ec5ccd3e
@ -162,32 +162,22 @@ 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}
|
||||
var c Coord
|
||||
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
|
||||
}
|
||||
c1 := InterleavedToCoord(zmin)
|
||||
c2 := InterleavedToCoord(zmax)
|
||||
cub := Cuboid{P1: c1, P2: c2}
|
||||
var c Coord
|
||||
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++ {
|
||||
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",
|
||||
|
Loading…
Reference in New Issue
Block a user