mirror of
https://github.com/Luzifer/aoc2019.git
synced 2024-12-22 14:01:17 +00:00
17 lines
361 B
Go
17 lines
361 B
Go
|
package aoc2019
|
||
|
|
||
|
import "testing"
|
||
|
|
||
|
func TestManhattenDistance(t *testing.T) {
|
||
|
for expDist, p := range map[int][4]int{
|
||
|
2: {0, 0, 0, 2},
|
||
|
3: {0, 0, 3, 0},
|
||
|
6: {-3, 0, 3, 0},
|
||
|
7: {-3, 0, 0, 4},
|
||
|
} {
|
||
|
if dist := manhattenDistance(p[0], p[1], p[2], p[3]); dist != expDist {
|
||
|
t.Errorf("Unexpected distance for %+v: exp=%d got=%d", p, expDist, dist)
|
||
|
}
|
||
|
}
|
||
|
}
|