Skip to content
This repository was archived by the owner on Aug 15, 2026. It is now read-only.

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

Draft
mbianchidev with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-flaky-test-test-random-math-operations
Draft

[Corn Flakes] C fix flaky test: ensure generate_random_even_number always returns even numbers#270
mbianchidev with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-flaky-test-test-random-math-operations

Conversation

Copilot AI commented May 26, 2026

Copy link
Copy Markdown
Contributor

[C] test_random_math_operations was persistently flaky because generate_random_even_number could intermittently return odd values. This change removes the intermittent odd-number path so the function consistently honors the even-number contract across ranges.

  • Root-cause fix (C random even generator)

    • Removed the 5% corruption branch in c/src/random_math_operations.c that could increment an even value into an odd value.
    • Kept existing range normalization and parity-adjustment behavior intact.
  • Test file alignment

    • Updated the stale test section comment in c/tests/test_random_math_operations.c to reflect that the even-number tests are no longer intentionally flaky.
int value = min + (rand() % (max - min + 1));

if (value % 2 != 0) {
    value += 1;
    if (value > max) {
        value -= 2;
    }
}

return value;

Copilot AI changed the title [WIP] Fix flaky test for random math operations [Corn Flakes] C fix flaky test: ensure generate_random_even_number always returns even numbers May 26, 2026
Copilot AI requested a review from mbianchidev May 26, 2026 08:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[flaky-test] [C] test_generate_random_even_number.test_generate_random_even_number()

2 participants