mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-16 10:42:25 +01:00
Updated CATCH_CONFIG_CONSOLE_WIDTH documentation to describe function usage
This commit is contained in:
parent
dc18c0556d
commit
807b9eac7a
@ -62,11 +62,29 @@ Typically you should place the ```#define``` before #including "catch.hpp" in yo
|
|||||||
|
|
||||||
## Console width
|
## Console width
|
||||||
|
|
||||||
CATCH_CONFIG_CONSOLE_WIDTH = x // where x is a number
|
CATCH_CONFIG_CONSOLE_WIDTH = x // where x is a number or a function
|
||||||
|
|
||||||
Catch formats output intended for the console to fit within a fixed number of characters. This is especially important as indentation is used extensively and uncontrolled line wraps break this.
|
Catch formats output intended for the console to fit within a fixed number of characters. This is especially important as indentation is used extensively and uncontrolled line wraps break this.
|
||||||
By default a console width of 80 is assumed but this can be controlled by defining the above identifier to be a different value.
|
By default a console width of 80 is assumed but this can be controlled by defining the above identifier to be a different value.
|
||||||
|
|
||||||
|
If the above identifier is set to a function, the function will be called to get the width of the console. This may
|
||||||
|
be used to set the console width based on the current number of columns of the terminal. The function is required to return
|
||||||
|
an integral result. The function must be declared before including the Catch header in the source file hosting the Catch implementation.
|
||||||
|
It is not necessary to do this in any othe file. For example:
|
||||||
|
|
||||||
|
int Catch2GetConsoleWidth();
|
||||||
|
#define CATCH_CONFIG_CONSOLE_WIDTH Catch2GetConsoleWidth()
|
||||||
|
#define CATCH_CONFIG_MAIN
|
||||||
|
#include "catch.hpp"
|
||||||
|
|
||||||
|
And then we can define the function elsewhere, or in the same file:
|
||||||
|
|
||||||
|
int Catch2GetConsoleWidth()
|
||||||
|
{
|
||||||
|
return Terminal::GetWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
## stdout
|
## stdout
|
||||||
|
|
||||||
CATCH_CONFIG_NOSTDOUT
|
CATCH_CONFIG_NOSTDOUT
|
||||||
|
Loading…
Reference in New Issue
Block a user