Sha256: 820b636e32b0659636fdc5c355ef2a064e01336eb2ffeb1f554c3ae61b371fdc
Contents?: true
Size: 742 Bytes
Versions: 128
Compression:
Stored size: 742 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("sum-of-multiples", &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 Factors []int Limit int Expected int } } // template applied to above data structure generates the Go test cases var tmpl = `package summultiples {{.Header}} var varTests = []struct { divisors []int limit int sum int }{ {{range .J.Cases}}{ {{.Factors | printf "%#v"}}, {{.Limit}}, {{.Expected}}}, // {{.Description}} {{end}}} `
Version data entries
128 entries across 128 versions & 1 rubygems