File: main.go

package info (click to toggle)
golang-github-muesli-combinator 0.3.0-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 96 kB
  • sloc: makefile: 3
file content (37 lines) | stat: -rw-r--r-- 674 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main

import (
	"fmt"

	"github.com/muesli/combinator"
)

func main() {
	type User struct {
		Name  string
		Age   uint
		Admin bool
	}

	/*
		Define potential test values. Make sure the struct's fields share the name and
		type of the structs you want to generate.
	*/
	testData := struct {
		Name  []string
		Age   []uint
		Admin []bool
	}{
		Name:  []string{"Alice", "Bob"},
		Age:   []uint{23, 42, 99},
		Admin: []bool{false, true},
	}

	// Generate all possible combinations
	var users []User
	combinator.Generate(&users, testData)

	for i, u := range users {
		fmt.Printf("Combination %2d | Name: %-5s | Age: %d | Admin: %v\n", i, u.Name, u.Age, u.Admin)
	}
}