(t *testing.T)
| 39 | } |
| 40 | |
| 41 | func TestFloydWarshall(t *testing.T) { |
| 42 | var floydWarshallTestData = []struct { |
| 43 | description string |
| 44 | graph [][]float64 |
| 45 | expected [][]float64 |
| 46 | }{ |
| 47 | { |
| 48 | description: "test empty graph", |
| 49 | graph: nil, |
| 50 | expected: nil, |
| 51 | }, |
| 52 | { |
| 53 | description: "test graph with wrong dimensions", |
| 54 | graph: [][]float64{ |
| 55 | {1, 2}, |
| 56 | {Inf}, |
| 57 | }, |
| 58 | expected: nil, |
| 59 | }, |
| 60 | { |
| 61 | description: "test graph with no edges", |
| 62 | graph: [][]float64{ |
| 63 | {Inf, Inf}, |
| 64 | {Inf, Inf}, |
| 65 | }, |
| 66 | expected: [][]float64{ |
| 67 | {Inf, Inf}, |
| 68 | {Inf, Inf}, |
| 69 | }, |
| 70 | }, |
| 71 | { |
| 72 | description: "test graph with only negative edges", |
| 73 | graph: [][]float64{ |
| 74 | {-3, -2}, |
| 75 | {-3, -2}, |
| 76 | }, |
| 77 | expected: [][]float64{ |
| 78 | {-17, -25}, |
| 79 | {-26, -34}, |
| 80 | }, |
| 81 | }, |
| 82 | { |
| 83 | description: "test graph with 5 vertices and self-loops", |
| 84 | graph: [][]float64{ |
| 85 | {1, 2, Inf, Inf, Inf}, |
| 86 | {Inf, Inf, 3, -4, Inf}, |
| 87 | {Inf, Inf, Inf, Inf, 5}, |
| 88 | {1, Inf, Inf, Inf, Inf}, |
| 89 | {Inf, Inf, Inf, 2, Inf}, |
| 90 | }, |
| 91 | expected: [][]float64{ |
| 92 | {-1, 1, 4, -3, 8}, |
| 93 | {-3, -1, 2, -5, 6}, |
| 94 | {7, 9, 12, 5, 5}, |
| 95 | {0, 2, 5, -2, 9}, |
| 96 | {2, 4, 7, 0, 9}, |
| 97 | }, |
| 98 | }, |
nothing calls this directly
no test coverage detected