File: entry_point_overview.qbk

package info (click to toggle)
boost1.74 1.74.0-9
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 464,084 kB
  • sloc: cpp: 3,338,324; xml: 131,293; python: 33,088; ansic: 14,336; asm: 4,034; sh: 3,351; makefile: 1,193; perl: 1,036; yacc: 478; php: 212; ruby: 102; lisp: 24; sql: 13; csh: 6
file content (39 lines) | stat: -rw-r--r-- 2,333 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
[/
 / Copyright (c) 2003 Boost.Test contributors
 /
 / Distributed under the Boost Software License, Version 1.0. (See accompanying
 / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 /]

[section:entry_point_overview Test module's entry point]

Typically, every C++ program contains exactly one definition of function `main`: the program's /entry point/.
When using the __UTF__ you do not have to define one. Function `main` will be generated for you by the framework.
The only thing you are required to do in case your program consists of more than one translation unit (`cpp` file)
is to indicate to the framework in which of the files it is supposed to generate function `main`.
You do it by defining macro __BOOST_TEST_MODULE__ before the inclusion of any of the framework files.
The value of this macro is used as a name of the [link ref_test_module test module] as well as the
[link boost_test.tests_organization.test_tree.master_test_suite master test suite].

The reason for defining function `main` for you is twofold:

# This allows the __UTF__ to perform some custom [link boost_test.adv_scenarios.test_module_init_overview ['test module initialization]].
# This prevents you defining `main`, and accidentally forgetting to run all the test (in which case running the program would incorrectly indicate a clean run).

By default, the test module's entry point is defined with signature:

```
int main(int argc, char* argv[]);
```

It calls [link boost_test.adv_scenarios.test_module_init_overview ['test module initialization]] function, then calls the
[link boost_test.adv_scenarios.test_module_runner_overview ['test module runner]] and forwards its return value to environment.

The default entry point is sufficient in most of the cases. Occasionally, a need may arise to declare an entry point with a
different name or signature. For overriding the definition of the default test module's entry point:

* [link boost_test.adv_scenarios.single_header_customizations.entry_point see here], for header-only usage variant,
* [link boost_test.adv_scenarios.static_lib_customizations.entry_point see here], for static library usage variant,
* [link boost_test.adv_scenarios.shared_lib_customizations.entry_point see here], for shared library usage variant.

[endsect] [/section:entry_point_overview]