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