Skip to content
This repository was archived by the owner on Nov 27, 2025. It is now read-only.

Commit ee1c8e3

Browse files
committed
Test merging AutoGenConfig
1 parent d730602 commit ee1c8e3

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
module Hedgehog.Experimental.Tests.AutoGenConfigTests
2+
3+
open Xunit
4+
open Swensen.Unquote
5+
open Hedgehog
6+
7+
[<Fact>]
8+
let ``merging AutoGenConfig preserves set values``() =
9+
let expectedRange = Range.exponential 2 6
10+
let expectedDepth = 2
11+
let config1 =
12+
AutoGenConfig.defaults
13+
|> AutoGenConfig.setSeqRange expectedRange
14+
|> AutoGenConfig.setRecursionDepth expectedDepth
15+
|> AutoGenConfig.addGenerator (Gen.int32 (Range.exponentialBounded()))
16+
let config2 = AutoGenConfig.defaults |> AutoGenConfig.addGenerator Gen.bool
17+
let merged = AutoGenConfig.merge config1 config2
18+
test <@ AutoGenConfig.recursionDepth merged = expectedDepth @>
19+
20+
let property = property {
21+
let! array = merged |> GenX.autoWith<(int * bool)[]>
22+
test <@ Array.length array >= 2 && Array.length array <= 6 @>
23+
}
24+
25+
Property.check property
26+
27+
[<Fact>]
28+
let ``merging AutoGenConfig overrides values``() =
29+
let previousRange = Range.exponential 10 15
30+
let expectedRange = Range.exponential 2 6
31+
let expectedDepth = 2
32+
let config1 = AutoGenConfig.defaults |> AutoGenConfig.setSeqRange previousRange |> AutoGenConfig.setRecursionDepth 1
33+
let config2 =
34+
AutoGenConfig.defaults
35+
|> AutoGenConfig.setSeqRange expectedRange
36+
|> AutoGenConfig.setRecursionDepth expectedDepth
37+
|> AutoGenConfig.addGenerator (Gen.int32 (Range.exponentialBounded()))
38+
39+
let merged = AutoGenConfig.merge config1 config2
40+
test <@ AutoGenConfig.recursionDepth merged = expectedDepth @>
41+
42+
let property = property {
43+
let! array = merged |> GenX.autoWith<int[]>
44+
test <@ Array.length array >= 2 && Array.length array <= 6 @>
45+
}
46+
47+
Property.check property

src/Hedgehog.Experimental.Tests/Hedgehog.Experimental.Tests.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<Compile Include="TypeUtilsTests.fs" />
1111
<Compile Include="GenTests.fs" />
1212
<Compile Include="GenericGenTests.fs" />
13+
<Compile Include="AutoGenConfigTests.fs" />
1314
</ItemGroup>
1415

1516
<ItemGroup>

0 commit comments

Comments
 (0)