Skip to content

Add explicit test case option#44

Open
echoumcp1 wants to merge 18 commits intomainfrom
explicit-test-case
Open

Add explicit test case option#44
echoumcp1 wants to merge 18 commits intomainfrom
explicit-test-case

Conversation

@echoumcp1
Copy link
Copy Markdown
Member

@echoumcp1 echoumcp1 commented Apr 2, 2026

Mirrors Hypothesis's example decorator. Provide an explicit test case as an input set:

hegel::hegel(
        [&] {
            auto x = hegel::draw(integers<int>());
            if (x == 10 || x == 20) {
                throw std::runtime_error("silly test failed");
            }
        },
        {.test_cases = 0, .examples = {{10}, {20}}});

x = 10 is tried first, then x = 20. The explicit test case is a list of draws. If value X is at the front of list when draw() is called, X is returned and popped from the front of the list (in actuality, the back, since the list is reversed). If the type of X does not match the type of the value that should be drawn, the test crashes.

If test_cases is 0, the server is never spawned and only the explicit test cases are used, otherwise the explicit test cases are tried first before asking the server for values.

Depends on #40

@echoumcp1 echoumcp1 changed the title Explicit test case Add examples option Apr 6, 2026
@echoumcp1 echoumcp1 changed the title Add examples option Add explicit test case option Apr 6, 2026
@echoumcp1 echoumcp1 requested a review from DRMacIver April 8, 2026 03:36
@echoumcp1 echoumcp1 marked this pull request as ready for review April 8, 2026 03:36
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.

1 participant