Commit Graph

43 Commits

Author SHA1 Message Date
Julien Brianceau
e8cdfdca87
Fix typos in the code base (#2206)
Note that only documentation and comments are impacted by this change.
2021-04-07 20:43:50 +02:00
Martin Hořeňovský
33ad1ee2ac
Split EventListener base from streaming_base.hpp
The base was also renamed from `TestEventListenerBase` to
`EventListenerBase`, and modified to derive directly from the
reporter interface, rather than deriving from `StreamingReporterBase`.
2020-08-29 19:09:54 +02:00
Martin Hořeňovský
ed7eaf2df3
Split catch_reporter_bases.hpp into two separate headers
Each of the two reporter bases now has its own header file, and
cpp file. Even though this adds another TU to the compilation,
the total CPU time taken by compilation is reduced by about 1%
for debug build and ~0.5% for optimized build of the main library.
(The improvement would be roughly doubles without splitting the TUs,
but the maintainability hit is not worth it.)

The code size of the static library build has also somewhat decreased.

Follow up: Introduce combined TU for reporters, and further split
apart the catch_reporter_streaming_base.hpp header into its
constituent parts, as it still contains a whole bunch of other stuff.
2020-08-23 07:30:26 +02:00
Martin Hořeňovský
4e0af77e29
Push includes for TestCaseInfo down into reporter TUs 2020-07-29 14:43:05 +02:00
Martin Hořeňovský
3b0f8c7ff0
Replace a TODO comment in examples 2020-07-22 21:49:58 +02:00
Richard Ash
2840ce1e70
Add an example of using GENERATE(table())
There are some examples on issue #850 of using this feature, but they
are not easily found from the documentation. Adding them here as an
example makes them more findable and ensures they keep working if the
API changes.
2020-07-22 21:49:54 +02:00
Martin Hořeňovský
480f3f418b
Improved generator tracking
* Successive executions of the same `GENERATE` macro (e.g. because
of a for loop) no longer lead to multiple nested generators.
* The same line can now contain multiple `GENERATE` macros without
issues.

Fixes #1913
2020-07-22 20:44:22 +02:00
Martin Hořeňovský
1d1ccf8f3c
Replace all uses of std::unique_ptr with Catch::Detail::unique_ptr
Doing some benchmarking with ClangBuildAnalyzer suggests that
compiling Catch2's `SelfTest` spends 10% of the time instantiating
`std::unique_ptr` for some interface types required for registering
and running tests.

The lesser compilation overhead of `Catch::Detail::unique_ptr` should
significantly reduce that time.

The compiled implementation was also changed to use the custom impl,
to avoid having to convert between using `std::unique_ptr` and
`Catch::Detail::unique_ptr`. This will likely also improve the compile
times of the implementation, but that is less important than improving
compilation times of the user's TUs with tests.
2020-05-31 15:20:24 +02:00
Martin Hořeňovský
db32550898
Remove catch_default_main.hpp
There are two reasons for this:

1) It is highly unlikely that someone has use for this header,
which has no customization points and only provides simplest
possible main, and cannot link the static library which also
provides a default main implementation.
2) It being a header was causing extra complications with
the convenience headers, and our checking script. This would either
require special handling in the checking script, or would break user's
of the main convenience header.

All in all, it is simpler and better in the long term to remove it,
than to fix its problems.
2020-05-09 18:00:49 +02:00
Martin Hořeňovský
19ecad6f68
Rename CMake/pkg-config target Catch2Main to Catch2WithMain
This describes the reality better, as it also links in the rest
of Catch2.

The on-disk name of the static library remains just `Catch2Main`,
as that is what it is -- single main function -- and on-disk artifacts
cannot describe link dependencies.
2020-05-03 18:54:38 +02:00
Martin Hořeňovský
b955355ec4
Avoid recompiling main for each example
Instead, link against `Catch2Main` CMake target as intended.
2020-04-24 21:13:07 +02:00
Martin Hořeňovský
e1e6872c4c
Standardize header names and file locations
This is both a really big and a really small commit. It is small in
that it only contains renaming, moving and modification of include
directives caused by this.

It is really big in the obvious way of touching something like 200
files.

The new rules for naming files is simple: headers use the `.hpp`
extension. The rules for physical file layout is still kinda in
progress, but the basics are also simple:
 * Significant parts of functionality get their own subfolder
   * Benchmarking is in `catch2/benchmark`
   * Matchers are in `catch2/matchers`
   * Generators are in `catch2/generators`
   * Reporters are in `catch2/reporters`
   * Baseline testing facilities are in `catch2/`
 * Various top level folders also contain `internal` subfolder,
   with files that users probably do not want to include directly,
   at least not until they have to write something like their own
   reporter.
    * The exact files in these subfolders is likely to change later
      on

Note that while some includes were cleaned up in this commit, it
is only the low hanging fruit and further cleanup using automatic
tooling will happen later.

Also note that various include guards, copyright notices and file
headers will also be standardized later, rather than in this commit.
2020-04-24 18:58:44 +02:00
Martin Hořeňovský
151dccbd31
Remove catch.hpp
This was an old "include all" header, that we no longer want to be
usable, to make the include differences in new versions explicit.

We will introduce new "include all" headers later, in the form of
`catch_all.hpp`, `catch_matchers_all.hpp` and so on...
2020-03-29 21:32:13 +02:00
Martin Hořeňovský
d1ffaf55a1
Fix warnings in ExtraTests and Examples 2020-02-26 16:07:54 +01:00
Martin Hořeňovský
6e270958a2
Add development build option to CMake and enable it on CI
Development build enables warnings and and `Werror` or equivalent.
2020-02-26 16:07:26 +01:00
offa
06c32862b3
Some refactorings:
- Overrides added
 - usages of push_back() replaced with emplace_back()
 - Loop variable made const-refernce
 - NULL replaced with nullptr
 - Names used in the declaration and definition unified
 - size() replaced with empty
 - Identical cases merged
2020-02-16 15:25:23 +01:00
Martin Hořeňovský
db1a0465dc
Outline GeneratorException from generators header 2020-02-14 16:15:47 +01:00
Martin Hořeňovský
ea6db67063
Use std::make_unique instead of our polyfill or naked new
The use we previously used the polyfill or naked new is that we
supported C++11, which did not yet have `std::make_unique`. However,
with the move to C++14 as the minimum, `std::make_unique` can be
expected to be always available.
2020-02-01 23:34:00 +01:00
Martin Hořeňovský
17281c09c3
Convert examples to piecemeal includes 2020-01-21 14:46:07 +01:00
Martin Hořeňovský
5fbf04cd59
Redo how the separate compilation tests are handled 2019-12-15 20:33:39 +01:00
Martin Hořeňovský
29b441949c
Port the last example 2019-12-08 20:58:52 +01:00
Martin Hořeňovský
70ef2f7f12
Update building of examples for static lib 2019-12-08 15:55:04 +01:00
Martin Hořeňovský
d36c15c3ca
Store tags in one big pre-allocated string and only work with refs
This should decrease the number of allocations before main is entered
significantly, but complicates the code somewhat in return.

Assuming I used `massif` right, doing just `SelfTest --list-tests`
went from 929 allocations at "Remove gcc-4.9 from the travis builds"
(2 commits up), to 614 allocations with this commit.
2019-11-14 10:53:12 +01:00
Martin Hořeňovský
302e2c0b06
Do not copy around TestCaseInfo
Now a `TEST_CASE` macro should create a single TestCaseInfo and then
it should never be copied around. This, together with latter changes,
should significantly decrease the number of allocations made before
`main` is even entered.
2019-11-14 10:52:34 +01:00
Martin Hořeňovský
d6f7f1fbed
Set CMakeLists to default to C++14 for our internal projects 2019-11-07 13:02:43 +01:00
Martin Hořeňovský
2c6ace04a7
Redo build matrix on .travis for C++14 and up
* Use Xenial as the base distribution
* Remove C++11 builds
* Add a lot more C++14 builds
* Add some C++17 builds
* Include newer versions of Clang and GCC
2019-10-31 16:19:56 +01:00
Martin Hořeňovský
2bcf1b3db6
Remove support for test case descriptions
Closes #1189
2019-10-29 14:07:18 +01:00
Martin Hořeňovský
c3c82f539c
Merge pull request #1336 from ax3l/topic-overrideVirtualRedundant
Refactor: override implies virtual
2019-04-18 14:10:24 +02:00
Martin Hořeňovský
3816e99d0c
Add GENERATE_COPY and GENERATE_VAR capturing generator macros 2019-03-31 14:11:10 +02:00
Martin Hořeňovský
5bf6e47381
Add another example for generators 2019-02-26 12:52:21 +01:00
Martin Hořeňovský
061f1f836a
Update documentation and examples for generators 2019-01-31 10:43:25 +01:00
Jozef Grajciar
73d533ff5c Examples: add semicolon after INFO 2019-01-22 12:37:03 +01:00
Martin Moene
558bbe7d24 Add example for TeamCity reporter and refer to it
Prevent warnings
- gnu: -Wcomment: multi-line comment
- clang: -Wweak-vtables 'class' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit
- clang: -Winconsistent-missing-override: 'method' overrides a member function but is not marked 'override'
- MSVC: C4702: unreachable code
2018-09-27 23:20:02 +02:00
Martin Hořeňovský
1e98c820bb Simplify the Appveyor configuration batch script 2018-09-09 10:18:30 +02:00
Martin Hořeňovský
1a501fcb48 Fix examples compilation for some combinations of Clang and libstdc++ 2018-08-28 10:12:53 +02:00
Axel Huebl
5347ff9e5f
Refactor: override implies virtual
If not used with `final`, override implies `virtual`.
Detected via CodeFactor score.

Another reference on SO:
  https://stackoverflow.com/questions/43466863/isnt-virtual-keyword-redundant-when-override-or-final-specifiers-are-used
2018-07-12 14:27:06 +02:00
Martin Hořeňovský
c8941cccb5 Add an example on providing streams with CATCH_CONFIG_NOSTDOUT
Related to #1037
Closes #1290
2018-07-08 13:38:42 +02:00
Phil Nash
9fb38fcc14 Restored description field in SectionInfo for now - but marked it deprecated 2018-06-25 20:18:41 +01:00
Martin Hořeňovský
44722f9ed3 Integrate CMake with <catch2/catch.hpp> include paths
This also goes for pkg-config installed by our CMake installation.

This includes

* Updating CMake version on Travis
* Adding a `Catch2` subfolder to the `single_include/` folder to
provide this include path both _inside_ the repository, and _outside_.
* Updated examples to build with the new paths
* Other general CMake cleanup
2018-06-24 12:32:22 +02:00
David Seifert
b0f4f16ee0 Namespace Catch CMake options 2018-01-18 23:20:26 +01:00
Martin Hořeňovský
87c125ecb8 Enable Werror for dev builds 2017-11-21 18:55:28 +01:00
Martin Moene
85de0727d4 Add examples subdirectory to CMake build; included if BUILD_EXAMPLES is true 2017-11-15 15:37:39 +01:00
Martin Moene
4ecb2e112e Add examples folder with initial examples 2017-11-15 15:37:39 +01:00