Skip to content

Commit 0b1468f

Browse files
committed
Add test for node attributes
1 parent a178955 commit 0b1468f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

binarytree_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,3 +333,19 @@ func TestIsBalanced(t *testing.T) {
333333
t.Fatal("tree should be balanced")
334334
}
335335
}
336+
337+
func TestNodeAttributes(t *testing.T) {
338+
root := binarytree.NewNode(1)
339+
340+
if root.GetDotAttributes() != "" {
341+
t.Fatal("node is expected to have no attributes")
342+
}
343+
344+
root.AddAttribute("color", "green")
345+
root.AddAttribute("fillcolor", "green")
346+
347+
wantAttrs := "color=green fillcolor=green"
348+
if root.GetDotAttributes() != wantAttrs {
349+
t.Fatal("node attributes mismatch")
350+
}
351+
}

0 commit comments

Comments
 (0)