Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow conditional function chaining on STRICT_EXPECTED_CALL #305

Open
mattdurak opened this issue Aug 11, 2023 · 0 comments
Open

Allow conditional function chaining on STRICT_EXPECTED_CALL #305

mattdurak opened this issue Aug 11, 2023 · 0 comments

Comments

@mattdurak
Copy link
Contributor

Current code might do something like this:

static void setup(int* optional_value)
{
    if (optional_value != NULL)
    {
        STRICT_EXPECTED_CALL(foo(IGNORED_ARG))
            .CopyOutArgumentBuffer_result(optional_value, sizeof(optional_value));
    }
    else
    {
        STRICT_EXPECTED_CALL(foo(IGNORED_ARG));
    }
}

Would be nice to reduce that to something like:

static void setup(int* optional_value)
{
    STRICT_EXPECTED_CALL(foo(IGNORED_ARG))
        .If(optional_value != NULL)
        .CopyOutArgumentBuffer_result(optional_value, sizeof(optional_value));
    // perhaps needs .EndIf()
}

Alternatively, something like this could work:

static void setup(int* optional_value)
{
    HELPER_TO_GET_TYPE x = STRICT_EXPECTED_CALL(foo(IGNORED_ARG));
    if (optional_value != NULL)
    {
        x.CopyOutArgumentBuffer_result(optional_value, sizeof(optional_value));
    }
}

Or maybe:

static void setup(int* optional_value)
{
    STRICT_EXPECTED_CALL(foo(IGNORED_ARG)).SaveExpectation(x);
    if (optional_value != NULL)
    {
        x.CopyOutArgumentBuffer_result(optional_value, sizeof(optional_value));
    }
}
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

No branches or pull requests

1 participant