Commit Graph

140 Commits

Author SHA1 Message Date
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
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ý
269303d9d9
Introduce random number (Integral and Float) generators 2019-02-20 00:09:15 +01:00
Martin Hořeňovský
dbbab8727c
v2.6.1 2019-02-12 19:58:12 +01:00
Darren Gilroy
9ccea82d7f Catch: resolve inconsistency in CATCH_REQUIRE_THROWS
The REQUIRE_THROWS and CATCH_REQUIRE_THROWS macros have
a subtle inconsistency in their implementation which can
cause a warning if [-Wunused-value] is used.

This commit changes CATCH_REQUIRE_THROWS so it has the
same implementation as REQUIRE_THROWS

It looks like REQUIRE_THROWS was change in commit
fae0fa4ec but not CATCH_REQUIRE_THROWS.

Similar changes for CATCH_CHECK_THROWS
2019-02-09 17:42:53 +01:00
Martin Hořeňovský
d75e9b3c0f
v2.6.0 2019-01-31 22:32:55 +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
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ý
03d122a35c v2.4.2 2018-10-26 21:14:16 +02:00
Martin Hořeňovský
054d356332 Add STATIC_REQUIRE assertion
By default, it expands into a `static_assert` + `SUCCEED` pair, but
it can also be deferred to runtime by defining
`CATCH_CONFIG_RUNTIME_STATIC_REQUIRE`, which causes it to expand
into plain old `REQUIRE`.

Closes #1362
Closes #1356
2018-10-16 16:16:00 +02:00
Martin Hořeňovský
9e1bdca466 v2.4.1 2018-09-28 15:52:51 +02:00
Martin Hořeňovský
60b05b2041 v2.4.0 2018-09-04 11:59:15 +02:00
Matthew Parnell
64fd5b8058 Add BDD AND_GIVEN based macros
issue #1360

It is possible to have multple  given contexts in a single BDD scenario;
if you have to type 'and' in the GIVEN description; it's very likely you
need an AND.

A generic AND  is not possible, thus a AND_GIVEN  is added to complement
the AND_WHEN and AND_THEN.

Can be used without needing to increase indent:

	SCENARIO("...") {
		GIVEN("...")
		AND_GIVEN("...") {
			WHEN("...") {
				THEN("...") {
					// ...
				}
			}
		}
	}

would correctly output, when requested/needed:

    Given: ...
And given: ...
     When: ...
     Then: ...

The padding had to be increased by a character in the output message, to
continue to be uniform.
2018-09-02 16:53:57 +02:00
Phil Nash
7c25dae9ea First attempt at data generator support
The support is to be considered experimental, that is, the interfaces,
the first party generators and helper functions can change or be removed
at any point in time.

Related to #850
2018-08-24 13:31:51 +02:00
Phil Nash
1cdaa48a0b CAPTURE is now variadic 2018-08-19 22:40:20 +02:00
Martin Hořeňovský
15cf3caace v2.3.0 2018-07-23 10:12:15 +02:00
Martin Hořeňovský
1c1b447ede Properly guard CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER definition 2018-07-03 09:29:26 +02:00
Phil Nash
0f49a600b0 Added DYNAMIC_SECTION to CATCH_CONFIG_DISABLE builds 2018-06-25 19:22:57 +01:00
Phil Nash
5c0efa1cfc Added DYNAMIC_SECTION and implemented GIVEN/ WHEN/ THEN in terms of it 2018-06-25 19:19:21 +01:00
Martin Hořeňovský
d2a130f243 v2.2.3 2018-06-06 23:19:06 +02:00
Martin Hořeňovský
d2d8455b57 v2.2.2 2018-04-06 12:11:22 +02:00
Martin Hořeňovský
0a34cc201e v2.2.1 2018-03-11 12:04:28 +01:00
Martin Hořeňovský
d14b7563c2 v2.2.0 2018-03-07 11:06:15 +01:00
Martin Hořeňovský
7cbd0b587a v2.1.2 2018-02-09 17:10:27 +01:00
Martin Hořeňovský
44dbda9f01 Add CATCH_VERSION_* defines for external use
I wonder how much use they will actually see, but their cost is
fairly minor.

Closes #1131
2018-01-26 20:56:14 +01:00
Martin Hořeňovský
a8a1c379c0 Introduce a way to intentionally expose interface for use in tests
Fixes #1076
2017-11-21 11:10:07 +01:00
Martin Hořeňovský
baf3d2f360 Split out ratio_string::symbol bodies 2017-11-19 14:54:52 +01:00
Martin Hořeňovský
9796a77a37 Initial prototype of PCH support
Related to #1061
2017-11-14 21:41:36 +01:00
Phil Nash
927f520a97 Moved windows proxy inclusion outside of CATCH_CONFIG_COLOUR_WINDOWS guard, so workaround early inclusion can be removed 2017-10-12 10:37:23 +01:00
philsquared
cc0b093c20 unconditional windows proxy 2017-10-11 14:58:20 +01:00
Martin Hořeňovský
f972732737 Workaround for stitching issue in #1020
Closes #1020
2017-10-03 18:41:49 +02:00
Phil Nash
c5608f0202 Changed all .hpp extensions to .h where there is now a corresponding .cpp 2017-09-07 11:24:33 +01:00
Phil Nash
2d37649377 Fixed Objective-C mode 2017-09-06 15:44:42 +01:00
Martin Hořeňovský
9796c516bb Always compile matchers implementation 2017-08-30 18:06:48 +02:00
Martin Hořeňovský
cde57d9365 Remove tag alias registry interface from the common path 2017-08-30 15:28:33 +02:00
Martin Hořeňovský
92444d8b72 Remove catch_context.h from the common include path 2017-08-29 15:36:09 +02:00
Martin Hořeňovský
75f143835e Prevent exception translator registration with CATCH_CONFIG_DISABLE 2017-08-29 09:52:25 +02:00
Martin Hořeňovský
053c29a2b8 Add partial implementation of CATCH_CONFIG_DISABLE
* Assertions are defined into (void)(0) no-op
* SECTIONs are defined away (leaving {} as scope)
* TEST_CASEs and TEST_CASE_METHODs are not registered.
* REGISTER_TEST_CASE is defined into (void)(0) no-op
* METHOD_AS_TEST_CASE is defined away
2017-08-27 22:05:25 +02:00
Martin Hořeňovský
cb2fceb119 Force include catch_platform.h before any if-defs
Closes #994
2017-08-21 14:58:50 +02:00
Martin Hořeňovský
24af32f378 Add define that pulls in reporter and listeners interfaces
This allows users to define reporters and listeners in files different
from the main file.

Related to #991, #986
2017-08-17 20:23:30 +02:00
Martin Hořeňovský
f99f511155 Removed *_REGISTER_REPORTER from main path
Also simplified them to single macro: CATCH_REGISTER_REPORTER
2017-08-17 20:03:16 +02:00
Phil Nash
8582780f11 Don't include string/ vector matchers if CATCH_CONFIG_MATCHERS defined 2017-08-16 14:38:04 +01:00
Phil Nash
97c06ca6fb Merge branch 'reevaluate' into dev-modernize 2017-08-10 16:18:05 +01:00
Martin Hořeňovský
3382312bd8 Remove obsoleted SCOPED_MSG and SCOPED_CAPTURE
Standard `MSG` and `CAPTURE` behave the same way these used to,
and are recommended instead.
2017-08-10 17:06:32 +02:00
Phil Nash
ee9b19efd3 Moved matcher-based capture macros into their own file
- this file excluded from the CATCH_CONFIG_DISABLE_MATCHERS path.
- matchers are always compiled in to the impl file
- _THROWS_WITH macros are still available with matchers disabled - but only the ones that take a string
- tests that use matchers have #ifdefs, so the whole SelfTest project can compile with matchers disable.
2017-08-09 12:10:14 +01:00
Phil Nash
e658bacb04 Refactored how FAST_COMPILE affects internal test macros (less duplication) 2017-08-07 00:09:54 +01:00
Phil Nash
a9b6813ad9 First draft of (experimental) benchmarking support 2017-08-04 19:23:30 +01:00
Martin Hořeňovský
d08e31d89e Fix inverted CATCH_CONFIG_DISABLE_MATCHERS toggle 2017-07-29 08:43:32 +02:00
Martin Hořeňovský
0ca4cfb743 Introduce compile time toggle to remove Matchers from TU
The toggle is `CATCH_CONFIG_DISABLE_MATCHERS` and the only use is
to speed up compilation of small TUs. For large ones it is likely
insignificant, because the speed up is constant relative to
number of tests/assertions in TU.
2017-07-28 21:34:34 +02:00