Skip to content

Commit

Permalink
Add missing indexOf test
Browse files Browse the repository at this point in the history
  • Loading branch information
nrwiersma committed Jan 15, 2019
1 parent 978cf93 commit c81892f
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions topology_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,36 @@ func TestContains(t *testing.T) {
}
}

func TestIndexOf(t *testing.T) {
node1 := &testNode{}
node2 := &testNode{}
node3 := &testNode{}
node4 := &testNode{}

tests := []struct {
node Node
nodes []Node
index int
}{
{
node: node1,
nodes: []Node{node1, node2, node3},
index: 0,
},
{
node: node4,
nodes: []Node{node1, node2, node3},
index: -1,
},
}

for _, tt := range tests {
i := indexOf(tt.node, tt.nodes)

assert.Equal(t, tt.index, i)
}
}

type testNode struct {
name string
children []Node
Expand Down

0 comments on commit c81892f

Please sign in to comment.