Sha256: bc1253c3a99c27de087e8246aa95d9022f6311cbb680f602989fc6adf6e6aefb
Contents?: true
Size: 747 Bytes
Versions: 18
Compression:
Stored size: 747 Bytes
Contents
// +build ignore 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("hamming", &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 Strand1 string Strand2 string Expected int } } // template applied to above data structure generates the Go test cases var tmpl = `package hamming {{.Header}} var testCases = []struct { s1 string s2 string want int }{ {{range .J.Cases}}{ // {{.Description}} {{printf "%q" .Strand1}}, {{printf "%q" .Strand2}}, {{.Expected}}, }, {{end}}} `
Version data entries
18 entries across 18 versions & 1 rubygems