Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,26 @@ CTEST_TO_STRING(my_type, MY_STRUCT, string, bufferSize, value)
- **Force Fail**: `CTEST_ASSERT_FAIL(message...)`
- **Optional Messages**: All assertions support `printf`-style format strings as final arguments

#### Prefer the actual enum type when asserting enum values
When asserting a value whose declared type is an enum, always pass the enum type as the first argument to
`ASSERT_ARE_EQUAL`. Do not cast to `int` just to make the assert compile:
Comment on lines +92 to +93

```c
// BAD - loses type information, no symbolic name on failure
ASSERT_ARE_EQUAL(int, (int)MY_RESULT_OK, (int)result);

// GOOD - prints the enum value names on failure
ASSERT_ARE_EQUAL(MY_RESULT, MY_RESULT_OK, result);
Comment on lines +96 to +100
```

Use `TEST_DEFINE_ENUM_TYPE` to define the enum for the test.
```c
TEST_DEFINE_ENUM_TYPE(MY_RESULT, MY_RESULT_VALUES);
```

The enum-typed assert prints the symbolic name of both expected and actual values (e.g. `MY_RESULT_TIMED_OUT` instead of `1`), which is far more useful when diagnosing failures from CI logs.


### Parameterized Tests
`CTEST_PARAMETERIZED_TEST_FUNCTION` generates multiple `CTEST_FUNCTION` wrappers from a single test body:
```c
Expand Down