mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2025-01-11 09:20:17 +01:00
Simplified unit test for BigMin.
This commit is contained in:
parent
a8c2a4c55d
commit
45ec5ccd3e
@ -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)
|
c1 := InterleavedToCoord(zmin)
|
||||||
c2 := InterleavedToCoord(zmax)
|
c2 := InterleavedToCoord(zmax)
|
||||||
cub := Cuboid{P1: c1, P2: c2}
|
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.X = c1.X; c.X <= c2.X; c.X++ {
|
||||||
for c.Y = c1.Y; c.Y <= c2.Y; c.Y++ {
|
for c.Y = c1.Y; c.Y <= c2.Y; c.Y++ {
|
||||||
for c.Z = c1.Z; c.Z <= c2.Z; c.Z++ {
|
for c.Z = c1.Z; c.Z <= c2.Z; c.Z++ {
|
||||||
code := CoordToInterleaved(c) + 1
|
zn := CoordToInterleaved(c) + 1
|
||||||
if code < zmin || code > zmax {
|
if zn > zmin && zn < zmax && !cub.Contains(InterleavedToCoord(zn)) {
|
||||||
continue
|
fn(zn)
|
||||||
}
|
|
||||||
c3 := InterleavedToCoord(code)
|
|
||||||
if !cub.Contains(c3) {
|
|
||||||
outs <- code
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
|
||||||
return outs
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBigMin(t *testing.T) {
|
func TestBigMin(t *testing.T) {
|
||||||
@ -214,7 +204,7 @@ func TestBigMin(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
errors, success := 0, 0
|
errors, success := 0, 0
|
||||||
for zcode := range outsiders(zmin, zmax) {
|
outsiders(zmin, zmax, func(zcode int64) {
|
||||||
nbm := NaiveBigMin(zmin, zmax, zcode)
|
nbm := NaiveBigMin(zmin, zmax, zcode)
|
||||||
cbm := BigMin(zmin, zmax, zcode)
|
cbm := BigMin(zmin, zmax, zcode)
|
||||||
//fmt.Printf("nbm: %b\n", nbm)
|
//fmt.Printf("nbm: %b\n", nbm)
|
||||||
@ -224,7 +214,7 @@ func TestBigMin(t *testing.T) {
|
|||||||
} else {
|
} else {
|
||||||
success++
|
success++
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
if errors > 0 {
|
if errors > 0 {
|
||||||
cub := Cuboid{P1: c1, P2: c2}
|
cub := Cuboid{P1: c1, P2: c2}
|
||||||
t.Errorf("BigMin: %s (%d %d) %d errors out of %d (%f)\n",
|
t.Errorf("BigMin: %s (%d %d) %d errors out of %d (%f)\n",
|
||||||
|
Loading…
Reference in New Issue
Block a user