Skip to content
This repository was archived by the owner on Aug 15, 2026. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions csharp/CornTest.Tests/RandomMathOperationsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ namespace CornTest.Tests;

/// <summary>
/// Tests for <see cref="RandomMathOperations"/>.
/// The even-number tests are intentionally flaky because the underlying
/// method has a 5% chance of returning an odd number. With 20 iterations
/// the probability of at least one failure is roughly 64%.
/// The even-number tests validate that generated values are always even.
/// </summary>
public class RandomMathOperationsTest
{
Expand Down
14 changes: 2 additions & 12 deletions csharp/CornTest/RandomMathOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace CornTest;

/// <summary>
/// Provides random number generation operations for testing flake detection.
/// The GenerateRandomEvenNumber method contains an intentional 5% flaw.
/// The GenerateRandomEvenNumber method always returns an even value.
/// </summary>
public class RandomMathOperations
{
Expand Down Expand Up @@ -30,21 +30,11 @@ public int GenerateRandomOddNumber()

/// <summary>
/// Produces a random even integer in the range [0, 100].
/// <para>
/// <b>Intentional flaw</b>: approximately 5% of invocations will
/// corrupt the result by adding 1, yielding an odd number instead.
/// </para>
/// </summary>
public int GenerateRandomEvenNumber()
{
// _rng.Next(51) yields 0..50, so result is 0,2,4,...,100
int value = _rng.Next(51) * 2;

// Intentional flaw: with ~5% probability, corrupt the even number
if (_rng.NextDouble() < 0.05)
value += 1;

return value;
return _rng.Next(51) * 2;
}

/// <summary>
Expand Down
Loading