Sha256: b7dd20cfd8e5297eed25c410ef74bc2decc2dc848cd3ce27e1be9e70e3d12729
Contents?: true
Size: 832 Bytes
Versions: 80
Compression:
Stored size: 832 Bytes
Contents
package main import ( "log" "text/template" "../../../gen" ) func main() { t, err := template.New("").Parse(tmpl) if err != nil { log.Fatal(err) } var j js if err := gen.Gen("transpose", &j, t); err != nil { log.Fatal(err) } } // The JSON structure we expect to be able to unmarshal into type js struct { Cases []struct { Description string Input struct { Lines []string } Expected []string } } // template applied to above data structure generates the Go test cases var tmpl = `package transpose {{.Header}} var testCases = []struct { description string input []string expected []string }{ {{range .J.Cases}}{ {{printf "%q" .Description}}, []string{ {{range .Input.Lines}} {{printf "%q" .}}, {{end}}}, []string{ {{range .Expected}} {{printf "%q" .}}, {{end}}}, }, {{end}}} `
Version data entries
80 entries across 80 versions & 1 rubygems