Skip to content

Commit

Permalink
More concise version by using Map to construct the pair
Browse files Browse the repository at this point in the history
  • Loading branch information
alfert committed Apr 17, 2021
1 parent a399d5d commit daf756e
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions example_flatmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,9 @@ func Example_flatmap() {
genIntPair := func() gopter.Gen {
return gen.IntRange(10, 20).FlatMap(func(v interface{}) gopter.Gen {
k := v.(int)
n := gen.Const(k)
m := gen.IntRange(2*k, 50)
var gen_map = map[string]gopter.Gen{"Fst": n, "Snd": m}
return gen.Struct(
reflect.TypeOf(IntPair{}),
gen_map,
)
return gen.IntRange(2*k, 50).Map(func(m int) IntPair {
return IntPair{Fst: k, Snd: m}
})
},
reflect.TypeOf(int(0)))
}
Expand Down

0 comments on commit daf756e

Please sign in to comment.