(t *testing.T)
| 354 | } |
| 355 | |
| 356 | func 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 | |
| 388 | type byComponentLengthOrStart [][]int |
| 389 |
nothing calls this directly
no test coverage detected
searching dependent graphs…