Debian Codegraph @

internal/graph/shortest_test.go

raw symbols SCIP
1 // Copyright 2026 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package graph
6
7 import (
8 "slices"
9 "testing"
10 )
11
12 func TestShortestPath(t *testing.T) {
13 g := stringGraph{
14 "A": {"B", "C"},
15 "B": {"D"},
16 "C": {"D"},
17 "D": {"E"},
18 "E": {},
19 }
20
21 got := ShortestPath(g, "A", "E")
22 want := []string{"A", "B", "D", "E"}
23 if !slices.Equal(got, want) {
24 t.Errorf("ShortestPath(A, E) = %v, want %v", got, want)
25 }
26
27 got = ShortestPath(g, "A", "F")
28 if got != nil {
29 t.Errorf("ShortestPath(A, F) = %v, want nil", got)
30 }
31 }