MCPcopy Index your code
hub / github.com/gonum/plot / TestJohnson

Function TestJohnson

plotter/johnson_test.go:356–386  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

354}
355
356func TestJohnson(t *testing.T) {
357 for i, test := range graphTests {
358 var g graph
359 if test.path != nil {
360 g = graphFrom(test.path)
361 } else {
362 g = test.g
363 }
364 gotCycles := cyclesIn(g)
365 // johnson.circuit does range iteration over maps,
366 // so sort to ensure consistent ordering.
367 sort.Sort(byComponentLengthOrStart(gotCycles))
368 if !reflect.DeepEqual(gotCycles, test.wantCycles) {
369 t.Errorf("unexpected johnson result for %d:\n\tgot:%#v\n\twant:%#v", i, gotCycles, test.wantCycles)
370 }
371
372 // Don't do path reconstruction tests without a path definition.
373 if test.path == nil {
374 continue
375 }
376
377 // Test we reconstruct paths correctly from cycles.
378 var gotPaths []path
379 for _, pi := range gotCycles {
380 gotPaths = append(gotPaths, test.path.subpath(pi))
381 }
382 if !reflect.DeepEqual(gotPaths, test.wantCyclePaths) {
383 t.Errorf("unexpected johnson path result for %d:\n\tgot:%#v\n\twant:%#v", i, gotPaths, test.wantCyclePaths)
384 }
385 }
386}
387
388type byComponentLengthOrStart [][]int
389

Callers

nothing calls this directly

Calls 4

graphFromFunction · 0.85
cyclesInFunction · 0.85
byComponentLengthOrStartTypeAlias · 0.85
subpathMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…