mirror of
https://github.com/catchorg/Catch2.git
synced 2025-09-11 16:05:40 +02:00
Compare commits
161 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ee67ac6b7c | ||
![]() |
8a14af701e | ||
![]() |
07c6bfc3b9 | ||
![]() |
616f7235ef | ||
![]() |
396ecf6021 | ||
![]() |
a6cdcd43aa | ||
![]() |
dcab8a5971 | ||
![]() |
017a63da62 | ||
![]() |
b90d0b7267 | ||
![]() |
efba988ccc | ||
![]() |
004228efb2 | ||
![]() |
e0aaba6cf8 | ||
![]() |
a09bef23ed | ||
![]() |
3e018ef131 | ||
![]() |
adb66f55a7 | ||
![]() |
377c9a746d | ||
![]() |
ea48ae0f75 | ||
![]() |
2d1739b429 | ||
![]() |
1c59034be4 | ||
![]() |
52a84788e0 | ||
![]() |
3e328f55fc | ||
![]() |
b18e67522f | ||
![]() |
4b086bd5b5 | ||
![]() |
aac594aae3 | ||
![]() |
a49fa0edbe | ||
![]() |
d271683c14 | ||
![]() |
0bb8e1247e | ||
![]() |
32d97caf42 | ||
![]() |
bc93b29789 | ||
![]() |
df5cf2d323 | ||
![]() |
b62c0256b2 | ||
![]() |
1ea84cb734 | ||
![]() |
2a5d3736e8 | ||
![]() |
3dcc923351 | ||
![]() |
589c40077b | ||
![]() |
d4e0b1d093 | ||
![]() |
b8443e67da | ||
![]() |
5604ec7266 | ||
![]() |
6f012f2d1d | ||
![]() |
98e61c31df | ||
![]() |
e641485132 | ||
![]() |
a3ceb8f007 | ||
![]() |
b819432271 | ||
![]() |
9ceae8f51f | ||
![]() |
5ffc8a84cd | ||
![]() |
6e0fa4be68 | ||
![]() |
a0ada2e935 | ||
![]() |
e4694f58da | ||
![]() |
fc7f0a02b8 | ||
![]() |
211b330346 | ||
![]() |
d36fe214a6 | ||
![]() |
a34c053f0a | ||
![]() |
4cdb203ec3 | ||
![]() |
8014bf1124 | ||
![]() |
49d87cf182 | ||
![]() |
eedcc82d31 | ||
![]() |
8e8259091c | ||
![]() |
7869e5b007 | ||
![]() |
a49af4648c | ||
![]() |
417b2bcf5c | ||
![]() |
8f0feaa6d2 | ||
![]() |
b95163bd3a | ||
![]() |
2809be87cc | ||
![]() |
ac369b7b83 | ||
![]() |
1aa3e4abfa | ||
![]() |
e5c5a636a9 | ||
![]() |
2bf30e9e5a | ||
![]() |
b591cb9a03 | ||
![]() |
714d01c07c | ||
![]() |
c6990cdf91 | ||
![]() |
da8786b8fd | ||
![]() |
5577322062 | ||
![]() |
1b03c5ab6a | ||
![]() |
7dd3c19027 | ||
![]() |
29d26d3179 | ||
![]() |
ca764ec8d9 | ||
![]() |
250f0ee7fb | ||
![]() |
09e4830199 | ||
![]() |
8f85d08e9f | ||
![]() |
3ae076ce8d | ||
![]() |
94425ad59b | ||
![]() |
0354d50278 | ||
![]() |
cdd83c2e15 | ||
![]() |
9a07dde16d | ||
![]() |
6e091d3991 | ||
![]() |
95d85fb186 | ||
![]() |
3a3f152979 | ||
![]() |
4fe2432e05 | ||
![]() |
c3a41e26a7 | ||
![]() |
4838039b65 | ||
![]() |
2a221b8fcd | ||
![]() |
79ce6930a2 | ||
![]() |
d762a7ca6c | ||
![]() |
f23b6b8b85 | ||
![]() |
4597b43912 | ||
![]() |
f64d914bff | ||
![]() |
d07999ddff | ||
![]() |
e04dc5105b | ||
![]() |
cffb031ce1 | ||
![]() |
f3ec843ba6 | ||
![]() |
55ed17f97b | ||
![]() |
6a502cc2f5 | ||
![]() |
6a009fabcb | ||
![]() |
7a8a0205b4 | ||
![]() |
4dc06bdb70 | ||
![]() |
08b597b3e2 | ||
![]() |
46d166406d | ||
![]() |
4ec8d53e91 | ||
![]() |
e7984e3711 | ||
![]() |
90d89377ea | ||
![]() |
0692317bc5 | ||
![]() |
e8b31108d6 | ||
![]() |
95fc8d62a2 | ||
![]() |
0c015aa887 | ||
![]() |
f69f821853 | ||
![]() |
485dbdc0e7 | ||
![]() |
0afd52b98d | ||
![]() |
38b05f1400 | ||
![]() |
db9866677e | ||
![]() |
4101ff314a | ||
![]() |
68da5a6d19 | ||
![]() |
e4a25ad5ff | ||
![]() |
5d6c744d38 | ||
![]() |
5dd0639520 | ||
![]() |
a2515755c3 | ||
![]() |
807941eb31 | ||
![]() |
a2e20b07f8 | ||
![]() |
ace70407a2 | ||
![]() |
613e1466f9 | ||
![]() |
d8f45cd5f1 | ||
![]() |
3afd077b55 | ||
![]() |
e95bf48445 | ||
![]() |
932a405e18 | ||
![]() |
9a037204fa | ||
![]() |
374c050a42 | ||
![]() |
8b8e3ee117 | ||
![]() |
af1ed708e4 | ||
![]() |
041498b221 | ||
![]() |
d5a5883a10 | ||
![]() |
6fea473414 | ||
![]() |
68e7fdce20 | ||
![]() |
b4c9bf5802 | ||
![]() |
e952fa8946 | ||
![]() |
84a178f0b0 | ||
![]() |
f9db24a824 | ||
![]() |
9bee606dd6 | ||
![]() |
be4f6ab8e1 | ||
![]() |
fd6c7aee6d | ||
![]() |
cd6de9cd34 | ||
![]() |
40f6a5b8a4 | ||
![]() |
95b0eb2b6c | ||
![]() |
0b28d3daf2 | ||
![]() |
8435dcbb61 | ||
![]() |
99347df70e | ||
![]() |
658b5f63ef | ||
![]() |
c6535a080e | ||
![]() |
673ec550f5 | ||
![]() |
ff78e7c45a | ||
![]() |
da023b2f9a | ||
![]() |
470561cbbd | ||
![]() |
417202b743 |
3
.github/pull_request_template.md
vendored
3
.github/pull_request_template.md
vendored
@@ -2,6 +2,9 @@
|
||||
Please do not submit pull requests changing the `version.hpp`
|
||||
or the single-include `catch.hpp` file, these are changed
|
||||
only when a new release is made.
|
||||
|
||||
Before submitting a PR you should probably read the contributor documentation
|
||||
at docs/contributing.md. It will tell you how to properly test your changes.
|
||||
-->
|
||||
|
||||
|
||||
|
112
.travis.yml
112
.travis.yml
@@ -11,25 +11,25 @@ matrix:
|
||||
apt:
|
||||
sources: ['llvm-toolchain-precise', 'ubuntu-toolchain-r-test']
|
||||
packages: ['clang']
|
||||
env: COMPILER='clang++' BUILD_TYPE='Release' CPP11=0
|
||||
env: COMPILER='clang++' BUILD_TYPE='Release'
|
||||
|
||||
- os: linux
|
||||
compiler: clang
|
||||
addons: *clang34
|
||||
env: COMPILER='clang++' BUILD_TYPE='Debug' CPP11=0
|
||||
|
||||
env: COMPILER='clang++' BUILD_TYPE='Debug'
|
||||
|
||||
- os: linux
|
||||
compiler: clang
|
||||
addons: &clang35
|
||||
apt:
|
||||
sources: ['llvm-toolchain-precise-3.5', 'ubuntu-toolchain-r-test']
|
||||
packages: ['clang-3.5']
|
||||
env: COMPILER='clang++-3.5' BUILD_TYPE='Release' CPP11=0
|
||||
env: COMPILER='clang++-3.5' BUILD_TYPE='Release'
|
||||
|
||||
- os: linux
|
||||
compiler: clang
|
||||
addons: *clang35
|
||||
env: COMPILER='clang++-3.5' BUILD_TYPE='Debug' CPP11=0
|
||||
env: COMPILER='clang++-3.5' BUILD_TYPE='Debug'
|
||||
|
||||
|
||||
- os: linux
|
||||
@@ -38,12 +38,12 @@ matrix:
|
||||
apt:
|
||||
sources: ['llvm-toolchain-precise-3.6', 'ubuntu-toolchain-r-test']
|
||||
packages: ['clang-3.6']
|
||||
env: COMPILER='clang++-3.6' BUILD_TYPE='Release' CPP11=0
|
||||
env: COMPILER='clang++-3.6' BUILD_TYPE='Release'
|
||||
|
||||
- os: linux
|
||||
compiler: clang
|
||||
addons: *clang36
|
||||
env: COMPILER='clang++-3.6' BUILD_TYPE='Debug' CPP11=0
|
||||
env: COMPILER='clang++-3.6' BUILD_TYPE='Debug'
|
||||
|
||||
|
||||
- os: linux
|
||||
@@ -52,12 +52,12 @@ matrix:
|
||||
apt:
|
||||
sources: ['llvm-toolchain-precise-3.7', 'ubuntu-toolchain-r-test']
|
||||
packages: ['clang-3.7']
|
||||
env: COMPILER='clang++-3.7' BUILD_TYPE='Release' CPP11=0
|
||||
env: COMPILER='clang++-3.7' BUILD_TYPE='Release'
|
||||
|
||||
- os: linux
|
||||
compiler: clang
|
||||
addons: *clang37
|
||||
env: COMPILER='clang++-3.7' BUILD_TYPE='Debug' CPP11=0
|
||||
env: COMPILER='clang++-3.7' BUILD_TYPE='Debug'
|
||||
|
||||
|
||||
- os: linux
|
||||
@@ -66,12 +66,12 @@ matrix:
|
||||
apt:
|
||||
sources: ['llvm-toolchain-precise-3.8', 'ubuntu-toolchain-r-test']
|
||||
packages: ['clang-3.8']
|
||||
env: COMPILER='clang++-3.8' BUILD_TYPE='Release' CPP11=0
|
||||
env: COMPILER='clang++-3.8' BUILD_TYPE='Release'
|
||||
|
||||
- os: linux
|
||||
compiler: clang
|
||||
addons: *clang38
|
||||
env: COMPILER='clang++-3.8' BUILD_TYPE='Debug' CPP11=0
|
||||
env: COMPILER='clang++-3.8' BUILD_TYPE='Debug'
|
||||
|
||||
|
||||
# 2/ Linux GCC Builds
|
||||
@@ -81,12 +81,12 @@ matrix:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-4.4']
|
||||
env: COMPILER='g++-4.4' BUILD_TYPE='Release' CPP11=0
|
||||
env: COMPILER='g++-4.4' BUILD_TYPE='Release'
|
||||
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
addons: *gcc44
|
||||
env: COMPILER='g++-4.4' BUILD_TYPE='Debug' CPP11=0
|
||||
env: COMPILER='g++-4.4' BUILD_TYPE='Debug'
|
||||
|
||||
|
||||
- os: linux
|
||||
@@ -95,12 +95,12 @@ matrix:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-4.7']
|
||||
env: COMPILER='g++-4.7' BUILD_TYPE='Release' CPP11=0
|
||||
env: COMPILER='g++-4.7' BUILD_TYPE='Release'
|
||||
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
addons: *gcc47
|
||||
env: COMPILER='g++-4.7' BUILD_TYPE='Debug' CPP11=0
|
||||
env: COMPILER='g++-4.7' BUILD_TYPE='Debug'
|
||||
|
||||
|
||||
- os: linux
|
||||
@@ -109,12 +109,12 @@ matrix:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-4.8']
|
||||
env: COMPILER='g++-4.8' BUILD_TYPE='Release' CPP11=0
|
||||
env: COMPILER='g++-4.8' BUILD_TYPE='Release'
|
||||
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
addons: *gcc48
|
||||
env: COMPILER='g++-4.8' BUILD_TYPE='Debug' CPP11=0
|
||||
env: COMPILER='g++-4.8' BUILD_TYPE='Debug'
|
||||
|
||||
|
||||
- os: linux
|
||||
@@ -123,12 +123,12 @@ matrix:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-4.9']
|
||||
env: COMPILER='g++-4.9' BUILD_TYPE='Release' CPP11=0
|
||||
env: COMPILER='g++-4.9' BUILD_TYPE='Release'
|
||||
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
addons: *gcc49
|
||||
env: COMPILER='g++-4.9' BUILD_TYPE='Debug' CPP11=0
|
||||
env: COMPILER='g++-4.9' BUILD_TYPE='Debug'
|
||||
|
||||
|
||||
- os: linux
|
||||
@@ -137,12 +137,12 @@ matrix:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-5']
|
||||
env: COMPILER='g++-5' BUILD_TYPE='Release' CPP11=0
|
||||
env: COMPILER='g++-5' BUILD_TYPE='Release'
|
||||
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
addons: *gcc5
|
||||
env: COMPILER='g++-5' BUILD_TYPE='Debug' CPP11=0
|
||||
env: COMPILER='g++-5' BUILD_TYPE='Debug'
|
||||
|
||||
|
||||
- os: linux
|
||||
@@ -151,20 +151,17 @@ matrix:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-6']
|
||||
env: COMPILER='g++-6' BUILD_TYPE='Release' CPP11=0
|
||||
env: COMPILER='g++-6' BUILD_TYPE='Release'
|
||||
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
addons: *gcc6
|
||||
env: COMPILER='g++-6' BUILD_TYPE='Debug' CPP11=0
|
||||
env: COMPILER='g++-6' BUILD_TYPE='Debug'
|
||||
|
||||
# 3a/ Linux C++11 GCC builds
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
addons: &gcc48
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-4.8']
|
||||
addons: *gcc48
|
||||
env: COMPILER='g++-4.8' BUILD_TYPE='Release' CPP11=1
|
||||
|
||||
- os: linux
|
||||
@@ -175,10 +172,7 @@ matrix:
|
||||
# 3b/ Linux C++11 Clang builds
|
||||
- os: linux
|
||||
compiler: clang
|
||||
addons: &clang38
|
||||
apt:
|
||||
sources: ['llvm-toolchain-precise-3.8', 'ubuntu-toolchain-r-test']
|
||||
packages: ['clang-3.8']
|
||||
addons: *clang38
|
||||
env: COMPILER='clang++-3.8' BUILD_TYPE='Release' CPP11=1
|
||||
|
||||
- os: linux
|
||||
@@ -186,27 +180,69 @@ matrix:
|
||||
addons: *clang38
|
||||
env: COMPILER='clang++-3.8' BUILD_TYPE='Debug' CPP11=1
|
||||
|
||||
# 4a/ Linux C++14 GCC builds
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
addons: *gcc6
|
||||
env: COMPILER='g++-6' BUILD_TYPE='Release' CPP14=1
|
||||
|
||||
# 4/ OSX Clang Builds
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
addons: *gcc6
|
||||
env: COMPILER='g++-6' BUILD_TYPE='Debug' CPP14=1
|
||||
|
||||
# 4b/ Linux C++14 Clang builds
|
||||
- os: linux
|
||||
compiler: clang
|
||||
addons: *clang38
|
||||
env: COMPILER='clang++-3.8' BUILD_TYPE='Release' CPP14=1
|
||||
|
||||
- os: linux
|
||||
compiler: clang
|
||||
addons: *clang38
|
||||
env: COMPILER='clang++-3.8' BUILD_TYPE='Debug' CPP14=1
|
||||
|
||||
|
||||
# 5/ OSX Clang Builds
|
||||
- os: osx
|
||||
osx_image: xcode7.3
|
||||
compiler: clang
|
||||
env: COMPILER='clang++' BUILD_TYPE='Debug' CPP11=0
|
||||
env: COMPILER='clang++' BUILD_TYPE='Debug'
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode7.3
|
||||
compiler: clang
|
||||
env: COMPILER='clang++' BUILD_TYPE='Release' CPP11=0
|
||||
env: COMPILER='clang++' BUILD_TYPE='Release'
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode8
|
||||
compiler: clang
|
||||
env: COMPILER='clang++' BUILD_TYPE='Debug' CPP11=0
|
||||
env: COMPILER='clang++' BUILD_TYPE='Debug'
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode8
|
||||
compiler: clang
|
||||
env: COMPILER='clang++' BUILD_TYPE='Release' CPP11=0
|
||||
env: COMPILER='clang++' BUILD_TYPE='Release'
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode8
|
||||
compiler: clang
|
||||
env: COMPILER='clang++' BUILD_TYPE='Debug' USE_CPP11=1
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode8
|
||||
compiler: clang
|
||||
env: COMPILER='clang++' BUILD_TYPE='Release' USE_CPP11=1
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode8
|
||||
compiler: clang
|
||||
env: COMPILER='clang++' BUILD_TYPE='Debug' USE_CPP14=1
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode8
|
||||
compiler: clang
|
||||
env: COMPILER='clang++' BUILD_TYPE='Release' USE_CPP14=1
|
||||
|
||||
|
||||
install:
|
||||
@@ -218,13 +254,13 @@ install:
|
||||
mkdir cmake && travis_retry wget --no-check-certificate --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C cmake
|
||||
export PATH=${DEPS_DIR}/cmake/bin:${PATH}
|
||||
elif [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
|
||||
which cmake || brew install cmake
|
||||
which cmake || brew install cmake
|
||||
fi
|
||||
|
||||
before_script:
|
||||
- export CXX=${COMPILER}
|
||||
- cd ${TRAVIS_BUILD_DIR}
|
||||
- cmake -H. -BBuild -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -Wdev -DUSE_CPP11=${CPP11}
|
||||
- cmake -H. -BBuild -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -Wdev -DUSE_CPP11=${CPP11} -DUSE_CPP14=${CPP14}
|
||||
- cd Build
|
||||
|
||||
script:
|
||||
|
@@ -19,6 +19,10 @@ elseif(USE_CPP14)
|
||||
set(CMAKE_CXX_FLAGS "-std=c++14 ${CMAKE_CXX_FLAGS}")
|
||||
endif()
|
||||
|
||||
if(USE_WMAIN)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ENTRY:wmainCRTStartup")
|
||||
endif()
|
||||
|
||||
#checks that the given hard-coded list contains all headers + sources in the given folder
|
||||
function(CheckFileList LIST_VAR FOLDER)
|
||||
set(MESSAGE " should be added to the variable ${LIST_VAR}")
|
||||
@@ -55,6 +59,7 @@ set(TEST_SOURCES
|
||||
${SELF_TEST_DIR}/CmdLineTests.cpp
|
||||
${SELF_TEST_DIR}/CompilationTests.cpp
|
||||
${SELF_TEST_DIR}/ConditionTests.cpp
|
||||
${SELF_TEST_DIR}/DecompositionTests.cpp
|
||||
${SELF_TEST_DIR}/EnumToString.cpp
|
||||
${SELF_TEST_DIR}/ExceptionTests.cpp
|
||||
${SELF_TEST_DIR}/GeneratorTests.cpp
|
||||
@@ -135,6 +140,7 @@ set(INTERNAL_HEADERS
|
||||
${HEADER_DIR}/internal/catch_debugger.h
|
||||
${HEADER_DIR}/internal/catch_debugger.hpp
|
||||
${HEADER_DIR}/internal/catch_default_main.hpp
|
||||
${HEADER_DIR}/internal/catch_errno_guard.hpp
|
||||
${HEADER_DIR}/internal/catch_evaluate.hpp
|
||||
${HEADER_DIR}/internal/catch_exception_translator_registry.hpp
|
||||
${HEADER_DIR}/internal/catch_expression_lhs.hpp
|
||||
@@ -244,28 +250,35 @@ SOURCE_GROUP("Benchmarks" FILES ${BENCH_SOURCES})
|
||||
|
||||
# configure the executable
|
||||
include_directories(${HEADER_DIR})
|
||||
add_executable(SelfTest ${TEST_SOURCES} ${IMPL_SOURCES} ${HEADERS})
|
||||
add_executable(Benchmark ${BENCH_SOURCES} ${HEADERS})
|
||||
|
||||
# Add desired warnings
|
||||
if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang|GNU" )
|
||||
target_compile_options( SelfTest PRIVATE -Wall -Wextra )
|
||||
target_compile_options( Benchmark PRIVATE -Wall -Wextra )
|
||||
endif()
|
||||
if ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
|
||||
target_compile_options( SelfTest PRIVATE /W4 )
|
||||
target_compile_options( Benchmark PRIVATE /W4 )
|
||||
endif()
|
||||
# Projects consuming Catch via ExternalProject_Add might want to use install step
|
||||
# without building all of our selftests.
|
||||
if (NOT NO_SELFTEST)
|
||||
add_executable(SelfTest ${TEST_SOURCES} ${IMPL_SOURCES} ${HEADERS})
|
||||
add_executable(Benchmark ${BENCH_SOURCES} ${HEADERS})
|
||||
|
||||
# Add desired warnings
|
||||
if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang|GNU" )
|
||||
target_compile_options( SelfTest PRIVATE -Wall -Wextra )
|
||||
target_compile_options( Benchmark PRIVATE -Wall -Wextra )
|
||||
endif()
|
||||
if ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
|
||||
target_compile_options( SelfTest PRIVATE /W4 /w44265 /WX )
|
||||
target_compile_options( Benchmark PRIVATE /W4 )
|
||||
endif()
|
||||
|
||||
|
||||
# configure unit tests via CTest
|
||||
enable_testing()
|
||||
add_test(NAME RunTests COMMAND SelfTest)
|
||||
# configure unit tests via CTest
|
||||
enable_testing()
|
||||
add_test(NAME RunTests COMMAND SelfTest)
|
||||
|
||||
add_test(NAME ListTests COMMAND SelfTest --list-tests)
|
||||
set_tests_properties(ListTests PROPERTIES PASS_REGULAR_EXPRESSION "[0-9]+ test cases")
|
||||
add_test(NAME ListTests COMMAND SelfTest --list-tests)
|
||||
set_tests_properties(ListTests PROPERTIES PASS_REGULAR_EXPRESSION "[0-9]+ test cases")
|
||||
|
||||
add_test(NAME ListTags COMMAND SelfTest --list-tags)
|
||||
set_tests_properties(ListTags PROPERTIES PASS_REGULAR_EXPRESSION "[0-9]+ tags")
|
||||
add_test(NAME ListTags COMMAND SelfTest --list-tags)
|
||||
set_tests_properties(ListTags PROPERTIES PASS_REGULAR_EXPRESSION "[0-9]+ tags")
|
||||
|
||||
install(DIRECTORY "single_include/" DESTINATION "include/catch/")
|
||||
endif() # !NO_SELFTEST
|
||||
|
||||
|
||||
install(DIRECTORY "single_include/" DESTINATION "include/catch")
|
||||
|
@@ -1,10 +1,10 @@
|
||||

|
||||
|
||||
*v1.8.0*
|
||||
[](https://github.com/philsquared/catch/releases)
|
||||
[](https://travis-ci.org/philsquared/Catch)
|
||||
[](https://ci.appveyor.com/project/philsquared/catch/branch/master)
|
||||
|
||||
Build status (on Travis CI) [](https://travis-ci.org/philsquared/Catch)
|
||||
|
||||
<a href="https://github.com/philsquared/Catch/releases/download/v1.8.0/catch.hpp">The latest, single header, version can be downloaded directly using this link</a>
|
||||
<a href="https://github.com/philsquared/Catch/releases/download/v1.9.6/catch.hpp">The latest, single header, version can be downloaded directly using this link</a>
|
||||
|
||||
## What's the Catch?
|
||||
|
||||
|
32
appveyor.yml
32
appveyor.yml
@@ -1,14 +1,30 @@
|
||||
# version string format -- This will be overwritten later anyway
|
||||
version: "{build}"
|
||||
|
||||
# Disable the dead branch for v2 development
|
||||
branches:
|
||||
except:
|
||||
- develop-v2
|
||||
|
||||
os:
|
||||
- Visual Studio 2013
|
||||
- Visual Studio 2017
|
||||
- Visual Studio 2015
|
||||
- Visual Studio 2013
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- additional_flags: "/permissive- /std:c++latest"
|
||||
wmain: 0
|
||||
|
||||
- additional_flags: ""
|
||||
wmain: 0
|
||||
|
||||
- additional_flags: "/D_UNICODE /DUNICODE"
|
||||
wmain: 1
|
||||
|
||||
matrix:
|
||||
exclude:
|
||||
-
|
||||
additional_flags: "/permissive- /std:c++latest"
|
||||
os: Visual Studio 2015
|
||||
-
|
||||
additional_flags: "/permissive- /std:c++latest"
|
||||
os: Visual Studio 2013
|
||||
|
||||
init:
|
||||
- git config --global core.autocrlf input
|
||||
@@ -31,8 +47,8 @@ configuration:
|
||||
|
||||
#Cmake will autodetect the compiler, but we set the arch
|
||||
before_build:
|
||||
- echo Running cmake...
|
||||
- cmake -H. -BBuild -A%PLATFORM%
|
||||
- set CXXFLAGS=%additional_flags%
|
||||
- cmake -H. -BBuild -A%PLATFORM% -DUSE_WMAIN=%wmain%
|
||||
|
||||
# build with MSBuild
|
||||
build:
|
||||
|
BIN
catch-hand-icon.png
Normal file
BIN
catch-hand-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 52 KiB |
BIN
catch-icon-tiny.png
Normal file
BIN
catch-icon-tiny.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 19 KiB |
Binary file not shown.
Before Width: | Height: | Size: 5.7 KiB |
149
contrib/ParseAndAddCatchTests.cmake
Normal file
149
contrib/ParseAndAddCatchTests.cmake
Normal file
@@ -0,0 +1,149 @@
|
||||
#==================================================================================================#
|
||||
# supported macros #
|
||||
# - TEST_CASE, #
|
||||
# - SCENARIO, #
|
||||
# - TEST_CASE_METHOD, #
|
||||
# - CATCH_TEST_CASE, #
|
||||
# - CATCH_SCENARIO, #
|
||||
# - CATCH_TEST_CASE_METHOD. #
|
||||
# #
|
||||
# Usage #
|
||||
# 1. make sure this module is in the path or add this otherwise: #
|
||||
# set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake.modules/") #
|
||||
# 2. make sure that you've enabled testing option for the project by the call: #
|
||||
# enable_testing() #
|
||||
# 3. add the lines to the script for testing target (sample CMakeLists.txt): #
|
||||
# project(testing_target) #
|
||||
# set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake.modules/") #
|
||||
# enable_testing() #
|
||||
# #
|
||||
# find_path(CATCH_INCLUDE_DIR "catch.hpp") #
|
||||
# include_directories(${INCLUDE_DIRECTORIES} ${CATCH_INCLUDE_DIR}) #
|
||||
# #
|
||||
# file(GLOB SOURCE_FILES "*.cpp") #
|
||||
# add_executable(${PROJECT_NAME} ${SOURCE_FILES}) #
|
||||
# #
|
||||
# include(ParseAndAddCatchTests) #
|
||||
# ParseAndAddCatchTests(${PROJECT_NAME}) #
|
||||
# #
|
||||
# The following variables affect the behavior of the script: #
|
||||
# #
|
||||
# PARSE_CATCH_TESTS_VERBOSE (Default OFF) #
|
||||
# -- enables debug messages #
|
||||
# #
|
||||
#==================================================================================================#
|
||||
|
||||
cmake_minimum_required(VERSION 2.8.8)
|
||||
|
||||
option(PARSE_CATCH_TESTS_VERBOSE "Print Catch to CTest parser debug messages" OFF)
|
||||
|
||||
function(PrintDebugMessage)
|
||||
if(PARSE_CATCH_TESTS_VERBOSE)
|
||||
message(STATUS "ParseAndAddCatchTests: ${ARGV}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# This removes the contents between
|
||||
# - block comments (i.e. /* ... */)
|
||||
# - full line comments (i.e. // ... )
|
||||
# contents have been read into '${CppCode}'.
|
||||
# !keep partial line comments
|
||||
function(RemoveComments CppCode)
|
||||
string(ASCII 2 CMakeBeginBlockComment)
|
||||
string(ASCII 3 CMakeEndBlockComment)
|
||||
string(REGEX REPLACE "/\\*" "${CMakeBeginBlockComment}" ${CppCode} "${${CppCode}}")
|
||||
string(REGEX REPLACE "\\*/" "${CMakeEndBlockComment}" ${CppCode} "${${CppCode}}")
|
||||
string(REGEX REPLACE "${CMakeBeginBlockComment}[^${CMakeEndBlockComment}]*${CMakeEndBlockComment}" "" ${CppCode} "${${CppCode}}")
|
||||
string(REGEX REPLACE "\n[ \t]*//+[^\n]+" "\n" ${CppCode} "${${CppCode}}")
|
||||
|
||||
set(${CppCode} "${${CppCode}}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Worker function
|
||||
function(ParseFile SourceFile TestTarget)
|
||||
# According to CMake docs EXISTS behavior is well-defined only for full paths.
|
||||
get_filename_component(SourceFile ${SourceFile} ABSOLUTE)
|
||||
if(NOT EXISTS ${SourceFile})
|
||||
message(WARNING "Cannot find source file: ${SourceFile}")
|
||||
return()
|
||||
endif()
|
||||
PrintDebugMessage("parsing ${SourceFile}")
|
||||
file(STRINGS ${SourceFile} Contents NEWLINE_CONSUME)
|
||||
|
||||
# Remove block and fullline comments
|
||||
RemoveComments(Contents)
|
||||
|
||||
# Find definition of test names
|
||||
string(REGEX MATCHALL "[ \t]*(CATCH_)?(TEST_CASE_METHOD|SCENARIO|TEST_CASE)[ \t]*\\([^\)]+\\)+[ \t\n]*{+[ \t]*(//[^\n]*[Tt][Ii][Mm][Ee][Oo][Uu][Tt][ \t]*[0-9]+)*" Tests "${Contents}")
|
||||
|
||||
foreach(TestName ${Tests})
|
||||
# Strip newlines
|
||||
string(REGEX REPLACE "\\\\\n|\n" "" TestName "${TestName}")
|
||||
|
||||
# Get test type and fixture if applicable
|
||||
string(REGEX MATCH "(CATCH_)?(TEST_CASE_METHOD|SCENARIO|TEST_CASE)[ \t]*\\([^,^\"]*" TestTypeAndFixture "${TestName}")
|
||||
string(REGEX MATCH "(CATCH_)?(TEST_CASE_METHOD|SCENARIO|TEST_CASE)" TestType "${TestTypeAndFixture}")
|
||||
string(REPLACE "${TestType}(" "" TestFixture "${TestTypeAndFixture}")
|
||||
|
||||
# Get string parts of test definition
|
||||
string(REGEX MATCHALL "\"+([^\\^\"]|\\\\\")+\"+" TestStrings "${TestName}")
|
||||
|
||||
# Strip wrapping quotation marks
|
||||
string(REGEX REPLACE "^\"(.*)\"$" "\\1" TestStrings "${TestStrings}")
|
||||
string(REPLACE "\";\"" ";" TestStrings "${TestStrings}")
|
||||
|
||||
# Validate that a test name and tags have been provided
|
||||
list(LENGTH TestStrings TestStringsLength)
|
||||
if(TestStringsLength GREATER 2 OR TestStringsLength LESS 1)
|
||||
message(FATAL_ERROR "You must provide a valid test name and tags for all tests in ${SourceFile}")
|
||||
endif()
|
||||
|
||||
# Assign name and tags
|
||||
list(GET TestStrings 0 Name)
|
||||
if("${TestType}" STREQUAL "SCENARIO")
|
||||
set(Name "Scenario: ${Name}")
|
||||
endif()
|
||||
if(TestFixture)
|
||||
set(CTestName "${TestFixture}:${Name}")
|
||||
else()
|
||||
set(CTestName "${Name}")
|
||||
endif()
|
||||
set(CTestName "${TestTarget}:${CTestName}")
|
||||
# add target to labels to enable running all tests added from this target
|
||||
set(Labels ${TestTarget})
|
||||
if(TestStringsLength EQUAL 2)
|
||||
list(GET TestStrings 1 Tags)
|
||||
string(TOLOWER "${Tags}" Tags)
|
||||
# remove target from labels if the test is hidden
|
||||
if("${Tags}" MATCHES ".*\\[!?(hide|\\.)\\].*")
|
||||
list(REMOVE_ITEM Labels ${TestTarget})
|
||||
endif()
|
||||
string(REPLACE "]" ";" Tags "${Tags}")
|
||||
string(REPLACE "[" "" Tags "${Tags}")
|
||||
endif()
|
||||
|
||||
list(APPEND Labels ${Tags})
|
||||
|
||||
PrintDebugMessage("Adding test \"${CTestName}\"")
|
||||
if(Labels)
|
||||
PrintDebugMessage("Setting labels to ${Labels}")
|
||||
endif()
|
||||
|
||||
# Add the test and set its properties
|
||||
add_test(NAME "\"${CTestName}\"" COMMAND ${TestTarget} ${Name} ${AdditionalCatchParameters})
|
||||
set_tests_properties("\"${CTestName}\"" PROPERTIES FAIL_REGULAR_EXPRESSION "No tests ran"
|
||||
LABELS "${Labels}")
|
||||
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
# entry point
|
||||
function(ParseAndAddCatchTests TestTarget)
|
||||
PrintDebugMessage("Started parsing ${TestTarget}")
|
||||
get_target_property(SourceFiles ${TestTarget} SOURCES)
|
||||
PrintDebugMessage("Found the following sources: ${SourceFiles}")
|
||||
foreach(SourceFile ${SourceFiles})
|
||||
ParseFile(${SourceFile} ${TestTarget})
|
||||
endforeach()
|
||||
PrintDebugMessage("Finished parsing ${TestTarget}")
|
||||
endfunction()
|
@@ -1,22 +1,29 @@
|
||||
These are the currently documented areas of the framework. There is more to come.
|
||||
|
||||
Before looking at this material be sure to read the [tutorial](tutorial.md)
|
||||
To get the most out of Catch, start with the [tutorial](tutorial.md).
|
||||
Once you're up and running consider the following reference material.
|
||||
|
||||
Writing tests:
|
||||
* [Assertion macros](assertions.md)
|
||||
* [Matchers](matchers.md)
|
||||
* [Logging macros](logging.md)
|
||||
* [Test cases and sections](test-cases-and-sections.md)
|
||||
* [Test fixtures](test-fixtures.md)
|
||||
* [Command line](command-line.md)
|
||||
* [Build systems](build-systems.md)
|
||||
* [Reporters](reporters.md)
|
||||
* [Event Listeners](event-listeners.md)
|
||||
|
||||
Fine tuning:
|
||||
* [Supplying your own main()](own-main.md)
|
||||
* [Configuration](configuration.md)
|
||||
* [Compile-time configuration](configuration.md)
|
||||
* [String Conversions](tostring.md)
|
||||
|
||||
Running:
|
||||
* [Command line](command-line.md)
|
||||
* [CI and Build system integration](build-systems.md)
|
||||
|
||||
FAQ:
|
||||
* [Why are my tests slow to compile?](slow-compiles.md)
|
||||
* [Known limitations](limitations.md)
|
||||
|
||||
Other
|
||||
|
||||
Other:
|
||||
* [Why Catch?](why-catch.md)
|
||||
* [Open Source Projects using Catch](opensource-users.md)
|
||||
* [Contributing](contributing.md)
|
||||
|
@@ -95,7 +95,7 @@ Expects that an exception (of any type) is be thrown during evaluation of the ex
|
||||
* **REQUIRE_THROWS_AS(** _expression_, _exception type_ **)** and
|
||||
* **CHECK_THROWS_AS(** _expression_, _exception type_ **)**
|
||||
|
||||
Expects that an exception of the _specified type_ is thrown during evaluation of the expression.
|
||||
Expects that an exception of the _specified type_ is thrown during evaluation of the expression. Note that the _exception type_ is used verbatim and you should include (const) reference.
|
||||
|
||||
* **REQUIRE_THROWS_WITH(** _expression_, _string or string matcher_ **)** and
|
||||
* **CHECK_THROWS_WITH(** _expression_, _string or string matcher_ **)**
|
||||
@@ -131,6 +131,11 @@ To support Matchers a slightly different form is used. Matchers have [their own
|
||||
|
||||
Matchers can be composed using `&&`, `||` and `!` operators.
|
||||
|
||||
## Thread Safety
|
||||
|
||||
Currently assertions in Catch are not thread safe.
|
||||
For more details, along with workarounds, see the section on [the limitations page](limitations.md#thread-safe-assertions).
|
||||
|
||||
---
|
||||
|
||||
[Home](Readme.md)
|
@@ -1,4 +1,4 @@
|
||||
# Integration with build systems
|
||||
# CI and build system integration
|
||||
|
||||
Build Systems may refer to low-level tools, like CMake, or larger systems that run on servers, like Jenkins or TeamCity. This page will talk about both.
|
||||
|
||||
@@ -56,8 +56,26 @@ Because of the incremental nature of Catch's test suites and ability to run spec
|
||||
|
||||
## CMake
|
||||
|
||||
You can use the following CMake script to automatically fetch Catch from github and configure it as an external project:
|
||||
In general we recommend "vendoring" Catch's single-include releases inside your own repository. If you do this, the following example shows a minimal CMake project:
|
||||
```CMake
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
|
||||
project(cmake_test)
|
||||
|
||||
# Prepare "Catch" library for other executables
|
||||
set(CATCH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/catch)
|
||||
add_library(Catch INTERFACE)
|
||||
target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR})
|
||||
|
||||
# Make test executable
|
||||
set(TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)
|
||||
add_executable(tests ${TEST_SOURCES})
|
||||
target_link_libraries(tests Catch)
|
||||
```
|
||||
Note that it assumes that the path to the Catch's header is `catch/catch.hpp` from the `CMakeLists.txt` file.
|
||||
|
||||
|
||||
You can also use the following CMake snippet to automatically fetch the entire Catch repository from github and configure it as an external project:
|
||||
```CMake
|
||||
cmake_minimum_required(VERSION 2.8.8)
|
||||
project(catch_builder CXX)
|
||||
@@ -90,6 +108,36 @@ include_directories(${CATCH_INCLUDE_DIR} ${COMMON_INCLUDES})
|
||||
enable_testing(true) # Enables unit-testing.
|
||||
```
|
||||
|
||||
The advantage of this approach is that you can always automatically update Catch to the latest release. The disadvantage is that it means bringing in lot more than you need.
|
||||
|
||||
|
||||
### Automatic test registration
|
||||
If you are also using ctest, `contrib/ParseAndAddCatchTests.cmake` is a CMake script that attempts to parse your test files and automatically register all test cases, using tags as labels. This means that these
|
||||
```cpp
|
||||
TEST_CASE("Test1", "[unit]") {
|
||||
int a = 1;
|
||||
int b = 2;
|
||||
REQUIRE(a == b);
|
||||
}
|
||||
|
||||
TEST_CASE("Test2") {
|
||||
int a = 1;
|
||||
int b = 2;
|
||||
REQUIRE(a == b);
|
||||
}
|
||||
|
||||
TEST_CASE("Test3", "[a][b][c]") {
|
||||
int a = 1;
|
||||
int b = 2;
|
||||
REQUIRE(a == b);
|
||||
}
|
||||
```
|
||||
would be registered as 3 tests, `Test1`, `Test2` and `Test3`, and ctest 4 labels would be created, `a`, `b`, `c` and `unit`.
|
||||
|
||||
### CodeCoverage module (GCOV, LCOV...)
|
||||
|
||||
If you are using GCOV tool to get testing coverage of your code, and are not sure how to integrate it with CMake and Catch, there should be an external example over at https://github.com/fkromer/catch_cmake_coverage
|
||||
|
||||
---
|
||||
|
||||
[Home](Readme.md)
|
||||
[Home](Readme.md)
|
||||
|
@@ -1,12 +1,16 @@
|
||||
# Commercial users of Catch
|
||||
|
||||
As well as [Open Source](opensource-users.md) users Catch is widely used within proprietary code bases too. Many companies like to keep this
|
||||
information internal, and that's fine, but if you're more open it would be great if we could list the names of as
|
||||
many organisations as possible that use Catch somewhere in their codebase. Enterprise environments often tend to be
|
||||
far more conservative in their tool adoption - and being aware that other companies are using Catch can ease the
|
||||
path in.
|
||||
As well as [Open Source](opensource-users.md) users Catch is widely used within proprietary code bases too.
|
||||
Many organisations like to keep this information internal, and that's fine,
|
||||
but if you're more open it would be great if we could list the names of as
|
||||
many organisations as possible that use Catch somewhere in their codebase.
|
||||
Enterprise environments often tend to be far more conservative in their tool adoption -
|
||||
and being aware that other companies are using Catch can ease the path in.
|
||||
|
||||
So if you are aware of Catch usage in your organisation, and are fairly confident there is no issue with sharing this
|
||||
fact then please let us know - either directly, via a PR or [issue](https://github.com/philsquared/Catch/issues), or on the [forums](https://groups.google.com/forum/?fromgroups#!forum/catch-forum).
|
||||
fact then please let us know - either directly, via a PR or
|
||||
[issue](https://github.com/philsquared/Catch/issues), or on the [forums](https://groups.google.com/forum/?fromgroups#!forum/catch-forum).
|
||||
|
||||
- Bloomberg
|
||||
- NASA
|
||||
- [Inscopix Inc.](https://www.inscopix.com/)
|
||||
|
@@ -52,17 +52,18 @@ This can be useful on certain platforms that do not provide ```std::cout``` and
|
||||
|
||||
# C++ conformance toggles
|
||||
|
||||
CATCH_CONFIG_CPP11_NULLPTR // nullptr is supported?
|
||||
CATCH_CONFIG_CPP11_NOEXCEPT // noexcept is supported?
|
||||
CATCH_CONFIG_CPP11_GENERATED_METHODS // delete and default keywords for methods
|
||||
CATCH_CONFIG_CPP11_IS_ENUM // std::is_enum is supported?
|
||||
CATCH_CONFIG_CPP11_TUPLE // std::tuple is supported
|
||||
CATCH_CONFIG_VARIADIC_MACROS // Usually pre-C++11 compiler extensions are sufficient
|
||||
CATCH_CONFIG_CPP11_LONG_LONG // generates overloads for the long long type
|
||||
CATCH_CONFIG_CPP11_OVERRIDE // CATCH_OVERRIDE expands to override (for virtual function implementations)
|
||||
CATCH_CONFIG_CPP11_UNIQUE_PTR // Use std::unique_ptr instead of std::auto_ptr
|
||||
CATCH_CONFIG_CPP11_SHUFFLE // Use std::shuffle instead of std::random_shuffle
|
||||
CATCH_CONFIG_CPP11_TYPE_TRAITS // Use std::enable_if and <type_traits>
|
||||
CATCH_CONFIG_CPP11_NULLPTR // nullptr is supported?
|
||||
CATCH_CONFIG_CPP11_NOEXCEPT // noexcept is supported?
|
||||
CATCH_CONFIG_CPP11_GENERATED_METHODS // delete and default keywords for methods
|
||||
CATCH_CONFIG_CPP11_IS_ENUM // std::is_enum is supported?
|
||||
CATCH_CONFIG_CPP11_TUPLE // std::tuple is supported
|
||||
CATCH_CONFIG_VARIADIC_MACROS // Usually pre-C++11 compiler extensions are sufficient
|
||||
CATCH_CONFIG_CPP11_LONG_LONG // generates overloads for the long long type
|
||||
CATCH_CONFIG_CPP11_OVERRIDE // CATCH_OVERRIDE expands to override (for virtual function implementations)
|
||||
CATCH_CONFIG_CPP11_UNIQUE_PTR // Use std::unique_ptr instead of std::auto_ptr
|
||||
CATCH_CONFIG_CPP11_SHUFFLE // Use std::shuffle instead of std::random_shuffle
|
||||
CATCH_CONFIG_CPP11_TYPE_TRAITS // Use std::enable_if and <type_traits>
|
||||
CATCH_CONFIG_CPP11_STREAM_INSERTABLE_CHECK // Use C++11 expression SFINAE to check if class can be inserted to std::ostream
|
||||
|
||||
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.
|
||||
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.
|
||||
@@ -70,24 +71,51 @@ You may also suppress any of these features by using the `_NO_` form, e.g. `CATC
|
||||
|
||||
All C++11 support can be disabled with `CATCH_CONFIG_NO_CPP11`
|
||||
|
||||
## `CATCH_CONFIG_CPP11_STREAM_INSERTABLE_CHECK`
|
||||
|
||||
This flag is off by default, but allows you to resolve problems caused by types with private base class that are streamable, but the classes themselves are not. Without it, the following code will cause a compilation error:
|
||||
```cpp
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch.hpp>
|
||||
struct A {};
|
||||
std::ostream &operator<< (std::ostream &o, const A &v) { return o << 0; }
|
||||
|
||||
struct B : private A {
|
||||
bool operator==(int){ return true;}
|
||||
};
|
||||
|
||||
B f ();
|
||||
std::ostream g ();
|
||||
|
||||
TEST_CASE ("Error in streamable check") {
|
||||
B x;
|
||||
REQUIRE (x == 4);
|
||||
}
|
||||
```
|
||||
|
||||
# Other toggles
|
||||
|
||||
CATCH_CONFIG_COUNTER // Use __COUNTER__ to generate unique names for test cases
|
||||
CATCH_CONFIG_WINDOWS_SEH // Enable SEH handling on Windows
|
||||
CATCH_CONFIG_FAST_COMPILE // Sacrifices some (extremely minor) features for compilation speed
|
||||
CATCH_CONFIG_FAST_COMPILE // Sacrifices some (rather minor) features for compilation speed
|
||||
CATCH_CONFIG_POSIX_SIGNALS // Enable handling POSIX signals
|
||||
CATCH_CONFIG_WINDOWS_CRTDBG // Enable leak checking using Windows's CRT Debug Heap
|
||||
|
||||
Currently Catch enables `CATCH_CONFIG_WINDOWS_SEH` only when compiled with MSVC, because some versions of MinGW do not have the necessary Win32 API support.
|
||||
|
||||
At this moment, `CATCH_CONFIG_FAST_COMPILE` changes only the behaviour of the `-b` (`--break`) flag, making it break into debugger in a stack frame *below* the actual test, unlike the default behaviour, where the break into debugger occurs in the same stack frame as the actual test. `CATCH_CONFIG_FAST_COMPILE` has to be either defined, or not defined, in all translation units that are linked into single test binary, or the behaviour of setting `-b` flag will be unpredictable.
|
||||
|
||||
`CATCH_CONFIG_POSIX_SIGNALS` is on by default, except when Catch is compiled under `Cygwin`, where it is disabled by default (but can be force-enabled by defining `CATCH_CONFIG_POSIX_SIGNALS`).
|
||||
|
||||
`CATCH_CONFIG_WINDOWS_CRTDBG` is off by default. If enabled, Windows's CRT is used to check for memory leaks, and displays them after the tests finish running.
|
||||
|
||||
Just as with the C++11 conformance toggles, these toggles can be disabled by using `_NO_` form of the toggle, e.g. `CATCH_CONFIG_NO_WINDOWS_SEH`.
|
||||
|
||||
## `CATCH_CONFIG_FAST_COMPILE`
|
||||
Defining this flag speeds up compilation of test files by ~20%, by making 2 changes:
|
||||
* The `-b` (`--break`) flag no longer makes Catch break into debugger in the same stack frame as the failed test, but rather in a stack frame *below*.
|
||||
* The `REQUIRE` family of macros (`REQUIRE`, `REQUIRE_FALSE` and `REQUIRE_THAT`) no longer uses local try-catch block. This disables exception translation, but should not lead to false negatives.
|
||||
|
||||
`CATCH_CONFIG_FAST_COMPILE` has to be either defined, or not defined, in all translation units that are linked into single test binary, or the behaviour of setting `-b` flag and throwing unexpected exceptions will be unpredictable.
|
||||
|
||||
# Windows header clutter
|
||||
|
||||
On Windows Catch includes `windows.h`. To minimize global namespace clutter in the implementation file, it defines `NOMINMAX` and `WIN32_LEAN_AND_MEAN` before including it. You can control this behaviour via two macros:
|
||||
|
@@ -18,8 +18,8 @@ Ongoing development is currently on _master_. At some point an integration branc
|
||||
_Users_ of Catch primarily use the single header version. _Maintainers_ should work with the full source (which is still,
|
||||
primarily, in headers). This can be found in the `include` folder. There are a set of test files, currently under
|
||||
`projects/SelfTest`. The test app can be built via CMake from the `CMakeLists.txt` file in the root, or you can generate
|
||||
project files for Visual Studio, XCode, and others (instructions in the `projects` folder). If you have access to CLion
|
||||
that can work with the CMake file directly.
|
||||
project files for Visual Studio, XCode, and others (instructions in the `projects` folder). If you have access to CLion,
|
||||
it can work with the CMake file directly.
|
||||
|
||||
As well as the runtime test files you'll also see a `SurrogateCpps` directory under `projects/SelfTest`.
|
||||
This contains a set of .cpp files that each `#include` a single header.
|
||||
@@ -34,6 +34,25 @@ __When submitting a pull request please do not include changes to the single inc
|
||||
as these are managed by the scripts!__
|
||||
|
||||
|
||||
## Testing your changes
|
||||
|
||||
Obviously all changes to Catch's code should be tested. If you added new functionality, you should add tests covering and
|
||||
showcasing it. Even if you have only made changes to Catch internals (ie you implemented some performance improvements),
|
||||
you should still test your changes.
|
||||
|
||||
This means 3 things
|
||||
|
||||
* Compiling Catch's SelfTest project -- code that does not compile is evidently incorrect. Obviously, you are not expected to
|
||||
have access to all compilers and platforms Catch supports, Catch's CI pipeline will compile your code using supported compilers
|
||||
once you open a PR.
|
||||
* Running the SelfTest binary. There should be no unexpected failures on simple run.
|
||||
* Running Catch's approval tests. Approval tests compare current output of the SelfTest binary in various configurations against
|
||||
known good output. Catch's repository provides utility scripts `approvalTests.py` to help you with this. It needs to be passed
|
||||
the SelfTest binary compiled with your changes, like so: `$ ./scripts/approvalTests.py clang-build/SelfTest`. The output should
|
||||
be fairly self-explanatory.
|
||||
|
||||
|
||||
|
||||
*this document is still in-progress...*
|
||||
|
||||
---
|
||||
|
73
docs/event-listeners.md
Normal file
73
docs/event-listeners.md
Normal file
@@ -0,0 +1,73 @@
|
||||
# Event Listeners
|
||||
|
||||
A `Listener` is a class you can register with Catch that will then be passed events,
|
||||
such as a test case starting or ending, as they happen during a test run.
|
||||
`Listeners` are actually types of `Reporters`, with a few small differences:
|
||||
|
||||
1. Once registered in code they are automatically used - you don't need to specify them on the command line
|
||||
2. They are called in addition to (just before) any reporters, and you can register multiple listeners.
|
||||
3. They derive from `Catch::TestEventListenerBase`, which has default stubs for all the events,
|
||||
so you are not forced to implement events you're not interested in.
|
||||
4. You register a listener with `CATCH_REGISTER_LISTENER`
|
||||
|
||||
|
||||
## Implementing a Listener
|
||||
|
||||
In your main source file (i.e. the one that has the `#define` for `CATCH_CONFIG_MAIN` or `CATCH_CONFIG_RUNNER`),
|
||||
simply derive a class from `Catch::TestEventListenerBase` and implement the methods you are interested in.
|
||||
Then register it using `INTERNAL_CATCH_REGISTER_LISTENER`.
|
||||
|
||||
For example:
|
||||
|
||||
```c++
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include "catch.hpp"
|
||||
|
||||
struct MyListener : Catch::TestEventListenerBase {
|
||||
|
||||
using TestEventListenerBase::TestEventListenerBase; // inherit constructor
|
||||
|
||||
virtual void testCaseStarting( Catch::TestCaseInfo const& testInfo ) override {
|
||||
// Perform some setup before a test case is run
|
||||
}
|
||||
|
||||
virtual void testCaseEnded( Catch::TestCaseStats const& testCaseStats ) override {
|
||||
// Tear-down after a test case is run
|
||||
}
|
||||
};
|
||||
CATCH_REGISTER_LISTENER( MyListener )
|
||||
```
|
||||
|
||||
_Note that you should not use any assertion macros within a Listener!_
|
||||
|
||||
## Events that can be hooked
|
||||
|
||||
The following are the methods that can be overriden in the Listener:
|
||||
|
||||
```c++
|
||||
// The whole test run, starting and ending
|
||||
virtual void testRunStarting( TestRunInfo const& testRunInfo );
|
||||
virtual void testRunEnded( TestRunStats const& testRunStats );
|
||||
|
||||
// Test cases starting and ending
|
||||
virtual void testCaseStarting( TestCaseInfo const& testInfo );
|
||||
virtual void testCaseEnded( TestCaseStats const& testCaseStats );
|
||||
|
||||
// Sections starting and ending
|
||||
virtual void sectionStarting( SectionInfo const& sectionInfo );
|
||||
virtual void sectionEnded( SectionStats const& sectionStats );
|
||||
|
||||
// Assertions before/ after
|
||||
virtual void assertionStarting( AssertionInfo const& assertionInfo );
|
||||
virtual bool assertionEnded( AssertionStats const& assertionStats );
|
||||
|
||||
// A test is being skipped (because it is "hidden")
|
||||
virtual void skipTest( TestCaseInfo const& testInfo );
|
||||
```
|
||||
|
||||
More information about the events (e.g. name of the test case) is contained in the structs passed as arguments -
|
||||
just look in the source code to see what fields are available.
|
||||
|
||||
---
|
||||
|
||||
[Home](Readme.md)
|
@@ -1,6 +1,32 @@
|
||||
# Logging macros
|
||||
|
||||
Additional messages can be logged during a test case.
|
||||
Additional messages can be logged during a test case. Note that the messages are scoped and thus will not be reported if failure occurs in scope preceding the message declaration. An example:
|
||||
|
||||
```cpp
|
||||
TEST_CASE("Foo") {
|
||||
INFO("Test case start");
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
INFO("The number is " << i);
|
||||
CHECK(i == 0);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Bar") {
|
||||
INFO("Test case start");
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
INFO("The number is " << i);
|
||||
CHECK(i == i);
|
||||
}
|
||||
CHECK(false);
|
||||
}
|
||||
```
|
||||
When the `CHECK` fails in the "Foo" test case, then two messages will be printed.
|
||||
```
|
||||
Test case start
|
||||
The number is 1
|
||||
```
|
||||
When the last `CHECK` fails in the "Bar" test case, then only one message will be printed: `Test case start`.
|
||||
|
||||
|
||||
## Streaming macros
|
||||
|
||||
@@ -26,6 +52,10 @@ The message is always reported but does not fail the test.
|
||||
|
||||
The message is reported and the test case fails.
|
||||
|
||||
**FAIL_CHECK(** _message expression_ **)**
|
||||
|
||||
AS `FAIL`, but does not abort the test
|
||||
|
||||
## Quickly capture a variable value
|
||||
|
||||
**CAPTURE(** _expression_ **)**
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# Open Source projects using Catch
|
||||
|
||||
Catch is great for open source. With it's [liberal license](../LICENSE_1_0.txt) and single-header, dependency-free, distribution
|
||||
Catch is great for open source. With it's [liberal license](../LICENSE.txt) and single-header, dependency-free, distribution
|
||||
it's easy to just drop the header into your project and start writing tests - what's not to like?
|
||||
|
||||
As a result Catch is now being used in many Open Source projects, including some quite well known ones.
|
||||
@@ -34,9 +34,18 @@ A, single-header, JSON parsing library that takes advantage of what C++ has to o
|
||||
### [MNMLSTC Core](https://github.com/mnmlstc/core)
|
||||
a small and easy to use C++11 library that adds a functionality set that will be available in C++14 and later, as well as some useful additions
|
||||
|
||||
### [nanodbc](https://github.com/lexicalunit/nanodbc/)
|
||||
A small C++ library wrapper for the native C ODBC API.
|
||||
|
||||
### [Nonius](https://github.com/libnonius/nonius)
|
||||
A header-only framework for benchmarking small snippets of C++ code.
|
||||
|
||||
### [SOCI](https://github.com/SOCI/soci)
|
||||
The C++ Database Access Library
|
||||
|
||||
### [polymorphic_value](https://github.com/jbcoe/polymorphic_value)
|
||||
A polymorphic value-type for C++
|
||||
|
||||
### [Ppconsul](https://github.com/oliora/ppconsul)
|
||||
A C++ client library for Consul. Consul is a distributed tool for discovering and configuring services in your infrastructure
|
||||
|
||||
@@ -48,9 +57,15 @@ A thread safe header only mocking framework for C++14
|
||||
|
||||
## Applications & Tools
|
||||
|
||||
### [ArangoDB](https://github.com/arangodb/arangodb)
|
||||
ArangoDB is a native multi-model database with flexible data models for documents, graphs, and key-values.
|
||||
|
||||
### [MAME](https://github.com/mamedev/mame)
|
||||
MAME originally stood for Multiple Arcade Machine Emulator
|
||||
|
||||
### [Newsbeuter](https://github.com/akrennmair/newsbeuter)
|
||||
Newsbeuter is an open-source RSS/Atom feed reader for text terminals.
|
||||
|
||||
### [Standardese](https://github.com/foonathan/standardese)
|
||||
Standardese aims to be a nextgen Doxygen
|
||||
|
||||
|
@@ -1,24 +1,169 @@
|
||||
# 1.9.6
|
||||
|
||||
### Improvements
|
||||
* Catch's runtime overhead has been significantly decreased (#937, #939)
|
||||
* Added `--list-extra-info` cli option (#934).
|
||||
* It lists all tests together with extra information, ie filename, line number and description.
|
||||
|
||||
|
||||
|
||||
# 1.9.5
|
||||
|
||||
### Fixes
|
||||
* Truthy expressions are now reconstructed properly, not as booleans (#914)
|
||||
* Various warnings are no longer erroneously suppressed in test files (files that include `catch.hpp`, but do not define `CATCH_CONFIG_MAIN` or `CATCH_CONFIG_RUNNER`) (#871)
|
||||
* Catch no longer fails to link when main is compiled as C++, but linked against Objective-C (#855)
|
||||
* Fixed incorrect gcc version detection when deciding to use `__COUNTER__` (#928)
|
||||
* Previously any GCC with minor version less than 3 would be incorrectly classified as not supporting `__COUNTER__`.
|
||||
* Suppressed C4996 warning caused by upcoming updated to MSVC 2017, marking `std::uncaught_exception` as deprecated. (#927)
|
||||
|
||||
### Improvements
|
||||
* CMake integration script now incorporates debug messages and registers tests in an improved way (#911)
|
||||
* Various documentation improvements
|
||||
|
||||
|
||||
|
||||
# 1.9.4
|
||||
|
||||
### Fixes
|
||||
* `CATCH_FAIL` macro no longer causes compilation error without variadic macro support
|
||||
* `INFO` messages are no longer cleared after being reported once
|
||||
|
||||
### Improvements and minor changes
|
||||
* Catch now uses `wmain` when compiled under Windows and `UNICODE` is defined.
|
||||
* Note that Catch still officially supports only ASCII
|
||||
|
||||
# 1.9.3
|
||||
|
||||
### Fixes
|
||||
* Completed the fix for (lack of) uint64_t in earlier Visual Studios
|
||||
|
||||
# 1.9.2
|
||||
|
||||
### Improvements and minor changes
|
||||
* All of `Approx`'s member functions now accept strong typedefs in C++11 mode (#888)
|
||||
* Previously `Approx::scale`, `Approx::epsilon`, `Approx::margin` and `Approx::operator()` didn't.
|
||||
|
||||
|
||||
### Fixes
|
||||
* POSIX signals are now disabled by default under QNX (#889)
|
||||
* QNX does not support current enough (2001) POSIX specification
|
||||
* JUnit no longer counts exceptions as failures if given test case is marked as ok to fail.
|
||||
* `Catch::Option` should now have its storage properly aligned.
|
||||
* Catch no longer attempts to define `uint64_t` on windows (#862)
|
||||
* This was causing trouble when compiled under Cygwin
|
||||
|
||||
### Other
|
||||
* Catch is now compiled under MSVC 2017 using `std:c++latest` (C++17 mode) in CI
|
||||
* We now provide cmake script that autoregisters Catch tests into ctest.
|
||||
* See `contrib` folder.
|
||||
|
||||
|
||||
# 1.9.1
|
||||
|
||||
### Fixes
|
||||
* Unexpected exceptions are no longer ignored by default (#885, #887)
|
||||
|
||||
|
||||
# 1.9.0
|
||||
|
||||
|
||||
### Improvements and minor changes
|
||||
* Catch no longer attempts to ensure the exception type passed by user in `REQUIRE_THROWS_AS` is a constant reference.
|
||||
* It was causing trouble when `REQUIRE_THROWS_AS` was used inside templated functions
|
||||
* This actually reverts changes made in v1.7.2
|
||||
* Catch's `Version` struct should no longer be double freed when multiple instances of Catch tests are loaded into single program (#858)
|
||||
* It is now a static variable in an inline function instead of being an `extern`ed struct.
|
||||
* Attempt to register invalid tag or tag alias now throws instead of calling `exit()`.
|
||||
* Because this happen before entering main, it still aborts execution
|
||||
* Further improvements to this are coming
|
||||
* `CATCH_CONFIG_FAST_COMPILE` now speeds-up compilation of `REQUIRE*` assertions by further ~15%.
|
||||
* The trade-off is disabling translation of unexpected exceptions into text.
|
||||
* When Catch is compiled using C++11, `Approx` is now constructible with anything that can be explicitly converted to `double`.
|
||||
* Captured messages are now printed on unexpected exceptions
|
||||
|
||||
### Fixes:
|
||||
* Clang's `-Wexit-time-destructors` should be suppressed for Catch's internals
|
||||
* GCC's `-Wparentheses` is now suppressed for all TU's that include `catch.hpp`.
|
||||
* This is functionally a revert of changes made in 1.8.0, where we tried using `_Pragma` based suppression. This should have kept the suppression local to Catch's assertions, but bugs in GCC's handling of `_Pragma`s in C++ mode meant that it did not always work.
|
||||
* You can now tell Catch to use C++11-based check when checking whether a type can be streamed to output.
|
||||
* This fixes cases when an unstreamable type has streamable private base (#877)
|
||||
* [Details can be found in documentation](configuration.md#catch_config_cpp11_stream_insertable_check)
|
||||
|
||||
|
||||
### Other notes:
|
||||
* We have added VS 2017 to our CI
|
||||
* Work on Catch 2 should start soon
|
||||
|
||||
|
||||
|
||||
# 1.8.2
|
||||
|
||||
|
||||
### Improvements and minor changes
|
||||
* TAP reporter now behaves as if `-s` was always set
|
||||
* This should be more consistent with the protocol desired behaviour.
|
||||
* Compact reporter now obeys `-d yes` argument (#780)
|
||||
* The format is "XXX.123 s: <section-name>" (3 decimal places are always present).
|
||||
* Before it did not report the durations at all.
|
||||
* XML reporter now behaves the same way as Console reporter in regards to `INFO`
|
||||
* This means it reports `INFO` messages on success, if output on success (`-s`) is enabled.
|
||||
* Previously it only reported `INFO` messages on failure.
|
||||
* `CAPTURE(expr)` now stringifies `expr` in the same way assertion macros do (#639)
|
||||
* Listeners are now finally [documented](event-listeners.md).
|
||||
* Listeners provide a way to hook into events generated by running your tests, including start and end of run, every test case, every section and every assertion.
|
||||
|
||||
|
||||
### Fixes:
|
||||
* Catch no longer attempts to reconstruct expression that led to a fatal error (#810)
|
||||
* This fixes possible signal/SEH loop when processing expressions, where the signal was triggered by expression decomposition.
|
||||
* Fixed (C4265) missing virtual destructor warning in Matchers (#844)
|
||||
* `std::string`s are now taken by `const&` everywhere (#842).
|
||||
* Previously some places were taking them by-value.
|
||||
* Catch should no longer change errno (#835).
|
||||
* This was caused by libstdc++ bug that we now work around.
|
||||
* Catch now provides `FAIL_CHECK( ... )` macro (#765).
|
||||
* Same as `FAIL( ... )`, but does not abort the test.
|
||||
* Functions like `fabs`, `tolower`, `memset`, `isalnum` are now used with `std::` qualification (#543).
|
||||
* Clara no longer assumes first argument (binary name) is always present (#729)
|
||||
* If it is missing, empty string is used as default.
|
||||
* Clara no longer reads 1 character past argument string (#830)
|
||||
* Regression in Objective-C bindings (Matchers) fixed (#854)
|
||||
|
||||
|
||||
### Other notes:
|
||||
* We have added VS 2013 and 2015 to our CI
|
||||
* Catch Classic (1.x.x) now contains its own, forked, version of Clara (the argument parser).
|
||||
|
||||
|
||||
|
||||
# 1.8.1
|
||||
|
||||
### Fixes
|
||||
|
||||
Cygwin issue with `gettimeofday` - `#define` was not early enough
|
||||
|
||||
# 1.8.0
|
||||
|
||||
### New features/ minor changes
|
||||
|
||||
* Matchers have new, simpler (and documented) interface.
|
||||
* Catch provides string and vector matchers.
|
||||
* For details see [Matchers documentation](docs/matchers.md).
|
||||
* For details see [Matchers documentation](matchers.md).
|
||||
* Changed console reporter test duration reporting format (#322)
|
||||
* Old format: `Some simple comparisons between doubles completed in 0.000123s`
|
||||
* New format: `xxx.123s: Some simple comparisons between doubles` _(There will always be exactly 3 decimal places)_
|
||||
* Added opt-in leak detection under MSVC + Windows (#439)
|
||||
* Enable it by compiling Catch's main with `CATCH_CONFIG_WINDOWS_CRTDBG`
|
||||
* Introduced new compile-time flag, `CATCH_CONFIG_FAST_COMPILE`, trading features for compilation speed.
|
||||
* Moves debug breaks out of tests and into implementation, speeding up compilation time by ~XX%
|
||||
* Moves debug breaks out of tests and into implementation, speeding up test compilation time (~10% on linux).
|
||||
* _More changes are coming_
|
||||
* Added [TAP (Test Anything Protocol)](https://testanything.org/) and [Automake](https://www.gnu.org/software/automake/manual/html_node/Log-files-generation-and-test-results-recording.html#Log-files-generation-and-test-results-recording) reporters.
|
||||
* These are not present in the default single-include header and need to be downloaded from GitHub separately.
|
||||
* For details see [documentation about integrating with build systems](docs/build-systems.md).
|
||||
* For details see [documentation about integrating with build systems](build-systems.md).
|
||||
* XML reporter now reports filename as part of the `Section` and `TestCase` tags.
|
||||
* `Approx` now supports an optional margin of absolute error
|
||||
* It has also received [new documentation]().
|
||||
* It has also received [new documentation](assertions.md).
|
||||
|
||||
### Fixes
|
||||
* Silenced C4312 ("conversion from int to 'ClassName *") warnings in the evaluate layer.
|
||||
@@ -61,7 +206,7 @@ Other:
|
||||
### Fixes:
|
||||
* Fixed inconsistency in defining `NOMINMAX` and `WIN32_LEAN_AND_MEAN` inside `catch.hpp`.
|
||||
* Fixed SEH-related compilation error under older MinGW compilers, by making Windows SEH handling opt-in for compilers other than MSVC.
|
||||
* For specifics, look into the [documentation](docs/configuration.md).
|
||||
* For specifics, look into the [documentation](configuration.md).
|
||||
* Fixed compilation error under MinGW caused by improper compiler detection.
|
||||
* Fixed XML reporter sometimes leaving an empty output file when a test ends with signal/structured exception.
|
||||
* Fixed XML reporter not reporting captured stdout/stderr.
|
||||
@@ -75,7 +220,7 @@ Other:
|
||||
* Microbenchmark focused on Catch's overhead went from ~3.4s to ~0.7s.
|
||||
* Real world test using [JSON for Modern C++](https://github.com/nlohmann/json)'s test suite went from ~6m 25s to ~4m 14s.
|
||||
* Catch can now run specific sections within test cases.
|
||||
* For now the support is only basic (no wildcards or tags), for details see the [documentation](docs/command-line.md).
|
||||
* For now the support is only basic (no wildcards or tags), for details see the [documentation](command-line.md).
|
||||
* Catch now supports SEH on Windows as well as signals on Linux.
|
||||
* After receiving a signal, Catch reports failing assertion and then passes the signal onto the previous handler.
|
||||
* Approx can be used to compare values against strong typedefs (available in C++11 mode only).
|
||||
@@ -112,7 +257,7 @@ Other:
|
||||
* Approval tests can now be run on Windows
|
||||
* CMake will now warn if a file is present in the `include` folder but not is not enumerated as part of the project
|
||||
* Catch now defines `NOMINMAX` and `WIN32_LEAN_AND_MEAN` before including `windows.h`
|
||||
* This can be disabled if needed, see [documentation](docs/configuration.md) for details.
|
||||
* This can be disabled if needed, see [documentation](configuration.md) for details.
|
||||
|
||||
|
||||
## 1.6.0
|
||||
|
44
docs/release-process.md
Normal file
44
docs/release-process.md
Normal file
@@ -0,0 +1,44 @@
|
||||
# How to release
|
||||
|
||||
When enough changes have accumulated, it is time to release new version of Catch. This document describes the proces in doing so, that no steps are forgotten. Note that all referenced scripts can be found in the `scripts/` directory.
|
||||
|
||||
|
||||
## Approval testing
|
||||
|
||||
Catch's releases are primarily validated against output from previous release, stored in `projects/SelfTest/Baselines`. To validate current sources, build the SelfTest binary and pass it to the `approvalTests.py` script: `approvalTests.py <path/to/SelfTest>`.
|
||||
|
||||
There should be no differences, as Approval tests should be updated when changes to Catch are made, but if there are, then they need to be manually reviewed and either approved (using `approve.py`) or Catch requires other fixes.
|
||||
|
||||
|
||||
## Incrementing version number
|
||||
|
||||
Catch uses a variant of [semantic versioning](http://semver.org/), with breaking API changes (and thus major version increments) being very rare. Thus, the release will usually increment the patch version, when it only contains couple of bugfixes, or minor version, when it contains new functionality, or larger changes in implementation of current functionality.
|
||||
|
||||
After deciding which part of version number should be incremented, you can use one of the `*Release.py` scripts to perform the required changes to Catch.
|
||||
|
||||
|
||||
## Generate updated single-include header
|
||||
|
||||
After updating version number, regenerate single-include header using `generateSingleHeader.py`.
|
||||
|
||||
|
||||
## Release notes
|
||||
|
||||
Once a release is ready, release notes need to be written. They should summarize changes done since last release. For rough idea of expected notes see previous releases. Once written, release notes should be placed in `docs/release-notes.md`.
|
||||
|
||||
|
||||
## Commit and push update to GitHub
|
||||
|
||||
After version number is incremented, single-include header is regenerated and release notes are updated, changes should be commited and pushed to GitHub.
|
||||
|
||||
|
||||
## Release on GitHub
|
||||
|
||||
After pushing changes to GitHub, GitHub release *needs* to be created. Tag version and release title should be same as the new version, description should contain the release notes for the current release. Single header version of `catch.hpp` *needs* to be attached as a binary, as that is where the official download link links to. Preferably it should use linux line endings.
|
||||
|
||||
|
||||
## vcpkg update
|
||||
|
||||
As a last step, optionally update Microsoft's package manager [vcpkg](https://github.com/Microsoft/vcpkg) with Catch's new version. `updateVcpkgPackage.py` can do a lot of neccessary work for you, but it assumes that you have your fork of vcpkg checked out in a directory next to the directory, where you have checked out Catch.
|
||||
|
||||
It creates a branch and commits neccessary changes, that you then should review, synchronize and open a PR against.
|
45
docs/reporters.md
Normal file
45
docs/reporters.md
Normal file
@@ -0,0 +1,45 @@
|
||||
# Reporters
|
||||
|
||||
Catch has a modular reporting system and comes bundled with a handful of useful reporters built in.
|
||||
You can also write your own reporters.
|
||||
|
||||
## Using different reporters
|
||||
|
||||
The reporter to use can easily be controlled from the command line.
|
||||
To specify a reporter use [`-r` or `--reporter`](command-line.md#choosing-a-reporter-to-use), followed by the name of the reporter, e.g.:
|
||||
|
||||
```
|
||||
-r xml
|
||||
```
|
||||
|
||||
If you don't specify a reporter then the console reporter is used by default.
|
||||
There are four reporters built in to the single include:
|
||||
|
||||
* `console` writes as lines of text, formatted to a typical terminal width, with colours if a capable terminal is detected.
|
||||
* `compact` similar to `console` but optimised for minimal output - each entry on one line
|
||||
* `junit` writes xml that corresponds to Ant's [junitreport](http://help.catchsoftware.com/display/ET/JUnit+Format) target. Useful for build systems that understand Junit. If you are using Jenkins with Catch 1.x, you can improve quality of output by applying changes in [#923](https://github.com/philsquared/Catch/pull/923).
|
||||
Because of the way the junit format is structured the run must complete before anything is written.
|
||||
* `xml` writes an xml format tailored to Catch. Unlike `junit` this is a streaming format so results are delivered progressively.
|
||||
|
||||
There are a few additional reporters, for specific build systems, in the Catch repository (in `include\reporters`) which you can `#include` in your project if you would like to make use of them.
|
||||
Do this in one source file - typically the same one you have `CATCH_CONFIG_MAIN` or `CATCH_CONFIG_RUNNER`.
|
||||
|
||||
* `teamcity` writes the native, streaming, format that [TeamCity](https://www.jetbrains.com/teamcity/) understands.
|
||||
Use this when building as part of a TeamCity build to see results as they happen.
|
||||
* `tap` writes in the TAP ([Test Anything Protocol](https://en.wikipedia.org/wiki/Test_Anything_Protocol)) format.
|
||||
* `automake` writes in a format that correspond to [automake .trs](https://www.gnu.org/software/automake/manual/html_node/Log-files-generation-and-test-results-recording.html) files
|
||||
|
||||
You see what reporters are available from the command line by running with `--list-reporters`.
|
||||
|
||||
By default all these reports are written to stdout, but can be redirected to a file with [`-o` or `--out`](command-line.md#sending-output-to-a-file)
|
||||
|
||||
## Writing your own reporter
|
||||
|
||||
You can write your own custom reporter and register it with Catch.
|
||||
At time of writing the interface is subject to some changes so is not, yet, documented here.
|
||||
If you are determined you shouldn't have too much trouble working it out from the existing implementations -
|
||||
but do keep in mind upcoming changes (these will be minor, simplifying, changes such as not needing to forward calls to the base class).
|
||||
|
||||
---
|
||||
|
||||
[Home](Readme.md)
|
@@ -28,7 +28,7 @@ The tag expression, ```"[widget]"``` selects A, B & D. ```"[gadget]"``` selects
|
||||
|
||||
For more detail on command line selection see [the command line docs](command-line.md#specifying-which-tests-to-run)
|
||||
|
||||
Tag names are not case sensitive.
|
||||
Tag names are not case sensitive and can contain any ASCII characters. This means that tags `[tag with spaces]` and `[I said "good day"]` are both allowed tags and can be filtered on. Escapes are not supported however and `[\]]` is not a valid tag.
|
||||
|
||||
### Special Tags
|
||||
|
||||
@@ -38,10 +38,10 @@ All tag names beginning with non-alphanumeric characters are reserved by Catch.
|
||||
|
||||
* `[!throws]` - lets Catch know that this test is likely to throw an exception even if successful. This causes the test to be excluded when running with `-e` or `--nothrow`.
|
||||
|
||||
* `[!shouldfail]` - reverse the failing logic of the test: if the test is successful if it fails, and vice-versa.
|
||||
|
||||
* `[!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.
|
||||
|
||||
* `[!shouldfail]` - like `[!mayfail]` but *fails* the test if it *passes*. This can be useful if you want to be notified of accidental, or third-party, fixes.
|
||||
|
||||
* `[!nonportable]` - Indicates that behaviour may vary between platforms or compilers.
|
||||
|
||||
* `[#<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]`.
|
||||
|
@@ -16,16 +16,7 @@ std::ostream& operator << ( std::ostream& os, T const& value ) {
|
||||
|
||||
(where ```T``` is your type and ```convertMyTypeToString``` is where you'll write whatever code is necessary to make your type printable - it doesn't have to be in another function).
|
||||
|
||||
You should put this function in the same namespace as your type.
|
||||
|
||||
Alternatively you may prefer to write it as a member function:
|
||||
|
||||
```
|
||||
std::ostream& T::operator << ( std::ostream& os ) const {
|
||||
os << convertMyTypeToString( *this );
|
||||
return os;
|
||||
}
|
||||
```
|
||||
You should put this function in the same namespace as your type and it has to be declared before including Catch's header.
|
||||
|
||||
## Catch::toString overload
|
||||
|
||||
@@ -39,11 +30,12 @@ namespace Catch {
|
||||
}
|
||||
```
|
||||
|
||||
Again ```T``` is your type and ```convertMyTypeToString``` is where you'll write whatever code is necessary to make your type printable. Note that the function must be in the Catch namespace, which itself must be in the global namespace.
|
||||
Again ```T``` is your type and ```convertMyTypeToString``` is where you'll write whatever code is necessary to make your type printable. Note that the function must be in the Catch namespace, which itself must be in the global namespace and must be declared _before_ Catch's header is included.
|
||||
|
||||
**Please note that overloading `Catch::toString` is currently considered legacy and will not be supported in the next major version of Catch.**
|
||||
|
||||
## Catch::StringMaker<T> specialisation
|
||||
|
||||
There are some cases where overloading toString does not work as expected. Specialising StringMaker<T> gives you more precise, and reliable, control - but at the cost of slightly more code and complexity:
|
||||
Another way of telling Catch how to convert a type to string is specialising `Catch::StringMaker` template. This allows you to have separate way of stringifying types for Catch, than you have for writing it to a stream and also doesn't require you to declare it before including Catch's header.
|
||||
|
||||
```
|
||||
namespace Catch {
|
||||
|
@@ -68,7 +68,7 @@ with expansion:
|
||||
0 == 1
|
||||
```
|
||||
|
||||
Note that we get the actual return value of Factorial(0) printed for us (0) - even though we used a natural expression with the == operator. That let's us immediately see what the problem is.
|
||||
Note that we get the actual return value of Factorial(0) printed for us (0) - even though we used a natural expression with the == operator. That lets us immediately see what the problem is.
|
||||
|
||||
Let's change the factorial function to:
|
||||
|
||||
|
@@ -57,16 +57,16 @@
|
||||
#include <crtdbg.h>
|
||||
class LeakDetector {
|
||||
public:
|
||||
LeakDetector() {
|
||||
int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
|
||||
flag |= _CRTDBG_LEAK_CHECK_DF;
|
||||
flag |= _CRTDBG_ALLOC_MEM_DF;
|
||||
_CrtSetDbgFlag(flag);
|
||||
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
|
||||
_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
|
||||
// Change this to leaking allocation's number to break there
|
||||
_CrtSetBreakAlloc(-1);
|
||||
}
|
||||
LeakDetector() {
|
||||
int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
|
||||
flag |= _CRTDBG_LEAK_CHECK_DF;
|
||||
flag |= _CRTDBG_ALLOC_MEM_DF;
|
||||
_CrtSetDbgFlag(flag);
|
||||
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
|
||||
_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
|
||||
// Change this to leaking allocation's number to break there
|
||||
_CrtSetBreakAlloc(-1);
|
||||
}
|
||||
};
|
||||
#else
|
||||
class LeakDetector {};
|
||||
@@ -91,33 +91,44 @@ LeakDetector leakDetector;
|
||||
// If this config identifier is defined then all CATCH macros are prefixed with CATCH_
|
||||
#ifdef CATCH_CONFIG_PREFIX_ALL
|
||||
|
||||
#define CATCH_REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE" )
|
||||
#define CATCH_REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, "CATCH_REQUIRE_FALSE" )
|
||||
#if defined(CATCH_CONFIG_FAST_COMPILE)
|
||||
#define CATCH_REQUIRE( expr ) INTERNAL_CATCH_TEST_NO_TRY( "CATCH_REQUIRE", Catch::ResultDisposition::Normal, expr )
|
||||
#define CATCH_REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST_NO_TRY( "CATCH_REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, expr )
|
||||
#else
|
||||
#define CATCH_REQUIRE( expr ) INTERNAL_CATCH_TEST( "CATCH_REQUIRE", Catch::ResultDisposition::Normal, expr )
|
||||
#define CATCH_REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( "CATCH_REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, expr )
|
||||
#endif
|
||||
|
||||
#define CATCH_REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, "", "CATCH_REQUIRE_THROWS" )
|
||||
#define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_THROWS_AS" )
|
||||
#define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, matcher, "CATCH_REQUIRE_THROWS_WITH" )
|
||||
#define CATCH_REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_NOTHROW" )
|
||||
#define CATCH_REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( "CATCH_REQUIRE_THROWS", Catch::ResultDisposition::Normal, "", expr )
|
||||
#define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CATCH_REQUIRE_THROWS_AS", exceptionType, Catch::ResultDisposition::Normal, expr )
|
||||
#define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( "CATCH_REQUIRE_THROWS_WITH", Catch::ResultDisposition::Normal, matcher, expr )
|
||||
#define CATCH_REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( "CATCH_REQUIRE_NOTHROW", Catch::ResultDisposition::Normal, expr )
|
||||
|
||||
#define CATCH_CHECK( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK" )
|
||||
#define CATCH_CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, "CATCH_CHECK_FALSE" )
|
||||
#define CATCH_CHECKED_IF( expr ) INTERNAL_CATCH_IF( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECKED_IF" )
|
||||
#define CATCH_CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECKED_ELSE" )
|
||||
#define CATCH_CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, "CATCH_CHECK_NOFAIL" )
|
||||
#define CATCH_CHECK( expr ) INTERNAL_CATCH_TEST( "CATCH_CHECK", Catch::ResultDisposition::ContinueOnFailure, expr )
|
||||
#define CATCH_CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( "CATCH_CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, expr )
|
||||
#define CATCH_CHECKED_IF( expr ) INTERNAL_CATCH_IF( "CATCH_CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure, expr )
|
||||
#define CATCH_CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( "CATCH_CHECKED_ELSE", Catch::ResultDisposition::ContinueOnFailure, expr )
|
||||
#define CATCH_CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( "CATCH_CHECK_NOFAIL", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, expr )
|
||||
|
||||
#define CATCH_CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, "", "CATCH_CHECK_THROWS" )
|
||||
#define CATCH_CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THROWS_AS" )
|
||||
#define CATCH_CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, matcher, "CATCH_CHECK_THROWS_WITH" )
|
||||
#define CATCH_CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_NOTHROW" )
|
||||
#define CATCH_CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( "CATCH_CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, "", expr )
|
||||
#define CATCH_CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CATCH_CHECK_THROWS_AS", exceptionType, Catch::ResultDisposition::ContinueOnFailure, expr )
|
||||
#define CATCH_CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( "CATCH_CHECK_THROWS_WITH", Catch::ResultDisposition::ContinueOnFailure, matcher, expr )
|
||||
#define CATCH_CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( "CATCH_CHECK_NOTHROW", Catch::ResultDisposition::ContinueOnFailure, expr )
|
||||
|
||||
#define CATCH_CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THAT" )
|
||||
#define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_THAT" )
|
||||
#define CATCH_CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CATCH_CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg )
|
||||
|
||||
#define CATCH_INFO( msg ) INTERNAL_CATCH_INFO( msg, "CATCH_INFO" )
|
||||
#define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, "CATCH_WARN", msg )
|
||||
#define CATCH_SCOPED_INFO( msg ) INTERNAL_CATCH_INFO( msg, "CATCH_INFO" )
|
||||
#define CATCH_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CATCH_CAPTURE" )
|
||||
#define CATCH_SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CATCH_CAPTURE" )
|
||||
#if defined(CATCH_CONFIG_FAST_COMPILE)
|
||||
#define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT_NO_TRY( "CATCH_REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg )
|
||||
#else
|
||||
#define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CATCH_REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg )
|
||||
#endif
|
||||
|
||||
|
||||
#define CATCH_INFO( msg ) INTERNAL_CATCH_INFO( "CATCH_INFO", msg )
|
||||
#define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( "CATCH_WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg )
|
||||
#define CATCH_SCOPED_INFO( msg ) INTERNAL_CATCH_INFO( "CATCH_INFO", msg )
|
||||
#define CATCH_CAPTURE( msg ) INTERNAL_CATCH_INFO( "CATCH_CAPTURE", #msg " := " << Catch::toString(msg) )
|
||||
#define CATCH_SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( "CATCH_CAPTURE", #msg " := " << Catch::toString(msg) )
|
||||
|
||||
#ifdef CATCH_CONFIG_VARIADIC_MACROS
|
||||
#define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
|
||||
@@ -125,16 +136,18 @@ LeakDetector leakDetector;
|
||||
#define CATCH_METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ )
|
||||
#define CATCH_REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ )
|
||||
#define CATCH_SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ )
|
||||
#define CATCH_FAIL( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "CATCH_FAIL", __VA_ARGS__ )
|
||||
#define CATCH_SUCCEED( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "CATCH_SUCCEED", __VA_ARGS__ )
|
||||
#define CATCH_FAIL( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ )
|
||||
#define CATCH_FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
|
||||
#define CATCH_SUCCEED( ... ) INTERNAL_CATCH_MSG( "CATCH_SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
|
||||
#else
|
||||
#define CATCH_TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
|
||||
#define CATCH_TEST_CASE_METHOD( className, name, description ) INTERNAL_CATCH_TEST_CASE_METHOD( className, name, description )
|
||||
#define CATCH_METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description )
|
||||
#define CATCH_REGISTER_TEST_CASE( function, name, description ) INTERNAL_CATCH_REGISTER_TESTCASE( function, name, description )
|
||||
#define CATCH_SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
|
||||
#define CATCH_FAIL( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "CATCH_FAIL", msg )
|
||||
#define CATCH_SUCCEED( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "CATCH_SUCCEED", msg )
|
||||
#define CATCH_FAIL( msg ) INTERNAL_CATCH_MSG( "CATCH_FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, msg )
|
||||
#define CATCH_FAIL_CHECK( msg ) INTERNAL_CATCH_MSG( "CATCH_FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, msg )
|
||||
#define CATCH_SUCCEED( msg ) INTERNAL_CATCH_MSG( "CATCH_SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, msg )
|
||||
#endif
|
||||
#define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "" )
|
||||
|
||||
@@ -160,50 +173,64 @@ LeakDetector leakDetector;
|
||||
// If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required
|
||||
#else
|
||||
|
||||
#define REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "REQUIRE" )
|
||||
#define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, "REQUIRE_FALSE" )
|
||||
#if defined(CATCH_CONFIG_FAST_COMPILE)
|
||||
#define REQUIRE( expr ) INTERNAL_CATCH_TEST_NO_TRY( "REQUIRE", Catch::ResultDisposition::Normal, expr )
|
||||
#define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST_NO_TRY( "REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, expr )
|
||||
|
||||
#define REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, "", "REQUIRE_THROWS" )
|
||||
#define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::Normal, "REQUIRE_THROWS_AS" )
|
||||
#define REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, matcher, "REQUIRE_THROWS_WITH" )
|
||||
#define REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::Normal, "REQUIRE_NOTHROW" )
|
||||
#else
|
||||
#define REQUIRE( expr ) INTERNAL_CATCH_TEST( "REQUIRE", Catch::ResultDisposition::Normal, expr )
|
||||
#define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( "REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, expr )
|
||||
#endif
|
||||
|
||||
#define CHECK( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK" )
|
||||
#define CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, "CHECK_FALSE" )
|
||||
#define CHECKED_IF( expr ) INTERNAL_CATCH_IF( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECKED_IF" )
|
||||
#define CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECKED_ELSE" )
|
||||
#define CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, "CHECK_NOFAIL" )
|
||||
#define REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( "REQUIRE_THROWS", Catch::ResultDisposition::Normal, "", expr )
|
||||
#define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "REQUIRE_THROWS_AS", exceptionType, Catch::ResultDisposition::Normal, expr )
|
||||
#define REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( "REQUIRE_THROWS_WITH", Catch::ResultDisposition::Normal, matcher, expr )
|
||||
#define REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( "REQUIRE_NOTHROW", Catch::ResultDisposition::Normal, expr )
|
||||
|
||||
#define CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, "", "CHECK_THROWS" )
|
||||
#define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THROWS_AS" )
|
||||
#define CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, matcher, "CHECK_THROWS_WITH" )
|
||||
#define CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK_NOTHROW" )
|
||||
#define CHECK( expr ) INTERNAL_CATCH_TEST( "CHECK", Catch::ResultDisposition::ContinueOnFailure, expr )
|
||||
#define CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( "CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, expr )
|
||||
#define CHECKED_IF( expr ) INTERNAL_CATCH_IF( "CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure, expr )
|
||||
#define CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( "CHECKED_ELSE", Catch::ResultDisposition::ContinueOnFailure, expr )
|
||||
#define CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( "CHECK_NOFAIL", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, expr )
|
||||
|
||||
#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THAT" )
|
||||
#define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::Normal, "REQUIRE_THAT" )
|
||||
#define CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( "CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, "", expr )
|
||||
#define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CHECK_THROWS_AS", exceptionType, Catch::ResultDisposition::ContinueOnFailure, expr )
|
||||
#define CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( "CHECK_THROWS_WITH", Catch::ResultDisposition::ContinueOnFailure, matcher, expr )
|
||||
#define CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( "CHECK_NOTHROW", Catch::ResultDisposition::ContinueOnFailure, expr )
|
||||
|
||||
#define INFO( msg ) INTERNAL_CATCH_INFO( msg, "INFO" )
|
||||
#define WARN( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, "WARN", msg )
|
||||
#define SCOPED_INFO( msg ) INTERNAL_CATCH_INFO( msg, "INFO" )
|
||||
#define CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CAPTURE" )
|
||||
#define SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CAPTURE" )
|
||||
#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg )
|
||||
|
||||
#if defined(CATCH_CONFIG_FAST_COMPILE)
|
||||
#define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT_NO_TRY( "REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg )
|
||||
#else
|
||||
#define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg )
|
||||
#endif
|
||||
|
||||
|
||||
#define INFO( msg ) INTERNAL_CATCH_INFO( "INFO", msg )
|
||||
#define WARN( msg ) INTERNAL_CATCH_MSG( "WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg )
|
||||
#define SCOPED_INFO( msg ) INTERNAL_CATCH_INFO( "INFO", msg )
|
||||
#define CAPTURE( msg ) INTERNAL_CATCH_INFO( "CAPTURE", #msg " := " << Catch::toString(msg) )
|
||||
#define SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( "CAPTURE", #msg " := " << Catch::toString(msg) )
|
||||
|
||||
#ifdef CATCH_CONFIG_VARIADIC_MACROS
|
||||
#define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
|
||||
#define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ )
|
||||
#define METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ )
|
||||
#define REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ )
|
||||
#define SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ )
|
||||
#define FAIL( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "FAIL", __VA_ARGS__ )
|
||||
#define SUCCEED( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "SUCCEED", __VA_ARGS__ )
|
||||
#define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
|
||||
#define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ )
|
||||
#define METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ )
|
||||
#define REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ )
|
||||
#define SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ )
|
||||
#define FAIL( ... ) INTERNAL_CATCH_MSG( "FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ )
|
||||
#define FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
|
||||
#define SUCCEED( ... ) INTERNAL_CATCH_MSG( "SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
|
||||
#else
|
||||
#define TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
|
||||
#define TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
|
||||
#define TEST_CASE_METHOD( className, name, description ) INTERNAL_CATCH_TEST_CASE_METHOD( className, name, description )
|
||||
#define METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description )
|
||||
#define REGISTER_TEST_CASE( method, name, description ) INTERNAL_CATCH_REGISTER_TESTCASE( method, name, description )
|
||||
#define SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
|
||||
#define FAIL( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "FAIL", msg )
|
||||
#define SUCCEED( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "SUCCEED", msg )
|
||||
#define FAIL( msg ) INTERNAL_CATCH_MSG( "FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, msg )
|
||||
#define FAIL_CHECK( msg ) INTERNAL_CATCH_MSG( "FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, msg )
|
||||
#define SUCCEED( msg ) INTERNAL_CATCH_MSG( "SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, msg )
|
||||
#endif
|
||||
#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "" )
|
||||
|
||||
|
@@ -125,7 +125,7 @@ namespace Catch {
|
||||
}
|
||||
|
||||
void showHelp( std::string const& processName ) {
|
||||
Catch::cout() << "\nCatch v" << libraryVersion << "\n";
|
||||
Catch::cout() << "\nCatch v" << libraryVersion() << "\n";
|
||||
|
||||
m_cli.usage( Catch::cout(), processName );
|
||||
Catch::cout() << "For more detail usage please see the project docs\n" << std::endl;
|
||||
@@ -166,6 +166,32 @@ namespace Catch {
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
#if defined(WIN32) && defined(UNICODE)
|
||||
int run( int argc, wchar_t const* const* const argv ) {
|
||||
|
||||
char **utf8Argv = new char *[ argc ];
|
||||
|
||||
for ( int i = 0; i < argc; ++i ) {
|
||||
int bufSize = WideCharToMultiByte( CP_UTF8, 0, argv[i], -1, NULL, 0, NULL, NULL );
|
||||
|
||||
utf8Argv[ i ] = new char[ bufSize ];
|
||||
|
||||
WideCharToMultiByte( CP_UTF8, 0, argv[i], -1, utf8Argv[i], bufSize, NULL, NULL );
|
||||
}
|
||||
|
||||
int returnCode = applyCommandLine( argc, utf8Argv );
|
||||
if( returnCode == 0 )
|
||||
returnCode = run();
|
||||
|
||||
for ( int i = 0; i < argc; ++i )
|
||||
delete [] utf8Argv[ i ];
|
||||
|
||||
delete [] utf8Argv;
|
||||
|
||||
return returnCode;
|
||||
}
|
||||
#endif
|
||||
|
||||
int run() {
|
||||
if( m_configData.showHelp )
|
||||
return 0;
|
||||
|
9
include/external/clara.h
vendored
9
include/external/clara.h
vendored
@@ -41,6 +41,7 @@
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
|
||||
// Use optional outer namespace
|
||||
#ifdef STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE
|
||||
@@ -397,7 +398,7 @@ namespace Clara {
|
||||
_dest = _source;
|
||||
}
|
||||
char toLowerCh(char c) {
|
||||
return static_cast<char>( ::tolower( c ) );
|
||||
return static_cast<char>( std::tolower( c ) );
|
||||
}
|
||||
inline void convertInto( std::string const& _source, bool& _dest ) {
|
||||
std::string sourceLC = _source;
|
||||
@@ -553,12 +554,13 @@ namespace Clara {
|
||||
}
|
||||
|
||||
void parseIntoTokens( std::string const& arg, std::vector<Token>& tokens ) {
|
||||
for( std::size_t i = 0; i <= arg.size(); ++i ) {
|
||||
for( std::size_t i = 0; i < arg.size(); ++i ) {
|
||||
char c = arg[i];
|
||||
if( c == '"' )
|
||||
inQuotes = !inQuotes;
|
||||
mode = handleMode( i, c, arg, tokens );
|
||||
}
|
||||
mode = handleMode( arg.size(), '\0', arg, tokens );
|
||||
}
|
||||
Mode handleMode( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) {
|
||||
switch( mode ) {
|
||||
@@ -591,6 +593,7 @@ namespace Clara {
|
||||
default: from = i; return ShortOpt;
|
||||
}
|
||||
}
|
||||
|
||||
Mode handleOpt( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) {
|
||||
if( std::string( ":=\0", 3 ).find( c ) == std::string::npos )
|
||||
return mode;
|
||||
@@ -924,7 +927,7 @@ namespace Clara {
|
||||
}
|
||||
|
||||
std::vector<Parser::Token> parseInto( std::vector<std::string> const& args, ConfigT& config ) const {
|
||||
std::string processName = args[0];
|
||||
std::string processName = args.empty() ? std::string() : args[0];
|
||||
std::size_t lastSlash = processName.find_last_of( "/\\" );
|
||||
if( lastSlash != std::string::npos )
|
||||
processName = processName.substr( lastSlash+1 );
|
||||
|
@@ -40,15 +40,22 @@ namespace Detail {
|
||||
return Approx( 0 );
|
||||
}
|
||||
|
||||
Approx operator()( double value ) {
|
||||
Approx approx( value );
|
||||
#if defined(CATCH_CONFIG_CPP11_TYPE_TRAITS)
|
||||
|
||||
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
|
||||
Approx operator()( T value ) {
|
||||
Approx approx( static_cast<double>(value) );
|
||||
approx.epsilon( m_epsilon );
|
||||
approx.margin( m_margin );
|
||||
approx.scale( m_scale );
|
||||
return approx;
|
||||
}
|
||||
|
||||
#if defined(CATCH_CONFIG_CPP11_TYPE_TRAITS)
|
||||
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
|
||||
explicit Approx( T value ): Approx(static_cast<double>(value))
|
||||
{}
|
||||
|
||||
|
||||
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
|
||||
friend bool operator == ( const T& lhs, Approx const& rhs ) {
|
||||
// Thanks to Richard Harris for his help refining this formula
|
||||
@@ -76,29 +83,54 @@ namespace Detail {
|
||||
}
|
||||
|
||||
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
|
||||
friend bool operator <= ( T lhs, Approx const& rhs )
|
||||
{
|
||||
return double(lhs) < rhs.m_value || lhs == rhs;
|
||||
friend bool operator <= ( T lhs, Approx const& rhs ) {
|
||||
return double(lhs) < rhs.m_value || lhs == rhs;
|
||||
}
|
||||
|
||||
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
|
||||
friend bool operator <= ( Approx const& lhs, T rhs )
|
||||
{
|
||||
return lhs.m_value < double(rhs) || lhs == rhs;
|
||||
friend bool operator <= ( Approx const& lhs, T rhs ) {
|
||||
return lhs.m_value < double(rhs) || lhs == rhs;
|
||||
}
|
||||
|
||||
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
|
||||
friend bool operator >= ( T lhs, Approx const& rhs )
|
||||
{
|
||||
return double(lhs) > rhs.m_value || lhs == rhs;
|
||||
friend bool operator >= ( T lhs, Approx const& rhs ) {
|
||||
return double(lhs) > rhs.m_value || lhs == rhs;
|
||||
}
|
||||
|
||||
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
|
||||
friend bool operator >= ( Approx const& lhs, T rhs )
|
||||
{
|
||||
return lhs.m_value > double(rhs) || lhs == rhs;
|
||||
friend bool operator >= ( Approx const& lhs, T rhs ) {
|
||||
return lhs.m_value > double(rhs) || lhs == rhs;
|
||||
}
|
||||
|
||||
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
|
||||
Approx& epsilon( T newEpsilon ) {
|
||||
m_epsilon = double(newEpsilon);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
|
||||
Approx& margin( T newMargin ) {
|
||||
m_margin = double(newMargin);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
|
||||
Approx& scale( T newScale ) {
|
||||
m_scale = double(newScale);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
Approx operator()( double value ) {
|
||||
Approx approx( value );
|
||||
approx.epsilon( m_epsilon );
|
||||
approx.margin( m_margin );
|
||||
approx.scale( m_scale );
|
||||
return approx;
|
||||
}
|
||||
|
||||
|
||||
friend bool operator == ( double lhs, Approx const& rhs ) {
|
||||
// Thanks to Richard Harris for his help refining this formula
|
||||
bool relativeOK = std::fabs( lhs - rhs.m_value ) < rhs.m_epsilon * (rhs.m_scale + (std::max)( std::fabs(lhs), std::fabs(rhs.m_value) ) );
|
||||
@@ -120,26 +152,21 @@ namespace Detail {
|
||||
return !operator==( rhs, lhs );
|
||||
}
|
||||
|
||||
friend bool operator <= ( double lhs, Approx const& rhs )
|
||||
{
|
||||
return lhs < rhs.m_value || lhs == rhs;
|
||||
friend bool operator <= ( double lhs, Approx const& rhs ) {
|
||||
return lhs < rhs.m_value || lhs == rhs;
|
||||
}
|
||||
|
||||
friend bool operator <= ( Approx const& lhs, double rhs )
|
||||
{
|
||||
return lhs.m_value < rhs || lhs == rhs;
|
||||
friend bool operator <= ( Approx const& lhs, double rhs ) {
|
||||
return lhs.m_value < rhs || lhs == rhs;
|
||||
}
|
||||
|
||||
friend bool operator >= ( double lhs, Approx const& rhs )
|
||||
{
|
||||
return lhs > rhs.m_value || lhs == rhs;
|
||||
friend bool operator >= ( double lhs, Approx const& rhs ) {
|
||||
return lhs > rhs.m_value || lhs == rhs;
|
||||
}
|
||||
|
||||
friend bool operator >= ( Approx const& lhs, double rhs )
|
||||
{
|
||||
return lhs.m_value > rhs || lhs == rhs;
|
||||
friend bool operator >= ( Approx const& lhs, double rhs ) {
|
||||
return lhs.m_value > rhs || lhs == rhs;
|
||||
}
|
||||
#endif
|
||||
|
||||
Approx& epsilon( double newEpsilon ) {
|
||||
m_epsilon = newEpsilon;
|
||||
@@ -155,6 +182,7 @@ namespace Detail {
|
||||
m_scale = newScale;
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string toString() const {
|
||||
std::ostringstream oss;
|
||||
|
@@ -33,22 +33,24 @@ namespace Catch {
|
||||
template<typename T> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator && ( T const& );
|
||||
template<typename T> STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator || ( T const& );
|
||||
|
||||
private:
|
||||
DecomposedExpression& operator = (DecomposedExpression const&);
|
||||
private:
|
||||
DecomposedExpression& operator = (DecomposedExpression const&);
|
||||
};
|
||||
|
||||
struct AssertionInfo
|
||||
{
|
||||
AssertionInfo() {}
|
||||
AssertionInfo( std::string const& _macroName,
|
||||
AssertionInfo( char const * _macroName,
|
||||
SourceLineInfo const& _lineInfo,
|
||||
std::string const& _capturedExpression,
|
||||
ResultDisposition::Flags _resultDisposition );
|
||||
char const * _capturedExpression,
|
||||
ResultDisposition::Flags _resultDisposition,
|
||||
char const * _secondArg = "");
|
||||
|
||||
std::string macroName;
|
||||
char const * macroName;
|
||||
SourceLineInfo lineInfo;
|
||||
std::string capturedExpression;
|
||||
char const * capturedExpression;
|
||||
ResultDisposition::Flags resultDisposition;
|
||||
char const * secondArg;
|
||||
};
|
||||
|
||||
struct AssertionResultData
|
||||
|
@@ -13,14 +13,16 @@
|
||||
namespace Catch {
|
||||
|
||||
|
||||
AssertionInfo::AssertionInfo( std::string const& _macroName,
|
||||
AssertionInfo::AssertionInfo( char const * _macroName,
|
||||
SourceLineInfo const& _lineInfo,
|
||||
std::string const& _capturedExpression,
|
||||
ResultDisposition::Flags _resultDisposition )
|
||||
char const * _capturedExpression,
|
||||
ResultDisposition::Flags _resultDisposition,
|
||||
char const * _secondArg)
|
||||
: macroName( _macroName ),
|
||||
lineInfo( _lineInfo ),
|
||||
capturedExpression( _capturedExpression ),
|
||||
resultDisposition( _resultDisposition )
|
||||
resultDisposition( _resultDisposition ),
|
||||
secondArg( _secondArg )
|
||||
{}
|
||||
|
||||
AssertionResult::AssertionResult() {}
|
||||
@@ -47,24 +49,30 @@ namespace Catch {
|
||||
}
|
||||
|
||||
bool AssertionResult::hasExpression() const {
|
||||
return !m_info.capturedExpression.empty();
|
||||
return m_info.capturedExpression[0] != 0;
|
||||
}
|
||||
|
||||
bool AssertionResult::hasMessage() const {
|
||||
return !m_resultData.message.empty();
|
||||
}
|
||||
|
||||
std::string capturedExpressionWithSecondArgument( char const * capturedExpression, char const * secondArg ) {
|
||||
return (secondArg[0] == 0 || secondArg[0] == '"' && secondArg[1] == '"')
|
||||
? capturedExpression
|
||||
: std::string(capturedExpression) + ", " + secondArg;
|
||||
}
|
||||
|
||||
std::string AssertionResult::getExpression() const {
|
||||
if( isFalseTest( m_info.resultDisposition ) )
|
||||
return '!' + m_info.capturedExpression;
|
||||
return '!' + capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg);
|
||||
else
|
||||
return m_info.capturedExpression;
|
||||
return capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg);
|
||||
}
|
||||
std::string AssertionResult::getExpressionInMacro() const {
|
||||
if( m_info.macroName.empty() )
|
||||
return m_info.capturedExpression;
|
||||
if( m_info.macroName[0] == 0 )
|
||||
return capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg);
|
||||
else
|
||||
return m_info.macroName + "( " + m_info.capturedExpression + " )";
|
||||
return std::string(m_info.macroName) + "( " + capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg) + " )";
|
||||
}
|
||||
|
||||
bool AssertionResult::hasExpandedExpression() const {
|
||||
|
@@ -16,7 +16,6 @@
|
||||
#include "catch_tostring.h"
|
||||
#include "catch_interfaces_runner.h"
|
||||
#include "catch_compiler_capabilities.h"
|
||||
#include "catch_type_traits.hpp"
|
||||
|
||||
|
||||
#if defined(CATCH_CONFIG_FAST_COMPILE)
|
||||
@@ -26,6 +25,33 @@
|
||||
// macro in each assertion
|
||||
#define INTERNAL_CATCH_REACT( resultBuilder ) \
|
||||
resultBuilder.react();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Another way to speed-up compilation is to omit local try-catch for REQUIRE*
|
||||
// macros.
|
||||
// This can potentially cause false negative, if the test code catches
|
||||
// the exception before it propagates back up to the runner.
|
||||
#define INTERNAL_CATCH_TEST_NO_TRY( macroName, resultDisposition, expr ) \
|
||||
do { \
|
||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \
|
||||
__catchResult.setExceptionGuard(); \
|
||||
CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
|
||||
( __catchResult <= expr ).endExpression(); \
|
||||
CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \
|
||||
__catchResult.unsetExceptionGuard(); \
|
||||
INTERNAL_CATCH_REACT( __catchResult ) \
|
||||
} while( Catch::isTrue( false && static_cast<bool>( !!(expr) ) ) ) // expr here is never evaluated at runtime but it forces the compiler to give it a look
|
||||
// The double negation silences MSVC's C4800 warning, the static_cast forces short-circuit evaluation if the type has overloaded &&.
|
||||
|
||||
#define INTERNAL_CHECK_THAT_NO_TRY( macroName, matcher, resultDisposition, arg ) \
|
||||
do { \
|
||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #arg ", " #matcher, resultDisposition ); \
|
||||
__catchResult.setExceptionGuard(); \
|
||||
__catchResult.captureMatch( arg, matcher, #matcher ); \
|
||||
__catchResult.unsetExceptionGuard(); \
|
||||
INTERNAL_CATCH_REACT( __catchResult ) \
|
||||
} while( Catch::alwaysFalse() )
|
||||
|
||||
#else
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// In the event of a failure works out if the debugger needs to be invoked
|
||||
@@ -34,12 +60,12 @@
|
||||
// source code rather than in Catch library code
|
||||
#define INTERNAL_CATCH_REACT( resultBuilder ) \
|
||||
if( resultBuilder.shouldDebugBreak() ) CATCH_BREAK_INTO_DEBUGGER(); \
|
||||
resultBuilder.react();
|
||||
resultBuilder.react();
|
||||
#endif
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ) \
|
||||
#define INTERNAL_CATCH_TEST( macroName, resultDisposition, expr ) \
|
||||
do { \
|
||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \
|
||||
try { \
|
||||
@@ -55,17 +81,17 @@
|
||||
// The double negation silences MSVC's C4800 warning, the static_cast forces short-circuit evaluation if the type has overloaded &&.
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_IF( expr, resultDisposition, macroName ) \
|
||||
INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \
|
||||
#define INTERNAL_CATCH_IF( macroName, resultDisposition, expr ) \
|
||||
INTERNAL_CATCH_TEST( macroName, resultDisposition, expr ); \
|
||||
if( Catch::getResultCapture().getLastResult()->succeeded() )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_ELSE( expr, resultDisposition, macroName ) \
|
||||
INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \
|
||||
#define INTERNAL_CATCH_ELSE( macroName, resultDisposition, expr ) \
|
||||
INTERNAL_CATCH_TEST( macroName, resultDisposition, expr ); \
|
||||
if( !Catch::getResultCapture().getLastResult()->succeeded() )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_NO_THROW( expr, resultDisposition, macroName ) \
|
||||
#define INTERNAL_CATCH_NO_THROW( macroName, resultDisposition, expr ) \
|
||||
do { \
|
||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \
|
||||
try { \
|
||||
@@ -79,7 +105,7 @@
|
||||
} while( Catch::alwaysFalse() )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_THROWS( expr, resultDisposition, matcher, macroName ) \
|
||||
#define INTERNAL_CATCH_THROWS( macroName, resultDisposition, matcher, expr ) \
|
||||
do { \
|
||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition, #matcher ); \
|
||||
if( __catchResult.allowThrows() ) \
|
||||
@@ -96,7 +122,7 @@
|
||||
} while( Catch::alwaysFalse() )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_THROWS_AS( expr, exceptionType, resultDisposition, macroName ) \
|
||||
#define INTERNAL_CATCH_THROWS_AS( macroName, exceptionType, resultDisposition, expr ) \
|
||||
do { \
|
||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr ", " #exceptionType, resultDisposition ); \
|
||||
if( __catchResult.allowThrows() ) \
|
||||
@@ -104,7 +130,7 @@
|
||||
static_cast<void>(expr); \
|
||||
__catchResult.captureResult( Catch::ResultWas::DidntThrowException ); \
|
||||
} \
|
||||
catch( Catch::add_const<Catch::add_lvalue_reference<exceptionType>::type>::type ) { \
|
||||
catch( exceptionType ) { \
|
||||
__catchResult.captureResult( Catch::ResultWas::Ok ); \
|
||||
} \
|
||||
catch( ... ) { \
|
||||
@@ -118,7 +144,7 @@
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef CATCH_CONFIG_VARIADIC_MACROS
|
||||
#define INTERNAL_CATCH_MSG( messageType, resultDisposition, macroName, ... ) \
|
||||
#define INTERNAL_CATCH_MSG( macroName, messageType, resultDisposition, ... ) \
|
||||
do { \
|
||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, "", resultDisposition ); \
|
||||
__catchResult << __VA_ARGS__ + ::Catch::StreamEndStop(); \
|
||||
@@ -126,7 +152,7 @@
|
||||
INTERNAL_CATCH_REACT( __catchResult ) \
|
||||
} while( Catch::alwaysFalse() )
|
||||
#else
|
||||
#define INTERNAL_CATCH_MSG( messageType, resultDisposition, macroName, log ) \
|
||||
#define INTERNAL_CATCH_MSG( macroName, messageType, resultDisposition, log ) \
|
||||
do { \
|
||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, "", resultDisposition ); \
|
||||
__catchResult << log + ::Catch::StreamEndStop(); \
|
||||
@@ -136,11 +162,11 @@
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_INFO( log, macroName ) \
|
||||
#define INTERNAL_CATCH_INFO( macroName, log ) \
|
||||
Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME( scopedMessage ) = Catch::MessageBuilder( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CHECK_THAT( arg, matcher, resultDisposition, macroName ) \
|
||||
#define INTERNAL_CHECK_THAT( macroName, matcher, resultDisposition, arg ) \
|
||||
do { \
|
||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #arg ", " #matcher, resultDisposition ); \
|
||||
try { \
|
||||
|
@@ -187,6 +187,10 @@ namespace Catch {
|
||||
.describe( "list all/matching test cases names only" )
|
||||
.bind( &ConfigData::listTestNamesOnly );
|
||||
|
||||
cli["--list-extra-info"]
|
||||
.describe( "list all/matching test cases with more info" )
|
||||
.bind( &ConfigData::listExtraInfo );
|
||||
|
||||
cli["--list-reporters"]
|
||||
.describe( "list all reporters" )
|
||||
.bind( &ConfigData::listReporters );
|
||||
|
@@ -63,6 +63,12 @@
|
||||
# endif
|
||||
|
||||
# if defined(CATCH_CPP11_OR_GREATER)
|
||||
# define CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
||||
_Pragma( "clang diagnostic push" ) \
|
||||
_Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" )
|
||||
# define CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
|
||||
_Pragma( "clang diagnostic pop" )
|
||||
|
||||
# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
|
||||
_Pragma( "clang diagnostic push" ) \
|
||||
_Pragma( "clang diagnostic ignored \"-Wparentheses\"" )
|
||||
@@ -74,13 +80,24 @@
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Cygwin
|
||||
#ifdef __CYGWIN__
|
||||
// We know some environments not to support full POSIX signals
|
||||
#if defined(__CYGWIN__) || defined(__QNX__)
|
||||
|
||||
# if !defined(CATCH_CONFIG_POSIX_SIGNALS)
|
||||
# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Cygwin
|
||||
#ifdef __CYGWIN__
|
||||
|
||||
// Required for some versions of Cygwin to declare gettimeofday
|
||||
// see: http://stackoverflow.com/questions/36901803/gettimeofday-not-declared-in-this-scope-cygwin
|
||||
# define _BSD_SOURCE
|
||||
|
||||
#endif // __CYGWIN__
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -108,23 +125,10 @@
|
||||
// GCC
|
||||
#ifdef __GNUC__
|
||||
|
||||
# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
|
||||
# define CATCH_GCC_HAS_NEW_PRAGMA
|
||||
# endif
|
||||
|
||||
# if __GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||
# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
|
||||
# endif
|
||||
|
||||
# if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) && defined(CATCH_GCC_HAS_NEW_PRAGMA)
|
||||
# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
|
||||
_Pragma( "GCC diagnostic push" ) \
|
||||
_Pragma( "GCC diagnostic ignored \"-Wparentheses\"" )
|
||||
# define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \
|
||||
_Pragma( "GCC diagnostic pop" )
|
||||
# endif
|
||||
|
||||
|
||||
|
||||
// - otherwise more recent versions define __cplusplus >= 201103L
|
||||
// and will get picked up below
|
||||
@@ -166,7 +170,7 @@
|
||||
|
||||
// Use __COUNTER__ if the compiler supports it
|
||||
#if ( defined _MSC_VER && _MSC_VER >= 1300 ) || \
|
||||
( defined __GNUC__ && __GNUC__ >= 4 && __GNUC_MINOR__ >= 3 ) || \
|
||||
( defined __GNUC__ && ( __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3 )) ) || \
|
||||
( defined __clang__ && __clang_major__ >= 3 )
|
||||
|
||||
#define CATCH_INTERNAL_CONFIG_COUNTER
|
||||
@@ -266,7 +270,7 @@
|
||||
# define CATCH_CONFIG_WINDOWS_SEH
|
||||
#endif
|
||||
// This is set by default, because we assume that unix compilers are posix-signal-compatible by default.
|
||||
#if !defined(CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_POSIX_SIGNALS)
|
||||
#if !defined(CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_POSIX_SIGNALS)
|
||||
# define CATCH_CONFIG_POSIX_SIGNALS
|
||||
#endif
|
||||
|
||||
@@ -274,6 +278,10 @@
|
||||
# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS
|
||||
# define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS
|
||||
#endif
|
||||
#if !defined(CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS)
|
||||
# define CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS
|
||||
# define CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
|
||||
#endif
|
||||
|
||||
// noexcept support:
|
||||
#if defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_NOEXCEPT)
|
||||
|
@@ -31,6 +31,7 @@ namespace Catch {
|
||||
listTags( false ),
|
||||
listReporters( false ),
|
||||
listTestNamesOnly( false ),
|
||||
listExtraInfo( false ),
|
||||
showSuccessfulTests( false ),
|
||||
shouldDebugBreak( false ),
|
||||
noThrow( false ),
|
||||
@@ -50,6 +51,7 @@ namespace Catch {
|
||||
bool listTags;
|
||||
bool listReporters;
|
||||
bool listTestNamesOnly;
|
||||
bool listExtraInfo;
|
||||
|
||||
bool showSuccessfulTests;
|
||||
bool shouldDebugBreak;
|
||||
@@ -109,6 +111,7 @@ namespace Catch {
|
||||
bool listTestNamesOnly() const { return m_data.listTestNamesOnly; }
|
||||
bool listTags() const { return m_data.listTags; }
|
||||
bool listReporters() const { return m_data.listReporters; }
|
||||
bool listExtraInfo() const { return m_data.listExtraInfo; }
|
||||
|
||||
std::string getProcessName() const { return m_data.processName; }
|
||||
|
||||
|
@@ -9,6 +9,7 @@
|
||||
#define TWOBLUECUBES_CATCH_CONSOLE_COLOUR_IMPL_HPP_INCLUDED
|
||||
|
||||
#include "catch_console_colour.hpp"
|
||||
#include "catch_errno_guard.hpp"
|
||||
|
||||
namespace Catch {
|
||||
namespace {
|
||||
@@ -148,6 +149,7 @@ namespace {
|
||||
};
|
||||
|
||||
IColourImpl* platformColourInstance() {
|
||||
ErrnoGuard guard;
|
||||
Ptr<IConfig const> config = getCurrentContext().getConfig();
|
||||
UseColour::YesOrNo colourMode = config
|
||||
? config->useColour()
|
||||
|
@@ -10,6 +10,7 @@
|
||||
#define TWOBLUECUBES_CATCH_DEBUGGER_HPP_INCLUDED
|
||||
|
||||
#include "catch_debugger.h"
|
||||
#include "catch_errno_guard.hpp"
|
||||
|
||||
#ifdef CATCH_PLATFORM_MAC
|
||||
|
||||
@@ -72,6 +73,9 @@
|
||||
// be strace, for example) in /proc/$PID/status, so just get it from
|
||||
// there instead.
|
||||
bool isDebuggerActive(){
|
||||
// Libstdc++ has a bug, where std::ifstream sets errno to 0
|
||||
// This way our users can properly assert over errno values
|
||||
ErrnoGuard guard;
|
||||
std::ifstream in("/proc/self/status");
|
||||
for( std::string line; std::getline(in, line); ) {
|
||||
static const int PREFIX_LEN = 11;
|
||||
|
@@ -10,9 +10,15 @@
|
||||
|
||||
#ifndef __OBJC__
|
||||
|
||||
#if defined(WIN32) && defined(_UNICODE) && !defined(DO_NOT_USE_WMAIN)
|
||||
// Standard C/C++ Win32 Unicode wmain entry point
|
||||
extern "C" int wmain (int argc, wchar_t * argv[], wchar_t * []) {
|
||||
#else
|
||||
// Standard C/C++ main entry point
|
||||
int main (int argc, char * argv[]) {
|
||||
int result = Catch::Session().run( argc, argv );
|
||||
#endif
|
||||
|
||||
int result = Catch::Session().run( argc, argv );
|
||||
return ( result < 0xff ? result : 0xff );
|
||||
}
|
||||
|
||||
|
25
include/internal/catch_errno_guard.hpp
Normal file
25
include/internal/catch_errno_guard.hpp
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Created by Martin on 06/03/2017.
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef TWOBLUECUBES_CATCH_ERRNO_GUARD_HPP_INCLUDED
|
||||
#define TWOBLUECUBES_CATCH_ERRNO_GUARD_HPP_INCLUDED
|
||||
|
||||
#include <cerrno>
|
||||
|
||||
|
||||
namespace Catch {
|
||||
|
||||
class ErrnoGuard {
|
||||
public:
|
||||
ErrnoGuard():m_oldErrno(errno){}
|
||||
~ErrnoGuard() { errno = m_oldErrno; }
|
||||
private:
|
||||
int m_oldErrno;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_ERRNO_GUARD_HPP_INCLUDED
|
@@ -81,7 +81,7 @@ public:
|
||||
}
|
||||
|
||||
virtual void reconstructExpression( std::string& dest ) const CATCH_OVERRIDE {
|
||||
dest = Catch::toString( m_truthy );
|
||||
dest = Catch::toString( m_lhs );
|
||||
}
|
||||
|
||||
private:
|
||||
|
@@ -28,7 +28,7 @@ namespace Catch {
|
||||
|
||||
namespace Catch {
|
||||
struct FatalConditionHandler {
|
||||
void reset() {}
|
||||
void reset() {}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -53,7 +53,6 @@ namespace Catch {
|
||||
static LONG CALLBACK handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo) {
|
||||
for (int i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) {
|
||||
if (ExceptionInfo->ExceptionRecord->ExceptionCode == signalDefs[i].id) {
|
||||
reset();
|
||||
reportFatal(signalDefs[i].name);
|
||||
}
|
||||
}
|
||||
@@ -107,7 +106,7 @@ namespace Catch {
|
||||
|
||||
namespace Catch {
|
||||
struct FatalConditionHandler {
|
||||
void reset() {}
|
||||
void reset() {}
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -10,7 +10,6 @@
|
||||
|
||||
#include "catch_context.h"
|
||||
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <stdlib.h>
|
||||
@@ -124,7 +123,7 @@ public:
|
||||
private:
|
||||
|
||||
void move( CompositeGenerator& other ) {
|
||||
std::copy( other.m_composed.begin(), other.m_composed.end(), std::back_inserter( m_composed ) );
|
||||
m_composed.insert( m_composed.end(), other.m_composed.begin(), other.m_composed.end() );
|
||||
m_totalSize += other.m_totalSize;
|
||||
other.m_composed.clear();
|
||||
}
|
||||
|
@@ -91,6 +91,7 @@ namespace Catch {
|
||||
TestSpec::NamePattern::~NamePattern() {}
|
||||
TestSpec::TagPattern::~TagPattern() {}
|
||||
TestSpec::ExcludedPattern::~ExcludedPattern() {}
|
||||
Matchers::Impl::MatcherUntypedBase::~MatcherUntypedBase() {}
|
||||
|
||||
void Config::dummy() {}
|
||||
|
||||
|
@@ -38,6 +38,8 @@ namespace Catch {
|
||||
virtual std::string getCurrentTestName() const = 0;
|
||||
virtual const AssertionResult* getLastResult() const = 0;
|
||||
|
||||
virtual void exceptionEarlyReported() = 0;
|
||||
|
||||
virtual void handleFatalErrorCondition( std::string const& message ) = 0;
|
||||
};
|
||||
|
||||
|
@@ -20,12 +20,15 @@ namespace Catch {
|
||||
struct IExceptionTranslator;
|
||||
struct IReporterRegistry;
|
||||
struct IReporterFactory;
|
||||
struct ITagAliasRegistry;
|
||||
|
||||
struct IRegistryHub {
|
||||
virtual ~IRegistryHub();
|
||||
|
||||
virtual IReporterRegistry const& getReporterRegistry() const = 0;
|
||||
virtual ITestCaseRegistry const& getTestCaseRegistry() const = 0;
|
||||
virtual ITagAliasRegistry const& getTagAliasRegistry() const = 0;
|
||||
|
||||
virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() = 0;
|
||||
};
|
||||
|
||||
@@ -35,6 +38,7 @@ namespace Catch {
|
||||
virtual void registerListener( Ptr<IReporterFactory> const& factory ) = 0;
|
||||
virtual void registerTest( TestCase const& testInfo ) = 0;
|
||||
virtual void registerTranslator( const IExceptionTranslator* translator ) = 0;
|
||||
virtual void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) = 0;
|
||||
};
|
||||
|
||||
IRegistryHub& getRegistryHub();
|
||||
|
@@ -30,8 +30,9 @@ namespace Catch {
|
||||
}
|
||||
|
||||
std::size_t matchedTests = 0;
|
||||
TextAttributes nameAttr, tagsAttr;
|
||||
TextAttributes nameAttr, descAttr, tagsAttr;
|
||||
nameAttr.setInitialIndent( 2 ).setIndent( 4 );
|
||||
descAttr.setIndent( 4 );
|
||||
tagsAttr.setIndent( 6 );
|
||||
|
||||
std::vector<TestCase> matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config );
|
||||
@@ -46,6 +47,13 @@ namespace Catch {
|
||||
Colour colourGuard( colour );
|
||||
|
||||
Catch::cout() << Text( testCaseInfo.name, nameAttr ) << std::endl;
|
||||
if( config.listExtraInfo() ) {
|
||||
Catch::cout() << " " << testCaseInfo.lineInfo << std::endl;
|
||||
std::string description = testCaseInfo.description;
|
||||
if( description.empty() )
|
||||
description = "(NO DESCRIPTION)";
|
||||
Catch::cout() << Text( description, descAttr ) << std::endl;
|
||||
}
|
||||
if( !testCaseInfo.tags.empty() )
|
||||
Catch::cout() << Text( testCaseInfo.tagsAsString, tagsAttr ) << std::endl;
|
||||
}
|
||||
@@ -69,9 +77,12 @@ namespace Catch {
|
||||
matchedTests++;
|
||||
TestCaseInfo const& testCaseInfo = it->getTestCaseInfo();
|
||||
if( startsWith( testCaseInfo.name, '#' ) )
|
||||
Catch::cout() << '"' << testCaseInfo.name << '"' << std::endl;
|
||||
Catch::cout() << '"' << testCaseInfo.name << '"';
|
||||
else
|
||||
Catch::cout() << testCaseInfo.name << std::endl;
|
||||
Catch::cout() << testCaseInfo.name;
|
||||
if ( config.listExtraInfo() )
|
||||
Catch::cout() << "\t@" << testCaseInfo.lineInfo;
|
||||
Catch::cout() << std::endl;
|
||||
}
|
||||
return matchedTests;
|
||||
}
|
||||
@@ -163,7 +174,7 @@ namespace Catch {
|
||||
|
||||
inline Option<std::size_t> list( Config const& config ) {
|
||||
Option<std::size_t> listedCount;
|
||||
if( config.listTests() )
|
||||
if( config.listTests() || ( config.listExtraInfo() && !config.listTestNamesOnly() ) )
|
||||
listedCount = listedCount.valueOr(0) + listTests( config );
|
||||
if( config.listTestNamesOnly() )
|
||||
listedCount = listedCount.valueOr(0) + listTestsNamesOnly( config );
|
||||
|
@@ -27,16 +27,25 @@ namespace Matchers {
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ~MatcherUntypedBase();
|
||||
virtual std::string describe() const = 0;
|
||||
mutable std::string m_cachedToString;
|
||||
private:
|
||||
MatcherUntypedBase& operator = ( MatcherUntypedBase const& );
|
||||
};
|
||||
|
||||
template<typename ObjectT, typename ComparatorT = ObjectT>
|
||||
struct MatcherBase : MatcherUntypedBase {
|
||||
|
||||
template<typename ObjectT>
|
||||
struct MatcherMethod {
|
||||
virtual bool match( ObjectT const& arg ) const = 0;
|
||||
};
|
||||
template<typename PtrT>
|
||||
struct MatcherMethod<PtrT*> {
|
||||
virtual bool match( PtrT* arg ) const = 0;
|
||||
};
|
||||
|
||||
template<typename ObjectT, typename ComparatorT = ObjectT>
|
||||
struct MatcherBase : MatcherUntypedBase, MatcherMethod<ObjectT> {
|
||||
|
||||
|
||||
MatchAllOf<ComparatorT> operator && ( MatcherBase const& other ) const;
|
||||
MatchAnyOf<ComparatorT> operator || ( MatcherBase const& other ) const;
|
||||
|
@@ -26,7 +26,7 @@ namespace Matchers {
|
||||
};
|
||||
|
||||
struct StringMatcherBase : MatcherBase<std::string> {
|
||||
StringMatcherBase( std::string operation, CasedString const& comparator );
|
||||
StringMatcherBase( std::string const& operation, CasedString const& comparator );
|
||||
virtual std::string describe() const CATCH_OVERRIDE;
|
||||
|
||||
CasedString m_comparator;
|
||||
|
@@ -29,7 +29,7 @@ namespace Matchers {
|
||||
}
|
||||
|
||||
|
||||
StringMatcherBase::StringMatcherBase( std::string operation, CasedString const& comparator )
|
||||
StringMatcherBase::StringMatcherBase( std::string const& operation, CasedString const& comparator )
|
||||
: m_comparator( comparator ),
|
||||
m_operation( operation ) {
|
||||
}
|
||||
|
@@ -38,7 +38,9 @@ namespace Catch {
|
||||
{}
|
||||
|
||||
ScopedMessage::~ScopedMessage() {
|
||||
getResultCapture().popScopedMessage( m_info );
|
||||
if ( !std::uncaught_exception() ){
|
||||
getResultCapture().popScopedMessage(m_info);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -105,64 +105,67 @@ namespace Catch {
|
||||
namespace Impl {
|
||||
namespace NSStringMatchers {
|
||||
|
||||
template<typename MatcherT>
|
||||
struct StringHolder : MatcherImpl<MatcherT, NSString*>{
|
||||
struct StringHolder : MatcherBase<NSString*>{
|
||||
StringHolder( NSString* substr ) : m_substr( [substr copy] ){}
|
||||
StringHolder( StringHolder const& other ) : m_substr( [other.m_substr copy] ){}
|
||||
StringHolder() {
|
||||
arcSafeRelease( m_substr );
|
||||
}
|
||||
|
||||
virtual bool match( NSString* arg ) const CATCH_OVERRIDE {
|
||||
return false;
|
||||
}
|
||||
|
||||
NSString* m_substr;
|
||||
};
|
||||
|
||||
struct Equals : StringHolder<Equals> {
|
||||
struct Equals : StringHolder {
|
||||
Equals( NSString* substr ) : StringHolder( substr ){}
|
||||
|
||||
virtual bool match( ExpressionType const& str ) const {
|
||||
virtual bool match( NSString* str ) const CATCH_OVERRIDE {
|
||||
return (str != nil || m_substr == nil ) &&
|
||||
[str isEqualToString:m_substr];
|
||||
}
|
||||
|
||||
virtual std::string toString() const {
|
||||
virtual std::string describe() const CATCH_OVERRIDE {
|
||||
return "equals string: " + Catch::toString( m_substr );
|
||||
}
|
||||
};
|
||||
|
||||
struct Contains : StringHolder<Contains> {
|
||||
struct Contains : StringHolder {
|
||||
Contains( NSString* substr ) : StringHolder( substr ){}
|
||||
|
||||
virtual bool match( ExpressionType const& str ) const {
|
||||
virtual bool match( NSString* str ) const {
|
||||
return (str != nil || m_substr == nil ) &&
|
||||
[str rangeOfString:m_substr].location != NSNotFound;
|
||||
}
|
||||
|
||||
virtual std::string toString() const {
|
||||
virtual std::string describe() const CATCH_OVERRIDE {
|
||||
return "contains string: " + Catch::toString( m_substr );
|
||||
}
|
||||
};
|
||||
|
||||
struct StartsWith : StringHolder<StartsWith> {
|
||||
struct StartsWith : StringHolder {
|
||||
StartsWith( NSString* substr ) : StringHolder( substr ){}
|
||||
|
||||
virtual bool match( ExpressionType const& str ) const {
|
||||
virtual bool match( NSString* str ) const {
|
||||
return (str != nil || m_substr == nil ) &&
|
||||
[str rangeOfString:m_substr].location == 0;
|
||||
}
|
||||
|
||||
virtual std::string toString() const {
|
||||
virtual std::string describe() const CATCH_OVERRIDE {
|
||||
return "starts with: " + Catch::toString( m_substr );
|
||||
}
|
||||
};
|
||||
struct EndsWith : StringHolder<EndsWith> {
|
||||
struct EndsWith : StringHolder {
|
||||
EndsWith( NSString* substr ) : StringHolder( substr ){}
|
||||
|
||||
virtual bool match( ExpressionType const& str ) const {
|
||||
virtual bool match( NSString* str ) const {
|
||||
return (str != nil || m_substr == nil ) &&
|
||||
[str rangeOfString:m_substr].location == [str length] - [m_substr length];
|
||||
}
|
||||
|
||||
virtual std::string toString() const {
|
||||
virtual std::string describe() const CATCH_OVERRIDE {
|
||||
return "ends with: " + Catch::toString( m_substr );
|
||||
}
|
||||
};
|
||||
|
@@ -66,8 +66,18 @@ namespace Catch {
|
||||
}
|
||||
|
||||
private:
|
||||
T* nullableValue;
|
||||
char storage[sizeof(T)];
|
||||
T *nullableValue;
|
||||
union {
|
||||
char storage[sizeof(T)];
|
||||
|
||||
// These are here to force alignment for the storage
|
||||
long double dummy1;
|
||||
void (*dummy2)();
|
||||
long double dummy3;
|
||||
#ifdef CATCH_CONFIG_CPP11_LONG_LONG
|
||||
long long dummy4;
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
} // end namespace Catch
|
||||
|
@@ -13,6 +13,7 @@
|
||||
#include "catch_test_case_registry_impl.hpp"
|
||||
#include "catch_reporter_registry.hpp"
|
||||
#include "catch_exception_translator_registry.hpp"
|
||||
#include "catch_tag_alias_registry.h"
|
||||
|
||||
namespace Catch {
|
||||
|
||||
@@ -35,6 +36,10 @@ namespace Catch {
|
||||
virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() CATCH_OVERRIDE {
|
||||
return m_exceptionTranslatorRegistry;
|
||||
}
|
||||
virtual ITagAliasRegistry const& getTagAliasRegistry() const CATCH_OVERRIDE {
|
||||
return m_tagAliasRegistry;
|
||||
}
|
||||
|
||||
|
||||
public: // IMutableRegistryHub
|
||||
virtual void registerReporter( std::string const& name, Ptr<IReporterFactory> const& factory ) CATCH_OVERRIDE {
|
||||
@@ -49,11 +54,15 @@ namespace Catch {
|
||||
virtual void registerTranslator( const IExceptionTranslator* translator ) CATCH_OVERRIDE {
|
||||
m_exceptionTranslatorRegistry.registerTranslator( translator );
|
||||
}
|
||||
virtual void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) CATCH_OVERRIDE {
|
||||
m_tagAliasRegistry.add( alias, tag, lineInfo );
|
||||
}
|
||||
|
||||
private:
|
||||
TestRegistry m_testCaseRegistry;
|
||||
ReporterRegistry m_reporterRegistry;
|
||||
ExceptionTranslatorRegistry m_exceptionTranslatorRegistry;
|
||||
TagAliasRegistry m_tagAliasRegistry;
|
||||
};
|
||||
|
||||
// Single, global, instance
|
||||
|
@@ -92,7 +92,11 @@ namespace Catch {
|
||||
#define INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) \
|
||||
namespace{ Catch::ReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name ); }
|
||||
|
||||
// Deprecated - use the form without INTERNAL_
|
||||
#define INTERNAL_CATCH_REGISTER_LISTENER( listenerType ) \
|
||||
namespace{ Catch::ListenerRegistrar<listenerType> catch_internal_RegistrarFor##listenerType; }
|
||||
|
||||
#define CATCH_REGISTER_LISTENER( listenerType ) \
|
||||
namespace{ Catch::ListenerRegistrar<listenerType> catch_internal_RegistrarFor##listenerType; }
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
|
||||
|
@@ -39,6 +39,7 @@ namespace Catch {
|
||||
char const* capturedExpression,
|
||||
ResultDisposition::Flags resultDisposition,
|
||||
char const* secondArg = "" );
|
||||
~ResultBuilder();
|
||||
|
||||
template<typename T>
|
||||
ExpressionLhs<T const&> operator <= ( T const& operand );
|
||||
@@ -46,7 +47,7 @@ namespace Catch {
|
||||
|
||||
template<typename T>
|
||||
ResultBuilder& operator << ( T const& value ) {
|
||||
m_stream.oss << value;
|
||||
m_stream().oss << value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -73,13 +74,22 @@ namespace Catch {
|
||||
template<typename ArgT, typename MatcherT>
|
||||
void captureMatch( ArgT const& arg, MatcherT const& matcher, char const* matcherString );
|
||||
|
||||
void setExceptionGuard();
|
||||
void unsetExceptionGuard();
|
||||
|
||||
private:
|
||||
AssertionInfo m_assertionInfo;
|
||||
AssertionResultData m_data;
|
||||
CopyableStream m_stream;
|
||||
|
||||
static CopyableStream &m_stream()
|
||||
{
|
||||
static CopyableStream s;
|
||||
return s;
|
||||
}
|
||||
|
||||
bool m_shouldDebugBreak;
|
||||
bool m_shouldThrow;
|
||||
bool m_guardException;
|
||||
};
|
||||
|
||||
} // namespace Catch
|
||||
|
@@ -18,20 +18,28 @@
|
||||
|
||||
namespace Catch {
|
||||
|
||||
std::string capturedExpressionWithSecondArgument( std::string const& capturedExpression, std::string const& secondArg ) {
|
||||
return secondArg.empty() || secondArg == "\"\""
|
||||
? capturedExpression
|
||||
: capturedExpression + ", " + secondArg;
|
||||
}
|
||||
ResultBuilder::ResultBuilder( char const* macroName,
|
||||
SourceLineInfo const& lineInfo,
|
||||
char const* capturedExpression,
|
||||
ResultDisposition::Flags resultDisposition,
|
||||
char const* secondArg )
|
||||
: m_assertionInfo( macroName, lineInfo, capturedExpressionWithSecondArgument( capturedExpression, secondArg ), resultDisposition ),
|
||||
: m_assertionInfo( macroName, lineInfo, capturedExpression, resultDisposition, secondArg ),
|
||||
m_shouldDebugBreak( false ),
|
||||
m_shouldThrow( false )
|
||||
{}
|
||||
m_shouldThrow( false ),
|
||||
m_guardException( false )
|
||||
{
|
||||
m_stream().oss.str("");
|
||||
}
|
||||
|
||||
ResultBuilder::~ResultBuilder() {
|
||||
#if defined(CATCH_CONFIG_FAST_COMPILE)
|
||||
if ( m_guardException ) {
|
||||
m_stream().oss << "Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE";
|
||||
captureResult( ResultWas::ThrewException );
|
||||
getCurrentContext().getResultCapture()->exceptionEarlyReported();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
ResultBuilder& ResultBuilder::setResultType( ResultWas::OfType result ) {
|
||||
m_data.resultType = result;
|
||||
@@ -49,7 +57,7 @@ namespace Catch {
|
||||
|
||||
void ResultBuilder::useActiveException( ResultDisposition::Flags resultDisposition ) {
|
||||
m_assertionInfo.resultDisposition = resultDisposition;
|
||||
m_stream.oss << Catch::translateActiveException();
|
||||
m_stream().oss << Catch::translateActiveException();
|
||||
captureResult( ResultWas::ThrewException );
|
||||
}
|
||||
|
||||
@@ -71,7 +79,7 @@ namespace Catch {
|
||||
assert( !isFalseTest( m_assertionInfo.resultDisposition ) );
|
||||
AssertionResultData data = m_data;
|
||||
data.resultType = ResultWas::Ok;
|
||||
data.reconstructedExpression = m_assertionInfo.capturedExpression;
|
||||
data.reconstructedExpression = capturedExpressionWithSecondArgument(m_assertionInfo.capturedExpression, m_assertionInfo.secondArg);
|
||||
|
||||
std::string actualMessage = Catch::translateActiveException();
|
||||
if( !matcher.match( actualMessage ) ) {
|
||||
@@ -137,13 +145,20 @@ namespace Catch {
|
||||
data.negate( expr.isBinaryExpression() );
|
||||
}
|
||||
|
||||
data.message = m_stream.oss.str();
|
||||
data.message = m_stream().oss.str();
|
||||
data.decomposedExpression = &expr; // for lazy reconstruction
|
||||
return AssertionResult( m_assertionInfo, data );
|
||||
}
|
||||
|
||||
void ResultBuilder::reconstructExpression( std::string& dest ) const {
|
||||
dest = m_assertionInfo.capturedExpression;
|
||||
dest = capturedExpressionWithSecondArgument(m_assertionInfo.capturedExpression, m_assertionInfo.secondArg);
|
||||
}
|
||||
|
||||
void ResultBuilder::setExceptionGuard() {
|
||||
m_guardException = true;
|
||||
}
|
||||
void ResultBuilder::unsetExceptionGuard() {
|
||||
m_guardException = false;
|
||||
}
|
||||
|
||||
} // end namespace Catch
|
||||
|
@@ -64,7 +64,8 @@ namespace Catch {
|
||||
m_context( getCurrentMutableContext() ),
|
||||
m_activeTestCase( CATCH_NULL ),
|
||||
m_config( _config ),
|
||||
m_reporter( reporter )
|
||||
m_reporter( reporter ),
|
||||
m_shouldReportUnexpected ( true )
|
||||
{
|
||||
m_context.setRunner( this );
|
||||
m_context.setConfig( m_config );
|
||||
@@ -144,11 +145,12 @@ namespace Catch {
|
||||
m_totals.assertions.failed++;
|
||||
}
|
||||
|
||||
if( m_reporter->assertionEnded( AssertionStats( result, m_messages, m_totals ) ) )
|
||||
m_messages.clear();
|
||||
// We have no use for the return value (whether messages should be cleared), because messages were made scoped
|
||||
// and should be let to clear themselves out.
|
||||
static_cast<void>(m_reporter->assertionEnded(AssertionStats(result, m_messages, m_totals)));
|
||||
|
||||
// Reset working state
|
||||
m_lastAssertionInfo = AssertionInfo( std::string(), m_lastAssertionInfo.lineInfo, "{Unknown expression after the reported line}" , m_lastAssertionInfo.resultDisposition );
|
||||
m_lastAssertionInfo = AssertionInfo( "", m_lastAssertionInfo.lineInfo, "{Unknown expression after the reported line}" , m_lastAssertionInfo.resultDisposition );
|
||||
m_lastResult = result;
|
||||
}
|
||||
|
||||
@@ -223,11 +225,19 @@ namespace Catch {
|
||||
return &m_lastResult;
|
||||
}
|
||||
|
||||
virtual void exceptionEarlyReported() {
|
||||
m_shouldReportUnexpected = false;
|
||||
}
|
||||
|
||||
virtual void handleFatalErrorCondition( std::string const& message ) {
|
||||
ResultBuilder resultBuilder = makeUnexpectedResultBuilder();
|
||||
resultBuilder.setResultType( ResultWas::FatalErrorCondition );
|
||||
resultBuilder << message;
|
||||
resultBuilder.captureExpression();
|
||||
// Don't rebuild the result -- the stringification itself can cause more fatal errors
|
||||
// Instead, fake a result data.
|
||||
AssertionResultData tempResult;
|
||||
tempResult.resultType = ResultWas::FatalErrorCondition;
|
||||
tempResult.message = message;
|
||||
AssertionResult result(m_lastAssertionInfo, tempResult);
|
||||
|
||||
getResultCapture().assertionEnded(result);
|
||||
|
||||
handleUnfinishedSections();
|
||||
|
||||
@@ -268,8 +278,9 @@ namespace Catch {
|
||||
m_reporter->sectionStarting( testCaseSection );
|
||||
Counts prevAssertions = m_totals.assertions;
|
||||
double duration = 0;
|
||||
m_shouldReportUnexpected = true;
|
||||
try {
|
||||
m_lastAssertionInfo = AssertionInfo( "TEST_CASE", testCaseInfo.lineInfo, std::string(), ResultDisposition::Normal );
|
||||
m_lastAssertionInfo = AssertionInfo( "TEST_CASE", testCaseInfo.lineInfo, "", ResultDisposition::Normal );
|
||||
|
||||
seedRng( *m_config );
|
||||
|
||||
@@ -289,7 +300,11 @@ namespace Catch {
|
||||
// This just means the test was aborted due to failure
|
||||
}
|
||||
catch(...) {
|
||||
makeUnexpectedResultBuilder().useActiveException();
|
||||
// Under CATCH_CONFIG_FAST_COMPILE, unexpected exceptions under REQUIRE assertions
|
||||
// are reported without translation at the point of origin.
|
||||
if (m_shouldReportUnexpected) {
|
||||
makeUnexpectedResultBuilder().useActiveException();
|
||||
}
|
||||
}
|
||||
m_testCaseTracker->close();
|
||||
handleUnfinishedSections();
|
||||
@@ -317,9 +332,9 @@ namespace Catch {
|
||||
private:
|
||||
|
||||
ResultBuilder makeUnexpectedResultBuilder() const {
|
||||
return ResultBuilder( m_lastAssertionInfo.macroName.c_str(),
|
||||
return ResultBuilder( m_lastAssertionInfo.macroName,
|
||||
m_lastAssertionInfo.lineInfo,
|
||||
m_lastAssertionInfo.capturedExpression.c_str(),
|
||||
m_lastAssertionInfo.capturedExpression,
|
||||
m_lastAssertionInfo.resultDisposition );
|
||||
}
|
||||
|
||||
@@ -349,6 +364,7 @@ namespace Catch {
|
||||
std::vector<SectionEndInfo> m_unfinishedSections;
|
||||
std::vector<ITracker*> m_activeSections;
|
||||
TrackerContext m_trackerContext;
|
||||
bool m_shouldReportUnexpected;
|
||||
};
|
||||
|
||||
IResultCapture& getResultCapture() {
|
||||
|
@@ -30,6 +30,10 @@ namespace Catch {
|
||||
m_timer.start();
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4996) // std::uncaught_exception is deprecated in C++17
|
||||
#endif
|
||||
Section::~Section() {
|
||||
if( m_sectionIncluded ) {
|
||||
SectionEndInfo endInfo( m_info, m_assertions, m_timer.getElapsedSeconds() );
|
||||
@@ -39,6 +43,9 @@ namespace Catch {
|
||||
getResultCapture().sectionEnded( endInfo );
|
||||
}
|
||||
}
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
// This indicates whether the section should be executed or not
|
||||
Section::operator bool() const {
|
||||
|
@@ -24,11 +24,7 @@
|
||||
#elif defined __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wvariadic-macros"
|
||||
# pragma GCC diagnostic ignored "-Wunused-variable"
|
||||
|
||||
// For newer version we can use __Pragma to disable the warnings locally
|
||||
# if __GNUC__ == 4 && __GNUC_MINOR__ >= 4 && __GNUC_MINOR__ <= 7
|
||||
# pragma GCC diagnostic ignored "-Wparentheses"
|
||||
# endif
|
||||
# pragma GCC diagnostic ignored "-Wparentheses"
|
||||
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wpadded"
|
||||
|
@@ -15,7 +15,7 @@
|
||||
namespace Catch {
|
||||
|
||||
struct TagAlias {
|
||||
TagAlias( std::string _tag, SourceLineInfo _lineInfo ) : tag( _tag ), lineInfo( _lineInfo ) {}
|
||||
TagAlias( std::string const& _tag, SourceLineInfo _lineInfo ) : tag( _tag ), lineInfo( _lineInfo ) {}
|
||||
|
||||
std::string tag;
|
||||
SourceLineInfo lineInfo;
|
||||
|
@@ -19,8 +19,7 @@ namespace Catch {
|
||||
virtual ~TagAliasRegistry();
|
||||
virtual Option<TagAlias> find( std::string const& alias ) const;
|
||||
virtual std::string expandAliases( std::string const& unexpandedTestSpec ) const;
|
||||
void add( char const* alias, char const* tag, SourceLineInfo const& lineInfo );
|
||||
static TagAliasRegistry& get();
|
||||
void add( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo );
|
||||
|
||||
private:
|
||||
std::map<std::string, TagAlias> m_registry;
|
||||
|
@@ -10,6 +10,8 @@
|
||||
|
||||
#include "catch_tag_alias_registry.h"
|
||||
#include "catch_console_colour.hpp"
|
||||
#include "catch_interfaces_registry_hub.h"
|
||||
#include "catch_stream.h"
|
||||
|
||||
namespace Catch {
|
||||
|
||||
@@ -38,41 +40,36 @@ namespace Catch {
|
||||
return expandedTestSpec;
|
||||
}
|
||||
|
||||
void TagAliasRegistry::add( char const* alias, char const* tag, SourceLineInfo const& lineInfo ) {
|
||||
void TagAliasRegistry::add( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) {
|
||||
|
||||
if( !startsWith( alias, "[@" ) || !endsWith( alias, ']' ) ) {
|
||||
std::ostringstream oss;
|
||||
oss << "error: tag alias, \"" << alias << "\" is not of the form [@alias name].\n" << lineInfo;
|
||||
oss << Colour( Colour::Red )
|
||||
<< "error: tag alias, \"" << alias << "\" is not of the form [@alias name].\n"
|
||||
<< Colour( Colour::FileName )
|
||||
<< lineInfo << '\n';
|
||||
throw std::domain_error( oss.str().c_str() );
|
||||
}
|
||||
if( !m_registry.insert( std::make_pair( alias, TagAlias( tag, lineInfo ) ) ).second ) {
|
||||
std::ostringstream oss;
|
||||
oss << "error: tag alias, \"" << alias << "\" already registered.\n"
|
||||
<< "\tFirst seen at " << find(alias)->lineInfo << '\n'
|
||||
<< "\tRedefined at " << lineInfo;
|
||||
oss << Colour( Colour::Red )
|
||||
<< "error: tag alias, \"" << alias << "\" already registered.\n"
|
||||
<< "\tFirst seen at "
|
||||
<< Colour( Colour::Red ) << find(alias)->lineInfo << '\n'
|
||||
<< Colour( Colour::Red ) << "\tRedefined at "
|
||||
<< Colour( Colour::FileName) << lineInfo << '\n';
|
||||
throw std::domain_error( oss.str().c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
TagAliasRegistry& TagAliasRegistry::get() {
|
||||
static TagAliasRegistry instance;
|
||||
return instance;
|
||||
ITagAliasRegistry::~ITagAliasRegistry() {}
|
||||
|
||||
ITagAliasRegistry const& ITagAliasRegistry::get() {
|
||||
return getRegistryHub().getTagAliasRegistry();
|
||||
}
|
||||
|
||||
ITagAliasRegistry::~ITagAliasRegistry() {}
|
||||
ITagAliasRegistry const& ITagAliasRegistry::get() { return TagAliasRegistry::get(); }
|
||||
|
||||
|
||||
RegistrarForTagAliases::RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ) {
|
||||
try {
|
||||
TagAliasRegistry::get().add( alias, tag, lineInfo );
|
||||
}
|
||||
catch( std::exception& ex ) {
|
||||
Colour colourGuard( Colour::Red );
|
||||
Catch::cerr() << ex.what() << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
getMutableRegistryHub().registerTagAlias( alias, tag, lineInfo );
|
||||
}
|
||||
|
||||
} // end namespace Catch
|
||||
|
@@ -38,17 +38,13 @@ namespace Catch {
|
||||
}
|
||||
inline void enforceNotReservedTag( std::string const& tag, SourceLineInfo const& _lineInfo ) {
|
||||
if( isReservedTag( tag ) ) {
|
||||
{
|
||||
Colour colourGuard( Colour::Red );
|
||||
Catch::cerr()
|
||||
<< "Tag name [" << tag << "] not allowed.\n"
|
||||
<< "Tag names starting with non alpha-numeric characters are reserved\n";
|
||||
}
|
||||
{
|
||||
Colour colourGuard( Colour::FileName );
|
||||
Catch::cerr() << _lineInfo << std::endl;
|
||||
}
|
||||
exit(1);
|
||||
std::ostringstream ss;
|
||||
ss << Colour(Colour::Red)
|
||||
<< "Tag name [" << tag << "] not allowed.\n"
|
||||
<< "Tag names starting with non alpha-numeric characters are reserved\n"
|
||||
<< Colour(Colour::FileName)
|
||||
<< _lineInfo << '\n';
|
||||
throw std::runtime_error(ss.str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -11,13 +11,14 @@
|
||||
#include "catch_compiler_capabilities.h"
|
||||
#include "catch_ptr.hpp"
|
||||
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <assert.h>
|
||||
#include <vector>
|
||||
#include <iterator>
|
||||
#include <stdexcept>
|
||||
|
||||
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS
|
||||
|
||||
namespace Catch {
|
||||
namespace TestCaseTracking {
|
||||
|
||||
@@ -290,12 +291,12 @@ namespace TestCaseTracking {
|
||||
if( !filters.empty() ) {
|
||||
m_filters.push_back(""); // Root - should never be consulted
|
||||
m_filters.push_back(""); // Test Case - not a section filter
|
||||
std::copy( filters.begin(), filters.end(), std::back_inserter( m_filters ) );
|
||||
m_filters.insert( m_filters.end(), filters.begin(), filters.end() );
|
||||
}
|
||||
}
|
||||
void addNextFilters( std::vector<std::string> const& filters ) {
|
||||
if( filters.size() > 1 )
|
||||
std::copy( filters.begin()+1, filters.end(), std::back_inserter( m_filters ) );
|
||||
m_filters.insert( m_filters.end(), ++filters.begin(), filters.end() );
|
||||
}
|
||||
};
|
||||
|
||||
@@ -365,4 +366,6 @@ using TestCaseTracking::IndexTracker;
|
||||
|
||||
} // namespace Catch
|
||||
|
||||
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED
|
||||
|
@@ -87,59 +87,76 @@ void registerTestCaseFunction
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \
|
||||
static void TestName(); \
|
||||
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); }\
|
||||
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
||||
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); } \
|
||||
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
|
||||
static void TestName()
|
||||
#define INTERNAL_CATCH_TESTCASE( ... ) \
|
||||
INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), __VA_ARGS__ )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \
|
||||
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); }
|
||||
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
||||
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); } \
|
||||
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_TEST_CASE_METHOD2( TestName, ClassName, ... )\
|
||||
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
||||
namespace{ \
|
||||
struct TestName : ClassName{ \
|
||||
void test(); \
|
||||
}; \
|
||||
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestName::test, #ClassName, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); \
|
||||
} \
|
||||
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
|
||||
void TestName::test()
|
||||
#define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... ) \
|
||||
INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, __VA_ARGS__ )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \
|
||||
Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) );
|
||||
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
||||
Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); \
|
||||
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
|
||||
|
||||
#else
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_TESTCASE2( TestName, Name, Desc ) \
|
||||
static void TestName(); \
|
||||
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
||||
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); }\
|
||||
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
|
||||
static void TestName()
|
||||
#define INTERNAL_CATCH_TESTCASE( Name, Desc ) \
|
||||
INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), Name, Desc )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, Name, Desc ) \
|
||||
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( Name, Desc ), CATCH_INTERNAL_LINEINFO ); }
|
||||
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
||||
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( Name, Desc ), CATCH_INTERNAL_LINEINFO ); } \
|
||||
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_TEST_CASE_METHOD2( TestCaseName, ClassName, TestName, Desc )\
|
||||
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
||||
namespace{ \
|
||||
struct TestCaseName : ClassName{ \
|
||||
void test(); \
|
||||
}; \
|
||||
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestCaseName::test, #ClassName, Catch::NameAndDesc( TestName, Desc ), CATCH_INTERNAL_LINEINFO ); \
|
||||
} \
|
||||
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
|
||||
void TestCaseName::test()
|
||||
#define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, TestName, Desc )\
|
||||
INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, TestName, Desc )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_REGISTER_TESTCASE( Function, Name, Desc ) \
|
||||
Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) );
|
||||
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
||||
Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); \
|
||||
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
|
||||
|
||||
#endif
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_TEST_REGISTRY_HPP_INCLUDED
|
||||
|
@@ -10,14 +10,20 @@
|
||||
|
||||
#include "catch_platform.h"
|
||||
|
||||
#ifdef CATCH_PLATFORM_WINDOWS
|
||||
typedef unsigned long long uint64_t;
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#ifdef _MSC_VER
|
||||
|
||||
namespace Catch {
|
||||
typedef unsigned long long UInt64;
|
||||
}
|
||||
#else
|
||||
#include <stdint.h>
|
||||
namespace Catch {
|
||||
typedef uint64_t UInt64;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
namespace Catch {
|
||||
class Timer {
|
||||
public:
|
||||
Timer() : m_ticks( 0 ) {}
|
||||
@@ -27,7 +33,7 @@ namespace Catch {
|
||||
double getElapsedSeconds() const;
|
||||
|
||||
private:
|
||||
uint64_t m_ticks;
|
||||
UInt64 m_ticks;
|
||||
};
|
||||
|
||||
} // namespace Catch
|
||||
|
@@ -20,34 +20,29 @@
|
||||
|
||||
#else
|
||||
|
||||
// Required for some versions of Cygwin to declare gettimeofday
|
||||
// see: http://stackoverflow.com/questions/36901803/gettimeofday-not-declared-in-this-scope-cygwin
|
||||
# ifdef __CYGWIN__
|
||||
# define _BSD_SOURCE
|
||||
# endif
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
#endif
|
||||
|
||||
namespace Catch {
|
||||
|
||||
namespace {
|
||||
#ifdef CATCH_PLATFORM_WINDOWS
|
||||
uint64_t getCurrentTicks() {
|
||||
static uint64_t hz=0, hzo=0;
|
||||
UInt64 getCurrentTicks() {
|
||||
static UInt64 hz=0, hzo=0;
|
||||
if (!hz) {
|
||||
QueryPerformanceFrequency( reinterpret_cast<LARGE_INTEGER*>( &hz ) );
|
||||
QueryPerformanceCounter( reinterpret_cast<LARGE_INTEGER*>( &hzo ) );
|
||||
}
|
||||
uint64_t t;
|
||||
UInt64 t;
|
||||
QueryPerformanceCounter( reinterpret_cast<LARGE_INTEGER*>( &t ) );
|
||||
return ((t-hzo)*1000000)/hz;
|
||||
}
|
||||
#else
|
||||
uint64_t getCurrentTicks() {
|
||||
UInt64 getCurrentTicks() {
|
||||
timeval t;
|
||||
gettimeofday(&t,CATCH_NULL);
|
||||
return static_cast<uint64_t>( t.tv_sec ) * 1000000ull + static_cast<uint64_t>( t.tv_usec );
|
||||
return static_cast<UInt64>( t.tv_sec ) * 1000000ull + static_cast<UInt64>( t.tv_usec );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -63,7 +63,7 @@ std::string toString( std::nullptr_t );
|
||||
|
||||
#ifdef __OBJC__
|
||||
std::string toString( NSString const * const& nsstring );
|
||||
std::string toString( NSString * CATCH_ARC_STRONG const& nsstring );
|
||||
std::string toString( NSString * CATCH_ARC_STRONG & nsstring );
|
||||
std::string toString( NSObject* const& nsObject );
|
||||
#endif
|
||||
|
||||
@@ -72,6 +72,7 @@ namespace Detail {
|
||||
|
||||
extern const std::string unprintableString;
|
||||
|
||||
#if !defined(CATCH_CONFIG_CPP11_STREAM_INSERTABLE_CHECK)
|
||||
struct BorgType {
|
||||
template<typename T> BorgType( T const& );
|
||||
};
|
||||
@@ -90,6 +91,20 @@ namespace Detail {
|
||||
static T const&t;
|
||||
enum { value = sizeof( testStreamable(s << t) ) == sizeof( TrueType ) };
|
||||
};
|
||||
#else
|
||||
template<typename T>
|
||||
class IsStreamInsertable {
|
||||
template<typename SS, typename TT>
|
||||
static auto test(int)
|
||||
-> decltype( std::declval<SS&>() << std::declval<TT>(), std::true_type() );
|
||||
|
||||
template<typename, typename>
|
||||
static auto test(...) -> std::false_type;
|
||||
|
||||
public:
|
||||
static const bool value = decltype(test<std::ostream,const T&>(0))::value;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(CATCH_CONFIG_CPP11_IS_ENUM)
|
||||
template<typename T,
|
||||
|
@@ -198,7 +198,7 @@ std::string toString( std::nullptr_t ) {
|
||||
return "nil";
|
||||
return "@" + toString([nsstring UTF8String]);
|
||||
}
|
||||
std::string toString( NSString * CATCH_ARC_STRONG const& nsstring ) {
|
||||
std::string toString( NSString * CATCH_ARC_STRONG & nsstring ) {
|
||||
if( !nsstring )
|
||||
return "nil";
|
||||
return "@" + toString([nsstring UTF8String]);
|
||||
|
@@ -25,7 +25,7 @@ namespace Catch {
|
||||
#else
|
||||
|
||||
template <typename T>
|
||||
struct add_const {
|
||||
struct add_const {
|
||||
typedef const T type;
|
||||
};
|
||||
|
||||
|
@@ -15,7 +15,7 @@ namespace Catch {
|
||||
Version( unsigned int _majorVersion,
|
||||
unsigned int _minorVersion,
|
||||
unsigned int _patchNumber,
|
||||
std::string const& _branchName,
|
||||
char const * const _branchName,
|
||||
unsigned int _buildNumber );
|
||||
|
||||
unsigned int const majorVersion;
|
||||
@@ -23,7 +23,7 @@ namespace Catch {
|
||||
unsigned int const patchNumber;
|
||||
|
||||
// buildNumber is only used if branchName is not null
|
||||
std::string const branchName;
|
||||
char const * const branchName;
|
||||
unsigned int const buildNumber;
|
||||
|
||||
friend std::ostream& operator << ( std::ostream& os, Version const& version );
|
||||
@@ -32,7 +32,7 @@ namespace Catch {
|
||||
void operator=( Version const& );
|
||||
};
|
||||
|
||||
extern Version libraryVersion;
|
||||
inline Version libraryVersion();
|
||||
}
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_VERSION_H_INCLUDED
|
||||
|
@@ -16,7 +16,7 @@ namespace Catch {
|
||||
( unsigned int _majorVersion,
|
||||
unsigned int _minorVersion,
|
||||
unsigned int _patchNumber,
|
||||
std::string const& _branchName,
|
||||
char const * const _branchName,
|
||||
unsigned int _buildNumber )
|
||||
: majorVersion( _majorVersion ),
|
||||
minorVersion( _minorVersion ),
|
||||
@@ -29,15 +29,18 @@ namespace Catch {
|
||||
os << version.majorVersion << '.'
|
||||
<< version.minorVersion << '.'
|
||||
<< version.patchNumber;
|
||||
|
||||
if( !version.branchName.empty() ) {
|
||||
os << '-' << version.branchName
|
||||
<< '.' << version.buildNumber;
|
||||
// branchName is never null -> 0th char is \0 if it is empty
|
||||
if (version.branchName[0]) {
|
||||
os << '-' << version.branchName
|
||||
<< '.' << version.buildNumber;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
Version libraryVersion( 1, 8, 0, "", 0 );
|
||||
inline Version libraryVersion() {
|
||||
static Version version( 1, 9, 6, "", 0 );
|
||||
return version;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -10,7 +10,6 @@
|
||||
|
||||
#include "catch_stream.h"
|
||||
#include "catch_compiler_capabilities.h"
|
||||
#include "catch_suppress_warnings.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
@@ -241,6 +240,5 @@ namespace Catch {
|
||||
};
|
||||
|
||||
}
|
||||
#include "catch_reenable_warnings.h"
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_XMLWRITER_HPP_INCLUDED
|
||||
|
@@ -9,12 +9,38 @@
|
||||
#define TWOBLUECUBES_CATCH_REPORTER_BASES_HPP_INCLUDED
|
||||
|
||||
#include "../internal/catch_interfaces_reporter.h"
|
||||
#include "../internal/catch_errno_guard.hpp"
|
||||
|
||||
#include <cstring>
|
||||
#include <cfloat>
|
||||
#include <cstdio>
|
||||
#include <assert.h>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
namespace {
|
||||
// Because formatting using c++ streams is stateful, drop down to C is required
|
||||
// Alternatively we could use stringstream, but its performance is... not good.
|
||||
std::string getFormattedDuration( double duration ) {
|
||||
// Max exponent + 1 is required to represent the whole part
|
||||
// + 1 for decimal point
|
||||
// + 3 for the 3 decimal places
|
||||
// + 1 for null terminator
|
||||
const size_t maxDoubleSize = DBL_MAX_10_EXP + 1 + 1 + 3 + 1;
|
||||
char buffer[maxDoubleSize];
|
||||
|
||||
// Save previous errno, to prevent sprintf from overwriting it
|
||||
ErrnoGuard guard;
|
||||
#ifdef _MSC_VER
|
||||
sprintf_s(buffer, "%.3f", duration);
|
||||
#else
|
||||
sprintf(buffer, "%.3f", duration);
|
||||
#endif
|
||||
return std::string(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct StreamingReporterBase : SharedImpl<IStreamingReporter> {
|
||||
|
||||
StreamingReporterBase( ReporterConfig const& _config )
|
||||
|
@@ -37,8 +37,7 @@ namespace Catch {
|
||||
stream << "No test cases matched '" << spec << '\'' << std::endl;
|
||||
}
|
||||
|
||||
virtual void assertionStarting( AssertionInfo const& ) {
|
||||
}
|
||||
virtual void assertionStarting( AssertionInfo const& ) {}
|
||||
|
||||
virtual bool assertionEnded( AssertionStats const& _assertionStats ) {
|
||||
AssertionResult const& result = _assertionStats.assertionResult;
|
||||
@@ -59,6 +58,12 @@ namespace Catch {
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void sectionEnded(SectionStats const& _sectionStats) CATCH_OVERRIDE {
|
||||
if (m_config->showDurations() == ShowDurations::Always) {
|
||||
stream << getFormattedDuration(_sectionStats.durationInSeconds) << " s: " << _sectionStats.sectionInfo.name << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void testRunEnded( TestRunStats const& _testRunStats ) {
|
||||
printTotals( _testRunStats.totals );
|
||||
stream << '\n' << std::endl;
|
||||
@@ -164,7 +169,7 @@ namespace Catch {
|
||||
stream << result.getSourceInfo() << ':';
|
||||
}
|
||||
|
||||
void printResultType( Colour::Code colour, std::string passOrFail ) const {
|
||||
void printResultType( Colour::Code colour, std::string const& passOrFail ) const {
|
||||
if( !passOrFail.empty() ) {
|
||||
{
|
||||
Colour colourGuard( colour );
|
||||
@@ -174,7 +179,7 @@ namespace Catch {
|
||||
}
|
||||
}
|
||||
|
||||
void printIssue( std::string issue ) const {
|
||||
void printIssue( std::string const& issue ) const {
|
||||
stream << ' ' << issue;
|
||||
}
|
||||
|
||||
|
@@ -18,25 +18,6 @@
|
||||
|
||||
namespace Catch {
|
||||
|
||||
namespace {
|
||||
// Because formatting using c++ streams is stateful, drop down to C is required
|
||||
// Alternatively we could use stringstream, but its performance is... not good.
|
||||
std::string getFormattedDuration( double duration ) {
|
||||
// Max exponent + 1 is required to represent the whole part
|
||||
// + 1 for decimal point
|
||||
// + 3 for the 3 decimal places
|
||||
// + 1 for null terminator
|
||||
const size_t maxDoubleSize = DBL_MAX_10_EXP + 1 + 1 + 3 + 1;
|
||||
char buffer[maxDoubleSize];
|
||||
#ifdef _MSC_VER
|
||||
sprintf_s(buffer, "%.3f", duration);
|
||||
#else
|
||||
sprintf(buffer, "%.3f", duration);
|
||||
#endif
|
||||
return std::string(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct ConsoleReporter : StreamingReporterBase {
|
||||
ConsoleReporter( ReporterConfig const& _config )
|
||||
@@ -59,18 +40,15 @@ namespace Catch {
|
||||
virtual bool assertionEnded( AssertionStats const& _assertionStats ) CATCH_OVERRIDE {
|
||||
AssertionResult const& result = _assertionStats.assertionResult;
|
||||
|
||||
bool printInfoMessages = true;
|
||||
bool includeResults = m_config->includeSuccessfulResults() || !result.isOk();
|
||||
|
||||
// Drop out if result was successful and we're not printing those
|
||||
if( !m_config->includeSuccessfulResults() && result.isOk() ) {
|
||||
if( result.getResultType() != ResultWas::Warning )
|
||||
return false;
|
||||
printInfoMessages = false;
|
||||
}
|
||||
// Drop out if result was successful but we're not printing them.
|
||||
if( !includeResults && result.getResultType() != ResultWas::Warning )
|
||||
return false;
|
||||
|
||||
lazyPrint();
|
||||
|
||||
AssertionPrinter printer( stream, _assertionStats, printInfoMessages );
|
||||
AssertionPrinter printer( stream, _assertionStats, includeResults );
|
||||
printer.print();
|
||||
stream << std::endl;
|
||||
return true;
|
||||
@@ -160,7 +138,11 @@ namespace Catch {
|
||||
case ResultWas::ThrewException:
|
||||
colour = Colour::Error;
|
||||
passOrFail = "FAILED";
|
||||
messageLabel = "due to unexpected exception with message";
|
||||
messageLabel = "due to unexpected exception with ";
|
||||
if (_stats.infoMessages.size() == 1)
|
||||
messageLabel += "message";
|
||||
if (_stats.infoMessages.size() > 1)
|
||||
messageLabel += "messages";
|
||||
break;
|
||||
case ResultWas::FatalErrorCondition:
|
||||
colour = Colour::Error;
|
||||
@@ -276,7 +258,7 @@ namespace Catch {
|
||||
stream << '\n' << getLineOfChars<'~'>() << '\n';
|
||||
Colour colour( Colour::SecondaryText );
|
||||
stream << currentTestRunInfo->name
|
||||
<< " is a Catch v" << libraryVersion << " host application.\n"
|
||||
<< " is a Catch v" << libraryVersion() << " host application.\n"
|
||||
<< "Run with -? for options\n\n";
|
||||
|
||||
if( m_config->rngSeed() != 0 )
|
||||
|
@@ -51,7 +51,8 @@ namespace Catch {
|
||||
public:
|
||||
JunitReporter( ReporterConfig const& _config )
|
||||
: CumulativeReporterBase( _config ),
|
||||
xml( _config.stream() )
|
||||
xml( _config.stream() ),
|
||||
m_okToFail( false )
|
||||
{
|
||||
m_reporterPrefs.shouldRedirectStdOut = true;
|
||||
}
|
||||
@@ -77,8 +78,11 @@ namespace Catch {
|
||||
CumulativeReporterBase::testGroupStarting( groupInfo );
|
||||
}
|
||||
|
||||
virtual void testCaseStarting( TestCaseInfo const& testCaseInfo ) CATCH_OVERRIDE {
|
||||
m_okToFail = testCaseInfo.okToFail();
|
||||
}
|
||||
virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE {
|
||||
if( assertionStats.assertionResult.getResultType() == ResultWas::ThrewException )
|
||||
if( assertionStats.assertionResult.getResultType() == ResultWas::ThrewException && !m_okToFail )
|
||||
unexpectedExceptions++;
|
||||
return CumulativeReporterBase::assertionEnded( assertionStats );
|
||||
}
|
||||
@@ -243,6 +247,7 @@ namespace Catch {
|
||||
std::ostringstream stdOutForSuite;
|
||||
std::ostringstream stdErrForSuite;
|
||||
unsigned int unexpectedExceptions;
|
||||
bool m_okToFail;
|
||||
};
|
||||
|
||||
INTERNAL_CATCH_REGISTER_REPORTER( "junit", JunitReporter )
|
||||
|
@@ -45,18 +45,9 @@ namespace Catch {
|
||||
virtual void assertionStarting( AssertionInfo const& ) {}
|
||||
|
||||
virtual bool assertionEnded( AssertionStats const& _assertionStats ) {
|
||||
AssertionResult const& result = _assertionStats.assertionResult;
|
||||
++counter;
|
||||
|
||||
bool printInfoMessages = true;
|
||||
|
||||
// Drop out if result was successful and we're not printing those
|
||||
if ( !m_config->includeSuccessfulResults() && result.isOk() ) {
|
||||
if ( result.getResultType() != ResultWas::Warning )
|
||||
return false;
|
||||
printInfoMessages = false;
|
||||
}
|
||||
|
||||
AssertionPrinter printer( stream, _assertionStats, printInfoMessages, ++counter );
|
||||
AssertionPrinter printer( stream, _assertionStats, counter );
|
||||
printer.print();
|
||||
stream << " # " << currentTestCaseInfo->name ;
|
||||
|
||||
@@ -75,13 +66,13 @@ namespace Catch {
|
||||
class AssertionPrinter {
|
||||
void operator= ( AssertionPrinter const& );
|
||||
public:
|
||||
AssertionPrinter( std::ostream& _stream, AssertionStats const& _stats, bool _printInfoMessages, size_t counter = 0 )
|
||||
AssertionPrinter( std::ostream& _stream, AssertionStats const& _stats, size_t counter )
|
||||
: stream( _stream )
|
||||
, stats( _stats )
|
||||
, result( _stats.assertionResult )
|
||||
, messages( _stats.infoMessages )
|
||||
, itMessage( _stats.infoMessages.begin() )
|
||||
, printInfoMessages( _printInfoMessages )
|
||||
, printInfoMessages( true )
|
||||
, counter(counter)
|
||||
{}
|
||||
|
||||
@@ -156,28 +147,23 @@ namespace Catch {
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
static Colour::Code dimColour() { return Colour::FileName; }
|
||||
|
||||
static const char* failedString() { return "not ok"; }
|
||||
static const char* passedString() { return "ok"; }
|
||||
|
||||
void printSourceInfo() const {
|
||||
Colour colourGuard( Colour::FileName );
|
||||
Colour colourGuard( dimColour() );
|
||||
stream << result.getSourceInfo() << ":";
|
||||
}
|
||||
|
||||
void printResultType( std::string passOrFail ) const {
|
||||
void printResultType( std::string const& passOrFail ) const {
|
||||
if( !passOrFail.empty() ) {
|
||||
{
|
||||
//Colour colourGuard( colour );
|
||||
stream << passOrFail << " " << counter;
|
||||
}
|
||||
stream << " -";
|
||||
stream << passOrFail << ' ' << counter << " -";
|
||||
}
|
||||
}
|
||||
|
||||
void printIssue( std::string issue ) const {
|
||||
void printIssue( std::string const& issue ) const {
|
||||
stream << " " << issue;
|
||||
}
|
||||
|
||||
@@ -218,8 +204,9 @@ namespace Catch {
|
||||
}
|
||||
|
||||
void printRemainingMessages( Colour::Code colour = dimColour() ) {
|
||||
if ( itMessage == messages.end() )
|
||||
if (itMessage == messages.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// using messages.end() directly yields compilation error:
|
||||
std::vector<MessageInfo>::const_iterator itEnd = messages.end();
|
||||
@@ -252,17 +239,6 @@ namespace Catch {
|
||||
size_t counter;
|
||||
};
|
||||
|
||||
// Colour, message variants:
|
||||
// - white: No tests ran.
|
||||
// - red: Failed [both/all] N test cases, failed [both/all] M assertions.
|
||||
// - white: Passed [both/all] N test cases (no assertions).
|
||||
// - red: Failed N tests cases, failed M assertions.
|
||||
// - green: Passed [both/all] N tests cases with M assertions.
|
||||
|
||||
std::string bothOrAll( std::size_t count ) const {
|
||||
return count == 1 ? "" : count == 2 ? "both " : "all " ;
|
||||
}
|
||||
|
||||
void printTotals( const Totals& totals ) const {
|
||||
if( totals.testCases.total() == 0 ) {
|
||||
stream << "1..0 # Skipped: No tests ran.";
|
||||
|
@@ -49,14 +49,7 @@ namespace Catch {
|
||||
return "Reports test results as TeamCity service messages";
|
||||
}
|
||||
|
||||
virtual void skipTest( TestCaseInfo const& testInfo ) CATCH_OVERRIDE {
|
||||
stream << "##teamcity[testIgnored name='"
|
||||
<< escape( testInfo.name ) << "'";
|
||||
if( testInfo.isHidden() )
|
||||
stream << " message='hidden test'";
|
||||
else
|
||||
stream << " message='test skipped because it didn|'t match the test spec'";
|
||||
stream << "]\n";
|
||||
virtual void skipTest( TestCaseInfo const& /* testInfo */ ) CATCH_OVERRIDE {
|
||||
}
|
||||
|
||||
virtual void noMatchingTestCases( std::string const& /* spec */ ) CATCH_OVERRIDE {}
|
||||
@@ -134,10 +127,19 @@ namespace Catch {
|
||||
" " << result.getExpandedExpression() << "\n";
|
||||
}
|
||||
|
||||
stream << "##teamcity[testFailed"
|
||||
<< " name='" << escape( currentTestCaseInfo->name )<< "'"
|
||||
<< " message='" << escape( msg.str() ) << "'"
|
||||
<< "]\n";
|
||||
if( currentTestCaseInfo->okToFail() ) {
|
||||
msg << "- failure ignore as test marked as 'ok to fail'\n";
|
||||
stream << "##teamcity[testIgnored"
|
||||
<< " name='" << escape( currentTestCaseInfo->name )<< "'"
|
||||
<< " message='" << escape( msg.str() ) << "'"
|
||||
<< "]\n";
|
||||
}
|
||||
else {
|
||||
stream << "##teamcity[testFailed"
|
||||
<< " name='" << escape( currentTestCaseInfo->name )<< "'"
|
||||
<< " message='" << escape( msg.str() ) << "'"
|
||||
<< "]\n";
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -148,6 +150,7 @@ namespace Catch {
|
||||
}
|
||||
|
||||
virtual void testCaseStarting( TestCaseInfo const& testInfo ) CATCH_OVERRIDE {
|
||||
m_testTimer.start();
|
||||
StreamingReporterBase::testCaseStarting( testInfo );
|
||||
stream << "##teamcity[testStarted name='"
|
||||
<< escape( testInfo.name ) << "']\n";
|
||||
@@ -164,7 +167,8 @@ namespace Catch {
|
||||
<< escape( testCaseStats.testInfo.name )
|
||||
<< "' out='" << escape( testCaseStats.stdErr ) << "']\n";
|
||||
stream << "##teamcity[testFinished name='"
|
||||
<< escape( testCaseStats.testInfo.name ) << "']\n";
|
||||
<< escape( testCaseStats.testInfo.name ) << "' duration='"
|
||||
<< m_testTimer.getElapsedMilliseconds() << "']\n";
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -203,7 +207,7 @@ namespace Catch {
|
||||
}
|
||||
private:
|
||||
bool m_headerPrintedForThisSection;
|
||||
|
||||
Timer m_testTimer;
|
||||
};
|
||||
|
||||
#ifdef CATCH_IMPL
|
||||
|
@@ -92,73 +92,77 @@ namespace Catch {
|
||||
virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE { }
|
||||
|
||||
virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE {
|
||||
const AssertionResult& assertionResult = assertionStats.assertionResult;
|
||||
|
||||
// Print any info messages in <Info> tags.
|
||||
if( assertionStats.assertionResult.getResultType() != ResultWas::Ok ) {
|
||||
AssertionResult const& result = assertionStats.assertionResult;
|
||||
|
||||
bool includeResults = m_config->includeSuccessfulResults() || !result.isOk();
|
||||
|
||||
if( includeResults ) {
|
||||
// Print any info messages in <Info> tags.
|
||||
for( std::vector<MessageInfo>::const_iterator it = assertionStats.infoMessages.begin(), itEnd = assertionStats.infoMessages.end();
|
||||
it != itEnd;
|
||||
++it ) {
|
||||
it != itEnd;
|
||||
++it ) {
|
||||
if( it->type == ResultWas::Info ) {
|
||||
m_xml.scopedElement( "Info" )
|
||||
.writeText( it->message );
|
||||
.writeText( it->message );
|
||||
} else if ( it->type == ResultWas::Warning ) {
|
||||
m_xml.scopedElement( "Warning" )
|
||||
.writeText( it->message );
|
||||
.writeText( it->message );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Drop out if result was successful but we're not printing them.
|
||||
if( !m_config->includeSuccessfulResults() && isOk(assertionResult.getResultType()) )
|
||||
if( !includeResults && result.getResultType() != ResultWas::Warning )
|
||||
return true;
|
||||
|
||||
// Print the expression if there is one.
|
||||
if( assertionResult.hasExpression() ) {
|
||||
m_xml.startElement( "Expression" )
|
||||
.writeAttribute( "success", assertionResult.succeeded() )
|
||||
.writeAttribute( "type", assertionResult.getTestMacroName() );
|
||||
|
||||
writeSourceInfo( assertionResult.getSourceInfo() );
|
||||
// Print the expression if there is one.
|
||||
if( result.hasExpression() ) {
|
||||
m_xml.startElement( "Expression" )
|
||||
.writeAttribute( "success", result.succeeded() )
|
||||
.writeAttribute( "type", result.getTestMacroName() );
|
||||
|
||||
writeSourceInfo( result.getSourceInfo() );
|
||||
|
||||
m_xml.scopedElement( "Original" )
|
||||
.writeText( assertionResult.getExpression() );
|
||||
.writeText( result.getExpression() );
|
||||
m_xml.scopedElement( "Expanded" )
|
||||
.writeText( assertionResult.getExpandedExpression() );
|
||||
.writeText( result.getExpandedExpression() );
|
||||
}
|
||||
|
||||
// And... Print a result applicable to each result type.
|
||||
switch( assertionResult.getResultType() ) {
|
||||
switch( result.getResultType() ) {
|
||||
case ResultWas::ThrewException:
|
||||
m_xml.startElement( "Exception" );
|
||||
writeSourceInfo( assertionResult.getSourceInfo() );
|
||||
m_xml.writeText( assertionResult.getMessage() );
|
||||
writeSourceInfo( result.getSourceInfo() );
|
||||
m_xml.writeText( result.getMessage() );
|
||||
m_xml.endElement();
|
||||
break;
|
||||
case ResultWas::FatalErrorCondition:
|
||||
m_xml.startElement( "FatalErrorCondition" );
|
||||
writeSourceInfo( assertionResult.getSourceInfo() );
|
||||
m_xml.writeText( assertionResult.getMessage() );
|
||||
writeSourceInfo( result.getSourceInfo() );
|
||||
m_xml.writeText( result.getMessage() );
|
||||
m_xml.endElement();
|
||||
break;
|
||||
case ResultWas::Info:
|
||||
m_xml.scopedElement( "Info" )
|
||||
.writeText( assertionResult.getMessage() );
|
||||
.writeText( result.getMessage() );
|
||||
break;
|
||||
case ResultWas::Warning:
|
||||
// Warning will already have been written
|
||||
break;
|
||||
case ResultWas::ExplicitFailure:
|
||||
m_xml.startElement( "Failure" );
|
||||
writeSourceInfo( assertionResult.getSourceInfo() );
|
||||
m_xml.writeText( assertionResult.getMessage() );
|
||||
writeSourceInfo( result.getSourceInfo() );
|
||||
m_xml.writeText( result.getMessage() );
|
||||
m_xml.endElement();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if( assertionResult.hasExpression() )
|
||||
if( result.hasExpression() )
|
||||
m_xml.endElement();
|
||||
|
||||
return true;
|
||||
|
@@ -3,6 +3,42 @@
|
||||
<exe-name> is a <version> host application.
|
||||
Run with -? for options
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
#748 - captures with unexpected exceptions
|
||||
outside assertions
|
||||
-------------------------------------------------------------------------------
|
||||
ExceptionTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
ExceptionTests.cpp:<line number>: FAILED:
|
||||
due to unexpected exception with messages:
|
||||
answer := 42
|
||||
expected exception
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
#748 - captures with unexpected exceptions
|
||||
inside REQUIRE_NOTHROW
|
||||
-------------------------------------------------------------------------------
|
||||
ExceptionTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
ExceptionTests.cpp:<line number>: FAILED:
|
||||
REQUIRE_NOTHROW( thisThrows() )
|
||||
due to unexpected exception with messages:
|
||||
answer := 42
|
||||
expected exception
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
#835 -- errno should not be touched by Catch
|
||||
-------------------------------------------------------------------------------
|
||||
MiscTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MiscTests.cpp:<line number>: FAILED:
|
||||
CHECK( f() == 0 )
|
||||
with expansion:
|
||||
1 == 0
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
'Not' checks that should fail
|
||||
-------------------------------------------------------------------------------
|
||||
@@ -276,6 +312,20 @@ MessageTests.cpp:<line number>
|
||||
|
||||
MessageTests.cpp:<line number>: FAILED:
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
FAIL_CHECK does not abort the test
|
||||
-------------------------------------------------------------------------------
|
||||
MessageTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MessageTests.cpp:<line number>: FAILED:
|
||||
explicitly with message:
|
||||
This is a failure
|
||||
|
||||
MessageTests.cpp:<line number>:
|
||||
warning:
|
||||
This message appears in the output
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
INFO and WARN do not abort tests
|
||||
-------------------------------------------------------------------------------
|
||||
@@ -318,7 +368,9 @@ MessageTests.cpp:<line number>: FAILED:
|
||||
CHECK( a == 0 )
|
||||
with expansion:
|
||||
2 == 0
|
||||
with message:
|
||||
with messages:
|
||||
this message may be logged later
|
||||
this message should be logged
|
||||
and this, but later
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
@@ -543,6 +595,17 @@ MessageTests.cpp:<line number>:
|
||||
warning:
|
||||
toString(p): 0x<hex digits>
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Reconstruction should be based on stringification: #914
|
||||
-------------------------------------------------------------------------------
|
||||
DecompositionTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
DecompositionTests.cpp:<line number>: FAILED:
|
||||
CHECK( truthy(false) )
|
||||
with expansion:
|
||||
Hey, its truthy!
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
SCOPED_INFO is reset for each loop
|
||||
-------------------------------------------------------------------------------
|
||||
@@ -890,6 +953,6 @@ with expansion:
|
||||
"first" == "second"
|
||||
|
||||
===============================================================================
|
||||
test cases: 163 | 118 passed | 43 failed | 2 failed as expected
|
||||
assertions: 953 | 849 passed | 86 failed | 18 failed as expected
|
||||
test cases: 168 | 119 passed | 45 failed | 4 failed as expected
|
||||
assertions: 968 | 859 passed | 88 failed | 21 failed as expected
|
||||
|
||||
|
@@ -15,26 +15,42 @@ with message:
|
||||
yay
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
#542
|
||||
#748 - captures with unexpected exceptions
|
||||
outside assertions
|
||||
-------------------------------------------------------------------------------
|
||||
CompilationTests.cpp:<line number>
|
||||
ExceptionTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
CompilationTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK_THROWS_AS( throws_int(true), int )
|
||||
ExceptionTests.cpp:<line number>: FAILED:
|
||||
due to unexpected exception with messages:
|
||||
answer := 42
|
||||
expected exception
|
||||
|
||||
CompilationTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK_THROWS_AS( throws_int(true), int& )
|
||||
-------------------------------------------------------------------------------
|
||||
#748 - captures with unexpected exceptions
|
||||
inside REQUIRE_NOTHROW
|
||||
-------------------------------------------------------------------------------
|
||||
ExceptionTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
CompilationTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK_THROWS_AS( throws_int(true), const int )
|
||||
ExceptionTests.cpp:<line number>: FAILED:
|
||||
REQUIRE_NOTHROW( thisThrows() )
|
||||
due to unexpected exception with messages:
|
||||
answer := 42
|
||||
expected exception
|
||||
|
||||
CompilationTests.cpp:<line number>:
|
||||
-------------------------------------------------------------------------------
|
||||
#748 - captures with unexpected exceptions
|
||||
inside REQUIRE_THROWS
|
||||
-------------------------------------------------------------------------------
|
||||
ExceptionTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
ExceptionTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK_THROWS_AS( throws_int(true), const int& )
|
||||
REQUIRE_THROWS( thisThrows() )
|
||||
with message:
|
||||
answer := 42
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
#809
|
||||
@@ -48,6 +64,65 @@ PASSED:
|
||||
with expansion:
|
||||
42 == {?}
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
#833
|
||||
-------------------------------------------------------------------------------
|
||||
CompilationTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
CompilationTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( a == t )
|
||||
with expansion:
|
||||
3 == 3
|
||||
|
||||
CompilationTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK( a == t )
|
||||
with expansion:
|
||||
3 == 3
|
||||
|
||||
CompilationTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE_THROWS( throws_int(true) )
|
||||
|
||||
CompilationTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK_THROWS_AS( throws_int(true), const int& )
|
||||
|
||||
CompilationTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE_NOTHROW( throws_int(false) )
|
||||
|
||||
CompilationTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE_THAT( "aaa", Catch::EndsWith("aaa") )
|
||||
with expansion:
|
||||
"aaa" ends with: "aaa"
|
||||
|
||||
CompilationTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( templated_tests<int>(3) )
|
||||
with expansion:
|
||||
true
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
#835 -- errno should not be touched by Catch
|
||||
-------------------------------------------------------------------------------
|
||||
MiscTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MiscTests.cpp:<line number>: FAILED:
|
||||
CHECK( f() == 0 )
|
||||
with expansion:
|
||||
1 == 0
|
||||
|
||||
MiscTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( errno == 1 )
|
||||
with expansion:
|
||||
1 == 1
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
'Not' checks that should fail
|
||||
-------------------------------------------------------------------------------
|
||||
@@ -603,6 +678,32 @@ PASSED:
|
||||
with expansion:
|
||||
true
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Capture and info messages
|
||||
Capture should stringify like assertions
|
||||
-------------------------------------------------------------------------------
|
||||
ToStringGeneralTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
ToStringGeneralTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( true )
|
||||
with message:
|
||||
i := 2
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Capture and info messages
|
||||
Info should NOT stringify the way assertions do
|
||||
-------------------------------------------------------------------------------
|
||||
ToStringGeneralTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
ToStringGeneralTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( true )
|
||||
with message:
|
||||
3
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Character pretty printing
|
||||
Specifically escaped
|
||||
@@ -718,7 +819,7 @@ TrickyTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( a )
|
||||
with expansion:
|
||||
true
|
||||
0x<hex digits>
|
||||
|
||||
TrickyTests.cpp:<line number>:
|
||||
PASSED:
|
||||
@@ -1173,6 +1274,20 @@ MessageTests.cpp:<line number>
|
||||
|
||||
MessageTests.cpp:<line number>: FAILED:
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
FAIL_CHECK does not abort the test
|
||||
-------------------------------------------------------------------------------
|
||||
MessageTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MessageTests.cpp:<line number>: FAILED:
|
||||
explicitly with message:
|
||||
This is a failure
|
||||
|
||||
MessageTests.cpp:<line number>:
|
||||
warning:
|
||||
This message appears in the output
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Factorials are computed
|
||||
-------------------------------------------------------------------------------
|
||||
@@ -2602,14 +2717,17 @@ MessageTests.cpp:<line number>: FAILED:
|
||||
CHECK( a == 1 )
|
||||
with expansion:
|
||||
2 == 1
|
||||
with message:
|
||||
with messages:
|
||||
this message may be logged later
|
||||
this message should be logged
|
||||
|
||||
MessageTests.cpp:<line number>: FAILED:
|
||||
CHECK( a == 0 )
|
||||
with expansion:
|
||||
2 == 0
|
||||
with message:
|
||||
with messages:
|
||||
this message may be logged later
|
||||
this message should be logged
|
||||
and this, but later
|
||||
|
||||
MessageTests.cpp:<line number>:
|
||||
@@ -2617,7 +2735,10 @@ PASSED:
|
||||
CHECK( a == 2 )
|
||||
with expansion:
|
||||
2 == 2
|
||||
with message:
|
||||
with messages:
|
||||
this message may be logged later
|
||||
this message should be logged
|
||||
and this, but later
|
||||
but not this
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
@@ -3292,7 +3413,7 @@ with expansion:
|
||||
re>"
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Long text is truncted
|
||||
Long text is truncated
|
||||
-------------------------------------------------------------------------------
|
||||
TestMain.cpp:<line number>
|
||||
...............................................................................
|
||||
@@ -4450,7 +4571,7 @@ TrickyTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK( True )
|
||||
with expansion:
|
||||
true
|
||||
1
|
||||
|
||||
TrickyTests.cpp:<line number>:
|
||||
PASSED:
|
||||
@@ -4462,7 +4583,7 @@ TrickyTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK_FALSE( False )
|
||||
with expansion:
|
||||
!false
|
||||
!0
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Operators at different namespace levels not hijacked by Koenig lookup
|
||||
@@ -5814,6 +5935,23 @@ MessageTests.cpp:<line number>:
|
||||
warning:
|
||||
toString(p): 0x<hex digits>
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Process can be configured on command line
|
||||
empty args don't cause a crash
|
||||
-------------------------------------------------------------------------------
|
||||
TestMain.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
TestMain.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK_NOTHROW( parser.parseInto( std::vector<std::string>(), config ) )
|
||||
|
||||
TestMain.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK( config.processName == "" )
|
||||
with expansion:
|
||||
"" == ""
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Process can be configured on command line
|
||||
default - no arguments
|
||||
@@ -5825,6 +5963,12 @@ TestMain.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK_NOTHROW( parseIntoConfig( argv, config ) )
|
||||
|
||||
TestMain.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK( config.processName == "test" )
|
||||
with expansion:
|
||||
"test" == "test"
|
||||
|
||||
TestMain.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK( config.shouldDebugBreak == false )
|
||||
@@ -6293,6 +6437,17 @@ TestMain.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE_THROWS_WITH( parseIntoConfig( argv, config ), Contains( "colour mode must be one of" ) )
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Reconstruction should be based on stringification: #914
|
||||
-------------------------------------------------------------------------------
|
||||
DecompositionTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
DecompositionTests.cpp:<line number>: FAILED:
|
||||
CHECK( truthy(false) )
|
||||
with expansion:
|
||||
Hey, its truthy!
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
SCOPED_INFO is reset for each loop
|
||||
-------------------------------------------------------------------------------
|
||||
@@ -6727,7 +6882,8 @@ PASSED:
|
||||
with expansion:
|
||||
"error: tag alias, "[@zzz]" already registered.
|
||||
First seen at file:2
|
||||
Redefined at file:10" contains: "[@zzz]"
|
||||
Redefined at file:10
|
||||
" contains: "[@zzz]"
|
||||
|
||||
TagAliasTests.cpp:<line number>:
|
||||
PASSED:
|
||||
@@ -6735,7 +6891,8 @@ PASSED:
|
||||
with expansion:
|
||||
"error: tag alias, "[@zzz]" already registered.
|
||||
First seen at file:2
|
||||
Redefined at file:10" contains: "file"
|
||||
Redefined at file:10
|
||||
" contains: "file"
|
||||
|
||||
TagAliasTests.cpp:<line number>:
|
||||
PASSED:
|
||||
@@ -6743,7 +6900,8 @@ PASSED:
|
||||
with expansion:
|
||||
"error: tag alias, "[@zzz]" already registered.
|
||||
First seen at file:2
|
||||
Redefined at file:10" contains: "2"
|
||||
Redefined at file:10
|
||||
" contains: "2"
|
||||
|
||||
TagAliasTests.cpp:<line number>:
|
||||
PASSED:
|
||||
@@ -6751,7 +6909,8 @@ PASSED:
|
||||
with expansion:
|
||||
"error: tag alias, "[@zzz]" already registered.
|
||||
First seen at file:2
|
||||
Redefined at file:10" contains: "10"
|
||||
Redefined at file:10
|
||||
" contains: "10"
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Tag alias can be registered against tag patterns
|
||||
@@ -9324,6 +9483,6 @@ MiscTests.cpp:<line number>:
|
||||
PASSED:
|
||||
|
||||
===============================================================================
|
||||
test cases: 163 | 117 passed | 44 failed | 2 failed as expected
|
||||
assertions: 955 | 849 passed | 88 failed | 18 failed as expected
|
||||
test cases: 168 | 118 passed | 46 failed | 4 failed as expected
|
||||
assertions: 970 | 859 passed | 90 failed | 21 failed as expected
|
||||
|
||||
|
@@ -15,26 +15,42 @@ with message:
|
||||
yay
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
#542
|
||||
#748 - captures with unexpected exceptions
|
||||
outside assertions
|
||||
-------------------------------------------------------------------------------
|
||||
CompilationTests.cpp:<line number>
|
||||
ExceptionTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
CompilationTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK_THROWS_AS( throws_int(true), int )
|
||||
ExceptionTests.cpp:<line number>: FAILED:
|
||||
due to unexpected exception with messages:
|
||||
answer := 42
|
||||
expected exception
|
||||
|
||||
CompilationTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK_THROWS_AS( throws_int(true), int& )
|
||||
-------------------------------------------------------------------------------
|
||||
#748 - captures with unexpected exceptions
|
||||
inside REQUIRE_NOTHROW
|
||||
-------------------------------------------------------------------------------
|
||||
ExceptionTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
CompilationTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK_THROWS_AS( throws_int(true), const int )
|
||||
ExceptionTests.cpp:<line number>: FAILED:
|
||||
REQUIRE_NOTHROW( thisThrows() )
|
||||
due to unexpected exception with messages:
|
||||
answer := 42
|
||||
expected exception
|
||||
|
||||
CompilationTests.cpp:<line number>:
|
||||
-------------------------------------------------------------------------------
|
||||
#748 - captures with unexpected exceptions
|
||||
inside REQUIRE_THROWS
|
||||
-------------------------------------------------------------------------------
|
||||
ExceptionTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
ExceptionTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK_THROWS_AS( throws_int(true), const int& )
|
||||
REQUIRE_THROWS( thisThrows() )
|
||||
with message:
|
||||
answer := 42
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
#809
|
||||
@@ -48,6 +64,65 @@ PASSED:
|
||||
with expansion:
|
||||
42 == {?}
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
#833
|
||||
-------------------------------------------------------------------------------
|
||||
CompilationTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
CompilationTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( a == t )
|
||||
with expansion:
|
||||
3 == 3
|
||||
|
||||
CompilationTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK( a == t )
|
||||
with expansion:
|
||||
3 == 3
|
||||
|
||||
CompilationTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE_THROWS( throws_int(true) )
|
||||
|
||||
CompilationTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK_THROWS_AS( throws_int(true), const int& )
|
||||
|
||||
CompilationTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE_NOTHROW( throws_int(false) )
|
||||
|
||||
CompilationTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE_THAT( "aaa", Catch::EndsWith("aaa") )
|
||||
with expansion:
|
||||
"aaa" ends with: "aaa"
|
||||
|
||||
CompilationTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( templated_tests<int>(3) )
|
||||
with expansion:
|
||||
true
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
#835 -- errno should not be touched by Catch
|
||||
-------------------------------------------------------------------------------
|
||||
MiscTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MiscTests.cpp:<line number>: FAILED:
|
||||
CHECK( f() == 0 )
|
||||
with expansion:
|
||||
1 == 0
|
||||
|
||||
MiscTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( errno == 1 )
|
||||
with expansion:
|
||||
1 == 1
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
'Not' checks that should fail
|
||||
-------------------------------------------------------------------------------
|
||||
@@ -69,6 +144,6 @@ ConditionTests.cpp:<line number>: FAILED:
|
||||
CHECK_FALSE( true )
|
||||
|
||||
===============================================================================
|
||||
test cases: 4 | 3 passed | 1 failed
|
||||
assertions: 10 | 6 passed | 4 failed
|
||||
test cases: 6 | 3 passed | 1 failed | 2 failed as expected
|
||||
assertions: 18 | 11 passed | 4 failed | 3 failed as expected
|
||||
|
||||
|
@@ -1,9 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<testsuitesspanner>
|
||||
<testsuite name="<exe-name>" errors="13" failures="76" tests="956" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
||||
<testsuite name="<exe-name>" errors="13" failures="78" tests="971" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
||||
<testcase classname="global" name="# A test name that starts with a #" time="{duration}"/>
|
||||
<testcase classname="global" name="#542" time="{duration}"/>
|
||||
<testcase classname="#748 - captures with unexpected exceptions" name="outside assertions" time="{duration}">
|
||||
<error type="TEST_CASE">
|
||||
expected exception
|
||||
answer := 42
|
||||
ExceptionTests.cpp:<line number>
|
||||
</error>
|
||||
</testcase>
|
||||
<testcase classname="#748 - captures with unexpected exceptions" name="inside REQUIRE_NOTHROW" time="{duration}">
|
||||
<error message="thisThrows()" type="REQUIRE_NOTHROW">
|
||||
expected exception
|
||||
answer := 42
|
||||
ExceptionTests.cpp:<line number>
|
||||
</error>
|
||||
</testcase>
|
||||
<testcase classname="#748 - captures with unexpected exceptions" name="inside REQUIRE_THROWS" time="{duration}"/>
|
||||
<testcase classname="global" name="#809" time="{duration}"/>
|
||||
<testcase classname="global" name="#833" time="{duration}"/>
|
||||
<testcase classname="global" name="#835 -- errno should not be touched by Catch" time="{duration}">
|
||||
<failure message="1 == 0" type="CHECK">
|
||||
MiscTests.cpp:<line number>
|
||||
</failure>
|
||||
</testcase>
|
||||
<testcase classname="global" name="'Not' checks that should fail" time="{duration}">
|
||||
<failure message="false != false" type="CHECK">
|
||||
ConditionTests.cpp:<line number>
|
||||
@@ -83,6 +103,8 @@ ExceptionTests.cpp:<line number>
|
||||
<testcase classname="Assertions then sections" name="A section" time="{duration}"/>
|
||||
<testcase classname="Assertions then sections" name="A section/Another section" time="{duration}"/>
|
||||
<testcase classname="Assertions then sections" name="A section/Another other section" time="{duration}"/>
|
||||
<testcase classname="Capture and info messages" name="Capture should stringify like assertions" time="{duration}"/>
|
||||
<testcase classname="Capture and info messages" name="Info should NOT stringify the way assertions do" time="{duration}"/>
|
||||
<testcase classname="Character pretty printing" name="Specifically escaped" time="{duration}"/>
|
||||
<testcase classname="Character pretty printing" name="General chars" time="{duration}"/>
|
||||
<testcase classname="Character pretty printing" name="Low ASCII" time="{duration}"/>
|
||||
@@ -192,6 +214,12 @@ MessageTests.cpp:<line number>
|
||||
</testcase>
|
||||
<testcase classname="global" name="FAIL does not require an argument" time="{duration}">
|
||||
<failure type="FAIL">
|
||||
MessageTests.cpp:<line number>
|
||||
</failure>
|
||||
</testcase>
|
||||
<testcase classname="global" name="FAIL_CHECK does not abort the test" time="{duration}">
|
||||
<failure type="FAIL_CHECK">
|
||||
This is a failure
|
||||
MessageTests.cpp:<line number>
|
||||
</failure>
|
||||
</testcase>
|
||||
@@ -209,10 +237,13 @@ MessageTests.cpp:<line number>
|
||||
</testcase>
|
||||
<testcase classname="global" name="INFO gets logged on failure, even if captured before successful assertions" time="{duration}">
|
||||
<failure message="2 == 1" type="CHECK">
|
||||
this message may be logged later
|
||||
this message should be logged
|
||||
MessageTests.cpp:<line number>
|
||||
</failure>
|
||||
<failure message="2 == 0" type="CHECK">
|
||||
this message may be logged later
|
||||
this message should be logged
|
||||
and this, but later
|
||||
MessageTests.cpp:<line number>
|
||||
</failure>
|
||||
@@ -250,7 +281,7 @@ ConditionTests.cpp:<line number>
|
||||
<testcase classname="Long strings can be wrapped" name="With wrap-before/ after characters/No wrapping" time="{duration}"/>
|
||||
<testcase classname="Long strings can be wrapped" name="With wrap-before/ after characters/Wrap before" time="{duration}"/>
|
||||
<testcase classname="Long strings can be wrapped" name="With wrap-before/ after characters/Wrap after" time="{duration}"/>
|
||||
<testcase classname="global" name="Long text is truncted" time="{duration}"/>
|
||||
<testcase classname="global" name="Long text is truncated" time="{duration}"/>
|
||||
<testcase classname="global" name="ManuallyRegistered" time="{duration}"/>
|
||||
<testcase classname="global" name="Matchers can be (AllOf) composed with the && operator" time="{duration}"/>
|
||||
<testcase classname="global" name="Matchers can be (AnyOf) composed with the || operator" time="{duration}"/>
|
||||
@@ -387,6 +418,7 @@ MessageTests.cpp:<line number>
|
||||
<testcase classname="global" name="Parsing a std::pair" time="{duration}"/>
|
||||
<testcase classname="global" name="Pointers can be compared to null" time="{duration}"/>
|
||||
<testcase classname="global" name="Pointers can be converted to strings" time="{duration}"/>
|
||||
<testcase classname="Process can be configured on command line" name="empty args don't cause a crash" time="{duration}"/>
|
||||
<testcase classname="Process can be configured on command line" name="default - no arguments" time="{duration}"/>
|
||||
<testcase classname="Process can be configured on command line" name="test lists/1 test" time="{duration}"/>
|
||||
<testcase classname="Process can be configured on command line" name="test lists/Specify one test case exclusion using exclude:" time="{duration}"/>
|
||||
@@ -411,6 +443,11 @@ MessageTests.cpp:<line number>
|
||||
<testcase classname="Process can be configured on command line" name="use-colour/yes" time="{duration}"/>
|
||||
<testcase classname="Process can be configured on command line" name="use-colour/no" time="{duration}"/>
|
||||
<testcase classname="Process can be configured on command line" name="use-colour/error" time="{duration}"/>
|
||||
<testcase classname="global" name="Reconstruction should be based on stringification: #914" time="{duration}">
|
||||
<failure message="Hey, its truthy!" type="CHECK">
|
||||
DecompositionTests.cpp:<line number>
|
||||
</failure>
|
||||
</testcase>
|
||||
<testcase classname="global" name="SCOPED_INFO is reset for each loop" time="{duration}">
|
||||
<failure message="10 < 10" type="REQUIRE">
|
||||
current counter 10
|
||||
|
@@ -4,39 +4,47 @@
|
||||
<TestCase name="# A test name that starts with a #" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="#542" filename="projects/<exe-name>/CompilationTests.cpp" >
|
||||
<Expression success="true" type="CHECK_THROWS_AS" filename="projects/<exe-name>/CompilationTests.cpp" >
|
||||
<Original>
|
||||
throws_int(true), int
|
||||
</Original>
|
||||
<Expanded>
|
||||
throws_int(true), int
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK_THROWS_AS" filename="projects/<exe-name>/CompilationTests.cpp" >
|
||||
<Original>
|
||||
throws_int(true), int&
|
||||
</Original>
|
||||
<Expanded>
|
||||
throws_int(true), int&
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK_THROWS_AS" filename="projects/<exe-name>/CompilationTests.cpp" >
|
||||
<Original>
|
||||
throws_int(true), const int
|
||||
</Original>
|
||||
<Expanded>
|
||||
throws_int(true), const int
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK_THROWS_AS" filename="projects/<exe-name>/CompilationTests.cpp" >
|
||||
<Original>
|
||||
throws_int(true), const int&
|
||||
</Original>
|
||||
<Expanded>
|
||||
throws_int(true), const int&
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<TestCase name="#748 - captures with unexpected exceptions" tags="[!shouldfail][!throws]" filename="projects/<exe-name>/ExceptionTests.cpp" >
|
||||
<Section name="outside assertions" filename="projects/<exe-name>/ExceptionTests.cpp" >
|
||||
<Info>
|
||||
answer := 42
|
||||
</Info>
|
||||
<Exception filename="projects/<exe-name>/ExceptionTests.cpp" >
|
||||
expected exception
|
||||
</Exception>
|
||||
<OverallResults successes="0" failures="1" expectedFailures="0"/>
|
||||
</Section>
|
||||
<Section name="inside REQUIRE_NOTHROW" filename="projects/<exe-name>/ExceptionTests.cpp" >
|
||||
<Info>
|
||||
answer := 42
|
||||
</Info>
|
||||
<Expression success="false" type="REQUIRE_NOTHROW" filename="projects/<exe-name>/ExceptionTests.cpp" >
|
||||
<Original>
|
||||
thisThrows()
|
||||
</Original>
|
||||
<Expanded>
|
||||
thisThrows()
|
||||
</Expanded>
|
||||
<Exception filename="projects/<exe-name>/ExceptionTests.cpp" >
|
||||
expected exception
|
||||
</Exception>
|
||||
</Expression>
|
||||
<OverallResults successes="0" failures="1" expectedFailures="0"/>
|
||||
</Section>
|
||||
<Section name="inside REQUIRE_THROWS" filename="projects/<exe-name>/ExceptionTests.cpp" >
|
||||
<Info>
|
||||
answer := 42
|
||||
</Info>
|
||||
<Expression success="true" type="REQUIRE_THROWS" filename="projects/<exe-name>/ExceptionTests.cpp" >
|
||||
<Original>
|
||||
thisThrows()
|
||||
</Original>
|
||||
<Expanded>
|
||||
thisThrows()
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="#809" filename="projects/<exe-name>/CompilationTests.cpp" >
|
||||
@@ -50,6 +58,84 @@
|
||||
</Expression>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="#833" filename="projects/<exe-name>/CompilationTests.cpp" >
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/CompilationTests.cpp" >
|
||||
<Original>
|
||||
a == t
|
||||
</Original>
|
||||
<Expanded>
|
||||
3 == 3
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK" filename="projects/<exe-name>/CompilationTests.cpp" >
|
||||
<Original>
|
||||
a == t
|
||||
</Original>
|
||||
<Expanded>
|
||||
3 == 3
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_THROWS" filename="projects/<exe-name>/CompilationTests.cpp" >
|
||||
<Original>
|
||||
throws_int(true)
|
||||
</Original>
|
||||
<Expanded>
|
||||
throws_int(true)
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK_THROWS_AS" filename="projects/<exe-name>/CompilationTests.cpp" >
|
||||
<Original>
|
||||
throws_int(true), const int&
|
||||
</Original>
|
||||
<Expanded>
|
||||
throws_int(true), const int&
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_NOTHROW" filename="projects/<exe-name>/CompilationTests.cpp" >
|
||||
<Original>
|
||||
throws_int(false)
|
||||
</Original>
|
||||
<Expanded>
|
||||
throws_int(false)
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/CompilationTests.cpp" >
|
||||
<Original>
|
||||
"aaa", Catch::EndsWith("aaa")
|
||||
</Original>
|
||||
<Expanded>
|
||||
"aaa" ends with: "aaa"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/CompilationTests.cpp" >
|
||||
<Original>
|
||||
templated_tests<int>(3)
|
||||
</Original>
|
||||
<Expanded>
|
||||
true
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="#835 -- errno should not be touched by Catch" tags="[!shouldfail]" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<Expression success="false" type="CHECK" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<Original>
|
||||
f() == 0
|
||||
</Original>
|
||||
<Expanded>
|
||||
1 == 0
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<Original>
|
||||
errno == 1
|
||||
</Original>
|
||||
<Expanded>
|
||||
1 == 1
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="'Not' checks that should fail" tags="[.][failing][hide]" filename="projects/<exe-name>/ConditionTests.cpp" >
|
||||
<Expression success="false" type="CHECK" filename="projects/<exe-name>/ConditionTests.cpp" >
|
||||
<Original>
|
||||
@@ -643,6 +729,37 @@
|
||||
</Section>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="Capture and info messages" filename="projects/<exe-name>/ToStringGeneralTests.cpp" >
|
||||
<Section name="Capture should stringify like assertions" filename="projects/<exe-name>/ToStringGeneralTests.cpp" >
|
||||
<Info>
|
||||
i := 2
|
||||
</Info>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringGeneralTests.cpp" >
|
||||
<Original>
|
||||
true
|
||||
</Original>
|
||||
<Expanded>
|
||||
true
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<Section name="Info should NOT stringify the way assertions do" filename="projects/<exe-name>/ToStringGeneralTests.cpp" >
|
||||
<Info>
|
||||
3
|
||||
</Info>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringGeneralTests.cpp" >
|
||||
<Original>
|
||||
true
|
||||
</Original>
|
||||
<Expanded>
|
||||
true
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="Character pretty printing" filename="projects/<exe-name>/ToStringGeneralTests.cpp" >
|
||||
<Section name="Specifically escaped" filename="projects/<exe-name>/ToStringGeneralTests.cpp" >
|
||||
<Expression success="true" type="CHECK" filename="projects/<exe-name>/ToStringGeneralTests.cpp" >
|
||||
@@ -773,7 +890,7 @@
|
||||
a
|
||||
</Original>
|
||||
<Expanded>
|
||||
true
|
||||
0x<hex digits>
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/TrickyTests.cpp" >
|
||||
@@ -1328,6 +1445,15 @@
|
||||
<Failure filename="projects/<exe-name>/MessageTests.cpp" />
|
||||
<OverallResult success="false"/>
|
||||
</TestCase>
|
||||
<TestCase name="FAIL_CHECK does not abort the test" tags="[.][failing][hide][messages]" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||
<Failure filename="projects/<exe-name>/MessageTests.cpp" >
|
||||
This is a failure
|
||||
</Failure>
|
||||
<Warning>
|
||||
This message appears in the output
|
||||
</Warning>
|
||||
<OverallResult success="false"/>
|
||||
</TestCase>
|
||||
<TestCase name="Factorials are computed" tags="[factorial]" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<Original>
|
||||
@@ -2607,6 +2733,9 @@
|
||||
<OverallResult success="false"/>
|
||||
</TestCase>
|
||||
<TestCase name="INFO gets logged on failure, even if captured before successful assertions" tags="[.][failing][hide][messages]" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||
<Info>
|
||||
this message may be logged later
|
||||
</Info>
|
||||
<Expression success="true" type="CHECK" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||
<Original>
|
||||
a == 2
|
||||
@@ -2615,6 +2744,9 @@
|
||||
2 == 2
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Info>
|
||||
this message may be logged later
|
||||
</Info>
|
||||
<Info>
|
||||
this message should be logged
|
||||
</Info>
|
||||
@@ -2626,6 +2758,12 @@
|
||||
2 == 1
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Info>
|
||||
this message may be logged later
|
||||
</Info>
|
||||
<Info>
|
||||
this message should be logged
|
||||
</Info>
|
||||
<Info>
|
||||
and this, but later
|
||||
</Info>
|
||||
@@ -2637,6 +2775,18 @@
|
||||
2 == 0
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Info>
|
||||
this message may be logged later
|
||||
</Info>
|
||||
<Info>
|
||||
this message should be logged
|
||||
</Info>
|
||||
<Info>
|
||||
and this, but later
|
||||
</Info>
|
||||
<Info>
|
||||
but not this
|
||||
</Info>
|
||||
<Expression success="true" type="CHECK" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||
<Original>
|
||||
a == 2
|
||||
@@ -3409,7 +3559,7 @@ re>"
|
||||
</Section>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="Long text is truncted" tags="[Text][Truncated]" filename="projects/<exe-name>/TestMain.cpp" >
|
||||
<TestCase name="Long text is truncated" tags="[Text][Truncated]" filename="projects/<exe-name>/TestMain.cpp" >
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/TestMain.cpp" >
|
||||
<Original>
|
||||
t.toString(), EndsWith( "... message truncated due to excessive size" )
|
||||
@@ -4545,7 +4695,7 @@ re>"
|
||||
True
|
||||
</Original>
|
||||
<Expanded>
|
||||
true
|
||||
1
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TrickyTests.cpp" >
|
||||
@@ -4561,7 +4711,7 @@ re>"
|
||||
!False
|
||||
</Original>
|
||||
<Expanded>
|
||||
!false
|
||||
!0
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResult success="true"/>
|
||||
@@ -6150,6 +6300,25 @@ re>"
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="Process can be configured on command line" tags="[command-line][config]" filename="projects/<exe-name>/TestMain.cpp" >
|
||||
<Section name="empty args don't cause a crash" filename="projects/<exe-name>/TestMain.cpp" >
|
||||
<Expression success="true" type="CHECK_NOTHROW" filename="projects/<exe-name>/TestMain.cpp" >
|
||||
<Original>
|
||||
parser.parseInto( std::vector<std::string>(), config )
|
||||
</Original>
|
||||
<Expanded>
|
||||
parser.parseInto( std::vector<std::string>(), config )
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
|
||||
<Original>
|
||||
config.processName == ""
|
||||
</Original>
|
||||
<Expanded>
|
||||
"" == ""
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="2" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<Section name="default - no arguments" filename="projects/<exe-name>/TestMain.cpp" >
|
||||
<Expression success="true" type="CHECK_NOTHROW" filename="projects/<exe-name>/TestMain.cpp" >
|
||||
<Original>
|
||||
@@ -6159,6 +6328,14 @@ re>"
|
||||
parseIntoConfig( argv, config )
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
|
||||
<Original>
|
||||
config.processName == "test"
|
||||
</Original>
|
||||
<Expanded>
|
||||
"test" == "test"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK" filename="projects/<exe-name>/TestMain.cpp" >
|
||||
<Original>
|
||||
config.shouldDebugBreak == false
|
||||
@@ -6191,7 +6368,7 @@ re>"
|
||||
true
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="5" failures="0" expectedFailures="0"/>
|
||||
<OverallResults successes="6" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<Section name="test lists" filename="projects/<exe-name>/TestMain.cpp" >
|
||||
<Section name="1 test" description="Specify one test case using" filename="projects/<exe-name>/TestMain.cpp" >
|
||||
@@ -6735,7 +6912,24 @@ re>"
|
||||
</Section>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="Reconstruction should be based on stringification: #914" tags="[.][Decomposition][failing][hide]" filename="projects/<exe-name>/DecompositionTests.cpp" >
|
||||
<Expression success="false" type="CHECK" filename="projects/<exe-name>/DecompositionTests.cpp" >
|
||||
<Original>
|
||||
truthy(false)
|
||||
</Original>
|
||||
<Expanded>
|
||||
Hey, its truthy!
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResult success="false"/>
|
||||
</TestCase>
|
||||
<TestCase name="SCOPED_INFO is reset for each loop" tags="[.][failing][hide][messages]" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||
<Info>
|
||||
current counter 0
|
||||
</Info>
|
||||
<Info>
|
||||
i := 0
|
||||
</Info>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||
<Original>
|
||||
i < 10
|
||||
@@ -6744,6 +6938,12 @@ re>"
|
||||
0 < 10
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Info>
|
||||
current counter 1
|
||||
</Info>
|
||||
<Info>
|
||||
i := 1
|
||||
</Info>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||
<Original>
|
||||
i < 10
|
||||
@@ -6752,6 +6952,12 @@ re>"
|
||||
1 < 10
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Info>
|
||||
current counter 2
|
||||
</Info>
|
||||
<Info>
|
||||
i := 2
|
||||
</Info>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||
<Original>
|
||||
i < 10
|
||||
@@ -6760,6 +6966,12 @@ re>"
|
||||
2 < 10
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Info>
|
||||
current counter 3
|
||||
</Info>
|
||||
<Info>
|
||||
i := 3
|
||||
</Info>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||
<Original>
|
||||
i < 10
|
||||
@@ -6768,6 +6980,12 @@ re>"
|
||||
3 < 10
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Info>
|
||||
current counter 4
|
||||
</Info>
|
||||
<Info>
|
||||
i := 4
|
||||
</Info>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||
<Original>
|
||||
i < 10
|
||||
@@ -6776,6 +6994,12 @@ re>"
|
||||
4 < 10
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Info>
|
||||
current counter 5
|
||||
</Info>
|
||||
<Info>
|
||||
i := 5
|
||||
</Info>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||
<Original>
|
||||
i < 10
|
||||
@@ -6784,6 +7008,12 @@ re>"
|
||||
5 < 10
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Info>
|
||||
current counter 6
|
||||
</Info>
|
||||
<Info>
|
||||
i := 6
|
||||
</Info>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||
<Original>
|
||||
i < 10
|
||||
@@ -6792,6 +7022,12 @@ re>"
|
||||
6 < 10
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Info>
|
||||
current counter 7
|
||||
</Info>
|
||||
<Info>
|
||||
i := 7
|
||||
</Info>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||
<Original>
|
||||
i < 10
|
||||
@@ -6800,6 +7036,12 @@ re>"
|
||||
7 < 10
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Info>
|
||||
current counter 8
|
||||
</Info>
|
||||
<Info>
|
||||
i := 8
|
||||
</Info>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||
<Original>
|
||||
i < 10
|
||||
@@ -6808,6 +7050,12 @@ re>"
|
||||
8 < 10
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Info>
|
||||
current counter 9
|
||||
</Info>
|
||||
<Info>
|
||||
i := 9
|
||||
</Info>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||
<Original>
|
||||
i < 10
|
||||
@@ -7156,7 +7404,8 @@ hello
|
||||
<Expanded>
|
||||
"error: tag alias, "[@zzz]" already registered.
|
||||
First seen at file:2
|
||||
Redefined at file:10" contains: "[@zzz]"
|
||||
Redefined at file:10
|
||||
" contains: "[@zzz]"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/TagAliasTests.cpp" >
|
||||
@@ -7166,7 +7415,8 @@ hello
|
||||
<Expanded>
|
||||
"error: tag alias, "[@zzz]" already registered.
|
||||
First seen at file:2
|
||||
Redefined at file:10" contains: "file"
|
||||
Redefined at file:10
|
||||
" contains: "file"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/TagAliasTests.cpp" >
|
||||
@@ -7176,7 +7426,8 @@ hello
|
||||
<Expanded>
|
||||
"error: tag alias, "[@zzz]" already registered.
|
||||
First seen at file:2
|
||||
Redefined at file:10" contains: "2"
|
||||
Redefined at file:10
|
||||
" contains: "2"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/TagAliasTests.cpp" >
|
||||
@@ -7186,7 +7437,8 @@ hello
|
||||
<Expanded>
|
||||
"error: tag alias, "[@zzz]" already registered.
|
||||
First seen at file:2
|
||||
Redefined at file:10" contains: "10"
|
||||
Redefined at file:10
|
||||
" contains: "10"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="4" failures="0" expectedFailures="0"/>
|
||||
@@ -9086,6 +9338,9 @@ spanner <OverallResult success="true"/>
|
||||
1 == 0
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Info>
|
||||
Testing if fib[2] (2) is even
|
||||
</Info>
|
||||
<Expression success="true" type="CHECK" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<Original>
|
||||
( fib[i] % 2 ) == 0
|
||||
@@ -9116,6 +9371,9 @@ spanner <OverallResult success="true"/>
|
||||
1 == 0
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Info>
|
||||
Testing if fib[5] (8) is even
|
||||
</Info>
|
||||
<Expression success="true" type="CHECK" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<Original>
|
||||
( fib[i] % 2 ) == 0
|
||||
@@ -9885,7 +10143,7 @@ spanner <OverallResult success="true"/>
|
||||
</Section>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<OverallResults successes="849" failures="89" expectedFailures="18"/>
|
||||
<OverallResults successes="859" failures="91" expectedFailures="21"/>
|
||||
</Group>
|
||||
<OverallResults successes="849" failures="88" expectedFailures="18"/>
|
||||
<OverallResults successes="859" failures="90" expectedFailures="21"/>
|
||||
</Catch>
|
||||
|
@@ -23,20 +23,50 @@ TEST_CASE("#809") {
|
||||
REQUIRE(42 == f);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// REQUIRE_THROWS_AS was changed to catch exceptions by const&
|
||||
// using type traits. This means that this should compile cleanly
|
||||
|
||||
// Provides indirection to prevent unreachable-code warnings
|
||||
// ------------------------------------------------------------------
|
||||
// Changes to REQUIRE_THROWS_AS made it stop working in a template in
|
||||
// an unfixable way (as long as C++03 compatibility is being kept).
|
||||
// To prevent these from happening in the future, this needs to compile
|
||||
|
||||
void throws_int(bool b) {
|
||||
if (b) {
|
||||
throw 1;
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("#542") {
|
||||
CHECK_THROWS_AS(throws_int(true), int);
|
||||
CHECK_THROWS_AS(throws_int(true), int&);
|
||||
CHECK_THROWS_AS(throws_int(true), const int);
|
||||
template <typename T>
|
||||
bool templated_tests(T t) {
|
||||
int a = 3;
|
||||
REQUIRE(a == t);
|
||||
CHECK(a == t);
|
||||
REQUIRE_THROWS(throws_int(true));
|
||||
CHECK_THROWS_AS(throws_int(true), const int&);
|
||||
REQUIRE_NOTHROW(throws_int(false));
|
||||
REQUIRE_THAT("aaa", Catch::EndsWith("aaa"));
|
||||
return true;
|
||||
}
|
||||
|
||||
TEST_CASE("#833") {
|
||||
REQUIRE(templated_tests<int>(3));
|
||||
}
|
||||
|
||||
// Test containing example where original stream insertable check breaks compilation
|
||||
#if defined (CATCH_CONFIG_CPP11_STREAM_INSERTABLE_CHECK)
|
||||
namespace {
|
||||
struct A {};
|
||||
std::ostream& operator<< (std::ostream &o, const A &) { return o << 0; }
|
||||
|
||||
struct B : private A {
|
||||
bool operator== (int) const { return true; }
|
||||
};
|
||||
|
||||
B f ();
|
||||
std::ostream g ();
|
||||
}
|
||||
|
||||
TEST_CASE( "#872" ) {
|
||||
B x;
|
||||
REQUIRE (x == 4);
|
||||
}
|
||||
#endif
|
||||
|
28
projects/SelfTest/DecompositionTests.cpp
Normal file
28
projects/SelfTest/DecompositionTests.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Created by Martin on 27/5/2017.
|
||||
* Copyright 2017 Two Blue Cubes Ltd. All rights reserved.
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
struct truthy {
|
||||
truthy(bool b):m_value(b){}
|
||||
operator bool() const {
|
||||
return false;
|
||||
}
|
||||
bool m_value;
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& o, truthy) {
|
||||
o << "Hey, its truthy!";
|
||||
return o;
|
||||
}
|
||||
|
||||
#include "catch.hpp"
|
||||
|
||||
TEST_CASE( "Reconstruction should be based on stringification: #914" , "[Decomposition][failing][.]") {
|
||||
CHECK(truthy(false));
|
||||
}
|
@@ -11,6 +11,10 @@
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4702) // Unreachable code -- MSVC 19 (VS 2015) sees right through the indirection
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
inline int thisThrows()
|
||||
@@ -205,3 +209,18 @@ TEST_CASE( "Mismatching exception messages failing the test", "[.][failing][!thr
|
||||
REQUIRE_THROWS_WITH( thisThrows(), "should fail" );
|
||||
REQUIRE_THROWS_WITH( thisThrows(), "expected exception" );
|
||||
}
|
||||
|
||||
TEST_CASE( "#748 - captures with unexpected exceptions", "[!shouldfail][!throws]" ) {
|
||||
int answer = 42;
|
||||
CAPTURE( answer );
|
||||
// the message should be printed on the first two sections but not on the third
|
||||
SECTION( "outside assertions" ) {
|
||||
thisThrows();
|
||||
}
|
||||
SECTION( "inside REQUIRE_NOTHROW" ) {
|
||||
REQUIRE_NOTHROW( thisThrows() );
|
||||
}
|
||||
SECTION( "inside REQUIRE_THROWS" ) {
|
||||
REQUIRE_THROWS( thisThrows() );
|
||||
}
|
||||
}
|
||||
|
@@ -53,6 +53,13 @@ TEST_CASE( "INFO gets logged on failure, even if captured before successful asse
|
||||
TEST_CASE( "FAIL aborts the test", "[failing][messages][.]" )
|
||||
{
|
||||
FAIL( "This is a " << "failure" ); // This should output the message and abort
|
||||
WARN( "We should never see this");
|
||||
}
|
||||
|
||||
TEST_CASE( "FAIL_CHECK does not abort the test", "[failing][messages][.]" )
|
||||
{
|
||||
FAIL_CHECK( "This is a " << "failure" ); // This should output the message then continue
|
||||
WARN( "This message appears in the output");
|
||||
}
|
||||
|
||||
#ifdef CATCH_CONFIG_VARIADIC_MACROS
|
||||
|
@@ -16,6 +16,7 @@
|
||||
#include "../include/internal/catch_xmlwriter.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <cerrno>
|
||||
|
||||
TEST_CASE( "random SECTION tests", "[.][sections][failing]" )
|
||||
{
|
||||
@@ -393,3 +394,14 @@ TEST_CASE( "This test 'should' fail but doesn't", "[.][failing][!shouldfail]" )
|
||||
TEST_CASE( "# A test name that starts with a #" ) {
|
||||
SUCCEED( "yay" );
|
||||
}
|
||||
|
||||
|
||||
static int f() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
TEST_CASE( "#835 -- errno should not be touched by Catch", "[!shouldfail]" ) {
|
||||
errno = 1;
|
||||
CHECK(f() == 0);
|
||||
REQUIRE(errno == 1); // Check that f() doesn't touch errno.
|
||||
}
|
||||
|
@@ -51,10 +51,18 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]"
|
||||
|
||||
Catch::ConfigData config;
|
||||
|
||||
SECTION( "empty args don't cause a crash" ) {
|
||||
Catch::Clara::CommandLine<Catch::ConfigData> parser = Catch::makeCommandLineParser();
|
||||
CHECK_NOTHROW( parser.parseInto( std::vector<std::string>(), config ) );
|
||||
|
||||
CHECK( config.processName == "" );
|
||||
}
|
||||
|
||||
SECTION( "default - no arguments", "" ) {
|
||||
const char* argv[] = { "test" };
|
||||
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||
|
||||
CHECK( config.processName == "test" );
|
||||
CHECK( config.shouldDebugBreak == false );
|
||||
CHECK( config.abortAfter == -1 );
|
||||
CHECK( config.noThrow == false );
|
||||
@@ -471,7 +479,7 @@ TEST_CASE( "Text can be formatted using the Text class", "" ) {
|
||||
CHECK( Text( "hi there", narrow ).toString() == "hi\nthere" );
|
||||
}
|
||||
|
||||
TEST_CASE( "Long text is truncted", "[Text][Truncated]" ) {
|
||||
TEST_CASE( "Long text is truncated", "[Text][Truncated]" ) {
|
||||
|
||||
std::string longLine( 90, '*' );
|
||||
|
||||
|
@@ -9,7 +9,6 @@
|
||||
|
||||
|
||||
TEST_CASE( "Character pretty printing" ){
|
||||
//
|
||||
SECTION("Specifically escaped"){
|
||||
char tab = '\t';
|
||||
char newline = '\n';
|
||||
@@ -36,5 +35,19 @@ TEST_CASE( "Character pretty printing" ){
|
||||
char c = static_cast<char>(i);
|
||||
REQUIRE(c == i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE( "Capture and info messages" ) {
|
||||
SECTION("Capture should stringify like assertions") {
|
||||
int i = 2;
|
||||
CAPTURE(i);
|
||||
REQUIRE(true);
|
||||
}
|
||||
SECTION("Info should NOT stringify the way assertions do") {
|
||||
int i = 3;
|
||||
INFO(i);
|
||||
REQUIRE(true);
|
||||
}
|
||||
}
|
||||
|
@@ -36,6 +36,13 @@ exeNameParser = re.compile(r'''
|
||||
# This is a hack until something more reasonable is figured out
|
||||
specialCaseParser = re.compile(r'file\((\d+)\)')
|
||||
|
||||
# errno macro expands into various names depending on platform, so we need to fix them up as well
|
||||
errnoParser = re.compile(r'''
|
||||
\(\*__errno_location\ \(\)\)
|
||||
|
|
||||
\(\*__error\(\)\)
|
||||
''', re.VERBOSE)
|
||||
|
||||
if len(sys.argv) == 2:
|
||||
cmdPath = sys.argv[1]
|
||||
else:
|
||||
@@ -45,9 +52,9 @@ overallResult = 0
|
||||
|
||||
def diffFiles(fileA, fileB):
|
||||
with open(fileA, 'r') as file:
|
||||
aLines = file.readlines()
|
||||
aLines = [line.rstrip() for line in file.readlines()]
|
||||
with open(fileB, 'r') as file:
|
||||
bLines = file.readlines()
|
||||
bLines = [line.rstrip() for line in file.readlines()]
|
||||
|
||||
shortenedFilenameA = fileA.rsplit(os.sep, 1)[-1]
|
||||
shortenedFilenameB = fileB.rsplit(os.sep, 1)[-1]
|
||||
@@ -90,6 +97,7 @@ def filterLine(line):
|
||||
line = durationsParser.sub(' time="{duration}"', line)
|
||||
line = timestampsParser.sub(' timestamp="{iso8601-timestamp}"', line)
|
||||
line = specialCaseParser.sub('file:\g<1>', line)
|
||||
line = errnoParser.sub('errno', line)
|
||||
return line
|
||||
|
||||
|
||||
@@ -119,7 +127,7 @@ def approve(baseName, args):
|
||||
if os.path.exists(baselinesPath):
|
||||
diffResult = diffFiles(baselinesPath, filteredResultsPath)
|
||||
if diffResult:
|
||||
print(''.join(diffResult))
|
||||
print('\n'.join(diffResult))
|
||||
print(" \n****************************\n \033[91mResults differed")
|
||||
if len(diffResult) > overallResult:
|
||||
overallResult = len(diffResult)
|
||||
|
@@ -124,16 +124,18 @@ args = parser.parse_args()
|
||||
compiler_path = args.compiler
|
||||
catch_path = args.catch_header
|
||||
|
||||
os.chdir(dir_name)
|
||||
if args.generate_files:
|
||||
create_temp_dir()
|
||||
copy_catch(catch_path)
|
||||
os.chdir(dir_name)
|
||||
# now create the fake test files
|
||||
generate_files()
|
||||
# Early exit
|
||||
print('Finished generating files')
|
||||
exit(1)
|
||||
|
||||
os.chdir(dir_name)
|
||||
|
||||
if args.flags:
|
||||
flags = args.flags
|
||||
|
||||
|
0
scripts/developBuild.py
Normal file → Executable file
0
scripts/developBuild.py
Normal file → Executable file
@@ -7,7 +7,7 @@ import string
|
||||
|
||||
from scriptCommon import catchPath
|
||||
|
||||
versionParser = re.compile( r'(\s*Version\slibraryVersion)\s*\(\s*(.*)\s*,\s*(.*)\s*,\s*(.*)\s*,\s*\"(.*)\"\s*,\s*(.*)\s*\).*' )
|
||||
versionParser = re.compile( r'(\s*static\sVersion\sversion)\s*\(\s*(.*)\s*,\s*(.*)\s*,\s*(.*)\s*,\s*\"(.*)\"\s*,\s*(.*)\s*\).*' )
|
||||
rootPath = os.path.join( catchPath, 'include/' )
|
||||
versionPath = os.path.join( rootPath, "internal/catch_version.hpp" )
|
||||
readmePath = os.path.join( catchPath, "README.md" )
|
||||
@@ -75,7 +75,6 @@ class Version:
|
||||
f.write( line + "\n" )
|
||||
|
||||
def updateReadmeFile(self):
|
||||
versionParser = re.compile( r'\*v\d+\.\d+\.\d+\*' )
|
||||
downloadParser = re.compile( r'<a href=\"https://github.com/philsquared/Catch/releases/download/v\d+\.\d+\.\d+/catch.hpp\">' )
|
||||
f = open( readmePath, 'r' )
|
||||
lines = []
|
||||
@@ -84,7 +83,6 @@ class Version:
|
||||
f.close()
|
||||
f = open( readmePath, 'w' )
|
||||
for line in lines:
|
||||
line = versionParser.sub( '*v{0}*'.format(self.getVersionString()), line)
|
||||
line = downloadParser.sub( r'<a href="https://github.com/philsquared/Catch/releases/download/v{0}/catch.hpp">'.format(self.getVersionString()) , line)
|
||||
f.write( line + "\n" )
|
||||
|
||||
|
0
scripts/releaseNotes.py
Normal file → Executable file
0
scripts/releaseNotes.py
Normal file → Executable file
115
scripts/updateVcpkgPackage.py
Normal file
115
scripts/updateVcpkgPackage.py
Normal file
@@ -0,0 +1,115 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import io, os, re, sys, subprocess
|
||||
import hashlib
|
||||
|
||||
from scriptCommon import catchPath
|
||||
from releaseCommon import Version
|
||||
|
||||
print(catchPath)
|
||||
|
||||
default_path = '../vcpkg/ports/catch/'
|
||||
|
||||
def adjusted_path(path):
|
||||
return os.path.join(catchPath, path)
|
||||
|
||||
def get_hash(path):
|
||||
BUFF_SIZE = 65536
|
||||
sha512 = hashlib.sha512()
|
||||
# The newlines should be normalized into \n, which is what we want
|
||||
# If reused use 'rb' with a file written with io.open(newline='\n')
|
||||
with open(path, 'r') as f:
|
||||
while True:
|
||||
data = f.read(BUFF_SIZE)
|
||||
if not data:
|
||||
break
|
||||
if sys.version_info[0] < 3:
|
||||
sha512.update(data)
|
||||
else:
|
||||
sha512.update(data.encode('utf-8'))
|
||||
return sha512.hexdigest()
|
||||
|
||||
def update_control(path):
|
||||
v = Version()
|
||||
ver_string = v.getVersionString()
|
||||
|
||||
# Update control
|
||||
lines = []
|
||||
control_path = os.path.join(path, 'CONTROL')
|
||||
with open(control_path, 'r') as f:
|
||||
for line in f:
|
||||
lines.append(line)
|
||||
with open(control_path, 'w') as f:
|
||||
for line in lines:
|
||||
if 'Version: ' in line:
|
||||
line = 'Version: {}\n'.format(v.getVersionString())
|
||||
f.write(line)
|
||||
|
||||
def update_portfile(path, header_hash, licence_hash):
|
||||
print('Updating portfile')
|
||||
v = Version()
|
||||
ver_string = v.getVersionString()
|
||||
|
||||
# Update portfile
|
||||
lines = []
|
||||
portfile_path = os.path.join(path, 'portfile.cmake')
|
||||
with open(portfile_path, 'r') as f:
|
||||
for line in f:
|
||||
lines.append(line)
|
||||
with open(portfile_path, 'w') as f:
|
||||
# Two things we need to change/update
|
||||
# 1) Link and hash of releaseCommon
|
||||
# 2) Link and hash of licence
|
||||
# We could assume licence never changes, but where is the fun in that?
|
||||
first_hash = True
|
||||
for line in lines:
|
||||
# Check what we are updating
|
||||
if 'vcpkg_download_distfile' in line:
|
||||
kind = line.split('(')[-1].strip()
|
||||
print(kind)
|
||||
|
||||
# Deal with URLS
|
||||
if 'URLS' in line and kind == 'HEADER':
|
||||
line = ' URLS "https://github.com/philsquared/Catch/releases/download/v{}/catch.hpp"\n'.format(v.getVersionString())
|
||||
if 'URLS' in line and kind == 'LICENSE':
|
||||
line = ' URLS "https://raw.githubusercontent.com/philsquared/Catch/v{}/LICENSE.txt"\n'.format(v.getVersionString())
|
||||
|
||||
# Deal with hashes
|
||||
if 'SHA512' in line and kind == 'HEADER':
|
||||
line = ' SHA512 {}\n'.format(header_hash)
|
||||
if 'SHA512' in line and kind == 'LICENSE':
|
||||
line = ' SHA512 {}\n'.format(licence_hash)
|
||||
f.write(line)
|
||||
|
||||
|
||||
def git_push(path_to_repo):
|
||||
v = Version()
|
||||
ver_string = v.getVersionString()
|
||||
|
||||
# Move to the repo dir
|
||||
old_path = os.getcwd()
|
||||
os.chdir(path_to_repo)
|
||||
|
||||
# Work with git
|
||||
# Make sure we branch off master
|
||||
subprocess.call('git checkout master', shell=True)
|
||||
|
||||
# Update repo to current master, so we don't work off old version of the portsfile
|
||||
subprocess.call('git pull Microsoft master', shell=True)
|
||||
subprocess.call('git push', shell=True)
|
||||
|
||||
# Create a new branch for the update
|
||||
subprocess.call('git checkout -b catch-{}'.format(ver_string), shell=True)
|
||||
# Add changed files (should be only our files)
|
||||
subprocess.call('git add -u .', shell=True)
|
||||
# Create a commit with these changes
|
||||
subprocess.call('git commit -m "Update Catch to {}"'.format(ver_string), shell=True)
|
||||
# Don't push, so author can review
|
||||
print('Changes were commited to the vcpkg fork. Please check, push and open PR.')
|
||||
|
||||
header_hash = get_hash(adjusted_path('single_include/catch.hpp'))
|
||||
licence_hash = get_hash(adjusted_path('LICENSE.txt'))
|
||||
update_control(adjusted_path(default_path))
|
||||
update_portfile(adjusted_path(default_path), header_hash, licence_hash)
|
||||
|
||||
git_push(adjusted_path('../vcpkg'))
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user