Sha256: 820b636e32b0659636fdc5c355ef2a064e01336eb2ffeb1f554c3ae61b371fdc

Contents?: true

Size: 742 Bytes

Versions: 128

Compression:

Stored size: 742 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("sum-of-multiples", &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
		Factors     []int
		Limit       int
		Expected    int
	}
}

// template applied to above data structure generates the Go test cases
var tmpl = `package summultiples

{{.Header}}

var varTests = []struct {
	divisors     []int
	limit        int
	sum          int
}{
{{range .J.Cases}}{ {{.Factors | printf "%#v"}}, {{.Limit}}, {{.Expected}}}, // {{.Description}}
{{end}}}
`

Version data entries

128 entries across 128 versions & 1 rubygems

Version Path
trackler-2.2.1.92 tracks/go/exercises/sum-of-multiples/.meta/gen.go
trackler-2.2.1.91 tracks/go/exercises/sum-of-multiples/.meta/gen.go
trackler-2.2.1.90 tracks/go/exercises/sum-of-multiples/.meta/gen.go
trackler-2.2.1.89 tracks/go/exercises/sum-of-multiples/.meta/gen.go
trackler-2.2.1.88 tracks/go/exercises/sum-of-multiples/.meta/gen.go
trackler-2.2.1.87 tracks/go/exercises/sum-of-multiples/.meta/gen.go
trackler-2.2.1.86 tracks/go/exercises/sum-of-multiples/.meta/gen.go
trackler-2.2.1.85 tracks/go/exercises/sum-of-multiples/.meta/gen.go
trackler-2.2.1.84 tracks/go/exercises/sum-of-multiples/.meta/gen.go
trackler-2.2.1.83 tracks/go/exercises/sum-of-multiples/.meta/gen.go
trackler-2.2.1.82 tracks/go/exercises/sum-of-multiples/.meta/gen.go
trackler-2.2.1.81 tracks/go/exercises/sum-of-multiples/.meta/gen.go
trackler-2.2.1.80 tracks/go/exercises/sum-of-multiples/.meta/gen.go
trackler-2.2.1.79 tracks/go/exercises/sum-of-multiples/.meta/gen.go
trackler-2.2.1.78 tracks/go/exercises/sum-of-multiples/.meta/gen.go
trackler-2.2.1.77 tracks/go/exercises/sum-of-multiples/.meta/gen.go
trackler-2.2.1.76 tracks/go/exercises/sum-of-multiples/.meta/gen.go
trackler-2.2.1.75 tracks/go/exercises/sum-of-multiples/.meta/gen.go
trackler-2.2.1.74 tracks/go/exercises/sum-of-multiples/.meta/gen.go
trackler-2.2.1.73 tracks/go/exercises/sum-of-multiples/.meta/gen.go