Ejemplo n.º 1
0
func makeGraphData(t testing.TB, n int) graph.Output {
	data := graph.Output{}
	if n > 0 {
		data.Defs = make([]*graph.Def, n)
		data.Refs = make([]*graph.Ref, n)
	}
	for i := 0; i < n; i++ {
		data.Defs[i] = &graph.Def{
			DefKey:   graph.DefKey{Path: fmt.Sprintf("def-path-%d", i)},
			Name:     fmt.Sprintf("def-name-%d", i),
			Kind:     "mykind",
			DefStart: uint32((i % 53) * 37),
			DefEnd:   uint32((i%53)*37 + (i % 20)),
			File:     fmt.Sprintf("dir%d/subdir%d/subsubdir%d/file-%d.foo", i%5, i%3, i%7, i%5),
			Exported: i%5 == 0,
			Local:    i%3 == 0,
			Data:     []byte(`"` + strings.Repeat("abcd", 50) + `"`),
		}
		data.Refs[i] = &graph.Ref{
			DefPath: fmt.Sprintf("ref-path-%d", i),
			Def:     i%5 == 0,
			Start:   uint32((i % 51) * 39),
			End:     uint32((i%51)*37 + (int(i) % 18)),
			File:    fmt.Sprintf("dir%d/subdir%d/subsubdir%d/file-%d.foo", i%3, i%5, i%7, i%5),
		}
		if i%3 == 0 {
			data.Refs[i].DefUnit = fmt.Sprintf("def-unit-%d", i%17)
			data.Refs[i].DefUnitType = fmt.Sprintf("def-unit-type-%d", i%3)
			if i%7 == 0 {
				data.Refs[i].DefRepo = fmt.Sprintf("def-repo-%d", i%13)
			}
		}
	}
	return data
}