Sha256: 0c8214f12692bf2ff81e4e7d946cd337ef1c06893a105ed8957f1ba7a5d5e14c
Contents?: true
Size: 858 Bytes
Versions: 6
Compression:
Stored size: 858 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("binary-search", &j, t); err != nil { log.Fatal(err) } } // The JSON structure we expect to be able to unmarshal into type js struct { Exercise string Version string Cases []oneCase } // Test cases type oneCase struct { Description string Property string Array []int Value int Expected int } // Template to generate test cases. var tmpl = `package binarysearch {{.Header}} var testCases = []struct { description string slice []int key int x int }{ {{range .J.Cases}} { description: {{printf "%q" .Description}}, slice: {{printf "%#v" .Array}}, key: {{printf "%d" .Value}}, x: {{printf "%d" .Expected}}, },{{end}} } `
Version data entries
6 entries across 6 versions & 1 rubygems