Commit Graph

1557 Commits

Author SHA1 Message Date
dmsteck
481f54b357
Make hidden tags behave identically (#1847)
Add both `[.]` and `[!hide]` tags when registering a hidden test case, as per documentation.

Co-authored-by: Martin Hořeňovský <martin.horenovsky@gmail.com>
2020-01-31 21:44:06 +01:00
offa
2d172dc688 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-01-25 09:01:04 +01:00
Daniel Griscom
587a20b312 Removed unneeded 'using uchar = unsigned char' 2020-01-24 14:26:22 +01:00
Matthias Moulin
4ea74ff966
Added <random> include for std::uniform_int_distribution 2020-01-14 12:48:09 +01:00
Martin Hořeňovský
d10b9bd02e
v2.11.1 2019-12-28 21:24:04 +01:00
Martin Hořeňovský
55794e9b27
Avoid detecting Clang as having MSVC's traditional preprocessor
Fixes #1806
2019-12-28 18:57:24 +01:00
ptc-tgamper
fa6211bfc2 catch_debugger.h - implement break into debugger assembler instructions for iOS 2019-12-23 21:26:13 +01:00
ptc-tgamper
4e90f910dc catch_console_colour.cpp - adjust useColourOnPlatform for iOS 2019-12-23 21:26:13 +01:00
ptc-tgamper
0c59cc83cf catch_debugger.cpp - debugger detection is identical on Mac OS X and iOS 2019-12-23 21:26:13 +01:00
Martin Hořeňovský
e4004e0adb
Provide const overload of ObjectStorage::stored_object()
Fixes #1820
2019-12-23 21:22:32 +01:00
Joe Burzinski
6c9a255dc2 Fix forwarding in SingleValueGenerator and generator creation
Fixes #1809
2019-12-15 20:50:43 +01:00
Joe Burzinski
cfba9dce97 Fix wrong namespacing of benchmarking constructor helpers 2019-11-21 16:22:04 +01:00
Martin Hořeňovský
a537ccae22
Suppress using-namespace lint in GENERATE* macros
Closes #1799
2019-11-16 17:39:28 +01:00
Martin Hořeňovský
e1c9d5569d
v2.11.0 2019-11-15 15:06:17 +01:00
Martin Hořeňovský
f23f96883a
Ensure the full benchmarking support is present in the single header
Fixes #1800
2019-11-15 11:59:43 +01:00
Martin Hořeňovský
930f49a641
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
2019-11-05 23:28:47 +01:00
Martin Hořeňovský
95bfb33167
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.
2019-11-04 00:05:35 +01:00
cericks0n
fa6d52e2a3
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>.
2019-11-01 15:52:38 -05:00
Martin Hořeňovský
3136c4fb6a
Refactored XMLWriter to provide finer-grained control over formatting 2019-10-29 13:59:18 +01:00
Martin Hořeňovský
fc320f6b8f
Extract FunctionReturnType to catch_meta.hpp 2019-10-28 15:15:13 +01:00
Martin Hořeňovský
5290d4bedc
Merge pull request #1791 from catchorg/dev-reorganize-warning-suppression
Rework how warning suppression in macros is done
2019-10-28 13:13:23 +01:00
Martin Hořeňovský
7ada02e21e
Avoid technically UB type punning when determining endianness 2019-10-27 22:07:10 +01:00
Martin Hořeňovský
849f2848bd
Rework how warning suppression in macros is done
Previously, each warning suppression was self-contained, with its
own pair of `SUPPRESS_X_WARNING` and `UNSUPPRESS_X_WARNING` macros.
This had the obvious advantage of being self-containing, but it
also meant that if we needed to suppress more than one warning
in a single place, then we would manipulate the compiler's warning
state multiple times, even though logically we would only need one
layer.

The new way of suppressing warnings in macros is to push compiler's
warning state with `CATCH_INTERNAL_START_WARNINGS_SUPPRESSION` macro,
then disable whatever macros we need with the
`CATCH_INTERNAL_SUPPRESS_X_WARNINGS` macro, and then return to the
previous state using `CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION`.
2019-10-27 21:07:21 +01:00
Manuel Drews
4327baba40 Enable range generator for floating point types 2019-10-26 20:52:09 +02:00
Martin Hořeňovský
50cc14c94c
Rework StringRef interface and internals
Now it no longer tries to be this weird hybrid between an owning
and non-owning reference, and is only ever non-owning. This is also
reflected in its interface, for example `StringRef::isNullTerminated`
is now public, and `StringRef::c_str()` has the precondition that it
is true.

Overview of the changes:
* The `StringRef::m_data` member has been completely removed, as it
had no more uses.
* `StringRef::isSubstring()` has been made public and renamed to
`StringRef::isNullTerminated()`, so that the name reflects what the
method actually does.
* `StringRef::currentData()` has been renamed to `StringRef::data()`,
to be in line with common C++ containers and container-alikes.
* `StringRef::c_str()` will no longer silently make copies. It instead
has a precondition that `isNullTerminated()` is true.
* If the user needs a null-terminated string, they should use the
`std::string` conversion operator and call `c_str()` on the resulting
`std::string`.
* Some small optimizations in various places.
* Basic functionality is now `constexpr`.
2019-10-25 13:57:52 +02:00
Jozef Grajciar
87b745da66
v2.10.2 2019-10-24 18:41:25 +02:00
Martin Hořeňovský
7d0b205564
Prevent warning suppression from leaking when registering a listener 2019-10-22 00:10:01 +02:00
Martin Hořeňovský
23c80bcc92
Provide workaround for platforms where INFINITY is double
Fixes #1782
2019-10-21 18:33:26 +02:00
Martin Hořeňovský
a2c8dce85c
v2.10.1 2019-10-20 21:03:22 +02:00
Jonathan Vander Mey
060a41ec7b Suppress false positive from clang-analyzer
Fixes issue #1230
2019-10-20 17:27:09 +02:00
Martin Hořeňovský
9e8ae7d470
Use scientific notation for the WithinULP matcher
This should now properly handle small numbers which would previously
output something like `[0.00000000000000019, 0.00000000000000019]`,
which does not allow user to read the numbers properly.

Closes #1760
2019-10-20 12:30:21 +02:00
amitherman95
84856844e1 Fixes #1766: Catch terminates when parsing invalid test name 2019-10-19 21:14:06 +02:00
Jozef Grajciar
ae14a47360 TemplateTests: suppress -Wunused-template warning in template test cases
this warning was introduced by rework to support NTTPs
since we have implementation macro for NTTPs and normal template test cases
warning is going to be suppressed

Fixes #1762
2019-10-18 18:38:39 +02:00
Jozef Grajciar
f2b23db6d1 TemplateTests: fix compilation with ICC
ICC in some cases fails on trailing return type with decltype

Closes #1748
2019-10-18 12:35:09 +02:00
Martin Hořeňovský
31906d83ec
Add parenthesis to prevent macro expansions of min/max
Closes #1772
2019-10-17 16:40:37 +02:00
Martin Hořeňovský
7c9f92bc1c
v2.10.0 2019-10-13 23:44:18 +02:00
Martin Hořeňovský
9ba48e2c9b
Remove superfluous includes in exception matchers 2019-10-13 20:49:36 +02:00
Martin Hořeňovský
2cc0c71856
Add a matcher that checks exception's message
Only works for exceptions that publicly derive from `std::exception`
and the matching is done exactly, including case and whitespace.

Closes #1649
Closes #1728

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Your branch is up-to-date with 'origin/master'.
#
# Changes to be committed:
#	modified:   ../docs/matchers.md
#	modified:   ../include/internal/catch_capture_matchers.h
#	modified:   ../projects/CMakeLists.txt
#	modified:   ../projects/SelfTest/Baselines/compact.sw.approved.txt
#	modified:   ../projects/SelfTest/Baselines/console.std.approved.txt
#	modified:   ../projects/SelfTest/Baselines/console.sw.approved.txt
#	modified:   ../projects/SelfTest/Baselines/junit.sw.approved.txt
#	modified:   ../projects/SelfTest/Baselines/xml.sw.approved.txt
#	modified:   ../projects/SelfTest/UsageTests/Matchers.tests.cpp
#
# Untracked files:
#	./
#	../clang-full/
#	../clang-test/
#	../clang10-build/
#	../coverage-build/
#	../gcc-build/
#	../gcc-full/
#	../include/internal/catch_matchers_exception.cpp
#	../include/internal/catch_matchers_exception.hpp
#	../misc-build/
#	../msvc-sln/
#	../notes.txt
#	../test-install/
#
2019-10-13 20:37:07 +02:00
Martin Hořeňovský
d2d418a9cb
Add a Relative Comparison matcher for floating point numbers
It checks Knuth's _close enough with tolerance_ relationship, that
is `|lhs - rhs| <= epsilon * max(|lhs|, |rhs|)`, rather then the
_very close with tolerance_ relationship that can be written down as
`|lhs - rhs| <= epsilon * min(|lhs|, |rhs|)`.

This is because it is the more common model around the internet, and
as such is likely to be less surprising to the users. In the future
we might want to provide the other model as well.

Closes #1746
2019-10-13 11:56:50 +02:00
Martin Hořeňovský
c8db4e77c4
Add a from_range(Container) overload to the generator helpers 2019-10-09 14:51:36 +02:00
amitherman95
adb4789136 Patch:Failure to apply filters through external file 2019-10-09 11:43:06 +02:00
Martin Hořeňovský
a5a22cdadb
Have the random generators use the global rng instance
This means that if you nest multiple random generators inside one
test case, they will not return the same sequence of numbers.

Idea taken from #1736 by Amit Herman.

Closes #1736
Closes #1734
2019-10-07 21:53:07 +02:00
Martin Hořeňovský
535da5c513
Introduce Catch's own RNG based on the PCG family of RNGs
In the future, we will also want to introduce our own
`uniform_int_distribution` and `uniform_real_distribution` to get
repeatable test runs across different platforms.
2019-10-07 19:56:23 +02:00
Martin Hořeňovský
319cb9e1da
Add a generator that takes an iterator pair 2019-10-06 13:55:10 +02:00
Martin Hořeňovský
4bd2c3ad6a
Fix compilation error with CATCH_CONFIG_GLOBAL_NEXTAFTER
Wrong nesting of namespaces resulted in the `Catch` namespace
being ambigous between `::Catch` and `::{anon}::Catch` namespaces.
This should fix it.

Closes #1761
2019-10-05 21:03:46 +02:00
Martin Hořeňovský
c38a5caa2e
Allow full range of target ULP values for the ULPMatcher
Previously it was limited to roughly 2 billion ULPs, rather than
the roughly 2^64 possible ones.
2019-10-05 13:38:22 +02:00
Wim Leflere
fcda35f645 update name of Value Generators in doc to match class names 2019-10-04 13:31:37 +02:00
Martin Hořeňovský
02ee130bd0
Special case Approx(inf) to better follow user expectations 2019-10-04 13:28:43 +02:00
amitherman95
2bcff9dd35 Escape characters bug patch(v2.9.2) 2019-09-21 00:46:58 +02:00
Martin Hořeňovský
3beccfb429
Remove the no longer used is_unique type trait
It was used in checking that types in TEMPLATE_TEST_CASE and friends
were unique, but this was removed for v2.8.0 (#1628). Since there
are no further uses of this trait, the simplest thing to do is to
just remove it.

Fixes #1757
2019-09-20 23:28:19 +02:00
Martin Hořeňovský
af8b2538a6
Ignore leading/trailing whitespace in test/section specs
The leading/trailing whitespace is problematic because of e.g.
`WHEN` macro having preceeding whitespace for alignment, and it is
generally messy.

Credits to Phil who did lot of the original work.

Closes #1708
2019-09-09 14:28:11 +02:00
Martin Hořeňovský
a156440b19
Reinline some StringRef methods with trivial bodies 2019-09-08 21:08:37 +02:00
Martin Hořeňovský
9f4c4777a5
Remove (mostly) unused overloads of StringRef operator + 2019-09-08 21:01:33 +02:00
Martin Hořeňovský
293012a002
Inline SourceLineInfo::empty definition 2019-09-08 18:20:49 +02:00
Martin Hořeňovský
e2b3443fe7
Do not blindly access empty StringRefs 2019-09-08 17:44:56 +02:00
Martin Hořeňovský
7b865daccc
Make StringRef's operator std::string explicit
This way it is explicit when there is a `StringRef` -> `std::string`
conversion and makes it easier to look for allocations that could
be avoided.

Doing this has already removed one allocation per registered test
case, as there was a completely pointless `StringRef` -> `std::string`
conversion when parsing tags of a test case.
2019-09-08 15:58:10 +02:00
Martin Hořeňovský
14362533bb
Check for empty expression properly
The old code was a left-over from the times when the
`capturedExpression` member was a `const char*`, which could always
be indexed. With the change to use `StringRef`, blindly indexing 0th
element is invalid, as it is not indexable part of a StringRef.
2019-09-08 14:35:01 +02:00
Matthias Moulin
a5bb3e3d91 Small updates to include directives (#1726)
Fixed some inconsistencies in include directives.
2019-09-08 14:25:23 +02:00
Martin Hořeňovský
923db16322
Use StringRefs through the enum registration 2019-09-08 14:14:46 +02:00
Martin Hořeňovský
fbbaadb704
Use StringRef literal for unknown enum values instead of string lit 2019-09-08 14:14:14 +02:00
Martin Hořeňovský
d27d580d0b
Add test for --libidentify command line flag 2019-09-07 20:36:12 +02:00
Martin Hořeňovský
fe967b1f41
Remove the ill-considered StringRef::numberOfCharacters
It never counted characters, only codepoints. If you think these
are interchangeable, you should not touch non-ascii text.
2019-09-07 20:13:22 +02:00
Martin Hořeňovský
f2c2711bdc
Add trim for StringRef 2019-09-07 11:31:00 +02:00
Martin Hořeňovský
4038ee6bc6
Stop compilation if registering an enum could truncate its value
We probably want to use a bigger type (e.g. `int64_t`) later on,
but the is a mess right now anyway.
2019-09-06 18:36:59 +02:00
Martin Hořeňovský
6e8d769775
Unify handling of __has_include checks 2019-09-06 13:38:58 +02:00
Martin Hořeňovský
addf799040
Workaround missing std::nextafter in uClibc
Luckily, the rest of C++11 features seem to be supported...

Closes #1739
2019-09-06 13:08:44 +02:00
Martin Hořeňovský
155274f0df
Add disabling the use of Android's logging at compile time
This is done via the new compile time toggle,
`CATCH_CONFIG_ANDROID_LOGWRITE`.

Closes #1743
2019-09-06 12:44:06 +02:00
Benjamin Worpitz
18d597cf10 Allow to use non-copyable and non-movable types in TEMPLATE_LIST_TEST_CASE
The parameter given to `convert` may not be copyable therefore it has to be
captured by const reference. For example an `std::tuple` that contains a
non-copyable type is itself non-copyable.

The NonDefaultConstructible test-case was reduced by one example type
because it did not add any value.
2019-09-06 12:15:09 +02:00
Martin Hořeňovský
46a70071a7
Use __android_log_write instead of __android_log_print
`print` version of the logging functions supports `printf`-like
formatting, which we do not use and given our current debug print
internals, will never use. This should be slightly more efficient
and expresses the intent better.
2019-08-10 14:51:38 +02:00
Jesse Alas
378cc1a670 Rename template parameter names to avoid name conflict on Solaris.
Closes #1722
2019-08-10 10:55:17 +02:00
Martin Hořeňovský
738818ae1d
Add a test for the internals 2019-08-09 10:50:53 +02:00
Martin Hořeňovský
2c869e17e4
v2.9.2 2019-08-08 14:05:24 +02:00
Martin Hořeňovský
0ab11aa9b4
(Hopefully) Fix Obj-C++ compilation of matchers
Thanks to bdb for the patch, related to #1661
2019-08-07 20:35:27 +02:00
Axel Huebl
820b1f12bf
static constexpr: storage class first
Seen with PGI compiler for `static constexpr`:
```
warning: storage class is not first
```
2019-08-06 19:17:16 -05:00
Steven Franzen
6070745cab Improve reporting of unmatched filters (#1684)
This PR ultimately does 3 things
* Separately tracks matched tests per each filter part (that is, a set of filters separated by an OR (`,`)), which allows Catch2 to report each of the alternative filters that don't match any tests.
* Fixes `-w NoTests` to return non-zero in the process
* Adds tests for `-w NoTests`.
2019-08-06 20:51:19 +02:00
Martin Hořeňovský
cf55cfd76f
Tiny speedup when listing tags
Noticed that the code was originally concatenating strings just to
then append the result to another string. Now it does not create
temporaries and also preallocates the string buffer.
2019-08-05 19:12:29 +02:00
Mike Cowan
e5c0e3322d Add Android implementation of writeToDebugConsole that prints to Logcat (#1710) 2019-07-31 23:12:34 +02:00
Martin Hořeňovský
ba9193370b
Add autoconfiguration for RTX
Closes #1693
2019-07-30 11:28:28 +02:00
Benjamin Worpitz
e7c26f09d1 Fix non-default-constructible type lists used in TEMPLATE_LIST_TEST_CASE (#1697)
* Fix non-default-constructible type lists used in TEMPLATE_LIST_TEST_CASE

std::tuple is not default constructible when the first type is not
default-constuctible. Therefore it can not be instantiated.
to circumvent this, we have to use std::declval in the unevaluate decltype
context.
2019-07-22 12:56:33 +02:00
Martin Hořeňovský
53281b471f
Prevent compilation of generators that use bool in dangerous manner
Closes #1692
2019-07-18 11:54:18 +02:00
Stuart Dootson
87739ad3fe Add std::byte stringification support (#1686)
* Add `std::byte` support

1. Add byte detection in Catch config
2. Add a `std::byte`specialisation for Catch2::Detail::StringMaker
2019-07-13 14:47:56 +02:00
Martin Hořeňovský
11488e63b6
Use _WIN32 macro for detecting MSVC Windows
Previously we used `WIN32`, which sometimes does exist, but according to
https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=vs-2019
`_WIN32` is the one that is actually provided by the compiler.

Closes #1676.
2019-07-06 16:55:10 +02:00
Martin Hořeňovský
c0d3a2e08f
Merge pull request #1672 from sommd/master
Fix ChunkGenerator with chunk-size 0
2019-07-01 18:07:37 +02:00
Steven Franzen
800f1b1d3d
Fix TrackerBase::close children completion check
Now verifies that all children have completed, instead of only the last.
2019-06-29 18:02:28 +02:00
David Sommerich
9cf5897a11 Fix ChunkGenerator with chunk-size 0
Fixes #1671
2019-06-29 23:48:30 +10:00
Martin Hořeňovský
2f631bb808
v2.9.1 2019-06-17 12:02:14 +02:00
Martin Hořeňovský
f9dce28e7d
v2.9.0 2019-06-16 10:42:59 +02:00
geh
bbbd5c4e08 Added null-ptr check in Colour::use() 2019-06-15 18:06:59 +02:00
Jozef Grajciar
f2cfc2b852 TEMPLATE_LIST_TEST_CASE implementation
Closes #1627
2019-06-15 15:40:39 +02:00
Martin Hořeňovský
c365ac392b
Standardize and document the parallel processing toggle 2019-06-15 12:50:36 +02:00
Martin Hořeňovský
e640c3837a
Move the async-using parts of benchmarking into a .cpp file
This keeps it out of the main include path when benchmarking is
enabled, somewhat reducing the compilation-time penalty.

Also moved some other functions into the .cpp file, especially
helpers that could be given internal linkage, and concretized some
iterator-templated code that only ever used
`std::vector<double>::iterator`.
2019-06-15 11:43:25 +02:00
Martin Hořeňovský
7142d5a8c9
Show bound when stringifying the WithinULP matcher
Closes #1581
2019-06-15 07:12:27 +02:00
Martin Hořeňovský
1967feac49
Introduce stubs for throwing specific exception types
This allows us to move <stdexcept> out of the common path, and replace
it with just <exception>. The difference between these two headers is
~13k lines after preprocessing on libstdc++ (16k vs 3k) and ~17k lines
for MS's STL(33k vs 16k).

Note that this is only beneficial if no other stdlib header we use
includes <stdexcept>. AFAIK this is true for the newest MS's STL,
but I have no idea of the applicability for libstdc++ and libc++.
2019-06-14 19:13:50 +02:00
Martin Hořeňovský
e340ab8db6
Various improvements to the benchmarking support
* Units from <ratio> are no longer redeclared in our own namespace
* The default clock is `steady_clock`, not `high_resolution_clock`,
because, as HH says "high_resolution_clock is useless. If you want
measure the passing of time, use steady_clock. If you want user
friendly time, use system_clock".
* Benchmarking support is opt-in, not opt-out, to avoid the large
(~10%) compile time penalty.
* Benchmarking-related options in CLI are always present, to decrease
the amount of code that is only compiled conditionally and making
the whole shebang more maintainble.
2019-06-06 21:28:56 +02:00
Joachim Meyer
ce2560ca95 Integrate Nonius benchmark into Catch2
Changes done to Nonius:
* Moved things into "Catch::Benchmark" namespace
* Benchmarks were integrated with `TEST_CASE`/`SECTION`/`GENERATE` macros
* Removed Nonius's parameters for benchmarks, Generators should be used instead
* Added relevant methods to the reporter interface (default-implemented, to avoid
breaking existing 3rd party reporters)
* Async processing is guarded with `_REENTRANT` macro for GCC/Clang, used by default
on MSVC
* Added a macro `CATCH_CONFIG_DISABLE_BENCHMARKING` that removes all traces of
benchmarking from Catch
2019-06-06 19:33:37 +02:00
Martin Hořeňovský
00347f1e79
v2.8.0 2019-05-26 22:47:00 +02:00
Martin Hořeňovský
a5a2d08fbb
Remove commented out code 2019-05-26 21:19:55 +02:00
Jozef Grajciar
0c43f98fa2 Nttp support
Closes #1531
2019-05-23 21:03:47 +02:00
Martin Hořeňovský
99602787cd
Fix error message when unmatched quotes are encountered by CAPTURE
Thanks to @ledvinap for noticing
2019-05-23 13:54:51 +02:00
Phil Nash
96355da34e StringRef no longer repoints m_start to m_data after c_str() on a substring.
This fixes an issue where a self-assignment of a StringRef copy would point into internally (and now dangling) data.
(now self-assignment check is no longer needed)
2019-05-21 00:04:44 +01:00