File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,42 @@ func TestIsLeafNode(t *testing.T) {
7777 }
7878}
7979
80+ func TestIsFullNode (t * testing.T ) {
81+ // Our test tree
82+ //
83+ // __1
84+ // / \
85+ // 2 3
86+ // / \
87+ // 4 5
88+ //
89+ root := binarytree .NewNode (1 )
90+ two := root .InsertLeft (2 )
91+ three := root .InsertRight (3 )
92+ four := two .InsertLeft (4 )
93+ five := two .InsertRight (5 )
94+
95+ if ! root .IsFullNode () {
96+ t .Fatal ("root node should be full" )
97+ }
98+
99+ if ! two .IsFullNode () {
100+ t .Fatal ("node (2) should be full" )
101+ }
102+
103+ if three .IsFullNode () {
104+ t .Fatal ("node (3) should not be full" )
105+ }
106+
107+ if four .IsFullNode () {
108+ t .Fatal ("node (4) should not be full" )
109+ }
110+
111+ if five .IsFullNode () {
112+ t .Fatal ("node (5) should not be full" )
113+ }
114+ }
115+
80116func TestWalkInOrder (t * testing.T ) {
81117 // Our test tree
82118 //
You can’t perform that action at this time.
0 commit comments