Skip to content

Commit a1b1600

Browse files
committed
Update change log and known issues.
Fix bug with infinity and NaN handling.
1 parent 3f7564e commit a1b1600

File tree

6 files changed

+154
-24
lines changed

6 files changed

+154
-24
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ If you'd like to leave the hard work to us, you might be interested in Ceedling,
1212

1313
If you're new to Unity, we encourage you to tour the [getting started guide][].
1414

15+
You can also find the [change log][] and [known issues][] in our documentation.
16+
1517
## Getting Started
1618

1719
The [docs][] folder contains a [getting started guide][] and much more tips about using Unity.
@@ -226,5 +228,7 @@ This is useful for specifying more information about the problem.
226228

227229
[CI]: https://github.com/ThrowTheSwitch/Unity/workflows/CI/badge.svg
228230
[getting started guide]: docs/UnityGettingStartedGuide.md
231+
[change log]: docs/UnityChangeLog.md
232+
[known issues]: docs/UnityKnownIssues.md
229233
[docs]: docs/
230234
[UnityAssertionsReference.md]: docs/UnityAssertionsReference.md

docs/UnityChangeLog.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Unity Test - Change Log
2+
3+
## A Note
4+
5+
This document captures significant features and fixes to the Unity project core source files
6+
and scripts. More detail can be found in the history on Github.
7+
8+
This project is now tracking changes in more detail. Previous releases get less detailed as
9+
we move back in histroy.
10+
11+
Prior to 2012, the project was hosted on SourceForge.net
12+
Prior to 2008, the project was an internal project and not released to the public.
13+
14+
## Log
15+
16+
### Unity 2.6.0 ()
17+
18+
New Features:
19+
20+
- Fill out missing variations of arrays, within, etc.
21+
- Add `TEST_PRINTF()`
22+
- Add `TEST_MATRIX()` and `TEST_RANGE()` options and documentation
23+
- Add support for searching `TEST_SOURCE_FILE()` for determining test dependencies
24+
- Add Unity BDD plugin
25+
- Add `UNITY_INCLUDE_EXEC_TIME` option to report test times
26+
- Allow user to override test abort underlying mechanism
27+
28+
Significant Bugfixes:
29+
30+
- More portable validation of NaN and Infinity. Added `UNITY_IS_NAN` and `UNITY_IS_INF` options
31+
- Add `UNITY_PROGMEM` configuration option
32+
- Fix overflow detection of hex values when using arrays
33+
- Fix scripts broken by Ruby standard changes
34+
35+
Other:
36+
37+
- Avoid pointer comparison when one is null to avoid compiler warnings
38+
- Significant improvements to documentation
39+
- Updates to match latest Ruby style specification
40+
- Meson, CMake, PlatformIO builds
41+
42+
### Unity 2.5.2 (January 2021)
43+
44+
- improvements to RUN_TEST macro and generated RUN_TEST
45+
- Fix `UNITY_TEST_ASSERT_BIT(S)_HIGH`
46+
- Cleaner handling of details tracking by CMock
47+
48+
### Unity 2.5.1 (May 2020)
49+
50+
Mostly a bugfix and stability release.
51+
Bonus Features:
52+
53+
- Optional TEST_PRINTF macro
54+
- Improve self-testing procedures.
55+
56+
### Unity 2.5.0 (October 2019)
57+
58+
It's been a LONG time since the last release of Unity. Finally, here it is!
59+
There are too many updates to list here, so some highlights:
60+
61+
- more standards compliant (without giving up on supporting ALL compilers, no matter how quirky)
62+
- many more specialized assertions for better test feedback
63+
- more examples for integrating into your world
64+
- many many bugfixes and tweaks
65+
66+
### Unity 2.4.3 (November 2017)
67+
68+
- Allow suiteSetUp() and suiteTearDown() to be povided as normal C functions
69+
- Fix & Expand Greater Than / Less Than assertions for integers
70+
- Built-in option to colorize test results
71+
- Documentation updates
72+
73+
### Unity 2.4.2 (September 2017)
74+
75+
- Fixed bug in UNTY_TEST_ASSERT_EACH_EQUAL_*
76+
- Added TEST_ASSERT_GREATER_THAN and TEST_ASSERT_LESS_THAN
77+
- Updated Module Generator to stop changing names when no style given
78+
- Cleanup to custom float printing for accuracy
79+
- Cleanup incorrect line numbers are partial name matching
80+
- Reduce warnings from using popular function names as variable names
81+
82+
### Unity 2.4.1 (April 2017)
83+
84+
- test runner generator can inject defines as well as headers
85+
- added a built-in floating point print routine instead of relying on printf
86+
- updated to new coding and naming standard
87+
- updated documentation to be markdown instead of pdf
88+
- fixed many many little bugs, most of which were supplied by the community (you people are awesome!)
89+
- coding standard actually enforced in CI
90+
91+
### Unity 2.4.0 (October, 2016)
92+
93+
- port from SourceForge and numerous bugfixes

docs/UnityConfigurationGuide.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,17 @@ _Example:_
222222
#define UNITY_FLOAT_PRECISION 0.001f
223223
```
224224
225+
#### `UNITY_IS_NAN` and `UNITY_IS_INF`
226+
227+
If your toolchain defines `isnan` and `isinf` in `math.h` as macros, nothing needs to be done. If your toolchain doesn't define these, Unity
228+
will create these macros itself. You may override either or both of these defines to specify how you want to evaluate if a number is NaN or Infinity.
229+
230+
_Example:_
231+
232+
```C
233+
#define UNITY_IS_NAN(n) ((n != n) ? 1 : 0)
234+
```
235+
225236
### Miscellaneous
226237
227238
#### `UNITY_EXCLUDE_STDDEF_H`

docs/UnityKnownIssues.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Unity Test - Known Issues
2+
3+
## A Note
4+
5+
This project will do its best to keep track of significant bugs that might effect your usage of this
6+
project and its supporting scripts. A more detailed and up-to-date list for cutting edge Unity can
7+
be found on our Github repository.
8+
9+
## Issues
10+
11+
- No built-in validation of no-return functions
12+
- Incomplete support for Printf-style formatting
13+
- Incomplete support for VarArgs

src/unity.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,11 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number)
356356
{
357357
UnityPrint("0");
358358
}
359-
else if (isnan(number))
359+
else if (UNITY_IS_NAN(number))
360360
{
361361
UnityPrint("nan");
362362
}
363-
else if (isinf(number))
363+
else if (UNITY_IS_INF(number))
364364
{
365365
UnityPrint("inf");
366366
}
@@ -895,15 +895,15 @@ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected,
895895
#ifndef UNITY_EXCLUDE_FLOAT
896896
/* Wrap this define in a function with variable types as float or double */
897897
#define UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff) \
898-
if (isinf(expected) && isinf(actual) && (((expected) < 0) == ((actual) < 0))) return 1; \
898+
if (UNITY_IS_INF(expected) && UNITY_IS_INF(actual) && (((expected) < 0) == ((actual) < 0))) return 1; \
899899
if (UNITY_NAN_CHECK) return 1; \
900900
(diff) = (actual) - (expected); \
901901
if ((diff) < 0) (diff) = -(diff); \
902902
if ((delta) < 0) (delta) = -(delta); \
903-
return !(isnan(diff) || isinf(diff) || ((diff) > (delta)))
903+
return !(UNITY_IS_NAN(diff) || UNITY_IS_INF(diff) || ((diff) > (delta)))
904904
/* This first part of this condition will catch any NaN or Infinite values */
905905
#ifndef UNITY_NAN_NOT_EQUAL_NAN
906-
#define UNITY_NAN_CHECK isnan(expected) && isnan(actual)
906+
#define UNITY_NAN_CHECK UNITY_IS_NAN(expected) && UNITY_IS_NAN(actual)
907907
#else
908908
#define UNITY_NAN_CHECK 0
909909
#endif
@@ -954,12 +954,12 @@ void UnityAssertWithinFloatArray(const UNITY_FLOAT delta,
954954
#endif
955955
}
956956

957-
if (isinf(in_delta))
957+
if (UNITY_IS_INF(in_delta))
958958
{
959959
return; /* Arrays will be force equal with infinite delta */
960960
}
961961

962-
if (isnan(in_delta))
962+
if (UNITY_IS_NAN(in_delta))
963963
{
964964
/* Delta must be correct number */
965965
UnityPrintPointlessAndBail();
@@ -1098,21 +1098,21 @@ void UnityAssertFloatSpecial(const UNITY_FLOAT actual,
10981098
{
10991099
case UNITY_FLOAT_IS_INF:
11001100
case UNITY_FLOAT_IS_NOT_INF:
1101-
is_trait = isinf(actual) && (actual > 0);
1101+
is_trait = UNITY_IS_INF(actual) && (actual > 0);
11021102
break;
11031103
case UNITY_FLOAT_IS_NEG_INF:
11041104
case UNITY_FLOAT_IS_NOT_NEG_INF:
1105-
is_trait = isinf(actual) && (actual < 0);
1105+
is_trait = UNITY_IS_INF(actual) && (actual < 0);
11061106
break;
11071107

11081108
case UNITY_FLOAT_IS_NAN:
11091109
case UNITY_FLOAT_IS_NOT_NAN:
1110-
is_trait = isnan(actual) ? 1 : 0;
1110+
is_trait = UNITY_IS_NAN(actual) ? 1 : 0;
11111111
break;
11121112

11131113
case UNITY_FLOAT_IS_DET: /* A determinate number is non infinite and not NaN. */
11141114
case UNITY_FLOAT_IS_NOT_DET:
1115-
is_trait = !isinf(actual) && !isnan(actual);
1115+
is_trait = !UNITY_IS_INF(actual) && !UNITY_IS_NAN(actual);
11161116
break;
11171117

11181118
case UNITY_FLOAT_INVALID_TRAIT: /* Supress warning */
@@ -1182,12 +1182,12 @@ void UnityAssertWithinDoubleArray(const UNITY_DOUBLE delta,
11821182
#endif
11831183
}
11841184

1185-
if (isinf(in_delta))
1185+
if (UNITY_IS_INF(in_delta))
11861186
{
11871187
return; /* Arrays will be force equal with infinite delta */
11881188
}
11891189

1190-
if (isnan(in_delta))
1190+
if (UNITY_IS_NAN(in_delta))
11911191
{
11921192
/* Delta must be correct number */
11931193
UnityPrintPointlessAndBail();
@@ -1325,21 +1325,21 @@ void UnityAssertDoubleSpecial(const UNITY_DOUBLE actual,
13251325
{
13261326
case UNITY_FLOAT_IS_INF:
13271327
case UNITY_FLOAT_IS_NOT_INF:
1328-
is_trait = isinf(actual) && (actual > 0);
1328+
is_trait = UNITY_IS_INF(actual) && (actual > 0);
13291329
break;
13301330
case UNITY_FLOAT_IS_NEG_INF:
13311331
case UNITY_FLOAT_IS_NOT_NEG_INF:
1332-
is_trait = isinf(actual) && (actual < 0);
1332+
is_trait = UNITY_IS_INF(actual) && (actual < 0);
13331333
break;
13341334

13351335
case UNITY_FLOAT_IS_NAN:
13361336
case UNITY_FLOAT_IS_NOT_NAN:
1337-
is_trait = isnan(actual) ? 1 : 0;
1337+
is_trait = UNITY_IS_NAN(actual) ? 1 : 0;
13381338
break;
13391339

13401340
case UNITY_FLOAT_IS_DET: /* A determinate number is non infinite and not NaN. */
13411341
case UNITY_FLOAT_IS_NOT_DET:
1342-
is_trait = !isinf(actual) && !isnan(actual);
1342+
is_trait = !UNITY_IS_INF(actual) && !UNITY_IS_NAN(actual);
13431343
break;
13441344

13451345
case UNITY_FLOAT_INVALID_TRAIT: /* Supress warning */

src/unity_internals.h

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -241,16 +241,25 @@
241241
#endif
242242
typedef UNITY_FLOAT_TYPE UNITY_FLOAT;
243243

244-
/* isinf & isnan macros should be provided by math.h */
245-
#ifndef isinf
246-
/* The value of Inf - Inf is NaN */
247-
#define isinf(n) (isnan((n) - (n)) && !isnan(n))
248-
#endif
249-
244+
/* isnan macro should be provided by math.h. Override if not macro */
245+
#ifndef UNITY_IS_NAN
250246
#ifndef isnan
251247
/* NaN is the only floating point value that does NOT equal itself.
252248
* Therefore if n != n, then it is NaN. */
253-
#define isnan(n) ((n != n) ? 1 : 0)
249+
#define UNITY_IS_NAN(n) ((n != n) ? 1 : 0)
250+
#else
251+
#define UNITY_IS_NAN(n) isnan(n)
252+
#endif
253+
#endif
254+
255+
/* isinf macro should be provided by math.h. Override if not macro */
256+
#ifndef UNITY_IS_INF
257+
#ifndef isinf
258+
/* The value of Inf - Inf is NaN */
259+
#define UNITY_IS_INF(n) (UNITY_IS_NAN((n) - (n)) && !UNITY_IS_NAN(n))
260+
#else
261+
#define UNITY_IS_INF(n) isinf(n)
262+
#endif
254263
#endif
255264

256265
#endif

0 commit comments

Comments
 (0)