Sha256: c0ec43579a26432ec4f03c46fecde21247549f4153d752addee9960a5442a157
Contents?: true
Size: 748 Bytes
Versions: 97
Compression:
Stored size: 748 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("bob", &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 { HeyBob string } Expected string } } // template applied to above data structure generates the Go test cases var tmpl = `package bob {{.Header}} var testCases = []struct { description string input string expected string }{ {{range .J.Cases}}{ {{printf "%q" .Description}}, {{printf "%q" .Input.HeyBob}}, {{printf "%q" .Expected}}, }, {{end}}} `
Version data entries
97 entries across 97 versions & 1 rubygems