✨ Add MultiGeneratorRandomOrder
This commit is contained in:
parent
2440f55563
commit
7c016df30f
3 changed files with 101 additions and 23 deletions
|
|
@ -7,18 +7,14 @@ import (
|
|||
)
|
||||
|
||||
func ExampleWithGenerator_customGenerator() {
|
||||
gen := func(*nomino.Config) (string, error) {
|
||||
var gen nomino.Generator = func(*nomino.Config) (string, error) {
|
||||
return "hello", nil
|
||||
}
|
||||
option := nomino.WithGenerator(gen)
|
||||
|
||||
str, _ := nomino.Make(nomino.NewConfig(option))
|
||||
str, _ := gen.Make()
|
||||
fmt.Println(str)
|
||||
|
||||
str, _ = nomino.Make(nomino.NewConfig(
|
||||
option,
|
||||
nomino.WithoutExtension(),
|
||||
))
|
||||
str, _ = gen.Make(nomino.WithoutExtension())
|
||||
fmt.Println(str)
|
||||
|
||||
// Output:
|
||||
|
|
@ -47,15 +43,14 @@ func ExampleMultiGeneratorInOrder() {
|
|||
return "goodbye", nil
|
||||
}
|
||||
gen := nomino.MultiGeneratorInOrder(gen1, gen2)
|
||||
option := nomino.WithGenerator(gen)
|
||||
|
||||
str, _ := nomino.Make(nomino.NewConfig(option))
|
||||
str, _ := gen.Make()
|
||||
fmt.Println(str)
|
||||
|
||||
str, _ = nomino.Make(nomino.NewConfig(option))
|
||||
str, _ = gen.Make()
|
||||
fmt.Println(str)
|
||||
|
||||
str, _ = nomino.Make(nomino.NewConfig(option))
|
||||
str, _ = gen.Make()
|
||||
fmt.Println(str)
|
||||
|
||||
// Output:
|
||||
|
|
@ -63,3 +58,22 @@ func ExampleMultiGeneratorInOrder() {
|
|||
// goodbye.txt
|
||||
// hello.txt
|
||||
}
|
||||
|
||||
func ExampleMultiGeneratorRandomOrder() {
|
||||
gen1 := func(*nomino.Config) (string, error) {
|
||||
return "hello", nil
|
||||
}
|
||||
gen2 := func(*nomino.Config) (string, error) {
|
||||
return "goodbye", nil
|
||||
}
|
||||
gen := nomino.MultiGeneratorRandomOrder(gen1, gen2)
|
||||
|
||||
str, _ := gen.Make()
|
||||
fmt.Println(str)
|
||||
|
||||
str, _ = gen.Make()
|
||||
fmt.Println(str)
|
||||
|
||||
str, _ = gen.Make()
|
||||
fmt.Println(str)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue