github.com/seeker-insurance/kit@v0.0.13/geojson/point_test.go (about) 1 package geojson 2 3 import ( 4 "fmt" 5 "reflect" 6 "testing" 7 ) 8 9 var p = Point{1, 2} 10 11 func TestPoint_GeoJSON(t *testing.T) { 12 tests := []struct { 13 name string 14 p *Point 15 want []byte 16 }{ 17 {"trivial", &p, []byte(`{"type": Point, "coordinates": [2.000000, 1.000000]}`)}, 18 } 19 for _, tt := range tests { 20 t.Run(tt.name, func(t *testing.T) { 21 if got := tt.p.GeoJSON(); !reflect.DeepEqual(got, tt.want) { 22 t.Errorf("Point.GeoJSON() = %v, want %v", got, tt.want) 23 } 24 }) 25 } 26 } 27 28 func TestPoint_Coordinates(t *testing.T) { 29 tests := []struct { 30 name string 31 p *Point 32 want string 33 }{ 34 {"unit", &Point{1, 0}, fmt.Sprintf(`[%f, %f]`, 0., 1.)}, 35 } 36 for _, tt := range tests { 37 t.Run(tt.name, func(t *testing.T) { 38 if got := tt.p.Coordinates(); got != tt.want { 39 t.Errorf("Point.Coordinates() = %v, want %v", got, tt.want) 40 } 41 }) 42 } 43 }