mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-07-17 15:39:05 +08:00
Catch up documentation to match these changes.
This commit is contained in:
@ -343,36 +343,6 @@ _Note:_
|
||||
specifying `UNITY_USE_FLUSH_STDOUT`. No other defines are required.
|
||||
|
||||
|
||||
##### `UNITY_WEAK_ATTRIBUTE`
|
||||
|
||||
##### `UNITY_WEAK_PRAGMA`
|
||||
|
||||
##### `UNITY_NO_WEAK`
|
||||
|
||||
For some targets, Unity can make the otherwise required setUp() and tearDown()
|
||||
functions optional. This is a nice convenience for test writers since setUp and
|
||||
tearDown don’t often actually do anything. If you’re using gcc or clang, this
|
||||
option is automatically defined for you. Other compilers can also support this
|
||||
behavior, if they support a C feature called weak functions. A weak function is
|
||||
a function that is compiled into your executable unless a non-weak version of
|
||||
the same function is defined elsewhere. If a non-weak version is found, the weak
|
||||
version is ignored as if it never existed. If your compiler supports this feature,
|
||||
you can let Unity know by defining UNITY_WEAK_ATTRIBUTE or UNITY_WEAK_PRAGMA as
|
||||
the function attributes that would need to be applied to identify a function as
|
||||
weak. If your compiler lacks support for weak functions, you will always need to
|
||||
define setUp and tearDown functions (though they can be and often will be just
|
||||
empty). You can also force Unity to NOT use weak functions by defining
|
||||
UNITY_NO_WEAK. The most common options for this feature are:
|
||||
|
||||
_Example:_
|
||||
```C
|
||||
#define UNITY_WEAK_ATTRIBUTE weak
|
||||
#define UNITY_WEAK_ATTRIBUTE __attribute__((weak))
|
||||
#define UNITY_WEAK_PRAGMA
|
||||
#define UNITY_NO_WEAK
|
||||
```
|
||||
|
||||
|
||||
##### `UNITY_PTR_ATTRIBUTE`
|
||||
|
||||
Some compilers require a custom attribute to be assigned to pointers, like
|
||||
|
@ -93,8 +93,9 @@ Next, a test file will include a `setUp()` and `tearDown()` function. The setUp
|
||||
function can contain anything you would like to run before each test. The
|
||||
tearDown function can contain anything you would like to run after each test.
|
||||
Both functions accept no arguments and return nothing. You may leave either or
|
||||
both of these blank if you have no need for them. If you're using a compiler
|
||||
that is configured to make these functions optional, you may leave them off
|
||||
both of these blank if you have no need for them.
|
||||
|
||||
If you're using Ceedling or the test runner generator script, you may leave these off
|
||||
completely. Not sure? Give it a try. If you compiler complains that it can't
|
||||
find setUp or tearDown when it links, you'll know you need to at least include
|
||||
an empty function for these.
|
||||
|
Reference in New Issue
Block a user