1
0
Fork 0

boost unit tests included

This commit is contained in:
Frank Celler 2016-04-27 21:47:16 +02:00
parent 22ea1ee55e
commit 0d97c7d15c
897 changed files with 57 additions and 78462 deletions

View File

@ -1,10 +0,0 @@
# (C) Copyright Juergen Hunold 2006-2010.
# Use, modification, and distribution are subject to 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)
#
# See http://www.boost.org/libs/test for the library home page.
build-project example ;
build-project test ;

View File

@ -1,21 +0,0 @@
![boosttest logo](doc/html/images/boost.test.logo.png)
This is the main directory for the Boost Test Library.
(Not to be confused with a directory containing test programs for the parent directory.)
Full instructions for use of this library can be accessed from
http://www.boost.org/doc/libs/release/libs/test/
This library is part of boost (see www.boost.org), the latest version
of the library is available from the boost web site, or development
snapshots from the boost git repository at
https://github.com/boostorg/test
************************************************************************
Copyright 2001-2014, Gennadiy Rozental.
Copyright 2013-2015, Boost.Test team.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at www.boost.org/LICENSE_1_0.txt)

View File

@ -1,143 +0,0 @@
#
# 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)
#
using quickbook ;
using doxygen ;
using boostbook ;
########################################################################
# Standalone HTML documentation
import doxygen ;
doxygen doxygen_reference_generated_doc
:
$(BOOST_ROOT)/libs/test/include/boost/test/debug_config.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/debug.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/execution_monitor.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/framework.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/tools/assertion_result.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/unit_test.hpp
# formatters
$(BOOST_ROOT)/libs/test/include/boost/test/output/xml_log_formatter.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/output/xml_report_formatter.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/output/plain_report_formatter.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/output/compiler_log_formatter.hpp
# log formatter
$(BOOST_ROOT)/libs/test/include/boost/test/unit_test_log_formatter.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/results_reporter.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/results_collector.hpp
# progress monitor
$(BOOST_ROOT)/libs/test/include/boost/test/progress_monitor.hpp
# test cases and suites
$(BOOST_ROOT)/libs/test/include/boost/test/tree/test_unit.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/parameterized_test.hpp
# execution monitor source files
$(BOOST_ROOT)/libs/test/include/boost/test/execution_monitor.hpp
# output test stream
$(BOOST_ROOT)/libs/test/include/boost/test/tools/output_test_stream.hpp
# datasets
$(BOOST_ROOT)/libs/test/include/boost/test/data/monomorphic/fwd.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/data/test_case.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/data/for_each_sample.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/data/size.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/data/monomorphic/initializer_list.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/data/monomorphic/array.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/data/monomorphic/collection.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/data/monomorphic/generate.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/data/monomorphic/grid.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/data/monomorphic/join.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/data/monomorphic/singleton.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/data/monomorphic/zip.hpp
# datasets generators
$(BOOST_ROOT)/libs/test/include/boost/test/data/config.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/data/monomorphic/generators.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/data/monomorphic/generators/keywords.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/data/monomorphic/generators/random.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/data/monomorphic/generators/xrange.hpp
# utils
$(BOOST_ROOT)/libs/test/include/boost/test/utils/algorithm.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/utils/named_params.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/tools/floating_point_comparison.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/utils/is_forward_iterable.hpp
# BOOST_TEST related functions
$(BOOST_ROOT)/libs/test/include/boost/test/tools/detail/bitwise_manip.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/tools/detail/lexicographic_manip.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/tools/detail/per_element_manip.hpp
$(BOOST_ROOT)/libs/test/include/boost/test/tools/detail/tolerance_manip.hpp
# others
$(BOOST_ROOT)/libs/test/include/boost/test/unit_test_parameters.hpp
:
<doxygen:param>EXTRACT_ALL=YES
<doxygen:param>"PREDEFINED=\"BOOST_TEST_DECL=\" \\
\"BOOST_TEST_DOXYGEN_DOC__=1\"
"
<doxygen:param>HIDE_UNDOC_MEMBERS=NO
<doxygen:param>HIDE_UNDOC_CLASSES=NO
<doxygen:param>INLINE_INHERITED_MEMB=YES
<doxygen:param>EXTRACT_PRIVATE=NO
<doxygen:param>ENABLE_PREPROCESSING=YES
<doxygen:param>MACRO_EXPANSION=YES
<doxygen:param>EXPAND_ONLY_PREDEF=YES
<doxygen:param>SEARCH_INCLUDES=YES
<doxygen:param>INCLUDE_PATH=$(BOOST_ROOT)/libs/test/include
<doxygen:param>EXAMPLE_PATH=$(BOOST_ROOT)/libs/test/doc/examples
<doxygen:param>BRIEF_MEMBER_DESC=YES
<doxygen:param>REPEAT_BRIEF=YES
<doxygen:param>ALWAYS_DETAILED_SEC=YES
<doxygen:param>MULTILINE_CPP_IS_BRIEF=YES
<doxygen:param>CASE_SENSE_NAMES=YES
<doxygen:param>INTERNAL_DOCS=NO
<doxygen:param>SUBGROUPING=YES
<doxygen:param>SHORT_NAMES=YES
;
########################################################################
# HTML documentation for $(BOOST_ROOT)/doc/html
xml test_doc
:
test.qbk
;
explicit test_doc ;
path-constant images_location : html ;
boostbook standalone
:
test_doc
:
<xsl:param>boost.root=../../../..
<xsl:param>html.stylesheet=boostbook.css
<xsl:param>chapter.autolabel=0
<xsl:param>toc.max.depth=3
<xsl:param>toc.section.depth=10
<xsl:param>chunk.section.depth=4
<xsl:param>chunk.first.sections=1
<xsl:param>generate.section.toc.level=3
<format>pdf:<xsl:param>img.src.path=$(images_location)/
<format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/libs/test/doc/html
<dependency>doxygen_reference_generated_doc
;
explicit test ;

View File

@ -1,68 +0,0 @@
This folder contains the documentation for the Boost.Test library.
Any contribution or submission to the library should be accompanied by the corresponding documentation.
The format of the documentation uses [http://www.boost.org/tools/quickbook/index.html Quickbook].
How to build the documentation
==============================
In order to generate the documentation, the following is needed:
* Docbook
* Doxygen
* xsltproc
Doxygen
-------
Part of the documentation needs [Doxygen](http://www.doxygen.org). `doxygen` should be accessible from the ``PATH``.
Docbook
-------
Quickbook needs Docbook (XSL and XML) to be installed. Download and untar the docbook archives:
* Docbook XSL that can be found here: http://sourceforge.net/projects/docbook/files/docbook-xsl/
* Docbook DTD that can be found here: http://www.docbook.org/schemas/
The directories `$docbook_xsl_directory` and `$docbook_dtd_directory`, respectively, will refer to the location
of the deflated archive.
Download xsltproc
-----------------
This program is needed by Docbook, in order to be able to transform XMLs into HTMLs.
`xsltproc` should be accessible from the ``PATH``.
Construct bjam
--------------
Simply by typing in a console at the root of the Boost repository:
```
> ./bootstrap.[sh|bat]
```
Build the documentation
-----------------------
Running the following commands will construct the documentation with `bjam` and
all the needed dependencies:
````
> cd $boost_root/libs/test/doc
> ../../../b2 -sDOCBOOK_XSL_DIR=$docbook_xsl_directory -sDOCBOOK_DTD_DIR=$docbook_dtd_directory
```
It is possible to run directly
```
> ../../../b2
```
but this results in a download from the Internet of the Docbook XLS and DTD, which is much slower.
Recommendations
===============
- Documentation is part of the "definition of done". A feature does not exist until it is implemented, tested, documented and reviewed.
- It is highly recommended that each of your pull request comes with an updated documentation. Not doing so put this work on the shoulders
of the maintainers and as a result, it would be likely that the pull request is not addressed in a timely manner.
- Please also update the changelog for referencing your contribution
- Every file should come with a copyright notice on the very beginning

View File

@ -1,52 +0,0 @@
[/
/ 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:adv_scenarios Advanced Usage Scenarios]
If you are reading this chapter, this means that the wide range of tools and interfaces covered
in the previous sections are not sufficient for the testing scenario
you have in mind. You are here to bend the __UTF__ to your will and ... we are not going to
stop you. Instead we'll try to guide you so that some dark corners do not look scary.
In most cases the __UTF__ is going to be supplied for you either as part of your system libraries
or set of libraries used by your companies. Yet if you are facing the necessity to build your
own static or dynamic library of the __UTF__ or need to customize the build for any reason, section
[link boost_test.adv_scenarios.build_utf Building the __UTF__] covers all the necessary steps.
To streamline the experience of setting up your test module, the __UTF__ provides some default
initialization logic for them. Usually the default test module initialization will work just fine,
but if you want to implement some custom initialization or change how default initialization
behaves you need to first look in [*Test module initialization] section. Here you'll learn
about various options the __UTF__ provides for you to customize this behavior.
The part of the framework which loads, initializes and executed your test module is called the
[*Test Runner]. Each usage variant comes with default test runner. If, instead, you prefer to
implement your own entry point into the test module (for example if you need to implement the
`main` function yourself and not use the one provided by the __UTF__, you need to learn about
__UTF__ interfaces involved in test runners operations. These are covered in the [*Test runners]
section. Let me reiterate that you only need to this section if regular regular options for
customization of initialization logic like
[link boost_test.tests_organization.fixtures fixtures] or [link boost_test.tests_organization.decorators decorators]
are not sufficient for your purposes.
[/ build and link with boost.test]
[include adv_scenarios/building_utf.qbk]
[include adv_scenarios/entry_point_overview.qbk]
[include adv_scenarios/test_module_init_overview.qbk]
[include adv_scenarios/test_module_runner_overview.qbk]
[include adv_scenarios/single_header_customizations.qbk]
[include adv_scenarios/static_lib_customizations.qbk]
[include adv_scenarios/shared_lib_customizations.qbk]
[include adv_scenarios/external_test_runner.qbk]
[include adv_scenarios/obsolete_init_func.qbk]
[/=============================================================================]
[endsect] [/Advanced usage scenarios]
[/ EOF]

View File

@ -1,65 +0,0 @@
[/
/ 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:build_utf Building the __UTF__]
In case you would like to use the [link boost_test.usage_variants.shared_lib shared library variant] or the [link boost_test.usage_variants.static_lib static library variant] of the __UTF__, the library needs to be built.
Building the __UTF__ is in fact quite easy.
In the sequel, we define
* $`boost_path` refers to the location where the boost archive was deflated
* $`boost_installation_prefix` refers to the location where you want to install the __UTF__
[/ not true
[note By default, the static and dynamic variant will be built for your operating system]
]
More documentation about *Boost's build system* can be found [@http://www.boost.org/more/getting_started/index.html here].
[h3 Windows]
You need to have a compilation toolchain. /Visual Studio Express/ is such one, freely available from the
Microsoft website. Once installed, open a /Visual Studio Command Line tools/ prompt and build the Boost build program `b2`
(see the link above). You will then be able to compile the __UTF__ with different variants.
[h4 Static variant]
For building 32bits libraries, open a console window and enter the following commands:
```
> cd ``$``boost_path
> bootstrap.bat
> b2 address-model=32 architecture=x86 --with-test link=static \
> --prefix=``$``boost_installation_prefix install
```
For building 64bits libraries, the commands become:
```
> cd ``$``boost_path
> bootstrap.bat
> b2 address-model=64 architecture=x86 --with-test link=static \
> --prefix=``$``boost_installation_prefix install
```
[h4 Shared library variant]
In order to build the shared library variant, the directive `link=static` should be replaced by `link=shared` on the above command lines.
For instance, for 64bits builds, the commands become:
```
> cd ``$``boost_path
> bootstrap.bat
> b2 address-model=64 architecture=x86 --with-test link=shared --prefix=``$``boost_installation_prefix install
```
[h3 Linux/OSX]
For Unix/Linux/OSX operating system, the build of the __UTF__ is very similar to the one on Windows:
```
> cd ``$``boost_path
> ./bootstrap.sh
> ./b2 --with-test --prefix=``$``boost_installation_prefix install
```
[endsect] [/build_utf]

View File

@ -1,39 +0,0 @@
[/
/ 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_suite.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 single header 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]

View File

@ -1,23 +0,0 @@
[/
/ 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:external_test_runner The external test runner usage variant]
This usage variant does not provide any [link boost_test.adv_scenarios.test_module_runner_overview test runner].
You employ it when you only want to define a [link ref_test_tree test tree] and possibly an
[link boost_test.adv_scenarios.test_module_init_overview initialization function],
and expect another (external) program to evaluate these tests. This external program will come with its own test runner.
If you plan to use an external test runner with your test module, you need to build it as a dynamic library.
You need to define macro flag __BOOST_TEST_DYN_LINK__ either in a makefile or before the header
`boost/test/unit_test.hpp` inclusion. An external test runner utility is required to link with dynamic library.
The __UTF__ comes with an example external test runner `console_test_runner`:
Given a name of the test module (implemented as a shared library), and a name of the initialization function defined therein,
the program can run all the tests from the module's test tree.
[endsect] [/section:external_test_runner]

View File

@ -1,93 +0,0 @@
[/
/ 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:link_references Build scenarios and behaviors]
[section:link_boost_test_main_macro `BOOST_TEST_MAIN`]
When defined, this macro creates a stub for the test module initialization (the main entry part). This
macro also expands properly into a `main` function in case the shared library variant of the __UTF__ is used.
[caution This macro should
# be defined before any inclusion directive to __UTF__ headers
# be defined exactly for one compilation unit of your test module
]
[tip The macro __BOOST_TEST_MODULE__ should be preferred]
[endsect]
[section:link_boost_test_module_macro `BOOST_TEST_MODULE`]
Serves the same purpose as the macro __BOOST_TEST_MAIN__ but, in addition, defines the name of the master test suite.
[caution As __BOOST_TEST_MAIN__, this macro should
# be defined before any inclusion directive to __UTF__ headers
# be defined exactly for one compilation unit of your test module
]
An example may be found [link ref_BOOST_TEST_MODULE here].
[endsect]
[section:link_boost_test_alternative_init_macro `BOOST_TEST_ALTERNATIVE_INIT_API`]
[endsect]
[section:link_boost_test_no_lib `BOOST_TEST_NO_LIB`]
Define this flag to prevent auto-linking.
[note The same flag is used for the __UTF__ and the __PEM__ components.]
[endsect]
[section:link_boost_test_dyn_link `BOOST_TEST_DYN_LINK`]
Define this flag to link against the __UTF__ shared library.
[note The same flag is used for the __UTF__ and the __PEM__ components.]
[endsect]
[section:link_boost_test_no_main `BOOST_TEST_NO_MAIN`]
Prevents the auto generation of the test module initialization functions. This macro is particularly relevant for
manually registered tests in conjunction with dynamic variant of the __UTF__. When defined, a `main` function
registering all the tests should be implemented.
An example of a module initialization would be
``
#define __BOOST_TEST_NO_MAIN__
#include <boost/test/unit_test.hpp>
// a function in another compilation unit registering tests under the master test suite.
void register_some_tests_manually(test_suite* test);
bool registering_all_tests()
{
test_suite* test_master_suite = &boost::unit_test::framework::master_test_suite();
register_some_tests_manually(test_master_suite);
// register any other tests function or test suite to the master test suite
// ...
return true;
}
int main(int argc, char* argv[])
{
return ::boost::unit_test::unit_test_main(&registering_all_tests, argc, argv);
}
``
[endsect]
[endsect]

View File

@ -1,46 +0,0 @@
[/
/ 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:obsolete_init_func The obsolete initialization function]
For backwards compatibility, the __UTF__ also allows the customization of an initialization function of a different type.
This is called the ['obsolete initialization function]. Its signature is:
```
boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]);
```
The original design of the __UTF__ required of the programmer to implement it. It was intended to initialize and return
the __master_test_suite__. No [link ref_BOOST_AUTO_TEST_CASE automatic test case registration] was available at that
time. The null-pointer value was considered an initialization error.
In the single-header usage variant, you fall back to the obsolete initialization function signature by omitting the
definition of macro __BOOST_TEST_ALTERNATIVE_INIT_API__ in test module code.
[bt_example custom_obsolete_init..using obsolete initialization function..run-fail]
In the static-library usage variant, you need to omit the definition of macro __BOOST_TEST_ALTERNATIVE_INIT_API__ in test
module and compile the __UTF__ static library without the compilation flag __BOOST_TEST_ALTERNATIVE_INIT_API__ (this is
the default).
In the shared-library usage variant, it is not possible to use the obsolete initialization function.
Even if you decide to us the obsolete initialization function, it is recommended that:
# You always return a null-pointer value and install the master test suite via
[memberref boost::unit_test::test_suite::add `test_suite::add`] as illustrated
[link ref_BOOST_TEST_CASE here]. The current framework does no longer treat the
null-pointer value as failure.
# You signal the failure by throwing [classref boost::unit_test::framework::setup_error] exception.
# You access the command-line arguments through the interface of the __master_test_suite__,
and ignore the function's arguments `argc` and `argv`.
[caution The obsolete initialization function is deprecated. It is recommended, to move from the old initialization
function API, and rely on the automated test unit registration and [link boost_test.tests_organization.fixtures
fixtures] (including [link boost_test.tests_organization.fixtures.global global fixtures]) for other set-up. ]
[endsect] [/section:obsolete_init_func]

View File

@ -1,88 +0,0 @@
[/
/ 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:shared_lib_customizations Shared-library variant customizations]
[caution Macro __BOOST_TEST_DYN_LINK__ (which instructs the compiler/linker to dynamically link against a shared library variant) may be implicitly defined when macro `BOOST_ALL_DYN_LINK` is defined.]
[caution In order to be able to run a test built with the dynamic variant, the operating system should be able
to find the dynamic library of the __UTF__. This means, for example on Linux and MacOSX respectively, setting the environment
variable `LD_LIBRARY_PATH` or `DYLD_LIBRARY_PATH` properly prior to the execution of the test module.]
[section:entry_point Customizing the module's entry point]
In this variant, in one of the source files, you now have to define your custom entry point, and invoke the default [link boost_test.adv_scenarios.test_module_runner_overview test runner] `unit_test_main` manually with the default [link boost_test.adv_scenarios.test_module_init_overview initialization function] `init_unit_test` as argument. You need to define __BOOST_TEST_NO_MAIN__ (its value is irrelevant) in the main file:
[table
[[In *exactly one* file][In all other files]]
[[```#define BOOST_TEST_MODULE test module name
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_NO_MAIN
#include <boost/test/unit_test.hpp>
// entry point:
int main(int argc, char* argv[], char* envp[])
{
return boost::unit_test::unit_test_main( &init_unit_test, argc, argv );
}
```]
[```#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
//
// test cases
//
//
// test cases
//
```]]
]
[endsect] [/section:entry_point]
[section:init_func Customizing the module's initialization function]
In the shared-library variant, it is impossible to customize the initialization function without [link boost_test.adv_scenarios.shared_lib_customizations.entry_point customizing the entry point]. We have to customize both. In one of the source files, you now have to define your custom entry point and [link boost_test.adv_scenarios.test_module_init_overview initialization function] `init_unit_test`; next invoke the default [link boost_test.adv_scenarios.test_module_runner_overview test runner] `unit_test_main` manually with `init_unit_test` as argument. You ['do not] define __BOOST_TEST_MODULE__ in the main file:
[table
[[In *exactly one* file][In all other files]]
[[```#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
// initialization function:
bool init_unit_test()
{
return true;
}
// entry point:
int main(int argc, char* argv[])
{
return boost::unit_test::unit_test_main( &init_unit_test, argc, argv );
}
```]
[```#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
//
// test cases
//
//
// test cases
//
//
// test cases
//
```]]
]
[endsect] [/section:init_func]
[endsect] [/section:shared_lib_customizations]

View File

@ -1,54 +0,0 @@
[/
/ 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:single_header_customizations Single-header variant customizations]
[section:entry_point Customizing the module's entry point]
In this usage variant, in your single translation unit, you need to define macros __BOOST_TEST_NO_MAIN__ and
__BOOST_TEST_ALTERNATIVE_INIT_API__ (their values are irrelevant) prior to including any of the framework's headers.
Next, you have to define your custom entry point, and invoke the default [link
boost_test.adv_scenarios.test_module_runner_overview test runner] `unit_test_main` manually with the default [link
boost_test.adv_scenarios.test_module_init_overview initialization function] `init_unit_test` as argument.
[bt_example custom_main..using custom entry point..run-fail]
In the above example, a custom entry point was selected because the test module, in addition to command line arguments
needs to obtain also the information about environment variables.
[note The above example also illustrates that it makes sense to define both __BOOST_TEST_MODULE__ and
__BOOST_TEST_NO_MAIN__. This way, no `main` is generated by the framework, but the specified name is assigned to the
[link boost_test.tests_organization.test_suite.master_test_suite Master Test Suite].]
[note The reason for defining __BOOST_TEST_ALTERNATIVE_INIT_API__ is described [link
boost_test.adv_scenarios.obsolete_init_func here].]
[endsect] [/section:entry_point]
[section:init_func Customizing the module's initialization function]
In this usage variant, you do not define macro __BOOST_TEST_MODULE__ and instead provide the definition of function
`init_unit_test`. This is going to be the custom initialization function. The default [link
boost_test.adv_scenarios.test_module_runner_overview test runner] will use it to initialize the test module.
[bt_example custom_init..using custom initialization function..run-fail]
[note Because we overwrote the default initialization function, it does no longer assign any name to the [link
boost_test.tests_organization.test_suite.master_test_suite master test suite]. Therefore the default name ("Master Test
Suite") is used.]
[note The reason for defining __BOOST_TEST_ALTERNATIVE_INIT_API__ is described [link
boost_test.adv_scenarios.obsolete_init_func here].]
[endsect] [/section:init_func]
[endsect] [/section:single_header_customizations]

View File

@ -1,96 +0,0 @@
[/
/ 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:static_lib_customizations Static-library variant customizations]
[section:entry_point Customizing the module's entry point]
In the static library variant, customizing the main entry point is quite troublesome, because the definition of function `main` is already compiled into the static library. This requires you to rebuild the __UTF__ static library with the defined symbol __BOOST_TEST_NO_MAIN__. In the Boost root directory you need to invoke command
```
> b2 --with-test link=static define=__BOOST_TEST_NO_MAIN__ define=__BOOST_TEST_ALTERNATIVE_INIT_API__ install
```
[warning This removal of entry point definition from the static library will affect everybody else who is linking against the library. It may be less intrusive to switch to the [link boost_test.adv_scenarios.shared_lib_customizations shared library usage variant] instead.]
In one of the source files, you now have to define your custom entry point, and invoke the default [link boost_test.adv_scenarios.test_module_runner_overview test runner] `unit_test_main` manually with the default [link boost_test.adv_scenarios.test_module_init_overview initialization function] `init_unit_test` as the first argument. There is no need to define __BOOST_TEST_NO_MAIN__ in your source code, but you need to define __BOOST_TEST_ALTERNATIVE_INIT_API__ in the main file:
[table
[[In *exactly one* file][In all other files]]
[[```#define BOOST_TEST_MODULE test module name
#define BOOST_TEST_ALTERNATIVE_INIT_API
#include <boost/test/unit_test.hpp>
// entry point:
int main(int argc, char* argv[], char* envp[])
{
return utf::unit_test_main(init_unit_test, argc, argv);
}
```]
[```#include <boost/test/unit_test.hpp>
//
// test cases
//
//
// test cases
//
```]]
]
[note The reason for defining __BOOST_TEST_ALTERNATIVE_INIT_API__ is described [link boost_test.adv_scenarios.obsolete_init_func here].]
[endsect] [/section:entry_point]
[section:init_func Customizing the module's initialization function]
In the static library variant, customizing the main entry point is quite troublesome, because the default test runner compiled into the static library uses the obsolete initialization function signature. This requires you to rebuild the __UTF__ static library with the defined symbol __BOOST_TEST_ALTERNATIVE_INIT_API__. In the Boost root directory you need to invoke command
```
> b2 --with-test link=static define=__BOOST_TEST_ALTERNATIVE_INIT_API__ install
```
[warning This alteration of the static library will affect everybody else who is linking against the library. Consider using the [link boost_test.adv_scenarios.obsolete_init_func obsolete test initialization function], which requires no rebuilding. Alternatively, it may be less intrusive to switch to the [link boost_test.adv_scenarios.shared_lib_customizations shared library usage variant] instead.]
In one of the source files, you now have to define your custom initialization function with signature:
```
bool init_unit_test();
```
The default [link boost_test.adv_scenarios.test_module_runner_overview test runner] will use it to initialize the test module. In your source code, you no longer define macro __BOOST_TEST_MODULE__; instead, you need to define __BOOST_TEST_ALTERNATIVE_INIT_API__ in the main file:
[table
[[In *exactly one* file][In all other files]]
[[```#define BOOST_TEST_ALTERNATIVE_INIT_API
#include <boost/test/unit_test.hpp>
// init func:
bool init_unit_test()
{
return true;
}
```]
[```#include <boost/test/unit_test.hpp>
//
// test cases
//
// test cases
//
```]]
]
[note The reason for defining __BOOST_TEST_ALTERNATIVE_INIT_API__ is described [link boost_test.adv_scenarios.obsolete_init_func here].]
[endsect] [/section:init_func]
[endsect] [/section:static_lib_customizations]

View File

@ -1,39 +0,0 @@
[/
/ 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:test_module_init_overview Test module's initialization]
In order for a unit test module to successfully link and execute, it has to have access to the ['test module's initialization function]. the module's initialization function is called only once during the execution of the program, just before the [link boost_test.adv_scenarios.test_module_runner_overview ['test module runner]] is run. By default, the __UTF__ provides a default definition of initialization function. The only thing you have to do is to instruct the framework in which translation unit (`cpp` file) it needs to provide the definition. You do it by defining macro __BOOST_TEST_MODULE__ in the designated file. The default implementation assigns the name to the [link ref_test_module test module] as well as the [link boost_test.tests_organization.test_suite.master_test_suite master test suite]. The name to be assigned is specified by the value of the macro __BOOST_TEST_MODULE__.
[important
For a test module consisting of multiple source files you have to define __BOOST_TEST_MODULE__ in a single test file only.
Otherwise you end up with multiple instances of the initialization function.
]
There is practically no need to ever alter the default behavior of the test module's initialization function. The __UTF__ provides superior tools for performing customization tasks:
* for automatic registration of test cases and test suites in the test tree, see section [link boost_test.tests_organization Tests organization];
* in order to assign the custom name to the master test suite define macro __BOOST_TEST_MODULE__ to desired value;
* in order to access the command-line parameters (except the ones consumed by the __UTF__), use the interface of the [link boost_test.tests_organization.test_suite.master_test_suite master test suite];
* in order to perform a global initialization of the state required by the test cases, [link boost_test.tests_organization.fixtures.global global fixtures] offer a superior alternative: you can specify global set-up and tear-down in one place, allow access to the global data from every test case, and guarantee that clean-up and tear-down is repeated each time the tests are re-run during the execution of the program;
* if the need for custom module initialization is only driven by legacy code (written against old versions of the __UTF__), it is recommended to update your program's code.
The default initialization function provided by the framework is defined with the following signature in the global namespace:
```
bool init_unit_test();
```
Return value `true` indicates a successful initialization. Value `false` indicates initialization failure.
For overriding the default definition:
* [link boost_test.adv_scenarios.single_header_customizations.init_func see here], for single header usage variant,
* [link boost_test.adv_scenarios.static_lib_customizations.init_func see here], for static library usage variant,
* [link boost_test.adv_scenarios.shared_lib_customizations.init_func see here], for shared library usage variant.
[endsect] [/section:test_module_init_overview]

View File

@ -1,47 +0,0 @@
[/
/ 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:test_module_runner_overview Test module runner]
A ['test module runner] is an ['orchestrator] or a ['driver] that, given the test tree, ensures the test tree is initialized, tests are executed and necessary reports generated. It performs the following operations:
* initialize the test module using the supplied [link boost_test.adv_scenarios.test_module_init_overview ['initialization function]];
* select output media for the test log and the test results report;
* execute test cases as specified by run-time parameters;
* produce the test results report;
* generate the appropriate return code.
The __UTF__ comes with the default test runner. There is no need to call it explicitly. The default generated test module's [link boost_test.adv_scenarios.entry_point_overview entry point] invokes the default test runner. The default test runner is declared with the following signature:
```
namespace boost { namespace unit_test {
typedef bool (*init_unit_test_func)();
int unit_test_main( init_unit_test_func init_func, int argc, char* argv[] );
} }
```
The test runner may return one of the following values:
[table
[[Value][Meaning]]
[[`boost::exit_success`][
* No errors occurred during testing, or
* the success result was forced with command-line argument `--[link boost_test.utf_reference.rt_param_reference.result_code `result_code`]=no`.]]
[[`boost::exit_test_failure`][
* Non-fatal errors detected and no uncaught exceptions were thrown during testing, or
* the initialization of the __UTF__ failed. ]]
[[`boost::exit_exception_failure`][
* Fatal errors were detected, or
* uncaught exceptions thrown during testing. ]]
]
An advanced test runner may provide additional features, including interactive GUI interfaces, test coverage and profiling support.
[endsect] [/section:test_module_runner_overview]

View File

@ -1,28 +0,0 @@
[/
/ 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 Acknowledgements]
[h4 Boost Test Team]
Boost.Test 3.0 is being developed and maintained by Gennadiy Rozental and Raffi Enficiaud.
[h4 New documentation]
Raffi Enficiaud and Andrzej Krzemienski efforts were a driving force behind the Boost.Test documentation overhaul.
[h4 Second incarnation including the Unit Test Framework]
Beman Dawes and Ullrich Koethe started the library. Fernando Cacciola, Jeremy Siek, Beman Dawes, Ullrich Koethe,
Dave Abrahams suggested numerous improvements during the Formal Review. Jeremy Siek was the review manager. Beman
Dawes was a great help in both final testing and merging library with rest of the boost. Gennadiy Rozental was the
developer and maintainer.
[h4 Original Test Library]
Ed Brey, Kevlin Henney, Ullrich Koethe, and Thomas Matelich provided very helpful comments during development.
Dave Abrahams, Ed Brey, William Kempf, Jens Maurer, and Wilka suggested numerous improvements during the Formal
Review. Jens Maurer was the review manager. Beman Dawes is the developer and maintainer.
[endsect]

View File

@ -1,177 +0,0 @@
[/
/ Copyright (c) 2013 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 Change log]
[h4 Boost.Test v3.2 / boost XXXX]
*
[h5 New features]
* now datasets support any [link boost_test.tests_organization.test_cases.test_case_generation.datasets arity], using the
variadic template support of the compiler.
* now datasets support fixtures through `BOOST_DATA_TEST_CASE_F`, see
[link boost_test.tests_organization.test_cases.test_case_generation.datasets here] for more details
[h5 Bugfixes and feature requests]
# [ticket 6767] Use of namespace qualifier with floating point exception functions breaks if they are macros
# [ticket 8905] boost/test/impl/debug.ipp: Ignores return value from WaitForSingleObject
# [ticket 9943] Runtime parameter Random seed for random order of test cases not respected correctly
# [ticket 11854] Add fixture support in `BOOST_DATA_TEST_CASE`
# [ticket 11887] `BOOST_TEST(3u == (std::max)(0u, 3u))` fails
# [ticket 11889] BOOST_DATA_TEST_CASE fails to compile for 4D and higher dimensional grids
# [ticket 11983] Boost Test XML Report contains unescaped XML characters
[h4 Boost.Test v3.1 / boost 1.60]
[h5 New major features]
* improved API for datasets
* it is now possible to use initializer lists
* the use of `make` as top left dataset is not necessary anymore
* improved command line interface
* clearer help commands
* now proposes closest matching command in case of ambiguity
* reports invalid or ambiguous parameters: this might break existing calls when user defined commands are
provided to the test module. The following calling convention should be adopted:
* if the test module uses user supplied commands, those should be passed after an empty token `--`
* all boost.test related commands should be passed before `--`, if any
Example:
the call
``
test_module --user-arg1=xy --log_level=test_suite
``
should be rewritten to
``
test_module --log_level=test_suite -- --user-arg1=xy
``
[h5 Bugfixes and feature requests]
# [ticket 3384] Double-quoted arguments including spaces are divided by Boost.Test.
# [ticket 3897] Test framework does not include `<osreldate.h>` before testing `__FreeBSD_version` (fixed in 1.59)
# [ticket 6032] Program options within `init_unit_test_suite` are incorrect when using path and whitespaces
# [ticket 6859] Boost.Test eats away last empty command line parameter
# [ticket 7257] Boost.Test alters and does not restore `ostream` precision after any Test macro (fixed in 1.59)
# [ticket 9228] Patch to make Boost.Test work with RTTI disabled (fixed in 1.59)
# [ticket 10317] boost::test corrupts contents of `argv` if a paramter contains whitespace
# [ticket 11279] invalid parameters should be reported
# [ticket 11478] Boost Test Exception Assert Failure has poor message
# [ticket 11571] Can't compile `BOOST_TEST( ..., per_element() )` comparison of `vector<string>`
# [ticket 11623] Clang rejects some simple `BOOST_TEST()` statements
# [ticket 11624] `BOOST_TEST( 0.0 == 0.0 )` fails under C++11 (GCC and Clang)
# [ticket 11625] `BOOST_TEST( ..., per_element() )` erroneously requires collections are comparable
[h4 Boost.Test v3 / boost 1.59]
[h5 New major features]
* __BOOST_TEST__ generic assertion
* [link boost_test.tests_organization.test_cases.test_case_generation data driven test cases]: supersedes the parametric test case (unary test cases)
* test units [link boost_test.tests_organization.decorators attributes], that allow finer control over test units property and behavior
* logical grouping of the test units using [link boost_test.tests_organization.tests_grouping labels]
* support for declaring [link boost_test.tests_organization.tests_dependencies dependencies] over test cases
* attributes for [link boost_test.tests_organization.enabling enabling or disabling] test execution based on static, compile-time or runtime rules
* extended [link boost_test.runtime_config.test_unit_filtering unit test filtering] from the command line (negation, labels, ...)
* color output with [link boost_test.utf_reference.rt_param_reference.color_output `color_output`]
* test bed listing with [link boost_test.utf_reference.rt_param_reference.list_content `list_content`]
* rewritten documentation using quickbook
[/* now having a more accurate timing (see [ticket 7397]) for the tests. Old format is still available through the command line option __param_deprecated_timer_format__
in case you experience problems with the new output. ]
[h5 Bugfixes and feature requests]
[/ pending
# [ticket 1136] Let BOOST_CHECK_EQUAL support `std::wstring`
# [ticket 4222] `feenablexcept` does not exist on mac
# [ticket 7397] Boost.Test, since boost 1.48 is using the deprecated Boost.Timer class - it should be updated to use the new class
]
# [ticket 2018] Error in the documentation chapter "Runtime parameters reference"
# [ticket 2450] equations in Floating-point comparison algorithms html are not rendered properly
# [ticket 2600] Unit Test Framework - missed documentation
# [ticket 2717] `BOOST_<level>_EQUAL_COLLECTION` docs typo
# [ticket 2759] Typos in test new-year-resolution.html
# [ticket 3182] `_CrtSetReportFile` can be used to redirect memory leaks report
# [ticket 3316] Access violation when trying to log from `init_tests_func`
# [ticket 3392] Boost::Test: Wrong contents for documentation of the `BOOST_TEST_PASSPOINT` macro
# [ticket 3402] Invalid define name in docummentation (duplicates #[ticket 2717])
# [ticket 3445] incorreect link in the docs
# [ticket 3463] `GT` is GREAT!
# [ticket 3542] Bug in documentation of detect_memory_leak parameter (duplicates #[ticket 2018])
# [ticket 3481] Boost Testing doesn't work under Sun Solaris Containers (duplicates #[ticket 3592])
# [ticket 3495] Boost::Test enters endless loop when running in `vserver` environment (duplicates #[ticket 3592])
# [ticket 3592] under_debugger() goes into infinite loop
# [ticket 3595] Typo (duplicates #[ticket 2759])
# [ticket 3623] Boost Test Typo (duplicates #[ticket 2759])
# [ticket 3664] `SIGCHLD` always considered fatal error
# [ticket 3784] Documentation errors in Execution Monitor Compilation
# [ticket 3785] Documentation errors in Program Execution Monitor implementation
# [ticket 3811] global namespace polution
# [ticket 3834] doc: probably incorrect HTML rendering (duplicates #[ticket 2450])
# [ticket 3896] erroneous documentation in boost test commandline parameter description
# [ticket 3932] Error in `BOOST_<level>_GT` description (duplicates #[ticket 3463])
# [ticket 3938] doc: incorrect macro name (duplicates #[ticket 2759])
# [ticket 3964] Documentation for `BOOST_<level>_CLOSE_FRACTION` is incorrect
# [ticket 3978] Failed to completely redirect TestLog to file, bugfix appended
# [ticket 3979] `<boost/test/exception_safety.hpp>` requires additional includes
# [ticket 4161] spelling mistakes...
# [ticket 4275] Documentation error Boost.Test (duplicates #[ticket 2717])
# [ticket 4389] Enable boost_test to run specific tests with any required dependent tests.
# [ticket 4434] `BOOST_AUTO_EST_CASE` typos in docs
# [ticket 4587] Broken link in website
# [ticket 4806] Invalid link (examples not showing up in documentation)
# [ticket 4911] ENH: boost.test output the exception real type name.
# [ticket 4923] Missing semicolon in documentation example
# [ticket 4924] Minor typo in Boost::Test docs
# [ticket 4982] Boost.Test has misspelled Gennadiy Rozental e-mail address
# [ticket 5008] Boost.Test does not do checkpointing of entry/exit of test cases
# [ticket 5036] Boost.Test VC memory leak report should direct to `stderr`
# [ticket 5262] Run tests by name utility doesn't support negation
# [ticket 5374] Errors from Boost.Test are no more shown in the Error list in VS2010
# [ticket 5412] XML formatter in test library processes strings with subsequences `]]>` incorrectly
# [ticket 5563] using a test macro in a global fixture crashes Boost.Test
# [ticket 5582] There is a memory leak in the `BOOST_AUTO_TEST_CASE_TEMPLATE`
# [ticket 5599] boost::test documentation gives poor instruction
# [ticket 5718] broken link to unit testing framework examples
# [ticket 5729] Missing static_cast in fpt_limits
# [ticket 5870] The warning stack is not maintained
# [ticket 5972] Support program option to only dump the test-tree in text to output stream
# [ticket 6002] Failed to completely redirect TestLog to file (duplicates)
# [ticket 6071] Boost Test (Boost 1.46.0) GCC 4.6.1 error: ambiguous overload for operator[]
# [ticket 6074] warnings-as-errors not usable with Boost.test in release mode
# [ticket 6161] SunOS: bad putenv declaration (duplicates #[ticket 6766])
# [ticket 6766] incorrect declaration for putenv in `config.hpp`
# [ticket 6712] Eliminate warnings with GCC
# [ticket 6748] Link in the documentation points to wrong page
# [ticket 7046] Output full error message, not just 512 chars
# [ticket 7136] Correct documentation for `BOOST_<level>_CLOSE_FRACTION` is not reflected into released documents
# [ticket 7410] Test Units (Cases and Suites) in Boost.Test do not capture `__FILE__` and `__LINE__` at declaration point making it impossible to provide source file linking using external test management tools
# [ticket 7894] Boost.Test documentation contains no linking instructions
# [ticket 8201] Broken link in document
# [ticket 8272] `BOOST_REQUIRE_CLOSE` fails to compile with `boost::multiprecision::cpp_dec_float_100` (duplicates #[ticket 11054])
# [ticket 8467] Incorrect link in document (duplicates #[ticket 6748])
# [ticket 8679] Boost.Test pollutes boost namespace with it's own `enable_if/disable_if` templates
# [ticket 8862] Boost.Test typo in documentation
# [ticket 8895] English error in test collection comparison
# [ticket 9179] Documentation: broken link (unable to find =const_string.hpp/const_string_test.cpp=)
# [ticket 9272] boost::test `BOOST_<level>_GT` documentation bug (duplicates #[ticket 3463])
# [ticket 9390] Incomplete `BOOST_TEST_DONT_PRINT_LOG_VALUE`
# [ticket 9409] Some source code examples are missing
# [ticket 9537] const_string_test example fails
# [ticket 9539] Floating-point comparison algorithms aren't formatted correctly
# [ticket 9581] Squassabia reference link gives 404 not found
# [ticket 9960] Warnings on Clang
# [ticket 10256] [boost test] - issue: `sigaltstack`
# [ticket 10318] Minor documentation fix
# [ticket 10394] Broken links in Boost Test documentation
# [ticket 10888] Assertion failures don't show up in the errors pane in VS 2010, VS 2012 or VS 2013 (duplicates)
# [ticket 11054] Floating-point comparison of multiprecision values fails if expression template is on
# [ticket 11347] `DS` identifier causes test failures in `doc/examples/dataset_example*.cpp`
# [ticket 11358] Boost.Test v3 warning could helpfully be suppressed.
# [ticket 11359] `BOOST_CHECK_EQUAL_COLLECTIONS`: can't control output operator (duplicates #9390)
# [ticket 11425] use-of-uninitialized-value (obsolete)
[endsect]

View File

@ -1,159 +0,0 @@
[/
/ 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:section_faq Frequently Asked Questions]
[h3 Where the latest version of the Boost Test Library is located?]
The latest version of Boost Test Library is available online at [@http://www.boost.org/libs/test].
[h3 I found a bug. Where can I report it?]
You can send a bug report to the boost users' mailing list and/or fill a ticket here [@https://svn.boost.org/trac/boost/].
[h3 I have a request for a new feature. Where can I ask for it?]
You can send a request to the boost developers' mailing list and/or and/or fill a ticket here [@https://svn.boost.org/trac/boost/].
[h3 How to create test case using the Unit Test Framework?]
To create a test case, use the macro
__BOOST_AUTO_TEST_CASE__( test_function );
For more details see the Unit Test Framework __BOOST_AUTO_TEST_CASE__ documentation.
[h3 How to create test suite using the Unit Test Framework?]
To create a test suite use the macro
__BOOST_AUTO_TEST_SUITE__( suite_name );
For more details see the Unit Test Framework __BOOST_AUTO_TEST_SUITE__ documentation.
[h3 Why did I get a linker error when compiling my test program?]
Boost Test Library components provide several usage variants: to create a test program you can
link with the one of the precompiled library variants or use single-header variant. For example, to use Unit Test
Framework you may either include
``
#include <boost/test/unit_test.hpp>
``
and link with ``libunit_test_framework.lib`` or you can include
``
#include <boost/test/included/unit_test.hpp>
``
in which case you should not need to link with any precompiled component. Note also that
you should strictly follow specification on initialization function in other case some compilers may produce linker
error like this.
``
Unresolved external init_unit_test_suite(int, char**).
``
The reason for this error is that in your implementation you should specify second argument of
`init_unit_test_suite` exactly as in the specification, i.e.: `char* []`.
[h3 How can I redirect testing output?]
Use ``unit_test_log::instance().set_log_output( std::ostream & )``
For more details see the __UTF__ __output_test_stream_tool__ documentation.
[h3 I want different default log trace level]
Use environment variable __BOOST_TEST_LOG_LEVEL__ to define desired log trace level. You still will be able to reset
this value from the command line. For the list of acceptable values see the __UTF__
__runtime_configuration__ documentation.
[h3 Is there DLL version of Boost.Test components available on Win32 platform?]
Yes. Starting with Boost 1.34.0.
[h3 How to set up a CMake project using __UTF__ (extended)]
Suppose, you are building a test module from one translation unit `test_file.cpp`. First, let's do it using the [link boost_test.usage_variants.single_header single-header usage variant] of the __UTF__.
Let's paste the following content in a `CMakeLists.txt`
at the same location than our test file `test_file.cpp`:
[pre
cmake_minimum_required(VERSION 2.8.7)
project(my_first_test)
enable_testing()
# indicates the location of the boost installation tree.
# hard-coded for our simple example.
set(BOOST_INCLUDE_DIRS $boost_installation_prefix/include)
# creates the executable
add_executable(test_executable test_file.cpp)
# indicates the include paths
target_include_directories(test_executable PRIVATE ${BOOST_INCLUDE_DIRS})
# declares a test with our executable
add_test(NAME test1 COMMAND test_executable)
]
We will now create the build directory for this project (separate directory),
configure and build the project, as follow:
```
> cd ``$``test_path
> mkdir build /*< we create a directory dedicated to the build, to avoid
any pollution of the sources with the temporary
build files >*/
> cd build
> cmake .. /*< configuration of the project >*/
> cmake --build . /*< this command builds the project, cmake drives a native
tool that is configured on the previous command line >*/
> ctest /*< runs the tests declared in the project and prints a report >*/
```
In the case you are using the [link boost_test.usage_variants.shared_lib shared libraries] variant of __UTF__,
some modifications should be done in your CMakeLists.txt.
[pre
cmake_minimum_required(VERSION 2.8.11)
project(my_first_test)
enable_testing()
# replace XX with the version you have
set(Boost_ADDITIONAL_VERSIONS "1.XX" "1.XX.0")
# finds boost, triggers an error otherwise
find_package(Boost XX REQUIRED COMPONENTS unit_test_framework)
# creates the executable
add_executable(test_executable test_file.cpp)
# indicates the include paths
target_include_directories(test_executable PRIVATE ${Boost_INCLUDE_DIRS})
# indicates the shared library variant
target_compile_definitions(test_executable PRIVATE "BOOST_TEST_DYN_LINK=1")
# indicates the link paths
target_link_libraries(test_executable ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
# declares a test with our executable
add_test(NAME test1 COMMAND test_executable)
]
We will now create the build directory for this project (separate directory), configure and build the project,
as follow:
```
> cd ``$``test_path
> mkdir build /*< we create a directory dedicated to the build, to avoid any pollution of the sources with the temporary
build files >*/
> cd build
> cmake -DBOOST_ROOT=``$``boost_installation_prefix .. /*< configuration of the project, the `BOOST_ROOT` configuration element indicates the
Boost module of `cmake` where to find our installation >*/
> cmake --build . /*< this command builds the project, cmake drives a native tool that is configured on the
previous command line >*/
> ctest /*< runs the tests declared in the project and prints a report >*/
```
[endsect] [/faq]

View File

@ -1,102 +0,0 @@
[/
/ 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:section_glossary Glossary]
Here is the list of terms used throughout this documentation.
[#ref_test_module][h3 Test module]
This is a single binary that performs the test. Physically a test module consists of one or more test source files,
which can be built into an executable or a dynamic library. A test module that consists of a single test source
file is called ['single-file test module]. Otherwise
it's called ['multi-file test module]. Logically, each test module consists of four parts:
# [link test_setup test setup] (or test initialization),
# [link test_body test body]
# [link test_cleanup test cleanup]
# [link test_runner test runner]
The test runner part is optional. If a test module is built as
an executable, the test runner is built-in. If a test module is built as a dynamic library, it is run by an
[link boost_test.adv_scenarios.external_test_runner external test runner].
[#test_body][h3 Test body]
This is the part of a test module that actually performs the test.
Logically test body is a collection of [link test_assertion test assertions] wrapped in
[link test_case test cases], which are organized in a [link ref_test_tree test tree].
[#ref_test_tree][h3 Test tree]
This is a hierarchical structure of [link test_suite test suites] (non-leaf nodes) and
[link test_case test cases] (leaf nodes). More details can be found [link boost_test.tests_organization here].
[#ref_test_unit][h3 Test unit]
This is a collective name when referred to either a [link test_suite test suite] or
[link test_case test cases]. See [link boost_test.tests_organization this section] for more details.
[#test_assertion][h3 Test assertion]
This is a single binary condition (binary in a sense that is has two outcomes: pass and fail) checked
by a test module.
There are different schools of thought on how many test assertions a test case should consist of. Two polar
positions are the one advocated by TDD followers - one assertion per test case; and opposite of this - all test
assertions within single test case - advocated by those only interested in the first error in a
test module. The __UTF__ supports both approaches.
[#test_case][h3 Test case]
This is an independently monitored function within a test module that
consists of one or more test assertions. The term ['independently monitored] in the definition above is
used to emphasize the fact, that all test cases are monitored independently. An uncaught exception or other normal
test case execution termination doesn't cause the testing to cease. Instead the error is caught by the test
case execution monitor, reported by the __UTF__ and testing proceeds to the next test case. Later on you are going
to see that this is on of the primary reasons to prefer multiple small test cases to a single big test function.
[#test_suite][h3 Test suite]
This is a container for one or more test cases. The test suite gives you an ability to group
test cases into a single referable entity. There are various reasons why you may opt to do so, including:
* To group test cases per subsystems of the unit being tested.
* To share test case setup/cleanup code.
* To run selected group of test cases only.
* To see test report split by groups of test cases.
* To skip groups of test cases based on the result of another test unit in a test tree.
A test suite can also contain other test suites, thus allowing a hierarchical test tree structure to be formed.
The __UTF__ requires the test tree to contain at least one test suite with at least one test case. The top level
test suite - root node of the test tree - is called the master test suite.
[#test_setup][h3 Test setup]
This is the part of a test module that is responsible for the test
preparation. It includes the following operations that take place prior to a start of the test:
* The __UTF__ initialization
* Test tree construction
* Global test module setup code
* ['Per test case] setup code, invoked for every test case it's assigned to, is also attributed to the
test initialization, even though it's executed as a part of the test case.
[#test_cleanup][h3 Test cleanup]
This is the part of test module that is responsible for cleanup operations.
[#test_fixture][h3 Test fixture]
Matching setup and cleanup operations are frequently united into a single entity called test fixture.
[#test_runner][h3 Test runner]
This is an ['orchestrator] or a ['driver] that, given the test tree, ensures the test tree is initialized, tests are executed and necessary reports generated. For more information [link boost_test.adv_scenarios.test_module_runner_overview see here].
[#test_log][h3 Test log]
This is the record of all events that occur during the testing.
[#test_report][h3 Test report]
This is the report produced by the __UTF__ after the testing is completed, that indicates which test cases/test
suites passed and which failed.
[endsect] [/ Glossary]

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,16 +0,0 @@
//[example_output
> ./boost_runtime_list_content --list_content
s1*: disabled suite 1
test1*: enabled
test2 : defaulted
test3 : defaulted
s14 : test suite which depends on another test suite
test1
s2*
test1 : defaulted
test2*: enabled w. precondition
s23*
test1
test2
test3*
//]

View File

@ -1,108 +0,0 @@
// (C) Copyright 2015 Boost.Test team.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE list_content
#include <boost/test/included/unit_test.hpp>
namespace utf=boost::unit_test;
//// --------------------------------------------------------------------------
// Test suite 1, disabled by default, s1/test2 is explicitely enabled.
BOOST_AUTO_TEST_SUITE( s1,
* utf::disabled() // suite is not disabled because of the
* utf::description( "disabled suite 1") // extra declaration at the end of the file
* utf::label( "label1" )
* utf::label( "label2" ))
BOOST_AUTO_TEST_CASE( test1, // s1/test1
* utf::enabled() * utf::description("enabled"))
{
BOOST_TEST(true);
}
BOOST_AUTO_TEST_CASE( test2, // s1/test2
* utf::description( "defaulted") * utf::expected_failures( 1 ))
{
BOOST_TEST(false);
}
BOOST_AUTO_TEST_CASE( test3, // s1/test3
* utf::description( "defaulted"))
{
BOOST_TEST(false);
}
BOOST_AUTO_TEST_SUITE_END()
//// --------------------------------------------------------------------------
// Test suite 2, disabled by default, s1/test2 is explicitely enabled.
BOOST_AUTO_TEST_SUITE( s2,
* utf::disabled()
* utf::label( "label1" )
* utf::expected_failures( 3 ))
BOOST_AUTO_TEST_CASE( test1, // s2/test1
* utf::description( "defaulted"))
{
BOOST_TEST(false);
}
boost::test_tools::assertion_result do_it( utf::test_unit_id )
{
return false;
}
BOOST_AUTO_TEST_CASE( test2, // s2/test2
* utf::enabled()
* utf::description( "enabled w. precondition")
* utf::precondition(do_it))
{
BOOST_TEST(false);
}
//// --------------------------------------------------------------------------
// Test suite s2/s23, disabled
BOOST_AUTO_TEST_SUITE( s23, * utf::disabled())
BOOST_AUTO_TEST_CASE( test1 ) // s2/s23/test1
{
BOOST_TEST(false);
}
BOOST_AUTO_TEST_CASE( test2, // s2/s23/test2
* utf::timeout( 10 ))
{
BOOST_TEST( true );
}
BOOST_AUTO_TEST_CASE( test3, // s2/s23/test3
* utf::enabled()
* utf::depends_on( "s2/test2" ))
{
BOOST_TEST( true );
}
BOOST_AUTO_TEST_SUITE_END() // s2/s23
BOOST_AUTO_TEST_SUITE_END() // s2
//// --------------------------------------------------------------------------
// Test suite s1 continued
BOOST_AUTO_TEST_SUITE( s1 )
BOOST_AUTO_TEST_SUITE( s14,
* utf::depends_on( "s2/s23/test3" )
* utf::description( "test suite which depends on another test suite"))
BOOST_AUTO_TEST_CASE( test1, // s1/s14/test1
* utf::depends_on( "s2" ))
{
BOOST_TEST( "s14" == "test" );
}
BOOST_AUTO_TEST_SUITE_END() // s1/s14
BOOST_AUTO_TEST_SUITE_END() // s1
//]

View File

@ -1,21 +0,0 @@
//[example_output
> ./boost_test_bitwise --log_level=all
Running 1 test case...
Entering test module "boost_test_bitwise"
test.cpp(13): Entering test case "test_bitwise"
test.cpp(17): error: in "test_bitwise": check a == (a & ~1) has failed [171 != 170]. Bitwise comparison failed
Mismatch at position 0
test.cpp(18): error: in "test_bitwise": check a == a + 1 has failed [171 != 172]. Bitwise comparison failed
Mismatch at position 0
Mismatch at position 1
Mismatch at position 2
test.cpp(19): info: check a != a + 1 has passed
test.cpp(21): error: in "test_bitwise": check a == b has failed [171 != 136]. Bitwise comparison failed
Mismatch at position 0
Mismatch at position 1
Mismatch at position 5
test.cpp(13): Leaving test case "test_bitwise"; testing time: 627us
Leaving test module "boost_test_bitwise"; testing time: 772us
*** 3 failures are detected in the test module "boost_test_bitwise"
//]

View File

@ -1,23 +0,0 @@
// (C) Copyright Raffi Enficiaud 2014.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE boost_test_bitwise
#include <boost/test/included/unit_test.hpp>
#include <sstream>
BOOST_AUTO_TEST_CASE(test_bitwise)
{
namespace tt = boost::test_tools;
int a = 0xAB;
BOOST_TEST( a == (a & ~1), tt::bitwise() );
BOOST_TEST( a == a + 1, tt::bitwise() );
BOOST_TEST( a != a + 1, tt::bitwise() );
int b = 0x88;
BOOST_TEST( a == b, tt::bitwise() );
}
//]

View File

@ -1,13 +0,0 @@
//[example_output
> ./boost_test_container_default --log_level=all
Running 1 test case...
Entering test module "boost_test_sequence"
test.cpp(13): Entering test case "test_collections_vectors"
test.cpp(23): info: check a < c has passed
test.cpp(24): error: in "test_collections_vectors": check a >= c has failed
test.cpp(25): info: check a != c has passed
test.cpp(13): Leaving test case "test_collections_vectors"; testing time: 208us
Leaving test module "boost_test_sequence"; testing time: 286us
*** 1 failure is detected in the test module "boost_test_container_default"
//]

View File

@ -1,27 +0,0 @@
// (C) Copyright Raffi Enficiaud 2014.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE boost_test_sequence
#include <boost/test/included/unit_test.hpp>
#include <vector>
BOOST_AUTO_TEST_CASE( test_collections_vectors )
{
std::vector<int> a{1,2,3}, c{1,5,3,4};
std::vector<long> b{1,5,3};
// the following does not compile
//BOOST_TEST(a == b);
//BOOST_TEST(a <= b);
// stl defaults to lexicographical comparison
BOOST_TEST(a < c);
BOOST_TEST(a >= c);
BOOST_TEST(a != c);
}
//]

View File

@ -1,17 +0,0 @@
//[example_output
> ./boost_test_container_lex --log_level=all
Running 1 test case...
Entering test module "boost_test_container_lex"
test.cpp(15): Entering test case "test_collections_vectors_lex"
test.cpp(19): error: in "test_collections_vectors_lex": check a < a has failed
Collections appear to be equal.
test.cpp(20): error: in "test_collections_vectors_lex": check a < b has failed
Failure at position 2: 3 >= 2.
test.cpp(21): info: check a < c has passed
test.cpp(22): error: in "test_collections_vectors_lex": check a >= c has failed
Second collection has extra trailing elements.
test.cpp(15): Leaving test case "test_collections_vectors_lex"; testing time: 267us
Leaving test module "boost_test_container_lex"; testing time: 341us
*** 3 failures are detected in the test module "boost_test_container_lex"
//]

View File

@ -1,28 +0,0 @@
// (C) Copyright Raffi Enficiaud 2014.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE boost_test_container_lex
#include <boost/test/included/unit_test.hpp>
#include <vector>
namespace tt = boost::test_tools;
BOOST_AUTO_TEST_CASE( test_collections_vectors_lex )
{
std::vector<int> a{1,2,3}, b{1,2,2}, c{1,2,3,4};
BOOST_TEST(a < a, tt::lexicographic());
BOOST_TEST(a < b, tt::lexicographic());
BOOST_TEST(a < c, tt::lexicographic());
BOOST_TEST(a >= c, tt::lexicographic());
// does not compile
//BOOST_TEST(a == c, tt::lexicographic());
//BOOST_TEST(a != c, tt::lexicographic());
}
//]

View File

@ -1,11 +0,0 @@
//[example_output
> ./boost_test_container_lex_default
Running 1 test case...
test.cpp:22: error: in "test_collections_vectors_lex": check a < a has failed.
Collections appear to be equal.
test.cpp:23: error: in "test_collections_vectors_lex": check a < b has failed.
Failure at position 2: 3 >= 2.
test.run-fail.cpp:24: error: in "test_collections_vectors_lex": check c < d has failed
*** 3 failures are detected in the test module "boost_test_container_lex_default"
//]

View File

@ -1,26 +0,0 @@
// (C) Copyright Raffi Enficiaud 2015.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE boost_test_container_lex_default
#include <boost/test/included/unit_test.hpp>
#include <vector>
namespace tt = boost::test_tools;
BOOST_TEST_SPECIALIZED_COLLECTION_COMPARE(std::vector<int>)
BOOST_AUTO_TEST_CASE( test_collections_vectors_lex )
{
std::vector<int> a{1,2,3}, b{1,2,2};
std::vector<long int> c{1,2,3,5}, d{1,2,3,4};
BOOST_TEST(a < a); // extended diagnostic
BOOST_TEST(a < b); // extended diagnostic
BOOST_TEST(c < d); // no extended diagnostic
}
//]

View File

@ -1,10 +0,0 @@
//[example_output
> ./boost_test_macro2 --log_level=all
Running 2 test cases...
test.cpp(16): error: in "test_op_precedence": check a % b == c has failed [13 % 2 != 12]
test.cpp(18): error: in "test_op_precedence": check a == c % b has failed [13 != 0]
test.cpp(25): error: in "test_op_right_associative": check !a has failed
test.cpp(26): error: in "test_op_right_associative": check --a has failed [(bool)0 is false]
*** 4 failures are detected in the test module "boost_test_macro2"
//]

View File

@ -1,28 +0,0 @@
// (C) Copyright Raffi Enficiaud 2014.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE boost_test_macro2
#include <boost/test/included/unit_test.hpp>
BOOST_AUTO_TEST_CASE( test_op_precedence )
{
int a = 13, b = 2, c = 12;
// left term of == is expanded in the logs
BOOST_TEST(a % b == c);
// right term of == is not expanded in the logs
BOOST_TEST(a == c % b);
}
BOOST_AUTO_TEST_CASE( test_op_right_associative )
{
int a = 1;
BOOST_TEST(a);
BOOST_TEST(!a);
BOOST_TEST(--a);
}
//]

View File

@ -1,14 +0,0 @@
//[example_output
> ./boost_test_macro3 --log_level=all
Running 1 test case...
Entering test module "boost_test_macro3"
test.cpp(12): Entering test case "test_op_reportings"
test.cpp(15): error: in "test_op_reportings": check a == b has failed [13 != 12]
test.cpp(16): error: in "test_op_reportings": check a < b has failed [13 >= 12]
test.cpp(17): error: in "test_op_reportings": check a - 1 < b has failed [13 - 1 >= 12]
test.cpp(18): error: in "test_op_reportings": check b > a - 1 has failed [12 <= 12]
test.cpp(12): Leaving test case "test_op_reportings"; testing time: 484us
Leaving test module "boost_test_macro3"; testing time: 588us
*** 2 failures are detected in the test module "boost_test_macro3"
//]

View File

@ -1,20 +0,0 @@
// (C) Copyright Raffi Enficiaud 2014.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE boost_test_macro3
#include <boost/test/included/unit_test.hpp>
BOOST_AUTO_TEST_CASE( test_op_reportings )
{
int a = 13, b = 12;
BOOST_TEST(a == b);
BOOST_TEST(a < b);
BOOST_TEST(a - 1 < b);
BOOST_TEST(b > a - 1);
}
//]

View File

@ -1,11 +0,0 @@
//[example_output
> ./boost_test_macro_container_c_array --log_level=all
Running 1 test case...
Entering test module "boost_test_container_c"
test.cpp(15): Entering test case "test_collections_not_on_c_arrays"
test.cpp(19): error: in "test_collections_not_on_c_arrays": check a == b has failed [0x7fff526e5bc4 != 0x7fff526e5bb0]
test.cpp(15): Leaving test case "test_collections_not_on_c_arrays"; testing time: 323us
Leaving test module "boost_test_container_c"; testing time: 526us
*** 1 failure is detected in the test module "boost_test_container_c"
//]

View File

@ -1,21 +0,0 @@
// (C) Copyright Raffi Enficiaud 2014.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE boost_test_container_c
#include <boost/test/included/unit_test.hpp>
#include <sstream>
#include <map>
#include <vector>
BOOST_AUTO_TEST_CASE( test_collections_not_on_c_arrays )
{
int a[] = {1, 2, 3};
int b[] = {1, 5, 3, 4};
BOOST_TEST(a == b);
}
//]

View File

@ -1,17 +0,0 @@
//[example_output
> ./boost_test_macro_overview --log_level=all
Running 1 test case...
Entering test module "boost_test_macro_overview"
test.cpp:12: Entering test case "test_macro_overview"
test.cpp:17: error: in "test_macro_overview": check a != b - 1 has failed [1 == 1]
test.cpp:18: error: in "test_macro_overview": check a + 1 < b has failed [1 + 1 >= 2]
test.cpp:19: error: in "test_macro_overview": 1 < 1 does not hold
test.cpp:20: error: in "test_macro_overview": check a == b has failed [1 != 2]. Bitwise comparison failed
Mismatch at position 0
Mismatch at position 1
test.cpp:21: error: in "test_macro_overview": check a + 0.1 == b - 0.8 has failed [1 + 0.10000000000000001 != 1.2]. Relative difference exceeds tolerance [0.0909091 > 0.01]
test.cpp:12: Leaving test case "test_macro_overview"; testing time: 380us
Leaving test module "boost_test_macro_overview"; testing time: 459us
*** 5 failures are detected in the test module "boost_test_macro_overview"
//]

View File

@ -1,23 +0,0 @@
// (C) Copyright Raffi Enficiaud 2014.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE boost_test_macro_overview
#include <boost/test/included/unit_test.hpp>
BOOST_AUTO_TEST_CASE( test_macro_overview )
{
namespace tt = boost::test_tools;
int a = 1;
int b = 2;
BOOST_TEST(a != b - 1);
BOOST_TEST(a + 1 < b);
BOOST_TEST(b -1 > a, a << " < " << b - 1 << " does not hold");
BOOST_TEST(a == b, tt::bitwise());
BOOST_TEST(a + 0.1 == b - 0.8, tt::tolerance(0.01));
}
//]

View File

@ -1,14 +0,0 @@
//[example_output
> ./boost_test_macro_workaround --log_level=all
Running 2 test cases...
Entering test module "boost_test_macro_workaround"
test.cpp:13: Entering test case "test_logical_not_allowed"
test.cpp:17: info: check (true && true) has passed
test.cpp:13: Leaving test case "test_logical_not_allowed"; testing time: 183us
test.cpp:20: Entering test case "test_ternary"
test.cpp:26: info: check (a + 1 == b ? true : false) has passed
test.cpp:20: Leaving test case "test_ternary"; testing time: 123us
Leaving test module "boost_test_macro_workaround"; testing time: 547us
*** No errors detected
//]

View File

@ -1,30 +0,0 @@
// (C) Copyright Raffi Enficiaud 2014.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE boost_test_macro_workaround
#include <boost/test/included/unit_test.hpp>
#include <sstream>
BOOST_AUTO_TEST_CASE( test_logical_not_allowed )
{
// Boost Unit Test Framework prevents compilation of
// BOOST_TEST(true && true);
BOOST_TEST((true && true)); // with extra brackets, it works as expected
}
BOOST_AUTO_TEST_CASE( test_ternary )
{
int a = 1;
int b = 2;
// Boost Unit Test Framework prevents compilation of
// BOOST_TEST(a == b ? true : false);
BOOST_TEST((a + 1 == b ? true : false)); // again works as expected with extra brackets
}
//]

View File

@ -1,12 +0,0 @@
//[example_output
> ./boost_test_message --log_level=all
Running 1 test case...
Entering test module "boost_test_message"
test.cpp(12): Entering test case "test_message"
test.cpp(15): error: in "test_message": a should be equal to b: 1!=2
test.cpp(16): info: check 'value of a=1' has passed
test.cpp(12): Leaving test case "test_message"; testing time: 219us
Leaving test module "boost_test_message"; testing time: 318us
*** 1 failure is detected in the test module "boost_test_message"
//]

View File

@ -1,18 +0,0 @@
// (C) Copyright Raffi Enficiaud 2014.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE boost_test_message
#include <boost/test/included/unit_test.hpp>
BOOST_AUTO_TEST_CASE( test_message )
{
const int a(1), b(2);
BOOST_TEST(a == b, "a should be equal to b: " << a << "!=" << b);
BOOST_TEST(a != 10, "value of a=" << a);
}
//]

View File

@ -1,17 +0,0 @@
//[example_output
> ./boost_test_sequence_per_element
Running 1 test case...
test.cpp(21): error: in "test_sequence_per_element": check a == b has failed
Mismatch at position 1: 2 != 5.
test.cpp(23): error: in "test_sequence_per_element": check a != b has failed
Mismatch at position 0: 1 == 1.
Mismatch at position 2: 3 == 3.
test.cpp(25): error: in "test_sequence_per_element": check b < c has failed
Collections size mismatch: 3 != 4
test.cpp(26): error: in "test_sequence_per_element": check b >= c has failed
Collections size mismatch: 3 != 4
test.cpp(27): error: in "test_sequence_per_element": check b != c has failed
Collections size mismatch: 3 != 4
*** 5 failures are detected in the test module "boost_test_sequence_per_element"
//]

View File

@ -1,29 +0,0 @@
// (C) Copyright Raffi Enficiaud 2014.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE boost_test_sequence_per_element
#include <boost/test/included/unit_test.hpp>
#include <vector>
#include <list>
namespace tt = boost::test_tools;
BOOST_AUTO_TEST_CASE( test_sequence_per_element )
{
std::vector<int> a{1,2,3};
std::vector<long> b{1,5,3};
std::list<short> c{1,5,3,4};
BOOST_TEST(a == b, tt::per_element()); // nok: a[1] != b[1]
BOOST_TEST(a != b, tt::per_element()); // nok: a[0] == b[0] ...
BOOST_TEST(a <= b, tt::per_element()); // ok
BOOST_TEST(b < c, tt::per_element()); // nok: size mismatch
BOOST_TEST(b >= c, tt::per_element()); // nok: size mismatch
BOOST_TEST(b != c, tt::per_element()); // nok: size mismatch
}
//]

View File

@ -1,16 +0,0 @@
//[example_output
> ./boost_test_strings --log_level=all
Running 2 test cases...
Entering test module "boost_test_strings"
test.cpp(15): Entering test case "test_pointers"
test.cpp(19): info: check a == b has passed
test.cpp(20): error: in "test_pointers": check pa == pb has failed [0x7fff51cdcc04 != 0x7fff51cdcc00]
test.cpp(15): Leaving test case "test_pointers"; testing time: 306us
test.cpp(23): Entering test case "test_strings"
test.cpp(28): error: in "test_strings": check a == b has failed [test1 != test2]
test.cpp(29): info: check a == c has passed
test.cpp(23): Leaving test case "test_strings"; testing time: 198us
Leaving test module "boost_test_strings"; testing time: 702us
*** 2 failures are detected in the test module "boost_test_strings"
//]

View File

@ -1,28 +0,0 @@
// (C) Copyright Raffi Enficiaud 2014.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE boost_test_strings
#include <boost/test/included/unit_test.hpp>
BOOST_AUTO_TEST_CASE( test_pointers )
{
float a(0.5f), b(0.5f);
const float* pa = &a, *pb = &b;
BOOST_TEST(a == b);
BOOST_TEST(pa == pb);
}
BOOST_AUTO_TEST_CASE( test_strings )
{
const char* a = "test1";
const char* b = "test2";
const char* c = "test1";
BOOST_TEST(a == b);
BOOST_TEST(a == c);
}
//]

View File

@ -1,8 +0,0 @@
//[example_output
> custom_init
using custom init
Running 1 test case...
test.cpp(7): error: in "test1": check false has failed
*** 1 failure is detected in the test module "Master Test Suite"
//]

View File

@ -1,23 +0,0 @@
// (C) Copyright Andrzej Krzemienski 2015.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_ALTERNATIVE_INIT_API
#include <boost/test/included/unit_test.hpp>
#include <iostream>
BOOST_AUTO_TEST_CASE(test1)
{
BOOST_TEST(false);
}
bool init_unit_test()
{
std::cout << "using custom init" << std::endl;
return true;
}
//]

View File

@ -1,8 +0,0 @@
//[example_output
> custom_main
Using custom entry point...
Running 1 test case...
test.cpp(10): error: in "test1": check false has failed
*** 1 failure is detected in the test module "custom_main"
//]

View File

@ -1,31 +0,0 @@
// (C) Copyright Andrzej Krzemienski 2015.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE custom_main
#define BOOST_TEST_NO_MAIN
#define BOOST_TEST_ALTERNATIVE_INIT_API
#include <boost/test/included/unit_test.hpp>
#include <iostream>
namespace utf = boost::unit_test;
BOOST_AUTO_TEST_CASE(test1)
{
BOOST_TEST(false);
}
void make_use_of(char**)
{
std::cout << "Using custom entry point..." << std::endl;
}
int main(int argc, char* argv[], char* envp[])
{
make_use_of(envp);
return utf::unit_test_main(init_unit_test, argc, argv);
}
//]

View File

@ -1,8 +0,0 @@
//[example_output
> custom_obsolete_init
using obsolete init
Running 1 test case...
test.cpp(6): error: in "test1": check false has failed
*** 1 failure is detected in the test module "Master Test Suite"
//]

View File

@ -1,22 +0,0 @@
// (C) Copyright Andrzej Krzemienski 2015.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#include <boost/test/included/unit_test.hpp>
#include <iostream>
BOOST_AUTO_TEST_CASE(test1)
{
BOOST_TEST(false);
}
boost::unit_test::test_suite* init_unit_test_suite(int /*argc*/, char* /*argv*/[])
{
std::cout << "using obsolete init" << std::endl;
return 0;
}
//]

View File

@ -1,17 +0,0 @@
//[example_output
> dataset_example61
Running 8 test cases...
test 1: 0
test 1: 1
test 1: 2
test 1: 3
test 1: 4
test 2: 1
test 2: 4
test 2: 7
test.cpp(27): error: in "test2": check (sample <= 4 && sample >= 0) has failed
Failure occurred in a following context:
sample = 7;
*** 1 failure is detected in the test module "dataset_example59"
//]

View File

@ -1,29 +0,0 @@
// (C) Copyright Raffi Enficiaud 2014.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE dataset_example59
#include <boost/test/included/unit_test.hpp>
#include <boost/test/data/test_case.hpp>
#include <boost/test/data/monomorphic.hpp>
namespace bdata = boost::unit_test::data;
BOOST_DATA_TEST_CASE( test1, bdata::xrange(5) )
{
std::cout << "test 1: " << sample << std::endl;
BOOST_TEST((sample <= 4 && sample >= 0));
}
BOOST_DATA_TEST_CASE(
test2,
bdata::xrange<int>( (bdata::begin=1, bdata::end=10, bdata::step=3)) )
{
std::cout << "test 2: " << sample << std::endl;
BOOST_TEST((sample <= 4 && sample >= 0));
}
//]

View File

@ -1,8 +0,0 @@
//[example_output
> dataset_example61
Running 2 test cases...
1, qwerty
2, asdfg
*** No errors detected
//]

View File

@ -1,27 +0,0 @@
// (C) Copyright Raffi Enficiaud 2014.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE dataset_example61
#include <boost/test/included/unit_test.hpp>
#include <boost/test/data/test_case.hpp>
#include <boost/test/data/monomorphic.hpp>
namespace data = boost::unit_test::data;
int samples1[] = {1,2};
char const* samples2[] = {"qwerty", "asdfg"};
BOOST_DATA_TEST_CASE(
test1,
data::make(samples1)^samples2,
integer_values,
string_value)
{
std::cout << integer_values << ", " << string_value << std::endl;
}
//]

View File

@ -1,11 +0,0 @@
//[example_output
> dataset_example62
Running 5 test cases...
1
2
8
9
10
*** No errors detected
//]

View File

@ -1,26 +0,0 @@
// (C) Copyright Raffi Enficiaud 2014.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE dataset_example62
#include <boost/test/included/unit_test.hpp>
#include <boost/test/data/test_case.hpp>
#include <boost/test/data/monomorphic.hpp>
namespace data = boost::unit_test::data;
int samples1[] = {1, 2};
int samples2[] = {8, 9, 10};
BOOST_DATA_TEST_CASE(
test1,
data::make(samples1) + samples2,
var)
{
std::cout << var << std::endl;
}
//]

View File

@ -1,35 +0,0 @@
//[example_output
> dataset_example63
Running 14 test cases...
test 1: 1, 0
test 1: 14, 1
test 1: 13, 2
test 1: 15, 3
test 1: 13, 4
test 1: 17, 5
test 1: 11, 6
test 2: 1.81472, 0
test.cpp(35): error: in "test2": check random_sample < 1.7 has failed
Failure occurred in a following context:
random_sample = 1.81472373; index = 0;
test 2: 1.13548, 1
test 2: 1.90579, 2
test.cpp(35): error: in "test2": check random_sample < 1.7 has failed
Failure occurred in a following context:
random_sample = 1.905792; index = 2;
test 2: 1.83501, 3
test.cpp(35): error: in "test2": check random_sample < 1.7 has failed
Failure occurred in a following context:
random_sample = 1.83500862; index = 3;
test 2: 1.12699, 4
test 2: 1.96887, 5
test.cpp(35): error: in "test2": check random_sample < 1.7 has failed
Failure occurred in a following context:
random_sample = 1.96886778; index = 5;
test 2: 1.91338, 6
test.cpp(35): error: in "test2": check random_sample < 1.7 has failed
Failure occurred in a following context:
random_sample = 1.91337585; index = 6;
*** 5 failures are detected in the test module "dataset_example63"
//]

View File

@ -1,37 +0,0 @@
// (C) Copyright Raffi Enficiaud 2014.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE dataset_example63
#include <boost/test/included/unit_test.hpp>
#include <boost/test/data/test_case.hpp>
#include <boost/test/data/monomorphic.hpp>
namespace bdata = boost::unit_test::data;
BOOST_DATA_TEST_CASE(
test1,
bdata::random(1, 17) ^ bdata::xrange(7),
random_sample, index )
{
std::cout << "test 1: " << random_sample
<< ", " << index << std::endl;
BOOST_TEST((random_sample <= 17 && random_sample >= 1));
}
BOOST_DATA_TEST_CASE(
test2,
bdata::random( (bdata::distribution=std::uniform_real_distribution<float>(1, 2)) )
^ bdata::xrange(7),
random_sample, index )
{
std::cout << "test 2: " << random_sample
<< ", " << index << std::endl;
BOOST_TEST(random_sample < 1.7); // 30% chance of failure
}
//]

View File

@ -1,30 +0,0 @@
//[example_output
> dataset_example64
Running 12 test cases...
test 1: 0, 0
test 1: 0, 1
test 1: 0, 2
test 1: 1, 0
test 1: 1, 1
test 1: 1, 2
test 2: 0 / 1.81472, 0
test.cpp(40): error: in "test2": check random_sample < 1.7 has failed [1.81472373 >= 1.7]
Failure occurred in a following context:
xr = 0; random_sample = 1.81472373; index = 0;
test 2: 0 / 1.13548, 1
test 2: 1 / 1.90579, 0
test.cpp(40): error: in "test2": check random_sample < 1.7 has failed [1.905792 >= 1.7]
Failure occurred in a following context:
xr = 1; random_sample = 1.905792; index = 0;
test 2: 1 / 1.83501, 1
test.cpp(40): error: in "test2": check random_sample < 1.7 has failed [1.83500862 >= 1.7]
Failure occurred in a following context:
xr = 1; random_sample = 1.83500862; index = 1;
test 2: 2 / 1.12699, 0
test 2: 2 / 1.96887, 1
test.cpp(40): error: in "test2": check random_sample < 1.7 has failed [1.96886778 >= 1.7]
Failure occurred in a following context:
xr = 2; random_sample = 1.96886778; index = 1;
*** 4 failures are detected in the test module "dataset_example64"
//]

View File

@ -1,42 +0,0 @@
// (C) Copyright Raffi Enficiaud 2014.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE dataset_example64
#include <boost/test/included/unit_test.hpp>
#include <boost/test/data/test_case.hpp>
#include <boost/test/data/monomorphic.hpp>
namespace bdata = boost::unit_test::data;
BOOST_DATA_TEST_CASE(
test1,
bdata::xrange(2) * bdata::xrange(3),
xr1, xr2)
{
std::cout << "test 1: " << xr1 << ", " << xr2 << std::endl;
BOOST_TEST((xr1 <= 2 && xr2 <= 3));
}
BOOST_DATA_TEST_CASE(
test2,
bdata::xrange(3)
*
( bdata::random(
bdata::distribution=std::uniform_real_distribution<float>(1, 2))
^ bdata::xrange(2)
),
xr, random_sample, index)
{
std::cout << "test 2: "
<< xr << " / "
<< random_sample << ", " << index
<< std::endl;
BOOST_TEST(random_sample < 1.7); // 30% chance of failure
}
//]

View File

@ -1,10 +0,0 @@
//[example_output
> dataset_example65
Running 4 test cases...
test 1: 2
test 2: 0, 2
test 2: 1, 2
test 2: 2, 2
*** No errors detected
//]

View File

@ -1,38 +0,0 @@
// (C) Copyright Raffi Enficiaud 2014.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE dataset_example65
#include <boost/test/included/unit_test.hpp>
#include <boost/test/data/test_case.hpp>
#include <boost/test/data/monomorphic.hpp>
namespace bdata = boost::unit_test::data;
BOOST_DATA_TEST_CASE(
test1,
bdata::make(2),
singleton)
{
std::cout
<< "test 1: "
<< singleton << std::endl;
BOOST_TEST(singleton == 2);
}
BOOST_DATA_TEST_CASE(
test2,
bdata::xrange(3) ^ bdata::make(2),
xr, singleton)
{
std::cout
<< "test 2: "
<< xr << ", " << singleton << std::endl;
BOOST_TEST(singleton == 2);
}
//]

View File

@ -1,8 +0,0 @@
//[example_output
> dataset_example66
Running 2 test cases...
test 1: 0, cat
test 1: 1, dog
*** No errors detected
//]

View File

@ -1,29 +0,0 @@
// (C) Copyright Raffi Enficiaud 2014.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE dataset_example66
#include <boost/test/included/unit_test.hpp>
#include <boost/test/data/test_case.hpp>
#include <boost/test/data/monomorphic.hpp>
namespace bdata = boost::unit_test::data;
const char* arr[] = {"cat", "dog"};
BOOST_DATA_TEST_CASE(
test1,
bdata::xrange(2) ^ bdata::make(arr),
xr, array_element)
{
std::cout << "test 1: "
<< xr << ", "
<< array_element
<< std::endl;
BOOST_TEST(array_element != "mammoth");
}
//]

View File

@ -1,21 +0,0 @@
//[example_output
> dataset_example67
Running 15 test cases...
test 1: 0
test 1: 1
test 1: 1
test 1: 2
test 1: 3
test 1: 5
test 1: 8
test 1: 13
test 2: "0", 0
test 2: "1", 1
test 2: "13", 13
test 2: "2", 2
test 2: "3", 3
test 2: "5", 5
test 2: "8", 8
*** No errors detected
//]

View File

@ -1,69 +0,0 @@
// (C) Copyright Raffi Enficiaud 2014.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE example67
#include <boost/test/included/unit_test.hpp>
#include <boost/test/data/test_case.hpp>
#include <boost/test/data/monomorphic.hpp>
#include <sstream>
namespace bdata = boost::unit_test::data;
// Generates a Fibonacci sequence
std::vector<float> fibonacci() {
std::vector<float> ret(8);
ret[0] = 0;
ret[1] = 1;
for(std::size_t s(2); s < ret.size(); s++)
{
ret[s] = ret[s-1] + ret[s-2];
}
return ret;
}
BOOST_DATA_TEST_CASE(
test1,
bdata::make(fibonacci()),
array_element)
{
std::cout << "test 1: "
<< array_element
<< std::endl;
BOOST_TEST(array_element <= 13);
}
// Generates a map from a vector
std::map<std::string, float> vect_2_str(std::vector<float> v)
{
std::map<std::string, float> out;
for(std::size_t s(0); s < v.size(); s++)
{
std::ostringstream o;
o << v[s];
out[o.str()] = v[s];
}
return out;
}
typedef std::pair<const std::string, float> pair_map_t;
BOOST_TEST_DONT_PRINT_LOG_VALUE( pair_map_t )
BOOST_DATA_TEST_CASE(
test2,
bdata::make(vect_2_str(fibonacci())),
array_element)
{
std::cout << "test 2: \""
<< array_element.first << "\", "
<< array_element.second
<< std::endl;
BOOST_TEST(array_element.second <= 13);
}
//]

View File

@ -1,12 +0,0 @@
//[example_output
> example68
Running 9 test cases...
test.cpp:61: error: in "test1": check fib_sample == exp has failed [34 != 35]
Failure occurred in a following context:
fib_sample = 34; exp = 35;
test.cpp:61: error: in "test1": check fib_sample == exp has failed [55 != 56]
Failure occurred in a following context:
fib_sample = 55; exp = 56;
*** 2 failures are detected in the test module "dataset_example68"
//]

View File

@ -1,62 +0,0 @@
// (C) Copyright Raffi Enficiaud 2014.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE dataset_example68
#include <boost/test/included/unit_test.hpp>
#include <boost/test/data/test_case.hpp>
#include <boost/test/data/monomorphic.hpp>
#include <sstream>
namespace bdata = boost::unit_test::data;
// Dataset generating a Fibonacci sequence
class fibonacci_dataset {
public:
// Samples type is int
using sample=int;
enum { arity = 1 };
struct iterator {
iterator() : a(1), b(1) {}
int operator*() const { return b; }
void operator++()
{
a = a + b;
std::swap(a, b);
}
private:
int a;
int b; // b is the output
};
fibonacci_dataset() {}
// size is infinite
bdata::size_t size() const { return bdata::BOOST_TEST_DS_INFINITE_SIZE; }
// iterator
iterator begin() const { return iterator(); }
};
namespace boost { namespace unit_test { namespace data { namespace monomorphic {
// registering fibonacci_dataset as a proper dataset
template <>
struct is_dataset<fibonacci_dataset> : boost::mpl::true_ {};
}}}}
// Creating a test-driven dataset
BOOST_DATA_TEST_CASE(
test1,
fibonacci_dataset() ^ bdata::make( { 1, 2, 3, 5, 8, 13, 21, 35, 56 } ),
fib_sample, exp)
{
BOOST_TEST(fib_sample == exp);
}
//]

View File

@ -1,7 +0,0 @@
//[example_output
> decorator_00 --list_content
test_1*: with description
test_1*: with description
test_1*: with description
test_1*: with description
//]

View File

@ -1,21 +0,0 @@
// (C) Copyright Andrzej Krzemienski 2015.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE decorator_00
#include <boost/test/included/unit_test.hpp>
#include <boost/test/data/test_case.hpp>
namespace utf = boost::unit_test;
namespace data = boost::unit_test::data;
BOOST_TEST_DECORATOR(* utf::description("with description"))
BOOST_DATA_TEST_CASE(test_1, data::xrange(4))
{
BOOST_TEST(sample >= 0);
}
//]

View File

@ -1,12 +0,0 @@
//[example_output
> decorator_01 --run_test=@trivial
Running 2 test cases...
*** No errors detected
> decorator_01 --run_test=@cmp
Running 1 test case...
*** No errors detected
//]

View File

@ -1,25 +0,0 @@
// (C) Copyright Andrzej Krzemienski 2015.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE decorator_01
#include <boost/test/included/unit_test.hpp>
namespace utf = boost::unit_test;
BOOST_AUTO_TEST_CASE(test_case1, * utf::label("trivial"))
{
BOOST_TEST(true);
}
BOOST_AUTO_TEST_CASE(test_case2,
* utf::label("trivial")
* utf::label("cmp")
* utf::description("testing equality of ones"))
{
BOOST_TEST(1 == 1);
}
//]

View File

@ -1,6 +0,0 @@
//[example_output
> decorator_02 --run_test=@trivial
Running 2 test cases...
*** No errors detected
//]

View File

@ -1,26 +0,0 @@
// (C) Copyright Andrzej Krzemienski 2015.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE decorator_02
#include <boost/test/included/unit_test.hpp>
namespace utf = boost::unit_test;
BOOST_AUTO_TEST_SUITE(suite1, * utf::label("trivial"))
BOOST_AUTO_TEST_CASE(test_case1)
{
BOOST_TEST(true);
}
BOOST_AUTO_TEST_CASE(test_case2)
{
BOOST_TEST(1 == 1);
}
BOOST_AUTO_TEST_SUITE_END()
//]

View File

@ -1,12 +0,0 @@
//[example_output
> decorator_03 --run_test=@trivial
Running 3 test cases...
*** No errors detected
> decorator_03 --run_test=@simple
Running 3 test cases...
*** No errors detected
//]

View File

@ -1,39 +0,0 @@
// (C) Copyright Andrzej Krzemienski 2015.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE decorator_03
#include <boost/test/included/unit_test.hpp>
namespace utf = boost::unit_test;
BOOST_AUTO_TEST_SUITE(suite1, * utf::label("trivial"))
BOOST_AUTO_TEST_CASE(test_case1)
{
BOOST_TEST(true);
}
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE(suite1, * utf::label("simple"))
BOOST_AUTO_TEST_CASE(test_case2)
{
BOOST_TEST(true);
}
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE(suite1)
BOOST_AUTO_TEST_CASE(test_case3)
{
BOOST_TEST(true);
}
BOOST_AUTO_TEST_SUITE_END()
//]

View File

@ -1,25 +0,0 @@
//[example_output
> decorator_04
Running 3 test cases...
test.cpp(8): error: in "test1": check false has failed
test.cpp(15): error: in "test2": check false has failed
test.cpp(20): error: in "test3": check false has failed
*** 3 failures are detected in the test module "decorator_04"
> decorator_04 --run_test=@l1
Running 2 test cases...
test.cpp(8): error: in "test1": check false has failed
test.cpp(15): error: in "test2": check false has failed
*** 2 failures are detected in the test module "decorator_04"
> decorator_04 --run_test=@l2
Running 1 test case...
test.cpp(15): error: in "test2": check false has failed
*** 1 failure is detected in the test module "decorator_04"
//]

View File

@ -1,30 +0,0 @@
// (C) Copyright Andrzej Krzemienski 2015.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE decorator_04
#include <boost/test/included/unit_test.hpp>
namespace utf = boost::unit_test;
BOOST_AUTO_TEST_CASE(test1,
* utf::label("l1"))
{
BOOST_TEST(false);
}
BOOST_AUTO_TEST_CASE(test2,
* utf::label("l1")
* utf::label("l2"))
{
BOOST_TEST(false);
}
BOOST_AUTO_TEST_CASE(test3)
{
BOOST_TEST(false);
}
//]

View File

@ -1,13 +0,0 @@
//[example_output
> decorator_05
Running 1 test case...
test.cpp(14): error: in "suite1/test2": check 2 != 2 has failed [2 == 2]
*** 1 failure is detected in the test module "decorator_05"
> decorator_05 --list_content
suite1*
test1
test2*
//]

View File

@ -1,26 +0,0 @@
// (C) Copyright Andrzej Krzemienski 2015.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE decorator_05
#include <boost/test/included/unit_test.hpp>
namespace utf = boost::unit_test;
BOOST_AUTO_TEST_SUITE(suite1, * utf::disabled())
BOOST_AUTO_TEST_CASE(test1)
{
BOOST_TEST(1 != 1);
}
BOOST_AUTO_TEST_CASE(test2, * utf::enabled())
{
BOOST_TEST(2 != 2);
}
BOOST_AUTO_TEST_SUITE_END()
//]

View File

@ -1,12 +0,0 @@
//[example_output
> decorator_06
Running 1 test case...
test.cpp(11): error: in "test_io": check 1 != 1 has failed [1 == 1]
*** 1 failure is detected in the test module "decorator_06"
> decorator_06 --list_content
test_io*
test_db
//]

View File

@ -1,27 +0,0 @@
// (C) Copyright Andrzej Krzemienski 2015.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE decorator_06
#include <boost/test/included/unit_test.hpp>
namespace utf = boost::unit_test;
const bool io_implemented = true;
const bool db_implemented = false;
BOOST_AUTO_TEST_CASE(test_io,
* utf::enable_if<io_implemented>())
{
BOOST_TEST(1 != 1);
}
BOOST_AUTO_TEST_CASE(test_db,
* utf::enable_if<db_implemented>())
{
BOOST_TEST(2 != 2);
}
//]

View File

@ -1,24 +0,0 @@
//[example_output
> decorator_07 --report_level=detailed
Running 4 test cases...
test.cpp(10): error: in "test3": check false has failed
Test module "decorator_07" has failed with:
1 test case out of 4 passed
1 test case out of 4 failed
2 test cases out of 4 skipped
1 assertion out of 2 passed
1 assertion out of 2 failed
Test case "test3" has failed with:
1 assertion out of 1 failed
Test case "test4" was skipped
Test case "test5" was skipped
Test suite "s1" has passed with:
1 test case out of 1 passed
1 assertion out of 1 passed
Test case "s1/test1" has passed with:
1 assertion out of 1 passed
//]

View File

@ -1,44 +0,0 @@
// (C) Copyright Andrzej Krzemienski 2015.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE decorator_07
#include <boost/test/included/unit_test.hpp>
namespace utf = boost::unit_test;
// test1 and test2 defined at the bottom
BOOST_AUTO_TEST_CASE(test3, * utf::depends_on("s1/test1"))
{
BOOST_TEST(false);
}
BOOST_AUTO_TEST_CASE(test4, * utf::depends_on("test3"))
{
BOOST_TEST(false);
}
BOOST_AUTO_TEST_CASE(test5, * utf::depends_on("s1/test2"))
{
BOOST_TEST(false);
}
BOOST_AUTO_TEST_SUITE(s1)
BOOST_AUTO_TEST_CASE(test1)
{
BOOST_TEST(true);
}
BOOST_AUTO_TEST_CASE(test2, * utf::disabled())
{
BOOST_TEST(false);
}
BOOST_AUTO_TEST_SUITE_END()
//]

View File

@ -1,17 +0,0 @@
//[example_output
> decorator_08 --log_level=test_suite
Running 4 test cases...
Entering test module "decorator_08"
test.cpp(6): Entering test case "test1"
test.cpp(6): Leaving test case "test1"; testing time: 1ms
test.cpp(11): Entering test case "test2"
test.cpp(13): error: in "test2": check false has failed
test.cpp(11): Leaving test case "test2"; testing time: 2ms
test.cpp(39): Entering test case "test3"
test.cpp(41): error: in "test3": check false has failed
test.cpp(39): Leaving test case "test3"; testing time: 2ms
test.cpp(45): Test case "test4" is skipped because test2 and test3 failed
Leaving test module "decorator_08"; testing time: 16ms
*** 2 failures are detected in the test module "decorator_08"
//]

View File

@ -1,57 +0,0 @@
// (C) Copyright Andrzej Krzemienski 2015.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE decorator_08
#include <boost/test/included/unit_test.hpp>
namespace utf = boost::unit_test;
namespace tt = boost::test_tools;
BOOST_AUTO_TEST_CASE(test1)
{
BOOST_TEST(true);
}
BOOST_AUTO_TEST_CASE(test2)
{
BOOST_TEST(false);
}
struct if_either
{
std::string tc1, tc2;
if_either(std::string t1, std::string t2)
: tc1(t1), tc2(t2) {}
tt::assertion_result operator()(utf::test_unit_id)
{
auto& master = utf::framework::master_test_suite();
auto& collector = utf::results_collector_t::instance();
auto& test1_result = collector.results(master.get(tc1));
auto& test2_result = collector.results(master.get(tc2));
if (test1_result.passed() || test2_result.passed())
return true;
tt::assertion_result ans(false);
ans.message() << tc1 << " and " << tc2 << " failed";
return ans;
}
};
BOOST_AUTO_TEST_CASE(test3,
* utf::precondition(if_either("test1", "test2")))
{
BOOST_TEST(false);
}
BOOST_AUTO_TEST_CASE(test4,
* utf::precondition(if_either("test2", "test3")))
{
BOOST_TEST(false);
}
//]

View File

@ -1,5 +0,0 @@
//[example_output
> decorator_09 --list_content
test_1 : enable only when ODBC is available
test_2*: descriptions add up
//]

View File

@ -1,26 +0,0 @@
// (C) Copyright Andrzej Krzemienski 2015.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE decorator_09
#include <boost/test/included/unit_test.hpp>
namespace utf = boost::unit_test;
BOOST_AUTO_TEST_CASE(test_1,
* utf::disabled()
* utf::description("enable only when ODBC is available"))
{
BOOST_TEST(1 == 1);
}
BOOST_AUTO_TEST_CASE(test_2,
* utf::description("descriptions ")
* utf::description("add up"))
{
BOOST_TEST(2 == 2);
}
//]

View File

@ -1,18 +0,0 @@
//[example_output
> decorator_10
Running 2 test cases...
test.cpp(11): error: in "suite1/test1": check false has failed
test.cpp(12): error: in "suite1/test1": check false has failed
test.cpp(17): error: in "suite1/test2": check false has failed
test.cpp(18): error: in "suite1/test2": check false has failed
*** 4 failures are detected (3 failures are expected) in the test module "decorator_10"
> decorator_10 --run_test=suite1/test1
Running 1 test case...
test.cpp(11): error: in "suite1/test1": check false has failed
test.cpp(12): error: in "suite1/test1": check false has failed
*** No errors detected
//]

View File

@ -1,30 +0,0 @@
// (C) Copyright Andrzej Krzemienski 2015.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE decorator_10
#include <boost/test/included/unit_test.hpp>
namespace utf = boost::unit_test;
BOOST_AUTO_TEST_SUITE(suite1,
* utf::expected_failures(1))
BOOST_AUTO_TEST_CASE(test1,
* utf::expected_failures(2))
{
BOOST_TEST(false);
BOOST_TEST(false);
}
BOOST_AUTO_TEST_CASE(test2)
{
BOOST_TEST(false);
BOOST_TEST(false);
}
BOOST_AUTO_TEST_SUITE_END()
//]

View File

@ -1,8 +0,0 @@
//[example_output
> decorator_11
Running 1 test case...
unknown location(0): fatal error: in "test1": signal: SIGALRM (timeout while executing function)
test.cpp(5): last checkpoint: "test1" entry.
*** 1 failures is detected in test module "decorator_11"
//]

View File

@ -1,22 +0,0 @@
// (C) Copyright Andrzej Krzemienski 2015.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE decorator_11
#include <boost/test/included/unit_test.hpp>
namespace utf = boost::unit_test;
BOOST_AUTO_TEST_CASE(test1, * utf::timeout(2))
{
#ifdef BOOST_SIGACTION_BASED_SIGNAL_HANDLING
for(;;) {}
BOOST_TEST(true);
#else
BOOST_TEST(false);
#endif
}
//]

View File

@ -1,14 +0,0 @@
//[example_output
> decorator_12 --log_level=message
Running 2 test cases...
set up FX
set up FX2
set up fun
running test1
tear down fun
running test2
tear down FX2
tear down FX
*** No errors detected
//]

View File

@ -1,41 +0,0 @@
// (C) Copyright Andrzej Krzemienski 2015.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE decorator_12
#include <boost/test/included/unit_test.hpp>
namespace utf = boost::unit_test;
struct Fx
{
std::string s;
Fx(std::string s = "") : s(s)
{ BOOST_TEST_MESSAGE("set up " << s); }
~Fx() { BOOST_TEST_MESSAGE("tear down " << s); }
};
void setup() { BOOST_TEST_MESSAGE("set up fun"); }
void teardown() { BOOST_TEST_MESSAGE("tear down fun"); }
BOOST_AUTO_TEST_SUITE(suite1,
* utf::fixture<Fx>(std::string("FX"))
* utf::fixture<Fx>(std::string("FX2")))
BOOST_AUTO_TEST_CASE(test1, * utf::fixture(&setup, &teardown))
{
BOOST_TEST_MESSAGE("running test1");
BOOST_TEST(true);
}
BOOST_AUTO_TEST_CASE(test2)
{
BOOST_TEST_MESSAGE("running test2");
BOOST_TEST(true);
}
BOOST_AUTO_TEST_SUITE_END()
//]

View File

@ -1,12 +0,0 @@
//[example_output
> decorator_13
Running 5 test cases...
test.cpp(9): error: in "test1": check 0.001 == 0.000 has failed [0.001 != 0]. Absolute value exceeds tolerance [|0.001| > 0.0005]
test.cpp(10): error: in "test1": check 1.100 == 1.101 has failed [1.1000000000000001 != 1.101]. Relative difference exceeds tolerance [0.000908265 > 0.0005]
test.cpp(21): error: in "test3": check 0.001 == 0.000 has failed [0.001 != 0]. Absolute value exceeds tolerance [|0.001| > 0]
test.cpp(22): error: in "test3": check 1.100 == 1.101 has failed [1.1000000000000001 != 1.101]
test.cpp(28): error: in "test4": check 0.001 == 0.000 has failed [0.001 != 0]. Absolute value exceeds tolerance [|0.001| > 0.0005]
test.cpp(29): error: in "test4": check 1.100 == 1.101 has failed [1.1000000000000001 != 1.101]. Relative difference exceeds tolerance [0.000908265 > 0.0005]
*** 6 failures are detected in the test module "decorator_13"
//]

View File

@ -1,46 +0,0 @@
// (C) Copyright Andrzej Krzemienski 2015.
// 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)
// See http://www.boost.org/libs/test for the library home page.
//[example_code
#define BOOST_TEST_MODULE decorator_13
#include <boost/test/included/unit_test.hpp>
namespace utf = boost::unit_test;
namespace fpc = boost::test_tools::fpc;
BOOST_AUTO_TEST_CASE(test1, * utf::tolerance(0.0005))
{
BOOST_TEST( 0.001 == 0.000 );
BOOST_TEST( 1.100 == 1.101 );
}
BOOST_AUTO_TEST_CASE(test2, * utf::tolerance(0.005))
{
BOOST_TEST( 0.001 == 0.000 );
BOOST_TEST( 1.100 == 1.101 );
}
BOOST_AUTO_TEST_CASE(test3, * utf::tolerance(0.05F))
{
BOOST_TEST( 0.001 == 0.000 );
BOOST_TEST( 1.100 == 1.101 );
}
BOOST_AUTO_TEST_CASE(test4,
* utf::tolerance(fpc::percent_tolerance(0.05)))
{
BOOST_TEST( 0.001 == 0.000 );
BOOST_TEST( 1.100 == 1.101 );
}
BOOST_AUTO_TEST_CASE(test5,
* utf::tolerance(fpc::percent_tolerance(0.5)))
{
BOOST_TEST( 0.001 == 0.000 );
BOOST_TEST( 1.100 == 1.101 );
}
//]

View File

@ -1,15 +0,0 @@
//[example_output
> decorator_20
Running 2 test cases...
test.cpp(18): error: in "suite1/test_2": check 2 != 2 has failed [2 == 2]
test.cpp(24): error: in "suite1/test_io": check 3 != 3 has failed [3 == 3]
*** 2 failures are detected in the test module "decorator_20"
> decorator_20 --list_content
suite1*
test_1
test_2*
test_io*
test_db
//]

Some files were not shown because too many files have changed in this diff Show More