26 lines
743 B
Go
26 lines
743 B
Go
package main
|
|
|
|
import "testing"
|
|
|
|
func stamped(min, floor int64) view {
|
|
return view{cable: cableView{min: min, floor: floor, ok: true}}
|
|
}
|
|
|
|
// Averaged across directions, since one direction alone carries a phy asymmetry
|
|
// that swamps the cable.
|
|
func TestCableMetresAveragesDirections(t *testing.T) {
|
|
m, ok := cableMetres([]view{stamped(1000, 900), stamped(1100, 900)}, 5)
|
|
if !ok || m != 30 {
|
|
t.Errorf("cableMetres = %v, %v; want 30, true", m, ok)
|
|
}
|
|
}
|
|
|
|
func TestCableMetresNeedsEveryDirection(t *testing.T) {
|
|
if _, ok := cableMetres(nil, 5); ok {
|
|
t.Error("no views should not yield a length")
|
|
}
|
|
if _, ok := cableMetres([]view{stamped(1000, 900), {}}, 5); ok {
|
|
t.Error("a direction with no stamp yet should not yield a length")
|
|
}
|
|
}
|