You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: manual.markdown
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -150,7 +150,7 @@ The failure of one of these macros causes the current test to immediately exit:
150
150
151
151
*CHECK_EQUAL Warning:*
152
152
153
-
CHECK_EQUAL(expected, actual) can produce misleading error reports as it will evaluate expected and actual more than ones. This especially leads to confusions when used with mocks. This happens if the mock function expects to be called exactly once, since the macro needs to evaluate the actual expression more than once. The problem does not occur with type specific checks (e.g. LONGS_EQUAL()), so it is recommended to use them if possible. Instead of:
153
+
CHECK_EQUAL(expected, actual) can produce misleading error reports as it will evaluate expected and actual more than once. This especially leads to confusions when used with mocks. This happens if the mock function expects to be called exactly once, since the macro needs to evaluate the actual expression more than once. The problem does not occur with type specific checks (e.g. LONGS_EQUAL()), so it is recommended to use them if possible. Instead of:
154
154
155
155
{% highlight c++ %}
156
156
CHECK_EQUAL(10, mock_returning_11())
@@ -306,10 +306,10 @@ If you want to completely disable memory leak detection then you can do so by bu
306
306
307
307
### Conflicts with operator new macros (STL!)
308
308
309
-
It is common for the memory leak detection macros to conflict with an overloaded operator new or with STL. This is because the macro replaces the call to operator new to a call to operator new with __FILE__, and __LINE__. If you overload operator new, it will replace your overloaded definition resulting in a compiler error. This is common when using Standard C++ library (STL).
309
+
It is common for the memory leak detection macros to conflict with an overloaded operator new or with STL. This is because the macro replaces the call to operator new to a call to operator new with __FILE__, and __LINE__. If you overload operator new, it will replace your overloaded definition resulting in a compiler error. This is common when using the Standard C++ library (STL).
310
310
311
311
#### Resolving conflicts with STL
312
-
The easiest way is not to pass the --include MemoryLeakDetectionNewMacros.h to the compiler, but this would lose all your file and line information. So this is not recommended. An alternative is to create your own NewMacros.h file which will include the STL file *before* the new macro is defined. For example, the following NewMacros file can be used for a program that uses std::list:
312
+
The easiest way is to not pass the --include MemoryLeakDetectionNewMacros.h to the compiler, but this would lose all your file and line information. So this is not recommended. An alternative is to create your own NewMacros.h file which will include the STL file *before* the new macro is defined. For example, the following NewMacros file can be used for a program that uses std::list:
313
313
314
314
{% highlight c++ %}
315
315
#include "list"
@@ -320,7 +320,7 @@ Now the call to the compiler needs to be -include MyOwnNewMacros.h and this will
320
320
321
321
### Conflicts with my own overload!
322
322
323
-
This one is harder (and luckily less common). You can solve this the same way as the conflict in STL, but it's probably better to use a finer grained control. So, instead you can temporary disable the new macros, overload operator new, enable the new macro again. This can be done with the following code:
323
+
This one is harder (and luckily less common). You can solve this the same way as the conflict with the STL, but it's probably better to use a finer grained control. So, instead you can temporary disable the new macros, overload operator new, enable the new macro again. This can be done with the following code:
324
324
325
325
{% highlight c++ %}
326
326
class NewDummyClass
@@ -349,7 +349,7 @@ Tbd
349
349
350
350
## Test Plugins
351
351
352
-
Test plugins let you add a preaction and a postaction to each test case. Plugin examples:
352
+
Test plugins let you add a pre-action and a post-action to each test case. Plugin examples:
353
353
354
354
* Memory leak detector (provided)
355
355
* Pointer restore mechanism (provided) - helpful when tests overwrite a pointer that must be restored to its original value after the test. This is especially helpful when a pointer to a function is modified for test purposes.
@@ -425,8 +425,8 @@ void printHelloWorld()
425
425
426
426
## Scripts
427
427
428
-
There are some scripts that are helpful in creating your initial h, source, and
429
-
Test files. These save a lot of typing. See scripts/README.TXT from the CppUTest distribution.
428
+
There are some scripts that are helpful in creating your initial header, source, and
429
+
Test files. These scripts save a lot of typing. See scripts/README.TXT from the CppUTest distribution.
430
430
431
431
<aid="advanced"> </a>
432
432
@@ -448,7 +448,7 @@ The Extensions directory has a few of these.
448
448
* TestPlugins can be used for, for example, system stability and resource handling like files, memory or network connection clean-up.
449
449
* In CppUTest, the memory leak detection is done via a default enabled TestPlugin
450
450
451
-
### How can tests run when they are linked in a library
451
+
### How to run tests when they are linked in a library
452
452
453
453
In larger projects, it is often useful if you can link the tests in "libraries of tests" and then link them to the library of a component or link them all together to be able to run all the unit tests. Putting the tests in a library however causes an interesting problem because the lack of reference to the tests (due to the auto-registration of tests) causes the linker to discard the tests and it won't run any of them. There are two different work-arounds for this:
0 commit comments