You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

25 lines
383 B

package composite
import (
"fmt"
"testing"
)
func TestComposite_Traverse(t *testing.T) {
composites := make([]Composite, 4)
for i := 0; i < 4; i++ {
for j := 0; j < 3; j++ {
composites[i].Add(NewLeaf(i*3 + j))
}
}
for i := 0; i < 4; i++ {
composites[0].Add(&composites[i])
}
for i := 0; i < 4; i++ {
composites[0].Traverse()
fmt.Println("+++++++++++")
}
}