func TestVisitGraph(t *testing.T) {
	mainFn := getTestMainFn(t)
	g := NewVisitGraph(false)
	if g.Size() != 0 {
		t.Errorf("New VisitGraph should have 0 node, got %d", g.Size())
	}
	n0 := NewVisitNode(mainFn.Blocks[0])
	g.Visit(n0)
	if g.Size() != 1 {
		t.Errorf("Add node(0) to VisitGraph should make size 1, but got %d",
			g.Size())
	}
	if g.nodes[0] != n0 {
		t.Errorf("nodes[0] should be %+v, got %+v", n0, g.nodes[0])
	}
	n1 := NewVisitNode(mainFn.Blocks[1])
	g.Visit(n1)
	if g.nodes[0] != n0 {
		t.Errorf("Add node(1) to VisitGraph should not change existing root, but got %+v",
			g.nodes[0])
	}
	if g.Size() != 2 {
		t.Errorf("Add node(1) to VisitGraph should make size 2, but got %d", g.Size())
	}
	if g.nodes[1] != n1 {
		t.Errorf("nodes[1] should be %+v, got %+v", n1, g.nodes[1])
	}
}
Tests basic usage of VisitGraph.
package block
import (
	"strings"
	"testing"
	"golang.org/x/tools/go/ssa"
	gssa "github.com/nickng/gospal/ssa"
	"github.com/nickng/gospal/ssa/build"
)
func getTestMainFn(t *testing.T) *ssa.Function {
	prog := `package main
	func main() {   
		x := 1
		if x < 2 {  
			x++
		}
		x = 0       
		x++
	}`
	conf := build.FromReader(strings.NewReader(prog))
	info, err := conf.Build()
	if err != nil {
		t.Errorf("SSA build failed: %v", err)
	}
	mains, _ := gssa.MainPkgs(info.Prog, false)
	return mains[0].Func("main")
}