Sha256: 3275a8be2137d8af6a599d8ea217d6d6228e306fdcf945d3d8a4c11a0ae67917
Contents?: true
Size: 864 Bytes
Versions: 92
Compression:
Stored size: 864 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("flatten-array", &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 Input struct { Array interface{} } Expected []interface{} } // Template to generate test cases. var tmpl = `package flatten {{.Header}} var testCases = []struct { description string input interface{} expected []interface{} }{ {{range .J.Cases}} { description: {{printf "%q" .Description}}, input: {{printf "%#v" .Input.Array}}, expected: {{printf "%#v" .Expected}}, },{{end}} } `
Version data entries
92 entries across 92 versions & 1 rubygems