Skip to content

Commit

Permalink
Updated CATCH_CONFIG_CONSOLE_WIDTH documentation to describe function…
Browse files Browse the repository at this point in the history
… usage
  • Loading branch information
nicramage committed Jul 26, 2021
1 parent 0529a96 commit 2ca051a
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,29 @@ Typically you should place the ```#define``` before #including "catch.hpp" in yo

## 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.
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

CATCH_CONFIG_NOSTDOUT
Expand Down Expand Up @@ -203,7 +221,7 @@ _Inspired by Doctest's `DOCTEST_CONFIG_DISABLE`_

On Windows Catch includes `windows.h`. To minimize global namespace clutter in the implementation file, it defines `NOMINMAX` and `WIN32_LEAN_AND_MEAN` before including it. You can control this behaviour via two macros:

CATCH_CONFIG_NO_NOMINMAX // Stops Catch from using NOMINMAX macro
CATCH_CONFIG_NO_NOMINMAX // Stops Catch from using NOMINMAX macro
CATCH_CONFIG_NO_WIN32_LEAN_AND_MEAN // Stops Catch from using WIN32_LEAN_AND_MEAN macro


Expand Down

0 comments on commit 2ca051a

Please sign in to comment.