Skip to content

Commit fdc42d0

Browse files
committed
Merged from develop branch
- now v1.3.0
2 parents d758428 + d274fc5 commit fdc42d0

File tree

95 files changed

+8034
-3310
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+8034
-3310
lines changed

.travis.yml

Lines changed: 154 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,163 @@
11
language: cpp
2+
sudo: false
23

3-
compiler:
4-
- clang
5-
- gcc
4+
cache:
5+
ccache: true
6+
directories:
7+
- $HOME/.ccache
68

79
env:
8-
- BUILD_TYPE=Debug
9-
- BUILD_TYPE=Release
10+
global:
11+
- USE_CCACHE=1
12+
- CCACHE_COMPRESS=1
13+
- CCACHE_MAXSIZE=200M
14+
- CCACHE_CPP2=1
15+
16+
17+
matrix:
18+
include:
19+
20+
# 1/ Linux Clang Builds
21+
- os: linux
22+
compiler: clang
23+
addons: &clang35
24+
apt:
25+
sources: ['llvm-toolchain-precise-3.5', 'ubuntu-toolchain-r-test']
26+
packages: ['clang-3.5']
27+
env: COMPILER='ccache clang++-3.5' BUILD_TYPE='Release'
28+
29+
- os: linux
30+
compiler: clang
31+
addons: *clang35
32+
env: COMPILER='ccache clang++-3.5' BUILD_TYPE='Debug'
33+
34+
35+
- os: linux
36+
compiler: clang
37+
addons: &clang36
38+
apt:
39+
sources: ['llvm-toolchain-precise-3.6', 'ubuntu-toolchain-r-test']
40+
packages: ['clang-3.6']
41+
env: COMPILER='ccache clang++-3.6' BUILD_TYPE='Release'
42+
43+
- os: linux
44+
compiler: clang
45+
addons: *clang36
46+
env: COMPILER='ccache clang++-3.6' BUILD_TYPE='Debug'
47+
48+
49+
- os: linux
50+
compiler: clang
51+
addons: &clang37
52+
apt:
53+
sources: ['llvm-toolchain-precise-3.7', 'ubuntu-toolchain-r-test']
54+
packages: ['clang-3.7']
55+
env: COMPILER='ccache clang++-3.7' BUILD_TYPE='Release'
56+
57+
- os: linux
58+
compiler: clang
59+
addons: *clang37
60+
env: COMPILER='ccache clang++-3.7' BUILD_TYPE='Debug'
61+
62+
63+
- os: linux
64+
compiler: clang
65+
addons: &clang38
66+
apt:
67+
sources: ['llvm-toolchain-precise', 'ubuntu-toolchain-r-test']
68+
packages: ['clang-3.8']
69+
env: COMPILER='ccache clang++-3.8' BUILD_TYPE='Release'
70+
71+
- os: linux
72+
compiler: clang
73+
addons: *clang38
74+
env: COMPILER='ccache clang++-3.8' BUILD_TYPE='Debug'
75+
76+
77+
# 2/ Linux GCC Builds
78+
- os: linux
79+
compiler: gcc
80+
addons: &gcc48
81+
apt:
82+
sources: ['ubuntu-toolchain-r-test']
83+
packages: ['g++-4.8']
84+
env: COMPILER='ccache g++-4.8' BUILD_TYPE='Release'
85+
86+
- os: linux
87+
compiler: gcc
88+
addons: *gcc48
89+
env: COMPILER='ccache g++-4.8' BUILD_TYPE='Debug'
90+
91+
92+
- os: linux
93+
compiler: gcc
94+
addons: &gcc49
95+
apt:
96+
sources: ['ubuntu-toolchain-r-test']
97+
packages: ['g++-4.9']
98+
env: COMPILER='ccache g++-4.9' BUILD_TYPE='Release'
99+
100+
- os: linux
101+
compiler: gcc
102+
addons: *gcc49
103+
env: COMPILER='ccache g++-4.9' BUILD_TYPE='Debug'
104+
105+
106+
- os: linux
107+
compiler: gcc
108+
addons: &gcc5
109+
apt:
110+
sources: ['ubuntu-toolchain-r-test']
111+
packages: ['g++-5']
112+
env: COMPILER='ccache g++-5' BUILD_TYPE='Release'
113+
114+
- os: linux
115+
compiler: gcc
116+
addons: *gcc5
117+
env: COMPILER='ccache g++-5' BUILD_TYPE='Debug'
118+
119+
120+
# 3/ OSX Clang Builds
121+
- os: osx
122+
osx_image: xcode6.4
123+
compiler: clang
124+
env: COMPILER='ccache clang++' BUILD_TYPE='Debug'
125+
126+
- os: osx
127+
osx_image: xcode6.4
128+
compiler: clang
129+
env: COMPILER='ccache clang++' BUILD_TYPE='Release'
130+
131+
132+
- os: osx
133+
osx_image: xcode7
134+
compiler: clang
135+
env: COMPILER='ccache clang++' BUILD_TYPE='Debug'
136+
137+
- os: osx
138+
osx_image: xcode7
139+
compiler: clang
140+
env: COMPILER='ccache clang++' BUILD_TYPE='Release'
141+
10142

11143
install:
12-
- cmake -Hprojects/CMake -BBuild -DCMAKE_BUILD_TYPE=$BUILD_TYPE
144+
- DEPS_DIR="${TRAVIS_BUILD_DIR}/deps"
145+
- mkdir -p ${DEPS_DIR} && cd ${DEPS_DIR}
146+
- |
147+
if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
148+
CMAKE_URL="http://www.cmake.org/files/v3.3/cmake-3.3.2-Linux-x86_64.tar.gz"
149+
mkdir cmake && travis_retry wget --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C cmake
150+
export PATH=${DEPS_DIR}/cmake/bin:${PATH}
151+
elif [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
152+
brew install cmake ccache
153+
fi
154+
155+
before_script:
156+
- export CXX=${COMPILER}
157+
- cd ${TRAVIS_BUILD_DIR}
158+
- cmake -Hprojects/CMake -BBuild -DCMAKE_BUILD_TYPE=${BUILD_TYPE}
13159
- cd Build
14-
- make
15-
- cd ..
16160

17161
script:
18-
- cd Build
19-
- ctest -V
162+
- make -j 2
163+
- ctest -V -j 2

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![catch logo](catch-logo-small.png)
22

3-
*v1.2.1*
3+
*v1.3.0*
44

55
Build status (on Travis CI) [![Build Status](https://travis-ci.org/philsquared/Catch.png)](https://travis-ci.org/philsquared/Catch)
66

docs/configuration.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ This can be useful on certain platforms that do not provide ```std::cout``` and
5858
CATCH_CONFIG_CPP11_IS_ENUM // std::is_enum is supported?
5959
CATCH_CONFIG_CPP11_TUPLE // std::tuple is supported
6060
CATCH_CONFIG_VARIADIC_MACROS // Usually pre-C++11 compiler extensions are sufficient
61+
CATCH_CONFIG_CPP11_LONG_LONG // generates overloads for the long long type
62+
CATCH_CONFIG_CPP11_OVERRIDE // CATCH_OVERRIDE expands to override (for virtual function implementations)
63+
CATCH_CONFIG_CPP11_UNIQUE_PTR // Use std::unique_ptr instead of std::auto_ptr
6164

6265
Catch has some basic compiler detection that will attempt to select the appropriate mix of these macros. However being incomplete - and often without access to the respective compilers - this detection tends to be conservative.
6366
So overriding control is given to the user. If a compiler supports a feature (and Catch does not already detect it) then one or more of these may be defined to enable it (or suppress it, in some cases). If you do do this please raise an issue, specifying your compiler version (ideally with an idea of how to detect it) and stating that it has such support.

docs/test-cases-and-sections.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,36 @@ The tag expression, ```"[widget]"``` selects A, B & D. ```"[gadget]"``` selects
2828

2929
For more detail on command line selection see [the command line docs](command-line.md#specifying-which-tests-to-run)
3030

31-
A special tag name, ```[hide]``` causes test cases to be skipped from the default list (ie when no test cases have been explicitly selected through tag expressions or name wildcards). ```[.]``` is an alias for ```[hide]```.
32-
3331
Tag names are not case sensitive.
3432

33+
### Special Tags
34+
35+
All tag names beginning with non-alphanumeric characters are reserved by Catch. Catch defines a number of "special" tags, which have meaning to the test runner itself. These special tags all begin with a symbol character. Following is a list of currently defined special tags and their meanings.
36+
37+
* `[!hide]` or `[.]` (or, for legacy reasons, `[hide]`) - causes test cases to be skipped from the default list (ie when no test cases have been explicitly selected through tag expressions or name wildcards). The hide tag is often combined with another, user, tag (for example `[.][integration]` - so all integration tests are excluded from the default run but can be run by passing `[integration]` on the command line). As a short-cut you can combine these by simply prefixing your user tag with a `.` - e.g. `[.integration]`. Because the hide tag has evolved to have several forms, all forms are added as tags if you use one of them.
38+
39+
* `[!throws]` - lets Catch know that this test is likely to throw an exception even if successful. This causes the test to be exluded when running with `-e` or `--nothrow`.
40+
41+
* `[!shouldfail]` - reverse the failing logic of the test: if the test is successful if it fails, and vice-versa.
42+
43+
* `[!mayfail]` - doesn't fail the test if any given assertion fails (but still reports it). This can be useful to flag a work-in-progress, or a known issue that you don't want to immediately fix but still want to track in the your tests.
44+
45+
* `[#<filename>]` - running with `-#` or `--filenames-as-tags` causes Catch to add the filename, prefixed with `#` (and with any extension stripped) as a tag. e.g. tests in testfile.cpp would all be tagged `[#testfile]`.
46+
47+
* `[@<alias>]` - tag aliases all begin with `@` (see below).
48+
49+
## Tag aliases
50+
51+
Between tag expressions and wildcarded test names (as well as combinations of the two) quite complex patterns can be constructed to direct which test cases are run. If a complex pattern is used often it is convenient to be able to create an alias for the expression. this can be done, in code, using the following form:
52+
53+
CATCH_REGISTER_TAG_ALIAS( <alias string>, <tag expression> )
54+
55+
Aliases must begining with the `@` character. An example of a tag alias is:
56+
57+
CATCH_REGISTER_TAG_ALIAS( "[@nhf]", "[failing]~[.]" )
58+
59+
Now when `[@nhf]` is used on the command line this matches all tests that are tagged `[failing]`, but which are not also hidden.
60+
3561
## BDD-style test cases
3662

3763
In addition to Catch's take on the classic style of test cases, Catch supports an alternative syntax that allow tests to be written as "executable specifications" (one of the early goals of [Behaviour Driven Development](http://dannorth.net/introducing-bdd/)). This set of macros map on to ```TEST_CASE```s and ```SECTION```s, with a little internal support to make them smoother to work with.

docs/tostring.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ namespace Catch {
5555
}
5656
```
5757

58+
## Exceptions
59+
60+
By default all exceptions deriving from `std::exception` will be translated to strings by calling the `what()` method. For exception types that do not derive from `std::exception` - or if `what()` does not return a suitable string - use `CATCH_TRANSLATE_EXCEPTION`. This defines a function that takes your exception type, by reference, and returns a string. It can appear anywhere in the code - it doesn't have to be in the same translation unit. For example:
61+
62+
```
63+
CATCH_TRANSLATE_EXCEPTION( MyType& ex ) {
64+
return ex.message();
65+
}
66+
```
67+
5868
---
5969

6070
[Home](Readme.md)

docs/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Although this was a simple test it's been enough to demonstrate a few things abo
9696

9797
Most test frameworks have a class-based fixture mechanism. That is, test cases map to methods on a class and common setup and teardown can be performed in ```setup()``` and ```teardown()``` methods (or constructor/ destructor in languages, like C++, that support deterministic destruction).
9898

99-
While Catch fully supports this way of working there are a few problems with the approach. In particular, the way your code must be split up and the blunt granularity of cause problems. You can only have one setup/ teardown pair across a set of methods, but sometimes you want slightly different setup in each method, or you may even want several levels of setup (a concept which we will clarify later on in this tutorial). It was <a href="http://jamesnewkirk.typepad.com/posts/2007/09/why-you-should-.html">problems like these</a> that led James Newkirk, who led the team that built NUnit, to start again from scratch and <a href="http://jamesnewkirk.typepad.com/posts/2007/09/announcing-xuni.html">build xUnit</a>).
99+
While Catch fully supports this way of working there are a few problems with the approach. In particular the way your code must be split up, and the blunt granularity of it, may cause problems. You can only have one setup/ teardown pair across a set of methods, but sometimes you want slightly different setup in each method, or you may even want several levels of setup (a concept which we will clarify later on in this tutorial). It was <a href="http://jamesnewkirk.typepad.com/posts/2007/09/why-you-should-.html">problems like these</a> that led James Newkirk, who led the team that built NUnit, to start again from scratch and <a href="http://jamesnewkirk.typepad.com/posts/2007/09/announcing-xuni.html">build xUnit</a>).
100100

101101
Catch takes a different approach (to both NUnit and xUnit) that is a more natural fit for C++ and the C family of languages. This is best explained through an example:
102102

0 commit comments

Comments
 (0)