29 lines
606 B
Go
29 lines
606 B
Go
package zip
|
|
|
|
import (
|
|
"fmt"
|
|
"sort"
|
|
"testing"
|
|
)
|
|
|
|
func TestZip(t *testing.T) {
|
|
_ = true
|
|
zip27006 := Get("27006")
|
|
zip84059 := Get("84059")
|
|
t.Logf("27006 = %+v", zip27006)
|
|
t.Logf("84059 = %+v", zip84059)
|
|
if zip27006.MilesTo(zip84059) < 1800 {
|
|
t.Error("failed to compute miles from advance to ut")
|
|
}
|
|
sorted := func(s []string) []string {
|
|
sort.Strings(s)
|
|
return s
|
|
}
|
|
if got := GetStatesWithin(Get("27006"), 100); fmt.Sprint(sorted(got)) != fmt.Sprint(sorted([]string{"NC", "SC", "TN", "VA"})) {
|
|
t.Error(got)
|
|
}
|
|
if got := FromCityState("ADVANCE", "nc"); got != zip27006 {
|
|
t.Error(got)
|
|
}
|
|
}
|