Commit Graph

717 Commits

Author SHA1 Message Date
Martin Hořeňovský
4c8454b5ec
Fix potential infinite loops in generators combined with section filter
The problem was that under specific circumstances, namely that none
of their children progressed, `GeneratorTracker` will not progress.
This was changed recently, to allow for code like this, where a
`SECTION` follows a `GENERATE` at the same level:

```cpp
SECTION("A") {}
auto a = GENERATE(1, 2);
SECTION("B") {}
```

However, this interacted badly with `SECTION` filters (`-c foo`),
as they could deactivate all `SECTION`s below a generator, and thus
stop it from progressing forever. This commit makes GeneratorTracker
check whether there are any filters active, and if they are, it checks
whether its section-children can ever run.

Fixes #2025
2020-10-23 21:21:15 +02:00
Martin Hořeňovský
8878f90323
Fix matching of non-lowercase filename tags
The bug was caused by forgetting to lower-case the filename tag
for matching against test spec.

Fixes #2064
2020-10-22 16:20:41 +02:00
Martin Hořeňovský
923bcc5d6f
Special case --list-tests --verbosity quiet
The new output (mostly) follows the old `--list-test-names-only`
format, with the exception of no longer supporting line output
for `--verbosity high`.

Fixes #2051
2020-10-20 15:09:48 +02:00
Martin Hořeňovský
b6a3e2e26b
Merge pull request #2058 from catchorg/devel-generators-cache
Fix types in generators: decay types, properly constrain forwarding
2020-10-20 12:46:31 +02:00
Martin Hořeňovský
6ffac61719
Fix types in generators: decay types, properly constrain forwarding
Fixes #2040
Closes #2012
2020-10-20 10:57:37 +02:00
Michael Vlach
4b2bc8757c Update catch_compiler_capabilities.hpp 2020-10-10 17:56:43 +02:00
Martin Hořeňovský
b9853b4b35
Bump version to v3.0.0 preview 3 2020-10-08 15:26:30 +02:00
Martin Hořeňovský
3f9e779542
Improve detection of std::uncaught_exceptions support
The problem was that Catch2 did not reliably include `<exception>`
before it checked for the feature test macro for
`std::uncaught_exceptions`. To avoid overhead of including
`<exception>` everywhere, the configuration check was split out
into a separate header.

Closes #2021
2020-10-08 12:39:50 +02:00
Martin Hořeňovský
b601b7faca
Workaround AppleClang bug by renaming TestHasher constructor argument
As far as I understand the standard, if there is a function called
`rng` in the global namespace, and a function argument called `rng`,
then the argument should shadow the function. This then means that
uses of `rng` inside the function should refer to the argument.

This is not the case for AppleClang 12.0.0. Luckily the workaround
is simple enough; just rename the argument. Given that the function
is 3 lines and uncomplicated, the change of the name doesn't really
affect readability.

Still, WTF AppleClang?

Closes #2030
2020-10-08 11:41:05 +02:00
Will Pazner
a4dfcf9042
Disable __builtin_constant_p when compiling with nvcc 2020-10-08 11:34:57 +02:00
Travis Wilson
b0214ff862
Make experimental capture work on Windows with read-write temp file behavior 2020-10-08 11:28:50 +02:00
Martin Hořeňovský
99d70c0c9d
Remove superfluous whitespace before #include 2020-09-07 20:01:04 +02:00
Dawid Kurek
8f44e09a72
Remove superfluous values
The `0`s were needed for the expansion of parameter pack for the sake of
expander. Now when we have `index++` it is no more needed.
2020-09-07 14:30:58 +02:00
Sean Middleditch
31d4831245
Support sentinel-based ranges in default stringify (#2004) 2020-09-07 14:23:47 +02:00
Gregory Bond
5ad1a4fe61
Issue 1992: Better c++17 std::byte detection
This fixed buld errors for ubuntu-16 + clang and similar situations
where C++17 is supported in the compiler but not the default
C++ standard library.
2020-09-07 13:01:51 +02:00
Martin Jeřábek
8851e779cf console colour: fix unintended colouring of user's stderr on POSIX
At some places, the colour reset code is printed after a newline.
Since the default output buffering to console is line-based, the reset
code is not actually written out. If messages from user code are printed
to stderr (different stream, same console), they are printed before
the colour reset code, and thus they are coloured.

Explicitly flushing the stream after writing the colour escape code solves
this.
2020-09-07 11:53:45 +02:00
Martin Hořeňovský
9155a9ff20
Fix -Wparentheses issue on g++9 2020-09-06 16:02:01 +02:00
Martin Hořeňovský
cc18bd719d
Sweep out Wshadow
Most of the changes are completely pointless renaming of constructor
arguments so that they do not use the same name as the type members,
but 🤷

Closes #2015
2020-09-06 13:11:42 +02:00
Martin Hořeňovský
90aeffb97d
Add standardized copyright notice + SPDX identifier to source files
This should also be done for test files, but that has lower priority.
2020-08-30 15:43:45 +02:00
Martin Hořeňovský
c2453c2bf8
Remove the rest of old-style copyright headers 2020-08-30 14:45:05 +02:00
Martin Hořeňovský
a822cb9717
Standardize include guard patterns to FILE_NAME_EXTENSION_INCLUDED
This commit also strips the old copyright comment header in touched
files, as those will also be replaced with a more standardized and
machine-friendly version.
2020-08-30 14:09:27 +02:00
Martin Hořeňovský
c26693df23
Fix doccomment on shouldShowDuration reporter helper 2020-08-29 19:55:17 +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ý
f9fdc96cbf
Push LazyStat down into catch_reporter_streaming_base.hpp 2020-08-24 11:27:21 +02:00
Martin Hořeňovský
360b82620e
Refactor serializeFilters implementation 2020-08-24 10:19:26 +02:00
Martin Hořeňovský
2a8e317cfb
Split various reporter helpers out from streaming_base.hpp
Due to also adding a new TU, there is no improvement to the
compilation times of the static library, but it improves the
compilation times of consumer's reporter TUs.
2020-08-24 10:19:24 +02:00
Martin Hořeňovský
6a08d401aa
Split out ReporterFactory out of catch_interfaces_reporter.hpp 2020-08-23 22:35:01 +02:00
Martin Hořeňovský
9677df6d8b
Split IReporterRegistry into its own header file
Doing this removes `<map>` from the include set of the base reporter
interface, and thus from bunch more TUs. This provides about 1.5%
improvements in the debug build of the static library, and 1% in
release build.
2020-08-23 21:01:04 +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ý
24559493bf
Anchor some Clara vtables into the cpp file
Anchoring the vtables does 2 things
1) Fixes some instances of `-Wweak-vtables`
2) Decreases code size and linker pressure

However, there are still some unanchored ones, and thus we have
to keep suppressing `-Wweak-vtables` warning for Clang.
2020-08-20 23:16:11 +02:00
Martin Hořeňovský
7500ad1ffd
Turn Clara::Detail::ResultBase::Type into its own enum class 2020-08-20 22:59:06 +02:00
Martin Hořeňovský
1a97af45f1
Cleanup some stuff found by MSVC's /analyze
* Added some missing `noexcept`s on custom destructors.
* Fixed `std::move` being called on a const-reference.
* Initialized `ScopedMessage::m_moved` in class definition, instead
of doing so in constructors explicitly.
* Turned some `enum`s into `enum class`es.
* Initialized `StreamingReporterBase::currentTestCaseInfo` in class
definition.
* Some cleanups in SelfTest code.
2020-08-20 20:42:21 +02:00
Martin Hořeňovský
2e480b6e56
Use StringRef for CasedString::caseSensitivitySuffix return type 2020-08-18 21:02:34 +02:00
Martin Hořeňovský
e418e75c74
Turn CaseSensitive into proper enum class 2020-08-18 21:02:30 +02:00
Martin Hořeňovský
6a46b344c0
Split out CaseSensitive enum out of catch_common.hpp
Only very few places actually use it, so there is no need to have
it be central to everywhere.
2020-08-18 21:02:25 +02:00
Martin Hořeňovský
e7eb749815
Split the NonCopyable helper out of catch_common.hpp 2020-08-18 21:02:23 +02:00
Martin Hořeňovský
c1bb699d45
Remove superfluous catch_reporter_registrars.hpp includes from reporters
The includes were an artifact of the old design where the built-in
reporter TUs used autoregistration to add the reporters to the
factory. Because the current design is to add them explicitly in
the central reporter factory TU, the includes are useless.
2020-08-14 09:33:53 +02:00
Martin Hořeňovský
bf1e902ca1
Remove <algorithm> include from catch_commandline.cpp 2020-08-14 09:33:42 +02:00
Martin Hořeňovský
49b55d53e4
Prune includes in catch_run_context.cpp 2020-08-14 09:33:28 +02:00
Martin Hořeňovský
07fb96d42c
Don't include catch_random_number_generator.hpp in catch_session.cpp 2020-08-14 09:33:16 +02:00
Martin Hořeňovský
34d9a588bb
Cleanup includes in catch_list.cpp 2020-08-14 09:32:59 +02:00
Martin Hořeňovský
05d7014e75
ApproxMacher uses Approx's overloads for double directly
This saves a tiny little bit of compilation times when the
`ApproxMatcher` is used and `epsilon`, `margin`, or `scale` are
used to customize its behaviour.
2020-08-11 19:07:37 +02:00
Martin Hořeňovský
aa28a917cb
Turn UseColour into enum class 2020-08-11 17:47:54 +02:00
Martin Hořeňovský
b0531404e4
Turn RunTests into TestRunOrder enum class 2020-08-11 17:47:00 +02:00
Martin Hořeňovský
60cc4c293d
Turn ShowDurations into an enum class 2020-08-11 15:03:37 +02:00
Martin Hořeňovský
6dc8345261
IStreamingReporter::list* only uses IConfig instead of full Config
As the full `Config` is not needed, the TUs implementing the `list*`
functions can require the less heavy header `catch_interfaces_config.hpp`
instead of the much heavier `catch_config.hpp`.

This commit also fixes up some other TUs that include `Config`,
while using just `IConfig`, to cleanup the includes further.
2020-08-11 09:39:00 +02:00
Martin Hořeňovský
24b83edf8a
Clara cleanups
* Clara is now split between a header and a cpp file.
* Removed the deprecated `+` and `+=` operators for composing
  a parser.
* Renamed `clara` and `detail` namespaces to be inline with the
rest of Catch2 (they are now `Clara` and `Detail` respectively).
* Taken most of user-exposed types out of the `Detail` namespace
completely (instead of using `using` directives to bring them into
the outer namespace).
2020-08-10 20:30:40 +02:00
Martin Hořeňovský
b824d06844
Fixup missing transitive includes
Found after updating to newest MSVC...
2020-08-10 20:28:14 +02:00
Martin Hořeňovský
e7aa432850
Split TextFlow out from Clara
Now that it has its own header, various reporter TUs that want to
format text do not have to also include Clara. Together with
outlining implementations from a header into a separate TU, this
has noticeably improved the compilation times of the testing impl.

As part of this split, I also implemented some improvements to the
TextFlow code in comparison to the upstream code. These are:

* Replaced the `Spacer` type with a free function that constructs
special `Column` that does the same thing.
* Generic performance improvements, such as eliminating needless
allocations, reserving space in needed allocations, and using smarter
algorithms in some places.
* Because `Column` only ever stored 1 string in its vector, it now
holds the string directly instead.
2020-08-03 23:40:14 +02:00
Martin Hořeňovský
81aa2d5582
Replace ostringstream with ReusableStringStream in ConsoleReporter 2020-08-03 22:59:43 +02:00
Martin Hořeňovský
9d591f19ff
Allow explicitly setting ReusableStringStream's serialized data 2020-08-03 22:59:09 +02:00
Martin Hořeňovský
a4ac07d104
Split out default CATCH_CONFIG_CONSOLE_WIDTH into its own header
This means that code that uses it no longer has to include all of
catch_config.hpp, which seems to provide significant reduction in
size of unoptimized compilation of the final static library.
2020-08-03 22:57:43 +02:00
Martin Hořeňovský
8b0845b1a2
Split catch_config.hpp out of reporter bases 2020-07-30 08:46:07 +02:00
Martin Hořeňovský
c5037743e6
Avoid copying SectionInfo while construction Section 2020-07-29 21:51:10 +02:00
Martin Hořeňovský
9d6ac62aff
Remove unused member from Section 2020-07-29 21:51:08 +02:00
Martin Hořeňovský
ed0ea30149
Apply some IWYU suggestions
This is not nearly all of them, because IWYU does not support the
way Catch2 manages includes -- it expects that non-system includes
are done using `#include "foo/bar/baz.hpp"`, while Catch2 uses
`<foo/bar/baz.hpp>`. This causes trouble, because IWYU suggests
removing every single internal header, and then adding them again,
but using `""` in the include directive... the resulting suggestions
cannot be used without a lot of manual work, as they are largely
bogus.

For bonus points, IWYU also _loves_ to suggest kinda-random stdlib
headers for `size_t` and similar. Still, the resulting inclusion
graph is somewhat better than it was before.
2020-07-29 21:51:05 +02:00
Martin Hořeňovský
35098a62d8
Sanitize includes in random_number_generator.cpp
I have no idea how those got there, but now its dependency graph
is much saner.
2020-07-29 14:58:14 +02:00
Martin Hořeňovský
ba57c17310
Remove some extraneous includes from run_context.hpp 2020-07-29 14:54:55 +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ý
eaf7113fd3
Cleanup stdlib includes in reporter_bases.hpp 2020-07-29 12:50:51 +02:00
Martin Hořeňovský
d090074da7
Devirtualize handling of ReporterPreferences
The new scheme is that there is one protected member instance of
`ReporterPreferences` in the `IStreamingReporter` base class,
and derived classes can modify it to express their own preferences.

Retrieving the preferences is now a non-virtual operation, which
makes it much cheaper to read them frequently. Previously, we
avoided doing so by caching the preferences in another variable,
but we still read them at least once per test case run.
2020-07-28 09:24:57 +02:00
Martin Hořeňovský
d218d6f9e2
Avoid recalculating string-literal size on root tracker construction
This is a tiiiiiiny performance optimization, but it's free.
2020-07-27 20:08:44 +02:00
Martin Hořeňovský
ef92178058
Devirtualize nested tracker handling 2020-07-27 19:53:54 +02:00
Martin Hořeňovský
125d4b4164
Devirtualize test case registration 2020-07-27 08:49:49 +02:00
Martin Hořeňovský
c9b4867441
Move some impls of StreamingReporterBase members to .cpp file 2020-07-27 08:46:35 +02:00
Martin Hořeňovský
258cac63f8
Move impls of CumulativeReporterBase member functions to .cpp file
`catch_reporter_bases.hpp` turned out fairly expensive for parsing
when building the main library, and the significant amount of code
in headers likely doesn't help. Since the reason it is in the header
is legacy from CRTP reporter bases, moving as much of the
implementations to the .cpp file is free compilation perf.
2020-07-27 07:32:21 +02:00
Martin Hořeňovský
5f6990d746
Only start Section's timer if the duration will be used
This is a small potential runtime optimization on systems with
virtual syscalls, and a significant runtime optimization on systems
without.
2020-07-26 21:33:49 +02:00
Martin Hořeňovský
6b3c563c38
Remove pointless CompactReporter::getPreferences override 2020-07-26 14:07:19 +02:00
Gavin S
87d0197cbd
Update catch_reporter_tap.hpp
TAP format requires all results to be reported.
Removed extraneous preferences function (handled by parent)
Incorporated fix from 3d9e7db2e0
Simplified total printing
2020-07-26 14:00:10 +02:00
Martin Hořeňovský
4565b826cf
Modify generator tracking to allow GENERATEs between SECTIONs
This means that code such as

```cpp
TEST_CASE() {
    SECTION("first") { SUCCEED(); }
    auto _ = GENERATE(1, 2);
    SECTION("second") { SUCCEED(); }
}
```

will run and report 3 assertions, 1 from section "first" and 2
from section "second". This also applies for greater and potentially
more confusing nesting, but fundamentally it is up to the user to
avoid overly complex and confusing nestings, just as with `SECTION`s.

The old behaviour of `GENERATE` as first thing in a `TEST_CASE`,
`GENERATE` not followed by a `SECTION`, etc etc should be unchanged.

Closes #1938
2020-07-26 11:35:06 +02:00
Martin Hořeňovský
13917c44b4
--min-duration is overriden by -d no 2020-07-26 10:48:01 +02:00
John Bytheway
80b0d6975c
Add --min-duration option
A test runner already has a --durations option to print durations.
However, this isn't entirely satisfactory.

When there are many tests, this produces output spam which makes it hard
to find the test failure output.  Nevertheless, it is helpful to be
informed of tests which are unusually slow.

Therefore, introduce a new option --min-duration that causes all
durations above a certain threshold to be printed.  This allows slow
tests to be visible without mentioning every test.
2020-07-26 10:47:53 +02:00
George Rhoten
a25c1a24af
Fix for macOS on ARM 2020-07-24 22:34:22 +02:00
Ryan Pavlik
7f58840163
Add OverallResultsCases element to XML reporter 2020-07-24 22:30:28 +02:00
Martin Hořeňovský
b74996a29c
Devirtualize NameAndLocation query on trackers 2020-07-22 21:23:12 +02:00
Martin Hořeňovský
de53773e46
Fix copy paste error in 7-arg TEMPLATE_TEST_CASE_SIG implementation
Closes #1954
2020-07-22 21:18:52 +02:00
Matthias Blankertz
9221a6ff65
Hide std::exception_ptr and friends if exceptions disabled
Some compilers, e.g. the Green Hills C++ compiler, react badly to the
appearance of std::exception_ptr, std::current_exception,
std::rethrow_exception and std::uncaught_exception(s). To allow usage of
Catch2 with these compilers when exceptions are disabled, hide the usage
of std::exception_ptr etc. when compiling with
CATCH_CONFIG_DISABLE_EXCEPTIONS.
2020-07-22 21:18:47 +02:00
Martin Hořeňovský
657ebf5db2
Replace stray tabs with spaces 2020-07-22 20:46:58 +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
bogdasar1985
3ceaad7d66
fixing UB 2020-07-22 17:17:33 +02:00
Martin Hořeňovský
5c502320e8
Remove obsolete comment in UnorderedEquals vector matcher 2020-07-12 21:28:50 +02:00
Martin Hořeňovský
f3fe2dcb11
Add status attribute to JUnit's section reporting
This brings our output inline with GTest's. We do not handle skipped
tests properly, but that should be currently less important than
having the attribute exist with proper value for non-skipped tests.

Thanks @joda-01.

Closes #1899
2020-07-12 21:22:15 +02:00
Natsu
8b5f6e26d3
Fix compilation failure when using libstdc++10 (#1929)
The issue is caused by deleted `std::__detail::begin` declared in `bits/iterator_concepts.h`. This would be found by ADL, and because it is deleted, compilation would fail. This change makes it so that we SFINAE on `begin(std::declval<T>())` and `end(std::declval<T>())` being well-formed.
2020-07-12 21:01:49 +02:00
Billy Robert O'Neal III
c24f7e5b34
Fix invalid isspace call detected by PREfast
D:\vcpkg\toolsrc\include\catch2\catch.hpp(11285): warning C6330: 'char' passed as _Param_(1) when 'unsigned char' is required in call to 'isspace'.
D:\vcpkg\toolsrc\include\catch2\catch.hpp(11288): warning C6330: 'char' passed as _Param_(1) when 'unsigned char' is required in call to 'isspace'.

ISO/IEC 9899:2011:
"7.4 Character handling <ctype.h>"/1
[...] In all cases the argument is an int, the value of which shall be
representable as an unsigned char or shall equal the value of the macro
EOF. If the argument has any other value, the behavior is undefined.

This means if isspace was passed a character like ñ it could corrupt
memory without the static_cast to treat it as a positive value after
integral promotion (and C libraries commonly use the int index supplied
as a key into a table which result in out of bounds access if the
resulting int is negative).
2020-07-12 21:00:25 +02:00
Martin Hořeňovský
7dae3efad2
Silence clang-tidy's hicpp-vararg (alias of coreguidelines vararg)
Ideally, clang-tidy would be smart that if one alias of a warning
is suppressed, then the other one is suppressed as well, but as of
right now, it isn't. This means that for now we have to suppress
both aliases of this warning. Opened upstream issue to fix this:
https://bugs.llvm.org/show_bug.cgi?id=45859

Obviously, ideally clang-tidy would also not warn that we are calling
a vararg function when it is an unevaluated magic builtin, but that
also is not happening right now and I opened an issue for it:
https://bugs.llvm.org/show_bug.cgi?id=45860

Closes #1921
2020-07-12 20:59:29 +02:00
Corentin Jabot
a71721801e Remove extra semi-colons 2020-07-10 13:40:42 +02:00
Corentin Jabot
2cd5e70012 Silence a -Wsign-conversio warning in Clara under GCC 2020-07-09 12:24:25 +02:00
Martin Hořeňovský
392e44ec21
Minor refactoring of CompactReporter 2020-05-31 22:34:37 +02:00
Martin Hořeňovský
317145514f
Add op+(StringRef, StringRef) -> std::string 2020-05-31 22:30:41 +02:00
Martin Hořeňovský
f2b9508081
Remove last vestiges of shared ptr use with IConfig 2020-05-31 15:25:14 +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ý
41bbaa6d57
Implement a simplified variant of std::unique_ptr<T>
This simplified variant supports only a subset of the functionality
in `std::unique_ptr<T>`. `Catch::Detail::unique_ptr<T>` only supports
single element pointer (no array support) with default deleter.

By removing the support for custom deleters, we also avoid requiring
significant machinery to support EBO, speeding up instantiations of
`unique_ptr<T>` significantly. Catch2 also currently does not need
to support `unique_ptr<T[]>`, so that is not supported either.
2020-05-31 15:08:47 +02:00
Martin Hořeňovský
66ab942903
Refactor StreamEndStop slightly 2020-05-30 15:44:46 +02:00
Martin Hořeňovský
1356788ea8
Avoid using std::result_of when std::invoke_result is available 2020-05-21 22:58:33 +02:00
Martin Hořeňovský
21d284df34
Session now holds Config in unique_ptr instead of shared_ptr 2020-05-20 20:25:51 +02:00
Martin Hořeňovský
668454b36b
Do not share ownership of Config in RunContext 2020-05-20 20:25:49 +02:00
Martin Hořeňovský
458241cc90
Do not use shared_ptr<Config> when listing things 2020-05-20 20:25:48 +02:00
Martin Hořeňovský
fa160cf3f2
Keep reporter pointer around in TestGroup 2020-05-20 20:25:45 +02:00
Martin Hořeňovský
a17b9f754a
Remove unused function 2020-05-20 20:25:43 +02:00
Martin Hořeňovský
c2852c9944
Remove some uses of std::shared_ptr 2020-05-20 20:25:40 +02:00
Martin Hořeňovský
4394d3ae65
Translate exceptions by const reference instead of plain ref 2020-05-20 08:15:27 +02:00
Martin Hořeňovský
4b2f1da02a
Split CATCH_TRANSLATE_EXCEPTION into its own header
As far as I know, only a few users actually use it, but these changes
allow us to avoid including a surprising amount of code in the main
compilation path.
2020-05-20 08:15:11 +02:00
Martin Hořeňovský
0c6fda6e7d
Cleanup benchmark headers a tiny bit 2020-05-20 08:00:24 +02:00
Martin Hořeňovský
bad8b7c866
Fix make_shared used instead of make_unique 2020-05-20 07:15:21 +02:00
Martin Hořeňovský
54882dbb11
Don't include <tuple> everywhere in benchmarks 2020-05-20 07:09:15 +02:00
Martin Hořeňovský
b4a61cfd29
Remove superfluous overload of operator== 2020-05-18 21:32:08 +02:00
Martin Hořeňovský
d86834e5b5
Push down #include <ostream> to .cpp files 2020-05-18 21:31:41 +02:00
Martin Hořeňovský
39e093021c
Remove some superfluous includes 2020-05-18 20:55:21 +02:00
Martin Hořeňovský
29d4b3768c
Add Wsuggest-override to warning flags 2020-05-13 16:09:34 +02:00
Martin Hořeňovský
03ef6b9f9a
Explicitly default smfs when relevant to avoid Wdeprecated-copy-dtor 2020-05-12 23:56:34 +02:00
Martin Hořeňovský
579dcd1a76
Ignore Wdeprecated for Clara 2020-05-12 23:56:24 +02:00
Martin Hořeňovský
eb267b424b
Tap reporter changes 2020-05-12 23:56:23 +02:00
Martin Hořeňovský
2528247351
Delete Capturer's smf
As part of `-Wdeprecated-copy-dtor` sweep, I noticed that Capturer's
copies are defaulted. Given that the class would likely break horribly
in the event of actual copy happening, they are now deleted.
2020-05-12 23:56:08 +02:00
Martin Hořeňovský
f56832d3ea
Add Catch2::Catch2 alias for Catch2 CMake target 2020-05-11 20:05:10 +02:00
Martin Hořeňovský
601ca1c670
Refactor some uses of virtual -> override 2020-05-11 16:34:55 +02:00
Martin Hořeňovský
a39154e115
Do not explicitly default smfs if all of them are defaulted 2020-05-11 00:00:55 +02:00
Martin Hořeňovský
7c622a79d4
Unvirtual bunch off destructors of simple data classes 2020-05-10 23:57:05 +02:00
Martin Hořeňovský
04cbbb8a4b
Replace getLineOfChars with non-templated, runtime version 2020-05-10 23:52:38 +02:00
Martin Hořeňovský
f64487bf70
Move LazyExpr's and MessageInfo's implementation to the combined TU
Some of the implementations were inlined instead.
2020-05-10 20:21:04 +02:00
Martin Hořeňovský
27f1756d8e
Split out LazyExpr into its own header
This enables us to avoid `catch_reporter_bases.hpp` being indirectly
dependent on `catch_tostring.hpp`, cutting apart quite a bit indirect
inclusions.
2020-05-10 20:21:02 +02:00
Martin Hořeňovský
824ffe6525
Inline and default LazyExpression's constructor 2020-05-10 20:20:59 +02:00
Martin Hořeňovský
d5e08a4beb
Rename catch_assertionhandler -> catch_assertion_handler 2020-05-10 20:20:56 +02:00
Martin Hořeňovský
ed967fd7fc
Split MessageInfo into its own header
This is first step towards splitting apart reporter implementation
and `catch_string.hpp`.
2020-05-10 20:20:52 +02:00
Martin Hořeňovský
7030d7740d
Remove some superfluous includes from reporters 2020-05-10 20:20:47 +02:00
Martin Hořeňovský
7efbc83ae0
Introduce combined TUs for compiling small TUs
This should improve the compilation times by decreasing the number
of TUs compiled, without making overly big TUs that would cause
problems with heavy-tailed compilation times.

There is one "combined TU" for the top level part, and each subpart,
except for Reporters, which currently do not have any trivial TUs.
2020-05-10 15:37:29 +02:00
Martin Hořeňovský
9e498278be
Move StringRef header to internals 2020-05-10 10:09:01 +02:00
Martin Hořeňovský
14533f5bb6
Make Colour's op<< hidden friend 2020-05-10 07:32:40 +02:00
Martin Hořeňovský
895d0a0696
Small improvements for StringRef
* `operator[]` is constexpr
* `operator<<` and `operator+=` are hidden friends
2020-05-10 07:22:11 +02:00
Martin Hořeňovský
094d840efe
Cleanup SourceLineInfo implementation
Special member functions are now implicit, which should make them
both noexcept and constexpr. The `operator<<` has been made into
hidden friend as per best practices.
2020-05-10 06:57:02 +02:00
Martin Hořeňovský
a595066ff9
Use internal linkage for float stringification helper 2020-05-10 06:54:23 +02:00
Martin Hořeňovský
cb25c4a8a3
Reinline some StringMaker impls 2020-05-09 21:26:42 +02:00
Martin Hořeňovský
b93cf932fb
Use UDLs to construct StringRefs for decomposed operators directly 2020-05-09 21:07:55 +02:00
Martin Hořeňovský
eef6c9b79b
Microopt: stream single char instead of single char string 2020-05-09 21:02:12 +02:00
Martin Hořeňovský
b5a287f09f
Make rest of the generators final 2020-05-09 20:56:25 +02:00
Martin Hořeňovský
e1a0cce82b
Remove Clara from external folder
As Clara is no longer maintained as a separate project, the
implementation was moved to the internal subfolder of top-level
folder. This removes one folder and avoids potential user confusion.

Also simplified the convenience header checking script accordingly.
2020-05-09 19:40:57 +02:00
Martin Hořeňovský
75b711a360
Fix ODR violation because of name clash in matchers 2020-05-09 18:00:51 +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ý
e78b4f6be7
Remove file list checking from CMake
I do not think we need a safeguard against not including files in
CMake anymore, and as it is, it caused annoying false positive about
the default main implementation.
2020-05-06 21:23:13 +02:00
Martin Hořeňovský
6020f8f27c
Add convenience headers that include all headers in a subpart
The naming scheme is simple, to include all matchers, include header
`catch2/matchers/catch_matchers_all.hpp`. To include **everything**,
include `catch2/catch_all.hpp`.
2020-05-06 11:21:46 +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ý
5b8cccaf6a
Add support for bitwise xor to the decomposer 2020-05-03 07:52:47 +02:00
Martin Hořeňovský
53434a2f32
Support bitand and bitor in REQUIRE/CHECK
This means that bit-flag-like types with conversion to bool can be
asserted on, like so `REQUIRE(var & Flags::AddNewline)`.
2020-05-03 07:45:04 +02:00
schallerr
2a93a65bc2
Support custom allocators in vector Matchers (#1909)
-- Combined with f4fc2dab2c
   during cherry-picking.
2020-05-03 07:40:04 +02:00
Martin Hořeňovský
bbbc7a0d7f
Fix CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTION interaction with feature macro 2020-05-01 20:26:40 +02:00
John Else
1bd7cac09f
Use macro to determine whether std::uncaught_exceptions is available
Catch assumes std::uncaught_exceptions is available whenever C++17 is
available, but for macOS versions older than 10.12 this is not the case.

Instead of checking the C++ version, use a macro to check whether the
feature is available.
2020-05-01 14:45:56 +02:00
John Bytheway
26b2c3e7e2
Change random test shuffling technique (refactored)
Previously a random test ordering was obtained by applying std::shuffle
to the tests in declaration order.  This has two problems:

- It depends on the declaration order, so the order in which the tests
  will be run will be platform-specific.
- When trying to debug accidental inter-test dependencies, it is helpful
  to be able to find a minimal subset of tests which exhibits the issue.
  However, any change to the set of tests being run will completely
  change the test ordering, making it difficult or impossible to reduce
  the set of tests being run in any reasonably efficient manner.

Therefore, change the randomization approach to resolve both these
issues.

Generate a random value based on the user-provided RNG seed.  Convert
every test case to an integer by hashing a combination of that value
with the test name.  Sort the test cases by this integer.

The test names and RNG are platform-independent, so this should be
consistent across platforms.  Also, removing one test does not change
the integer value associated with the remaining tests, so they remain in
the same order.

To hash, use the FNV-1a hash, except with the basis being our randomly
selected value rather than the fixed basis set in the algorithm.  Cannot
use std::hash, because it is important that the result be
platform-independent.
2020-05-01 12:32:38 +02:00
Martin Hořeňovský
87a8b61d5a
Fix bug in test spec parser handling of escaping in ORed patterns
It did not clear out all of its internal state when switching from
one pattern to another, so when it should've escaped `,`, it took
its position from its position in the original user-provided string,
rather than its position in the current pattern.

Fixes #1905
2020-05-01 09:56:34 +02:00
Andrew Gaspar
ca27b0dcc5
Remove usage of __builtin_constant_p under IBM XL 2020-05-01 09:31:59 +02:00
Moritz Haase
87c8055176
Suppress clang-tidy warning about vararg usage in assertion macros
CATCH_INTERNAL_IGNORE_BUT_WARN() introduced with b7b346c triggers
clang-tidy warning 'cppcoreguidelines-pro-type-vararg' for every usage
of assertion macros like CHECK() and REQUIRE(). Silence it via NOLINT
in the '#if defined(__clang__)' block only, as clang-tidy honors those.
2020-05-01 09:31:48 +02:00
pi1024e
02a998598c
C-header updates 2020-05-01 09:30:50 +02:00
Joel Uckelman
beb8c3a99d
Fixed typo in "benchmark name" column width calculation. Closes #1885. 2020-05-01 09:30:17 +02:00
Martin Hořeňovský
5198fd3c9a
Fix compilation error when lambdas are used in assertions
This is a partial revert of b7b346c3e5.
2020-05-01 09:24:26 +02:00
Martin Hořeňovský
95a2e54702
Different approach to proper colouring of filters 2020-04-29 21:28:25 +02:00
Till Hofmann
6badd7d9ed
Switch back to uncolored output after printing filters
After printing the list of filters, switch back from yellow to black
before printing a newline to avoid the remaining output to be colored in
yellow.
2020-04-29 21:28:18 +02:00
Martin Hořeňovský
60cfaa38fb
Make warnings in assertions fire for GCC/Clang again
The old code caused warnings to fire under MSVC, and Clang <3.8.
I could not find a GCC version where it worked, but I assume that it
did at some point.

This new code causes all of MSVC, GCC, Clang, in current versions,
to emit signed/unsigned comparison warning in test like this:

```cpp
TEST_CASE() {
    int32_t i = -1;
    uint32_t j = 1;
    REQUIRE(i != j);
}
```

Where previously only MSVC would emit the warning.

Fixes #1880
2020-04-29 21:27:57 +02:00
khyperia
efbfaa1704
Don't cast nanoseconds to integers when writing output 2020-04-29 16:54:46 +02:00
khyperia
c4e5b05cfc
include <iterator> in catch_stats.hpp
needed for std::back_inserter on some platforms
2020-04-29 16:54:39 +02:00
Martin Hořeňovský
0fdeb10c65
Cleanup how configuration-dependent test macros are defined 2020-04-29 15:36:40 +02:00
Martin Hořeňovský
783ab5ef87
Move around message macros and implementation 2020-04-29 14:02:53 +02:00
Martin Hořeňovský
8d50f04419
Move around matcher macro implementation 2020-04-26 21:33:55 +02:00
Martin Hořeňovský
804e2df099
Move Benchmarking macros to catch_benchmark.hpp 2020-04-26 19:24:36 +02:00
Martin Hořeňovský
0470794a68
Split TEMPLATE_TEST* macros into their own set of files
These files are not included by the default
`#include <catch2/catch_test_macros.hpp>` path, so that users do
not have to pay for them if they do not use them. Follow up is to
split out the small part of `catch_preprocessor.hpp` used by the
default test macros (AFAIK, it is just `INTERNAL_CATCH_REMOVE_PARENS`
macro), so that it is not included by the default path either.

Also fixes #1892 by providing the missing macros.
2020-04-26 16:25:43 +02:00
Martin Hořeňovský
5150fa4476
Rename catch_capture.hpp to more descriptive catch_test_macro_impl.hpp 2020-04-26 13:32:17 +02:00
Martin Hořeňovský
c078373f3f
Rename internal macro for suppression of unused variable warnings 2020-04-25 18:13:17 +02:00
Martin Hořeňovský
517839fb3f
Small cleanup of fatal condition handler 2020-04-25 14:07:50 +02:00
Martin Hořeňovský
c5ec936a72
Inline TagAlias constructor
It is trivial enough that the function call is not worth it, and
lets us remove one TU from compilation.
2020-04-24 21:09:10 +02:00
Martin Hořeňovský
8d44c2450c
Add some explanatory comments to ErrnoGuard 2020-04-24 21:04:54 +02:00
Martin Hořeňovský
7c97554565
Remove Obj-C(++) support 2020-04-24 20:42:52 +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ý
3836aa9ceb
Remove catch_user_interfaces
It used to be a file that would collect interfaces we always wanted
to provide to users, so that the single header stitching script
would place them in the common part of the single header version.

As v3 is moving to separate headers model, the file is no longer
useful.
2020-04-24 15:34:12 +02:00
Martin Hořeňovský
3f2ada03d5
Remove unused catch_impl.hpp header
It became useless when we moved away from the single-header model,
because it was used an entry point for stitching CPP into the single
header file.
2020-04-24 14:25:33 +02:00
Martin Hořeňovský
7892954c99
Remove global warning manipulation headers
They were unused except for one test file anyway.
2020-04-05 19:14:16 +02:00
Martin Hořeňovský
54a7eb1aed
Rename reporters to use .hpp suffix
I want to standardize _all_ of Catch2 headers on the `.hpp` suffix.
2020-04-05 19:10:57 +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ý
a25d83d8c4
Matcher type flattening overloads of && and || are now hidden friends 2020-03-29 14:03:29 +02:00
Martin Hořeňovský
f7d7aa9eb2
Fix and extend tests for composing generic matchers 2020-03-29 14:03:12 +02:00
Martin Hořeňovský
ca5af2e85b
Cleanup vector matchers
Once again, added doxygen comments and removed the inner-most namespace.
2020-03-28 15:17:12 +01:00
Martin Hořeňovský
904c47a634
Cleanup string matchers
Removed nested `StdString` namespace and added Doxygen comments.
Also renamed some matchers to avoid colisions now that there are
less separate namespaces for matchers to go to. Since this is a
breaking release anyway, it shouldn't matter, and the factory
functions that the users should use remain the same anyway.
2020-03-28 15:15:31 +01:00
Martin Hořeňovský
afc8b28c07
Cleanup for floating point matchers
Removed the `Floating` nested namespace and added Doxygen comments
for the factory methods.
2020-03-28 12:48:19 +01:00
Martin Hořeňovský
a6baa6dda6
Cleanup in exception matchers
No more nested namespace for the matcher, and there is now a doxygen
explanatory comment on the factory function.
2020-03-28 11:06:14 +01:00
Martin Hořeňovský
5c9367d4f1
Small cleanup for PredicateMatcher
Removed the `generic` nested namespace, so PredicateMatcher now
lives in `Catch::Matchers` namespace, just like other matchers.
Also cleaned up and doxygenized comments on the `Predicate` factory
function for `PredicateMatcher`.
2020-03-27 14:56:33 +01:00
Martin Hořeňovský
ab0ca2f566
Rename some matcher-related files
The two changes are
`catch_matchers_templates` -> `catch_matchers_templated` and
`catch_matchers_generic` -> `catch_matchers_predicate`. The former
is mostly cosmetic, but the second was previously significantly
misleading, and as the library is now to be consumed by including
specific headers, this needed to be fixed.
2020-03-27 10:24:08 +01:00
Martin Hořeňovský
3a3efebd16
Add IsEmpty and SizeIs matchers for ranges/containers
`SizeIs` can accept both `size_t` and a matcher. In the first case,
it checks whether the size of the range is equal to specified size.
In the second case, it checks whether the provided matcher accepts
the size of the range.
2020-03-27 10:24:08 +01:00
Martin Hořeňovský
f52a58e857
Make concrete matchers final
Outside of `MatcherBase` and `GenericMatcherBase`, matchers are not
designed to be overriden. This means that doing so can easily lead
to errors, and matchers are generally fairly simple functionality-wise.
so there is not much code reuse to be gained anyway.

Thus, Catch2-provided concrete matchers are now final.
2020-03-27 10:22:25 +01:00
Martin Hořeňovský
007efc173a
Add generic Contains matcher
It matches a range iff the range contains a specific element,
or an element in the range matches the provided matcher.
2020-03-27 10:22:25 +01:00
Martin Hořeňovský
89e857349b
Use _t form of traits 2020-03-27 10:22:25 +01:00
Martin Hořeňovský
c2daf468bb
Standardize matcher headers to use .hpp suffix 2020-03-27 10:22:25 +01:00
Martin Hořeňovský
a15ffb735d
Make ListeningReporter final
In general, for Catch2 v3 we are making virtual types `final`,
unless they were explicitly designed to be derived-from.
`ListeningReporter` is definitely not designed to be derived-from.
2020-03-09 21:15:30 +01:00
Martin Hořeňovský
727b26ab35
Remove IStreamingReporter::isMulti query
This was previously used to avoid `dynamic_cast` inside our code,
when we were creating more than one reporter, or a reporter
together with listeners. However, since then the offending code
was refactored to be smarter instead, and this query member function
is no longer needed nor used.
2020-03-09 21:07:32 +01:00
Martin Hořeňovský
9de6eae6bb
ConsoleReporter no longer creates a string when writing time units
This is minor perf improvement only, but it is free and trivial.
2020-03-08 14:04:35 +01:00
Martin Hořeňovský
33b47f7309
Fix warnings from stringifying functions
The only way to stream those is to use the `bool` overload of `op<<`.
However, to convert a function to bool, GCC creates AST equivalent
of `A? true : false`. Then, because `A` is a function, it warns that
it will never be `false`. 🤦

As a bonus, newer GCC versions issue _two_ different warnings about
this, but older GCC versions do not know both of them, so we also
have to suppress warning about unknown warning suppression.
2020-02-26 16:07:41 +01:00
Martin Hořeňovský
8d1e7ca896
Suppress unused variable warning for template test cases
The variable initialization has test registration as a side-effect,
but as far as GCC is concerned, the variable itself is unused.
Because the macro substitution always happens at global scope, we
cannot use cast to `void` as is usually done.
2020-02-26 16:07:39 +01:00
Martin Hořeňovský
e601a5dc4f
Suppress empty-variadic macros warning under GCC 2020-02-26 16:07:36 +01:00
Martin Hořeňovský
e9caeb7d0b
Fix Wparentheses for GCC
Sadly most versions still cannot properly handle the suppression
via `_Pragma`, so it has to leak to the users when they use older
GCC versions to compile their code
2020-02-26 16:07:34 +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
Martin Hořeňovský
50b2cfa5de
Fix -Wmissing-braces in new matchers 2020-02-21 23:10:34 +01:00
Martin Hořeňovský
34e7a5e0cf
Bunch of warning fixes 2020-02-21 23:10:22 +01:00
Martin Hořeňovský
04f18d996b
Suppress global constructor warning in benchmarking 2020-02-21 23:10:12 +01:00
Martin Hořeňovský
3bb9fcd916
Remove trailing semi in REGISTER_TEST_CASE 2020-02-21 23:10:01 +01:00
Martin Hořeňovský
c3013a6251
Move matcher implementation to their own subfolder
In the future we can expect many more matchers, so let's give them
a place to live.

Also moved matcher-related internal files to `internal` subfolder.
Ideally we should sort out all of our source code, but that will
have to come later.
2020-02-20 17:42:11 +01:00
Martin Hořeňovský
40e35d4318
Reorganize base headers for matchers 2020-02-20 13:39:04 +01:00
Martin Hořeňovský
b83a12b12c
Replace enable_if with enable_if_t 2020-02-20 13:03:38 +01:00
Martin Hořeňovský
d33af93e17
Cleanup visibility in generic not matcher 2020-02-20 13:03:36 +01:00
Martin Hořeňovský
25c5ae240c
Disable copies on generic matcher combinators 2020-02-20 13:03:34 +01:00
Martin Hořeňovský
260263b9bf
Combined matchers are now final 2020-02-20 13:03:32 +01:00
Martin Hořeňovský
cf6575576f
Start fixing up Matchers: namespaces, composition ops
This commit also forbids composing lvalues of composed matchers, as
per previous deprecation notice. I do not expect this to be contentious
in practice, because there was a bug in that usage for years, and
nobody complained.
2020-02-20 13:03:30 +01:00
Martin Hořeňovský
ae1d21315c
Specialize CATCH_TRAP() for iOS + thumb instruction set combo
Fixes #1862
2020-02-16 16:11:29 +01:00
Tristan Stenner
6a2c025bfc
Add command line option 'never' to --wait-for-keypress (#1866)
Co-authored-by: Martin Hořeňovský <martin.horenovsky@gmail.com>
2020-02-16 16:11:11 +01:00
Martin Hořeňovský
f8794634c2
Fix significant bug with storing composed matchers
Given that in the 2 or so years that matchers are thing nobody complained,
it seems that people do not actually write this sort of code, and the
possibility will be removed in v3. However, to avoid correctness bugs,
we will have to support this weird code in v2.
2020-02-16 16:02:31 +01:00
Martin Hořeňovský
d6b2a3793b
Check for Windows instead of WIN32 for wmain entry point
Closes #1849
2020-02-16 15:54:24 +01:00
Martin Hořeňovský
548de655fd
Cleanup nextafter workaround 2020-02-16 15:52:14 +01:00
khyperia
3c7e737a7b
Allow configuring of benchmark warmup time 2020-02-16 15:44:23 +01:00
khyperia
e880da93bd
Make CATCH_BREAK_INTO_DEBUGGER be user-configurable 2020-02-16 15:27:21 +01:00
Rosen Penev
3e01d4b239
catch_compiler_capabilities.h: use proper math define
C++11 math requires _GLIBCXX_USE_C99_MATH_TR1 to be true with gcc/clang.

Also fixes an issue with uClibc-ng where __UCLIBC__ is defined in features.h but
that is not included here and is thus no-op.
2020-02-16 15:27:04 +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
Daniel Griscom
ab520f4e97
Removed unneeded 'using uchar = unsigned char' 2020-02-16 15:12:07 +01:00
melak47
17c4b2d093
Feature: generic matchers (#1843)
This commit extends the Matchers feature with the ability to have type-independent (e.g. templated) matchers. This is done by adding a new base type that Matchers can extend, `MatcherGenericBase`, and overloads of operators `!`, `&&` and `||` that handle matchers extending `MatcherGenericBase` in a special manner.

These new matchers can also take their arguments as values and non-const references.

Closes #1307 
Closes #1553 
Closes #1554 

Co-authored-by: Martin Hořeňovský <martin.horenovsky@gmail.com>
2020-02-16 11:19:10 +01:00
Martin Hořeňovský
db1a0465dc
Outline GeneratorException from generators header 2020-02-14 16:15:47 +01:00
Martin Hořeňovský
b009d190bf
Avoid detecting Clang as having MSVC's traditional preprocessor
Fixes #1806
2020-02-13 16:28:30 +01:00
ptc-tgamper
ac83087bc2
catch_debugger.h - implement break into debugger assembler instructions for iOS 2020-02-13 16:28:02 +01:00
ptc-tgamper
123b449f8d
catch_console_colour.cpp - adjust useColourOnPlatform for iOS 2020-02-13 16:27:56 +01:00
ptc-tgamper
6ad743a62b
catch_debugger.cpp - debugger detection is identical on Mac OS X and iOS 2020-02-13 16:27:46 +01:00
Martin Hořeňovský
0f47fe16bd
Provide const overload of ObjectStorage::stored_object()
Fixes #1820
2020-02-13 16:26:06 +01:00
Joe Burzinski
82baef62e2
Fix forwarding in SingleValueGenerator and generator creation
Fixes #1809
2020-02-13 16:19:50 +01:00
Joe Burzinski
0fbf4f3e15
Fix wrong namespacing of benchmarking constructor helpers 2020-02-13 16:15:50 +01:00
Martin Hořeňovský
ad3f50bbc1
Suppress using-namespace lint in GENERATE* macros
Closes #1799
2020-02-13 15:31:09 +01:00
Martin Hořeňovský
2945b80f61
Add more constexpr to StringRef 2020-02-13 15:01:03 +01:00
Martin Hořeňovský
c50ba09cde
Split [.foo] into [.][foo] when parsing test specs
b77cec05c0 fixed this problem for tagging tests, so that a test
case tagged with `[.foo]` would be parsed as tagged with `[.][foo]`.
This does the same for the test spec parsing.

Fixes #1798
2020-02-13 13:35:10 +01:00
Martin Hořeňovský
c165bd15c5
Forbid copying ReusableStringStream
Copying a `ReusableStringStream` would lead to "double free" of
the stream, and thus it could be used in multiple places at the
same time, breaking the output.
2020-02-12 19:21:15 +01:00
cericks0n
4f0de7bbad
Fix error when period of steady_clock is not nano
On systems where std::chrono::steady_clock::period is not std::nano, benchmark tests fail to compile due to trying to convert analysis.samples from a vector of duration<double, clock::period> to a vector of std::chrono::duration<double, std::nano>.
2020-02-12 19:20:41 +01:00
Martin Hořeňovský
21b24e8326
Remove catch_external_interfaces.h
Its intent was to show which headers are expected to be useable by
Catch2's users, and to enforce their inclusion in the single header
distribution at the right place.

Given the new library model, the second use case is not needed and
the first one is better served with documentation and physical file
layout.
2020-02-12 16:57:15 +01:00
Martin Hořeňovský
0b2874b6b1
Move SonarQube reporter implementation to a cpp file 2020-02-07 11:26:33 +01:00
Martin Hořeňovský
e6ea53ab49
Move Automake reporter to a cpp file 2020-02-07 11:26:30 +01:00
Martin Hořeňovský
338572a4f7
Move TAP reporter implementation to a cpp file 2020-02-07 11:26:28 +01:00
Martin Hořeňovský
70836d49ba
Move include of catch_enforce out of the reporter bases 2020-02-07 11:26:24 +01:00
Martin Hořeňovský
db148c42d7
Move TeamCity implementation to a cpp file 2020-02-07 11:26:21 +01:00
Martin Hořeňovský
cd7d7a1c67
Remove CATCH_CONFIG_ENABLE_BENCHMARKING compilation toggle
Now that Catch2 is a proper library, we can always build the full
library (comparatively minor slowdown) and the user can avoid
including benchmarking headers to avoid the compilation slowdown.
2020-02-06 11:36:46 +01:00
Martin Hořeňovský
bce5b364d3
Unconditionally provide <chrono> StringMakers 2020-02-03 20:53:36 +01:00
Martin Hořeňovský
c3a5e21648
Move Approx out of the Detail namespace 2020-02-03 15:14:59 +01:00
offa
bd9520c0f9 GCC pragma fixed. 2020-02-03 09:27:34 +01:00
Martin Hořeňovský
3b297cf9b5
Outline Config destructor to avoid including superfluous header 2020-02-02 14:43:26 +01:00
Martin Hořeňovský
66fe591477
Replace C++11 use of ::type with the _t suffix for std traits 2020-02-02 12:59:19 +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ý
ddd0e7218d
Remove the !hide special tag 2020-01-28 20:48:32 +01:00
Martin Hořeňovský
d0257fc1ff
Do not use shared_ptrs for filters and patterns 2020-01-25 20:39:17 +01:00
Martin Hořeňovský
df2379218b
Reduce the use of shared_ptrs for various Config objects
Ideally they would not be used at all, but the main config lifetime
is a weird mess right now and will require further refactoring.
2020-01-25 17:41:38 +01:00
Martin Hořeňovský
7134ad9913
Replace shared_ptr with unique_ptr for reporters 2020-01-25 14:07:29 +01:00
Martin Hořeňovský
2f4a7dda68
Have the in-development version report as v3.0.0
Because some of the tooling used by Catch2 does not properly support
version postfixes, such as `preview-1`, we will report the
in-development version is `v3.0.0`, and the first real release will
have to be `v3.0.1`.

Closes #1824
2020-01-25 09:15:46 +01:00
Martin Hořeňovský
6c3a5ef625
Remove CATCH_CONFIG_DISABLE_MATCHERS
Now that the recommended distribution and usage method is proper
library, users can just avoid including the matcher headers to get
basically the same effect.
2020-01-25 09:07:36 +01:00
Martin Hořeňovský
26f78f96aa
Start using piecemeal includes in test files 2020-01-21 10:03:54 +01:00
Martin Hořeňovský
c381b49c60
Split the test macros into their own file 2020-01-19 16:01:50 +01:00
Martin Hořeňovský
acf975cab1
Separate version macros to its own header 2020-01-19 15:39:11 +01:00
Martin Hořeňovský
4005d87460
Use proper linkage between Catch2Main and Catch2 2019-12-18 20:14:34 +01:00
Martin Hořeňovský
0c62a50392
Add the catch_main source file 2019-12-18 18:02:57 +01:00
Martin Hořeňovský
1cc05122d7
Add Catch2Main CMake target that contains test main 2019-12-18 17:25:04 +01:00
Martin Hořeňovský
add7068f21
Fixup installation 2019-12-16 22:33:56 +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ý
8b42acc328
Reintegrate extra tests 2019-12-09 10:04:26 +01:00
Martin Hořeňovský
29b441949c
Port the last example 2019-12-08 20:58:52 +01:00
Martin Hořeňovský
248f922465
Cleanup impl and main from the main header 2019-12-08 11:31:47 +01:00
Martin Hořeňovský
82cc5bc034
Rewrite includes inside the library to use <catch2/> form 2019-12-02 12:04:55 +01:00
Martin Hořeňovský
fef4f217b1
Unit tests build and run (todo: projects, includes, extras) 2019-11-30 20:45:34 +01:00
Martin Hořeňovský
e341b11467
WIP: CMake changes to build static lib + tests separately 2019-11-30 17:41:41 +01:00
Martin Hořeňovský
4385951a55
Move files into catch2/ subdir 2019-11-30 17:30:32 +01:00
Martin Hořeňovský
7c6de33977
Fixed up include paths 2019-11-30 17:13:22 +01:00
Martin Hořeňovský
e1a43b5b0f Move files from internal/ up a level 2019-11-30 12:23:37 +01:00
Martin Hořeňovský
8e56b8b0ec Rename include/ to src/ 2019-11-30 12:17:16 +01:00