Azure / Azure/umock-c

Allow conditional function chaining on STRICT_EXPECTED_CALL

Open
#305 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
36
Forks
27
Avg merge
32m
Merged PRs (30d)
3

Description

Current code might do something like this:

```c
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:

```c
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:

```c
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:

```c
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));
}
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the STRICT_EXPECTED_CALL entry point and its existing function-chaining implementation. Compare the proposed conditional chaining and saved-expectation alternatives, then define the supported API and verify that optional copy-out behavior is covered before considering the issue done.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.