Commit Graph

267 Commits

Author SHA1 Message Date
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