Skip to content

Commit

Permalink
add Uniform to UInt, Long, ULong
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyLloyd committed Dec 8, 2024
1 parent 115ca8b commit 3a84374
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions CsCheck/Gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1778,6 +1778,17 @@ public override uint Generate(PCG pcg, Size? min, out Size size)
return new Range(start, finish - start + 1U);
}
}
sealed class GenUniform : Gen<uint>
{
public override uint Generate(PCG pcg, Size? min, out Size size)
{
var i = pcg.Next();
size = new Size(i);
return i;
}
}
/// <summary>Generate a uint uniformly distributed with all values.</summary>
public Gen<uint> Uniform = new GenUniform();
}
public sealed class GenUInt4 : Gen<uint>
{
Expand Down Expand Up @@ -1901,6 +1912,17 @@ public override long Generate(PCG pcg, Size? min, out Size size)
return new Range(start, (ulong)(finish - start + 1));
}
}
sealed class GenUniform : Gen<long>
{
public override long Generate(PCG pcg, Size? min, out Size size)
{
var i = (long)pcg.Next64();
size = new Size(Zigzag(i));
return i;
}
}
/// <summary>Generate a long uniformly distributed with all values.</summary>
public Gen<long> Uniform = new GenUniform();
}

public sealed class GenULong : Gen<ulong>
Expand Down Expand Up @@ -1930,6 +1952,17 @@ public override ulong Generate(PCG pcg, Size? min, out Size size)
return new Range(start, finish - start + 1UL);
}
}
sealed class GenUniform : Gen<ulong>
{
public override ulong Generate(PCG pcg, Size? min, out Size size)
{
var i = pcg.Next64();
size = new Size(i);
return i;
}
}
/// <summary>Generate a ulong uniformly distributed with all values.</summary>
public Gen<ulong> Uniform = new GenUniform();
}

public sealed class GenFloat : Gen<float>
Expand Down

0 comments on commit 3a84374

Please sign in to comment.