Sha256: 98996b49eeb22769d5b19a976d29f3e5b9eeabc80c3353ab45858c98a4e8cf2c
Contents?: true
Size: 971 Bytes
Versions: 76
Compression:
Stored size: 971 Bytes
Contents
// +build ignore package main import ( "log" "strings" "text/template" "../../gen" ) func main() { m := template.FuncMap{"week": strings.Title} t, err := template.New("").Funcs(m).Parse(tmpl) if err != nil { log.Fatal(err) } var j js if err := gen.Gen("meetup", &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 Year int Month int Week string Dayofweek string Dayofmonth int } } // template applied to above data structure generates the Go test cases var tmpl = `package meetup // Source: {{.Ori}} {{if .Commit}}// Commit: {{.Commit}} {{end}} import "time" var testCases = []struct { year int month time.Month week WeekSchedule weekday time.Weekday expDay int }{ {{range .J.Cases}}{ {{.Year}}, {{.Month}}, {{week .Week}}, time.{{.Dayofweek}}, {{.Dayofmonth}}}, // {{.Description}} {{end}}} `
Version data entries
76 entries across 76 versions & 1 rubygems