MCPcopy
hub / github.com/golang/geo / TestLoopEncodeDecodeFuzzed

Function TestLoopEncodeDecodeFuzzed

s2/encode_test.go:312–338  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

310}
311
312func TestLoopEncodeDecodeFuzzed(t *testing.T) {
313 for i := 3; i < 100; i++ {
314 var pts []Point
315 for j := 0; j < i; j++ {
316 pts = append(pts, randomPoint())
317 }
318 loop := LoopFromPoints(pts)
319 if err := loop.Validate(); err != nil {
320 t.Fatalf("loop(%v).Validate: %v", loop, err)
321 }
322 polygon := PolygonFromLoops([]*Loop{loop})
323 var buf bytes.Buffer
324 if err := polygon.Encode(&buf); err != nil {
325 t.Fatal(err)
326 }
327 got := new(Loop)
328 if err := got.Decode(&buf); err != nil {
329 // TODO(nsch): Uncomment the next line as soon as decoding of all encoded loops works.
330 // t.Fatalf("decode(encode(%v)): %v", loop, err)
331 continue
332 }
333
334 if !reflect.DeepEqual(got, polygon) {
335 t.Errorf("decode(encode()) = %v, want %v", got, polygon)
336 }
337 }
338}
339
340func BenchmarkRectDecode(b *testing.B) {
341 rect := RectFromCenterSize(LatLngFromDegrees(80, 170), LatLngFromDegrees(40, 60))

Callers

nothing calls this directly

Calls 6

randomPointFunction · 0.85
LoopFromPointsFunction · 0.85
PolygonFromLoopsFunction · 0.85
EncodeMethod · 0.65
DecodeMethod · 0.65
ValidateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…