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("+++++++++++") } }