(t *testing.T)
| 752 | } |
| 753 | |
| 754 | func TestBFS(t *testing.T) { |
| 755 | t.Parallel() |
| 756 | t.Run("Chain", func(t *testing.T) { |
| 757 | t.Parallel() |
| 758 | g, _ := buildChainGraph() |
| 759 | result := collectValues(g.BFS(TraversalConfig{})) |
| 760 | expected := []string{"A", "B", "C"} |
| 761 | if !slices.Equal(result, expected) { |
| 762 | t.Errorf("expected %v, got %v", expected, result) |
| 763 | } |
| 764 | }) |
| 765 | |
| 766 | t.Run("Diamond", func(t *testing.T) { |
| 767 | t.Parallel() |
| 768 | g, _ := buildDiamondGraph() |
| 769 | result := collectValues(g.BFS(TraversalConfig{})) |
| 770 | // A (level 0), B and C (level 1), D (level 2) |
| 771 | expected := []string{"A", "B", "C", "D"} |
| 772 | if !slices.Equal(result, expected) { |
| 773 | t.Errorf("expected %v, got %v", expected, result) |
| 774 | } |
| 775 | }) |
| 776 | |
| 777 | t.Run("CustomStart", func(t *testing.T) { |
| 778 | t.Parallel() |
| 779 | g, n := buildDiamondGraph() |
| 780 | result := collectValues(g.BFS(TraversalConfig{Start: []NodeIndex{n[1]}})) |
| 781 | expected := []string{"B", "D"} |
| 782 | if !slices.Equal(result, expected) { |
| 783 | t.Errorf("expected %v, got %v", expected, result) |
| 784 | } |
| 785 | }) |
| 786 | |
| 787 | t.Run("IncomingDirection", func(t *testing.T) { |
| 788 | t.Parallel() |
| 789 | g, n := buildDiamondGraph() |
| 790 | result := collectValues(g.BFS(TraversalConfig{Start: []NodeIndex{n[3]}, Direction: Incoming})) |
| 791 | // From D: D, then B and C (incoming neighbors), then A |
| 792 | expected := []string{"D", "B", "C", "A"} |
| 793 | if !slices.Equal(result, expected) { |
| 794 | t.Errorf("expected %v, got %v", expected, result) |
| 795 | } |
| 796 | }) |
| 797 | } |
| 798 | |
| 799 | func TestTopo(t *testing.T) { |
| 800 | t.Parallel() |
nothing calls this directly
no test coverage detected