Commit Graph

1373 Commits

Author SHA1 Message Date
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ý b77cec05c0
Fix test tag parsing to split [.foo] into [.][foo] 2019-03-29 10:48:56 +01:00
Omer Ozarslan 54089c4c8c Deducing return type of map generator helper (#1576)
* Deduce map return type implicitly

Giving the first template argument to map generator function to deduce
return type is now optional even if the return type is different from
the type generated by mapped generator.
2019-03-24 15:44:22 +01:00
Alex Alabuzhev 0531965349
Suppress warning caused by ntstatus.h inclusion 2019-03-19 23:57:56 +00:00
Martin Hořeňovský d633072794
v2.7.0 2019-03-07 21:44:57 +01:00
Omer Ozarslan 99575b45db Add unscoped info functionality
This adds UNSCOPED_INFO macro, creating a log message that is stored
until the end of next assertion or the end of test case, whichever comes
first. These messages are not scoped locally, unlike messages created by
INFO macro.
2019-03-06 22:04:35 +01:00
SimonChh 7d2451f119 Fix output redirection in failing tests (#1525)
Fixes #1514
2019-03-02 21:18:48 +01:00
Martin Hořeňovský 29b3b7ae6b
Namespace our type traits in catch_meta
Previously they could conflict with user-defined type traits that
were in the global namespace.

Fixes #1548
2019-02-23 21:06:20 +01:00
Martin Hořeňovský 693647c43f
Add ChunkGenerator
This generator collects values from the underlying generator until it
has a specified amount of them, and then returns them in one "chunk".
In case the underlying generator does not have enough elements for
a specific chunk, the left-over elements are discarded.

Closes #1538
2019-02-23 20:28:58 +01:00
Martin Hořeňovský 288387fa10
Cleanup: move things around 2019-02-23 17:16:28 +01:00
Rick de Water 165de9b072 Add RangeGenerator 2019-02-23 16:58:34 +01:00
Martin Hořeňovský 269303d9d9
Introduce random number (Integral and Float) generators 2019-02-20 00:09:15 +01:00
Khem Raj e8bfd882e8 Fix -Wdefaulted-function-deleted warning
Clang8 warns

catch_interfaces_reporter.h:84:25: error: explicitly defaulted move assignment operator is implicitly deleted [-Werror,-Wdefaulted-function-deleted]
|         AssertionStats& operator = ( AssertionStats && )     = default;
|                         ^

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2019-02-18 20:42:42 +01:00
Paul Lesur 2bd0722470 fix "code will never be executed" under clang 2019-02-18 19:01:43 +01:00
Igor Akhmetov 45ebf17ec7 Do not open the output file twice
7f229b4f caused the output file to get opened twice, while
some types of files (e.g. named pipes) can be only opened once.

After this change Session::applyCommandLine opens the output file
only when there is an error to print.
2019-02-18 18:59:54 +01:00
Martin Hořeňovský 093b72416d
Remove non-ASCII characters from the distributable parts
Closes #1542
2019-02-18 10:33:41 +01:00
Tobias Ribizel c99a346490 Use correct type name instead of index for TEMPLATE_PRODUCT_TEST_CASE (#1544)
Previously, for a TEMPLATE_PRODUCT_TEST_CASE("Test" ..., T, (P1, P2)),
the generated test case names were

  Test - 0
  Test - 1

With this commit, the correct typename is used:

  Test - T<P1>
  Test - T<P2>

-----------

MSVC needs another indirection to evaluate INTERNAL_CATCH_STRINGIZE
and also inserts a space before theINTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS
parameter, which we can get rid of by pointer arithmetic.
2019-02-17 21:52:22 +01:00
Martin Hořeňovský dbbab8727c
v2.6.1 2019-02-12 19:58:12 +01:00
Jozef Grajciar 7f229b4ff1 fix SEGFAULTs
issue was that mutable context had no config thus trying to get stream
caused SEGFAULT

Closes #1533, #1534
2019-02-08 10:41:23 +01:00
Martin Hořeňovský d75e9b3c0f
v2.6.0 2019-01-31 22:32:55 +01:00
Robin Moussu 16dc219704 Add to string for std::optional 2019-01-31 15:35:13 +01:00
Martin Hořeňovský 5929d9530c
Add generic generator modifiers
This means mutiple generic generators and some inference helper
* take(n, generator)
* filter(predicate, generator)
* map(func, generator)
* repeat(generator, repeats)
2019-01-31 10:43:15 +01:00
Martin Hořeňovský e46a70f829
Redo generator interface 2019-01-31 10:43:06 +01:00
Martin Hořeňovský 64a9c02315
Remove obsolete IndexTracker 2019-01-29 14:45:52 +01:00
Robin Moussu 50fefd059a fix variant detection with non-clang compiler 2019-01-26 18:35:14 +01:00
Martin Hořeňovský d9e99dc2ca
Improve explanation of why -Wparentheses suppression leaks
Related to #1508
2019-01-25 21:29:12 +01:00
Jozef Grajciar 899c5ed3df Console Colour: fix compilation 2019-01-19 23:12:54 +01:00
Martin Hořeňovský 084b1d5fe6
Fix colourized output to file
This change should be backwards compatible, but it would be better
to make the console colour API take an argument in the long term.

Fixes #1502
2019-01-19 13:32:39 +01:00
Martin Hořeňovský 61e1ea9185
Merge pull request #1492 from Lotterleben/fix_1394
fix #1394: avoid superfluous re-run when specific section is selected
2019-01-18 16:46:40 +01:00
Lotte Steenbrink d084162b2f Avoid superfluous re-run when specific section is selected
Fixes #1394
2019-01-18 15:13:40 +01:00
Martin Hořeňovský 75200b462c
Change CATCH_BREAK_INTO_DEBUGGER to always expand into a function call
This avoids -Wextra-semi-stmt warning inside our code
2019-01-13 23:22:36 +01:00
Martin Hořeňovský 17e09be3b9
Fix stupid (C4800) warning 2019-01-13 19:01:12 +01:00
Martin Hořeňovský 1c99b0ff81
Minor cleanup in decomposer 2019-01-13 16:23:20 +01:00
Martin Hořeňovský 64a0f466ec
Add missing noexcept in move constructors
Because both copy and move operations are trivial, this doesn't
actually change anything, but it silences a static analysis warning.
2019-01-13 16:17:42 +01:00
Axel Huebl 47602ac556 RunContext: Uninit Member
Fix an uninitialized member in `RunContext`.

Found with coverity in a downstream project.
2019-01-13 10:26:47 +01:00
Axel Huebl d1e7344f16 ClockEstimate: DivByZero
The clock estimator has a potential division by zero.
Using `iteration + 1` seems also more logical to me for
an average.

Found with coverity in a downstream project.
2019-01-11 11:55:51 +01:00
Jozef Grajciar bdee512057 small cleanup of code 2019-01-10 13:07:54 +01:00
Axel Huebl 188b3e6511 hexEscapeChar: restore stream
The ostream passed as reference to `hexEscapeChar` is manipulated
and its original state not restored. This fixes it.

Seen via coverity in a downstream project.
2019-01-10 13:05:36 +01:00
Antonio Mallia bbf70ca74b Missing <type_traits> include 2019-01-10 12:52:15 +01:00
Martin Hořeňovský c1720d0c42
Fix assert message
I messed up copy-paste when modifying the assert messages in last
commit.
2019-01-03 10:14:15 +01:00
hbina4326 d54c2258e0 Add additional static_assert for the REQUIRE(a == b && c == d) case 2019-01-02 22:44:54 +01:00
BiCapitalization b3faceede2 Add nice error messages for unsupported && and ||
As explained in issue #1273, `operator&&` and `operator||` should give
a proper compile time error on use instead of the compiler complaining
about them not being defined. This commit adds an `always_false` type in
`catch_meta.hpp` used for implementing a nice `static_assert` for both
of the abovementioned operators.

Closes #1273
2019-01-01 19:13:47 +01:00
Khem Raj 799c7a2eed Remove redundant move to avoid Wredundant-move with Clang
Signed-off-by: Khem Raj <raj.khem@gmail.com>
2018-12-29 22:56:37 +01:00
Martin Hořeňovský 9bc15939a5
Don't use exception-related std:: functions with -fno-exceptions
This doesn't cause trouble with GCC/Clang and libstdc++, but IAR
and its stdlib apparently doesn't compile when you use `fno-exceptions`
and `std::current_exception`/`std::rethrow_exception`.

Fixes #1462
2018-12-18 20:19:39 +01:00
Jozef Grajciar 21a1cd5683 Template tests: added TEMPLATE_PRODUCT_TEST_CASE
support for generating test cases based on multiple template template
types combined with template arguments for each of the template template
types specified

e.g.
```
TEMPLATE_PRODUCT_TEST_CASE("template product","[template]",
			   (std::tuple, std::pair, std::map),
			   ((int,float),(char,double),(int,char)))
```
will effectively create 9 test cases with types:
std::tuple<int,float>
std::tuple<char,double>
std::tuple<int,char>
std::pair<int,float>
std::pair<char, double>
std::pair<int,char>
std::map<int,float>
std::map<char,double>
std::map<int,char>

Tested type is accessible in test case body as TestType
Unique name is created by appending ` - <index>` to test name
since preprocessor has some limitations in recursions

Closes #1454
2018-12-10 08:22:09 +01:00
Martin Hořeňovský 6ccd467094
v2.5.0 2018-11-26 20:50:38 +01:00
Martin Hořeňovský 59087f74d9
Fix CAPTURE macro for nontrivial uses
The previous implemetation was just plain broken for most of
possible uses, the new one should work (even though it is ugly
as all hell, and should be improved ASAP).

Fixes #1436
2018-11-21 16:48:09 +01:00
Martin Hořeňovský c6a89f14c2
Add `std::isnan` polyfill, fixing compilation under Embarcadero
Fixes #1438
2018-11-17 20:52:18 +01:00
Jozef Grajciar 2d906a92cb Add support for templated tests
This adds support for templated tests and test methods via
`TEMPLATE_TEST_CASE` and `TEMPLATE_TEST_CASE_METHOD` macros. These
work mostly just like their regular counterparts*, but take an
unlimited** number of types as their last arguments.

* Unlike the plain `TEST_CASE*` macros, the `TEMPLATE*` variants
require a tag string.

** In practice there is limit of about 300 types.
2018-11-16 21:21:23 +01:00
Martin Hořeňovský de6bfb5c25 Remove obsolete comment 2018-11-05 20:05:17 +01:00