This commit change the regex to accept more spaces inside the brackets
of the TEST_RANGE().
I use clang-format through vscode "editor.formatOnSave": true feature and it produce
padding spaces inside the array brackets by default.
```c
int a[] = [1, 2];
```
is changed into
```c
int a[] = [ 1, 2 ];
```
Also, every time I save a file containing a TEST_RANGE() with ctrl + s,
it breaks it.
This is a fix from the change I made in
`commit 418c1635f2f1bcd353b6fce23a16594c914047b8`
where I added options to compile unity with the `fixture` and `memory`
extensions:
In that version, Unity had been able to build, but there were some issues when
trying to install it. Namely, the CMake generator expressions were not
evaluated correctly, and it would try to install with a path that had
un-expanded generator commands in it, which would obviously fail and throw an
error. I've got a feeling that this is a bug with CMake, but for now the
workaround that worked in [this stackoverflow
post](https://stackoverflow.com/questions/51541678/nested-cmake-generator-expressions-are-only-partially-evaluated)
seemed to work here, as well.
Another issue with that commit was that it tried to include a
`unity_memory_internals.h` file, which did not exist. This has also been
resolved.
With a test file guarded we can include this file on IDE project
(MPLAB X in my case) and compile without excluding test files.
Excluding test files on MPLAB X disable autocompletion and function
navigation.
The high/low bits masks for TEST_ASSERT_BIT(S)_HIGH/LOW are created
by casting 0/-1 to UNITY_UINT32. This isn't OK on 64-bit platforms
as it results in a high bits mask of 0x00000000ffffffff instead of
0xffffffffffffffff.
Cast 0/-1 to UNITY_UINT instead.
GCC (& Clang) have the notion of pure and const functions [1],
where those attributes are intended to help the optimiser.
Annotate a few APIs here with the appropriate key words, which
also fixes Wsuggest-attribute=noreturn warning, which a
source base might have enabled:
Compiling unity.c...
.../src/unity.c: In function ‘UnityFail’:
.../src/unity.c:1759:6: warning: function might be candidate for attribute ‘noreturn’ [-Wsuggest-attribute=noreturn]
1759 | void UnityFail(const char* msg, const UNITY_LINE_TYPE line)
| ^~~~~~~~~
.../src/unity.c: In function ‘UnityIgnore’:
.../src/unity.c:1796:6: warning: function might be candidate for attribute ‘noreturn’ [-Wsuggest-attribute=noreturn]
1796 | void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line)
| ^~~~~~~~~~~
[1] https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
Signed-off-by: André Draszik <git@andred.net>
Compiling a source base / test with Wswitch-enum enabled, gives
the following warning:
../src/unity.c: In function ‘UnityAssertFloatSpecial’:
../src/unity.c:1092:5: warning: enumeration value ‘UNITY_FLOAT_INVALID_TRAIT’ not handled in switch [-Wswitch-enum]
1092 | switch (style)
| ^~~~~~
Fix by adding the missing value to the default (unhandled) case.
Signed-off-by: André Draszik <git@andred.net>
Compiling a source base / test with Wsign-compare enabled, gives
the following warning:
build/test/runners/test_system_runner.c: In function ‘run_test’:
build/test/runners/test_system_runner.c:62:35: warning: conversion to ‘UNITY_UINT’ {aka ‘long unsigned int’} from ‘int’ may change the sign of the result [-Wsign-conversion]
62 | Unity.CurrentTestLineNumber = line_num;
| ^~~~~~~~
Fix by updating the type in the function declaration.
Signed-off-by: André Draszik <git@andred.net>