package main import ( "fmt" "testing" ) const result = `(0) / ├──(0) i1 │ ├──(0) i1s1 │ │ ├──(0) i1s1b1 │ │ ├──(0) i1s1b2 │ │ └──(0) i1s1b3 │ │ (0) i1s1b3 │ ├──(0) i1s2 │ │ ├──(0) i1s2b1 │ │ └──(0) i1s2b2 │ │ (0) i1s2b2 │ ├──(0) i1s3 │ │ ├──(0) i1s3s1 │ │ │ ├──(0) i1s3s1b1 │ │ │ ├──(0) i1s3s1b2 │ │ │ └──(0) i1s3s1b3 │ │ │ (0) i1s3s1b3 │ │ └──(0) i1s3b1 │ │ (0) i1s3b1 │ └──(0) i1s4 │ (0) i1s4b1 ├──(0) i2 │ ├──(0) i2b1 │ └──(0) i2b2 │ (0) i2b2 └──(0) i3 ├──(0) i3s1 │ └──(0) i3s1b1 │ (0) i3s1b1 ├──(0) i3s2 │ ├──(0) i3s2b1 │ └──(0) i3s2b2 │ (0) i3s2b2 └──(0) i3s3 (0) i3s3b1 ` func createTree() *Top { t := NewTop("/") i1 := t.newChild("i1", IntermediateType).(*Intermediate) i2 := t.newChild("i2", IntermediateType).(*Intermediate) i3 := t.newChild("i3", IntermediateType).(*Intermediate) i1s1 := i1.newChild("i1s1", IntermediateType).(*Intermediate) i1s2 := i1.newChild("i1s2", IntermediateType).(*Intermediate) i1s3 := i1.newChild("i1s3", IntermediateType).(*Intermediate) i1s4 := i1.newChild("i1s4", IntermediateType).(*Intermediate) i3s1 := i3.newChild("i3s1", IntermediateType).(*Intermediate) i3s2 := i3.newChild("i3s2", IntermediateType).(*Intermediate) i3s3 := i3.newChild("i3s3", IntermediateType).(*Intermediate) _ = i1s1.newChild("i1s1b1", BottomType).(*Bottom) _ = i1s1.newChild("i1s1b2", BottomType).(*Bottom) _ = i1s1.newChild("i1s1b3", BottomType).(*Bottom) _ = i1s2.newChild("i1s2b1", BottomType).(*Bottom) _ = i1s2.newChild("i1s2b2", BottomType).(*Bottom) i1s3s1 := i1s3.newChild("i1s3s1", IntermediateType).(*Intermediate) _ = i1s3.newChild("i1s3b1", BottomType).(*Bottom) _ = i1s4.newChild("i1s4b1", BottomType).(*Bottom) _ = i2.newChild("i2b1", BottomType).(*Bottom) _ = i2.newChild("i2b2", BottomType).(*Bottom) _ = i3s1.newChild("i3s1b1", BottomType).(*Bottom) _ = i3s2.newChild("i3s2b1", BottomType).(*Bottom) _ = i3s2.newChild("i3s2b2", BottomType).(*Bottom) _ = i3s3.newChild("i3s3b1", BottomType).(*Bottom) _ = i1s3s1.newChild("i1s3s1b1", BottomType).(*Bottom) _ = i1s3s1.newChild("i1s3s1b2", BottomType).(*Bottom) _ = i1s3s1.newChild("i1s3s1b3", BottomType).(*Bottom) return t } func TestString(t *testing.T) { tree := createTree() repr := fmt.Sprintf("%s", tree) if repr != result { t.Errorf("%s", repr) } }