Skip to content

[Corn Flakes] C++ fix flaky test: ensure generate_random_even_number returns even numbers - #258

Draft
mbianchidev with Copilot wants to merge 2 commits into
mainfrom
copilot/corn-flakes-detection-fix
Draft

[Corn Flakes] C++ fix flaky test: ensure generate_random_even_number returns even numbers#258
mbianchidev with Copilot wants to merge 2 commits into
mainfrom
copilot/corn-flakes-detection-fix

Conversation

Copilot AI commented May 20, 2026

Copy link
Copy Markdown
Contributor

generateRandomEvenNumber() had an embedded 5% flaw that added 1 to the result, producing an odd number. With 20 test iterations, this yielded ~64% failure rate — matching the observed 60% in CI.

Change

  • cpp/src/random_math_operations.cpp: Removed the flaw. Function now unconditionally returns dist(gen) * 2.
// Before
int number = dist(gen) * 2;
std::uniform_real_distribution<> flaw(0.0, 1.0);
if (flaw(gen) < 0.05) number += 1;  // ← intentional bug
return number;

// After
return dist(gen) * 2;  // always even, range [0, 100]

Copilot AI changed the title [WIP] Fix flaky test RandomMathOperationsTest.EvenNumberIsEven [Corn Flakes] C++ fix flaky test: ensure generate_random_even_number returns even numbers May 20, 2026
Copilot AI requested a review from mbianchidev May 20, 2026 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[flaky-test] [C++] RandomMathOperationsTest.GenerateRandomEvenNumber()

2 participants