Merge branch 'master' into appveyor-mingw-enable-tests-again

This commit is contained in:
Gennadiy Civil 2018-09-25 21:29:51 -07:00 committed by GitHub
commit 9241466921
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 62 additions and 677 deletions

View File

@ -18,14 +18,14 @@ matrix:
- os: linux
compiler: clang
sudo : true
env: TEST_CLANG_FORMAT="yes"
install: ./ci/install-linux.sh && ./ci/log-config.sh
script: ./ci/test_format.sh && ./ci/build-linux-bazel.sh
script: ./ci/build-linux-bazel.sh
- os: linux
group: deprecated-2017Q4
compiler: gcc
install: ./ci/install-linux.sh && ./ci/log-config.sh
script: ./ci/build-linux-autotools.sh
env: VERBOSE=1 CXXFLAGS=-std=c++11
- os: linux
group: deprecated-2017Q4
compiler: gcc
@ -66,7 +66,6 @@ addons:
packages:
- g++-4.9
- clang-3.9
- clang-format-3.9
notifications:
email: false

View File

@ -20,10 +20,6 @@ environment:
- compiler: msvc-14-seh
generator: "Visual Studio 14 2015 Win64"
- compiler: gcc-5.3.0-posix
generator: "MinGW Makefiles"
cxx_path: 'C:\mingw-w64\i686-5.3.0-posix-dwarf-rt_v4-rev0\mingw32\bin'
- compiler: gcc-6.3.0-posix
generator: "MinGW Makefiles"
cxx_path: 'C:\mingw-w64\i686-6.3.0-posix-dwarf-rt_v5-rev1\mingw32\bin'
@ -39,6 +35,7 @@ install:
Write-Output "Compiler: $env:compiler"
Write-Output "Generator: $env:generator"
Write-Output "Env:Configuation: $env:configuration"
Write-Output "Env: $env"
if (-not (Test-Path env:APPVEYOR_PULL_REQUEST_NUMBER)) {
Write-Output "This is *NOT* a pull request build"
} else {

View File

@ -1,33 +0,0 @@
#!/bin/bash
echo "clang-format - checking Code Formatting..."
if [[ "${TRAVIS_OS_NAME}" == "linux" ]] && \
[[ "${TEST_CLANG_FORMAT}" == "yes" ]]; then
RETURN=0
CLANG_FORMAT="clang-format-3.9"
which clang-format-3.9
if [ ! -f ".clang-format" ]; then
echo ".clang-format file not found!"
exit 1
fi
FILES=`git diff master --name-only | grep -E "\.(cc|cpp|h)$"`
for FILE in $FILES; do
$CLANG_FORMAT $FILE | cmp $FILE >/dev/null
if [ $? -ne 0 ]; then
echo "[!] Clang-Format Found INCORRECT FORMATTING. Please re-format and re-submit. The following file failed: $FILE" >&2
RETURN=1
fi
done
exit $RETURN
fi
exit 0

View File

@ -553,452 +553,6 @@ Args(const InnerMatcher& matcher) {
k9, k10>(matcher);
}
// ElementsAre(e_1, e_2, ... e_n) matches an STL-style container with
// n elements, where the i-th element in the container must
// match the i-th argument in the list. Each argument of
// ElementsAre() can be either a value or a matcher. We support up to
// 10 arguments.
//
// The use of DecayArray in the implementation allows ElementsAre()
// to accept string literals, whose type is const char[N], but we
// want to treat them as const char*.
//
// NOTE: Since ElementsAre() cares about the order of the elements, it
// must not be used with containers whose elements's order is
// undefined (e.g. hash_map).
inline internal::ElementsAreMatcher<
::testing::tuple<> >
ElementsAre() {
typedef ::testing::tuple<> Args;
return internal::ElementsAreMatcher<Args>(Args());
}
template <typename T1>
inline internal::ElementsAreMatcher<
::testing::tuple<
typename internal::DecayArray<T1>::type> >
ElementsAre(const T1& e1) {
typedef ::testing::tuple<
typename internal::DecayArray<T1>::type> Args;
return internal::ElementsAreMatcher<Args>(Args(e1));
}
template <typename T1, typename T2>
inline internal::ElementsAreMatcher<
::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type> >
ElementsAre(const T1& e1, const T2& e2) {
typedef ::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type> Args;
return internal::ElementsAreMatcher<Args>(Args(e1, e2));
}
template <typename T1, typename T2, typename T3>
inline internal::ElementsAreMatcher<
::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type> >
ElementsAre(const T1& e1, const T2& e2, const T3& e3) {
typedef ::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type> Args;
return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3));
}
template <typename T1, typename T2, typename T3, typename T4>
inline internal::ElementsAreMatcher<
::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type,
typename internal::DecayArray<T4>::type> >
ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4) {
typedef ::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type,
typename internal::DecayArray<T4>::type> Args;
return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4));
}
template <typename T1, typename T2, typename T3, typename T4, typename T5>
inline internal::ElementsAreMatcher<
::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type,
typename internal::DecayArray<T4>::type,
typename internal::DecayArray<T5>::type> >
ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
const T5& e5) {
typedef ::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type,
typename internal::DecayArray<T4>::type,
typename internal::DecayArray<T5>::type> Args;
return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5));
}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6>
inline internal::ElementsAreMatcher<
::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type,
typename internal::DecayArray<T4>::type,
typename internal::DecayArray<T5>::type,
typename internal::DecayArray<T6>::type> >
ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
const T5& e5, const T6& e6) {
typedef ::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type,
typename internal::DecayArray<T4>::type,
typename internal::DecayArray<T5>::type,
typename internal::DecayArray<T6>::type> Args;
return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6));
}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7>
inline internal::ElementsAreMatcher<
::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type,
typename internal::DecayArray<T4>::type,
typename internal::DecayArray<T5>::type,
typename internal::DecayArray<T6>::type,
typename internal::DecayArray<T7>::type> >
ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
const T5& e5, const T6& e6, const T7& e7) {
typedef ::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type,
typename internal::DecayArray<T4>::type,
typename internal::DecayArray<T5>::type,
typename internal::DecayArray<T6>::type,
typename internal::DecayArray<T7>::type> Args;
return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6, e7));
}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8>
inline internal::ElementsAreMatcher<
::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type,
typename internal::DecayArray<T4>::type,
typename internal::DecayArray<T5>::type,
typename internal::DecayArray<T6>::type,
typename internal::DecayArray<T7>::type,
typename internal::DecayArray<T8>::type> >
ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
const T5& e5, const T6& e6, const T7& e7, const T8& e8) {
typedef ::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type,
typename internal::DecayArray<T4>::type,
typename internal::DecayArray<T5>::type,
typename internal::DecayArray<T6>::type,
typename internal::DecayArray<T7>::type,
typename internal::DecayArray<T8>::type> Args;
return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6, e7,
e8));
}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8, typename T9>
inline internal::ElementsAreMatcher<
::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type,
typename internal::DecayArray<T4>::type,
typename internal::DecayArray<T5>::type,
typename internal::DecayArray<T6>::type,
typename internal::DecayArray<T7>::type,
typename internal::DecayArray<T8>::type,
typename internal::DecayArray<T9>::type> >
ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9) {
typedef ::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type,
typename internal::DecayArray<T4>::type,
typename internal::DecayArray<T5>::type,
typename internal::DecayArray<T6>::type,
typename internal::DecayArray<T7>::type,
typename internal::DecayArray<T8>::type,
typename internal::DecayArray<T9>::type> Args;
return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6, e7,
e8, e9));
}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8, typename T9, typename T10>
inline internal::ElementsAreMatcher<
::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type,
typename internal::DecayArray<T4>::type,
typename internal::DecayArray<T5>::type,
typename internal::DecayArray<T6>::type,
typename internal::DecayArray<T7>::type,
typename internal::DecayArray<T8>::type,
typename internal::DecayArray<T9>::type,
typename internal::DecayArray<T10>::type> >
ElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9,
const T10& e10) {
typedef ::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type,
typename internal::DecayArray<T4>::type,
typename internal::DecayArray<T5>::type,
typename internal::DecayArray<T6>::type,
typename internal::DecayArray<T7>::type,
typename internal::DecayArray<T8>::type,
typename internal::DecayArray<T9>::type,
typename internal::DecayArray<T10>::type> Args;
return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6, e7,
e8, e9, e10));
}
// UnorderedElementsAre(e_1, e_2, ..., e_n) is an ElementsAre extension
// that matches n elements in any order. We support up to n=10 arguments.
//
// If you have >10 elements, consider UnorderedElementsAreArray() or
// UnorderedPointwise() instead.
inline internal::UnorderedElementsAreMatcher<
::testing::tuple<> >
UnorderedElementsAre() {
typedef ::testing::tuple<> Args;
return internal::UnorderedElementsAreMatcher<Args>(Args());
}
template <typename T1>
inline internal::UnorderedElementsAreMatcher<
::testing::tuple<
typename internal::DecayArray<T1>::type> >
UnorderedElementsAre(const T1& e1) {
typedef ::testing::tuple<
typename internal::DecayArray<T1>::type> Args;
return internal::UnorderedElementsAreMatcher<Args>(Args(e1));
}
template <typename T1, typename T2>
inline internal::UnorderedElementsAreMatcher<
::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type> >
UnorderedElementsAre(const T1& e1, const T2& e2) {
typedef ::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type> Args;
return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2));
}
template <typename T1, typename T2, typename T3>
inline internal::UnorderedElementsAreMatcher<
::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type> >
UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3) {
typedef ::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type> Args;
return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3));
}
template <typename T1, typename T2, typename T3, typename T4>
inline internal::UnorderedElementsAreMatcher<
::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type,
typename internal::DecayArray<T4>::type> >
UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4) {
typedef ::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type,
typename internal::DecayArray<T4>::type> Args;
return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4));
}
template <typename T1, typename T2, typename T3, typename T4, typename T5>
inline internal::UnorderedElementsAreMatcher<
::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type,
typename internal::DecayArray<T4>::type,
typename internal::DecayArray<T5>::type> >
UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
const T5& e5) {
typedef ::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type,
typename internal::DecayArray<T4>::type,
typename internal::DecayArray<T5>::type> Args;
return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5));
}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6>
inline internal::UnorderedElementsAreMatcher<
::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type,
typename internal::DecayArray<T4>::type,
typename internal::DecayArray<T5>::type,
typename internal::DecayArray<T6>::type> >
UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
const T5& e5, const T6& e6) {
typedef ::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type,
typename internal::DecayArray<T4>::type,
typename internal::DecayArray<T5>::type,
typename internal::DecayArray<T6>::type> Args;
return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,
e6));
}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7>
inline internal::UnorderedElementsAreMatcher<
::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type,
typename internal::DecayArray<T4>::type,
typename internal::DecayArray<T5>::type,
typename internal::DecayArray<T6>::type,
typename internal::DecayArray<T7>::type> >
UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
const T5& e5, const T6& e6, const T7& e7) {
typedef ::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type,
typename internal::DecayArray<T4>::type,
typename internal::DecayArray<T5>::type,
typename internal::DecayArray<T6>::type,
typename internal::DecayArray<T7>::type> Args;
return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,
e6, e7));
}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8>
inline internal::UnorderedElementsAreMatcher<
::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type,
typename internal::DecayArray<T4>::type,
typename internal::DecayArray<T5>::type,
typename internal::DecayArray<T6>::type,
typename internal::DecayArray<T7>::type,
typename internal::DecayArray<T8>::type> >
UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
const T5& e5, const T6& e6, const T7& e7, const T8& e8) {
typedef ::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type,
typename internal::DecayArray<T4>::type,
typename internal::DecayArray<T5>::type,
typename internal::DecayArray<T6>::type,
typename internal::DecayArray<T7>::type,
typename internal::DecayArray<T8>::type> Args;
return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,
e6, e7, e8));
}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8, typename T9>
inline internal::UnorderedElementsAreMatcher<
::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type,
typename internal::DecayArray<T4>::type,
typename internal::DecayArray<T5>::type,
typename internal::DecayArray<T6>::type,
typename internal::DecayArray<T7>::type,
typename internal::DecayArray<T8>::type,
typename internal::DecayArray<T9>::type> >
UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9) {
typedef ::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type,
typename internal::DecayArray<T4>::type,
typename internal::DecayArray<T5>::type,
typename internal::DecayArray<T6>::type,
typename internal::DecayArray<T7>::type,
typename internal::DecayArray<T8>::type,
typename internal::DecayArray<T9>::type> Args;
return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,
e6, e7, e8, e9));
}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8, typename T9, typename T10>
inline internal::UnorderedElementsAreMatcher<
::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type,
typename internal::DecayArray<T4>::type,
typename internal::DecayArray<T5>::type,
typename internal::DecayArray<T6>::type,
typename internal::DecayArray<T7>::type,
typename internal::DecayArray<T8>::type,
typename internal::DecayArray<T9>::type,
typename internal::DecayArray<T10>::type> >
UnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,
const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9,
const T10& e10) {
typedef ::testing::tuple<
typename internal::DecayArray<T1>::type,
typename internal::DecayArray<T2>::type,
typename internal::DecayArray<T3>::type,
typename internal::DecayArray<T4>::type,
typename internal::DecayArray<T5>::type,
typename internal::DecayArray<T6>::type,
typename internal::DecayArray<T7>::type,
typename internal::DecayArray<T8>::type,
typename internal::DecayArray<T9>::type,
typename internal::DecayArray<T10>::type> Args;
return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,
e6, e7, e8, e9, e10));
}
// AllOf(m1, m2, ..., mk) matches any value that matches all of the given
// sub-matchers. AllOf is called fully qualified to prevent ADL from firing.

View File

@ -263,75 +263,6 @@ Args(const InnerMatcher& matcher) {
}
]]
// ElementsAre(e_1, e_2, ... e_n) matches an STL-style container with
// n elements, where the i-th element in the container must
// match the i-th argument in the list. Each argument of
// ElementsAre() can be either a value or a matcher. We support up to
// $n arguments.
//
// The use of DecayArray in the implementation allows ElementsAre()
// to accept string literals, whose type is const char[N], but we
// want to treat them as const char*.
//
// NOTE: Since ElementsAre() cares about the order of the elements, it
// must not be used with containers whose elements's order is
// undefined (e.g. hash_map).
$range i 0..n
$for i [[
$range j 1..i
$if i>0 [[
template <$for j, [[typename T$j]]>
]]
inline internal::ElementsAreMatcher<
::testing::tuple<
$for j, [[
typename internal::DecayArray<T$j[[]]>::type]]> >
ElementsAre($for j, [[const T$j& e$j]]) {
typedef ::testing::tuple<
$for j, [[
typename internal::DecayArray<T$j[[]]>::type]]> Args;
return internal::ElementsAreMatcher<Args>(Args($for j, [[e$j]]));
}
]]
// UnorderedElementsAre(e_1, e_2, ..., e_n) is an ElementsAre extension
// that matches n elements in any order. We support up to n=$n arguments.
//
// If you have >$n elements, consider UnorderedElementsAreArray() or
// UnorderedPointwise() instead.
$range i 0..n
$for i [[
$range j 1..i
$if i>0 [[
template <$for j, [[typename T$j]]>
]]
inline internal::UnorderedElementsAreMatcher<
::testing::tuple<
$for j, [[
typename internal::DecayArray<T$j[[]]>::type]]> >
UnorderedElementsAre($for j, [[const T$j& e$j]]) {
typedef ::testing::tuple<
$for j, [[
typename internal::DecayArray<T$j[[]]>::type]]> Args;
return internal::UnorderedElementsAreMatcher<Args>(Args($for j, [[e$j]]));
}
]]
// AllOf(m1, m2, ..., mk) matches any value that matches all of the given

View File

@ -5170,23 +5170,6 @@ std::string DescribeMatcher(const M& matcher, bool negation = false) {
return ss.str();
}
#if GTEST_LANG_CXX11
// Define variadic matcher versions. They are overloaded in
// gmock-generated-matchers.h for the cases supported by pre C++11 compilers.
template <typename... Args>
internal::AllOfMatcher<typename std::decay<const Args&>::type...> AllOf(
const Args&... matchers) {
return internal::AllOfMatcher<typename std::decay<const Args&>::type...>(
matchers...);
}
template <typename... Args>
internal::AnyOfMatcher<typename std::decay<const Args&>::type...> AnyOf(
const Args&... matchers) {
return internal::AnyOfMatcher<typename std::decay<const Args&>::type...>(
matchers...);
}
template <typename... Args>
internal::ElementsAreMatcher<tuple<typename std::decay<const Args&>::type...>>
ElementsAre(const Args&... matchers) {
@ -5204,6 +5187,23 @@ UnorderedElementsAre(const Args&... matchers) {
make_tuple(matchers...));
}
#if GTEST_LANG_CXX11
// Define variadic matcher versions. They are overloaded in
// gmock-generated-matchers.h for the cases supported by pre C++11 compilers.
template <typename... Args>
internal::AllOfMatcher<typename std::decay<const Args&>::type...> AllOf(
const Args&... matchers) {
return internal::AllOfMatcher<typename std::decay<const Args&>::type...>(
matchers...);
}
template <typename... Args>
internal::AnyOfMatcher<typename std::decay<const Args&>::type...> AnyOf(
const Args&... matchers) {
return internal::AnyOfMatcher<typename std::decay<const Args&>::type...>(
matchers...);
}
#endif // GTEST_LANG_CXX11
// AllArgs(m) is a synonym of m. This is useful in

View File

@ -1189,18 +1189,6 @@ class NativeArray {
GTEST_DISALLOW_ASSIGN_(NativeArray);
};
class AdditionalMessage {
public:
AdditionalMessage(const char* message) : msg(message) {}
void set(const std::string& message) { msg = message; }
operator bool() const { return true; }
const std::string& get() const { return msg; }
private:
std::string msg;
};
} // namespace internal
} // namespace testing
@ -1226,60 +1214,45 @@ class AdditionalMessage {
#define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) \
if (::testing::internal::AlwaysTrue()) { statement; }
#define GTEST_TEST_THROW_(statement, expected_exception, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (::testing::internal::AdditionalMessage message = "") { \
bool gtest_caught_expected = false; \
try { \
try { \
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
} catch (expected_exception const&) { \
gtest_caught_expected = true; \
throw; \
} \
} catch (const std::exception& e) { \
if (!gtest_caught_expected) { \
message.set( \
"it throws a different type " \
"with message: " + \
std::string(e.what())); \
goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
} \
} catch (...) { \
if (!gtest_caught_expected) { \
message.set("it throws a different type."); \
goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
} \
} \
if (!gtest_caught_expected) { \
message.set("it throws nothing."); \
goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
} \
} else \
GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__) \
: fail(("Expected: " #statement \
" throws an exception of type " #expected_exception \
".\n Actual: " + \
message.get()) \
.c_str())
#define GTEST_TEST_THROW_(statement, expected_exception, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (::testing::internal::ConstCharPtr gtest_msg = "") { \
bool gtest_caught_expected = false; \
try { \
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
} \
catch (expected_exception const&) { \
gtest_caught_expected = true; \
} \
catch (...) { \
gtest_msg.value = \
"Expected: " #statement " throws an exception of type " \
#expected_exception ".\n Actual: it throws a different type."; \
goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
} \
if (!gtest_caught_expected) { \
gtest_msg.value = \
"Expected: " #statement " throws an exception of type " \
#expected_exception ".\n Actual: it throws nothing."; \
goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
} \
} else \
GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \
fail(gtest_msg.value)
#define GTEST_TEST_NO_THROW_(statement, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (::testing::internal::AdditionalMessage message = ".") { \
try { \
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
} catch (const std::exception& e) { \
message.set(std::string(": ") + e.what()); \
goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
} catch (...) { \
goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
} \
} else \
GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__) \
: fail(("Expected: " #statement " doesn't throw an exception.\n" \
" Actual: it throws" + \
message.get()) \
.c_str())
#define GTEST_TEST_NO_THROW_(statement, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (::testing::internal::AlwaysTrue()) { \
try { \
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
} \
catch (...) { \
goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
} \
} else \
GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__): \
fail("Expected: " #statement " doesn't throw an exception.\n" \
" Actual: it throws.")
#define GTEST_TEST_ANY_THROW_(statement, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \

View File

@ -3328,7 +3328,6 @@ TEST_F(SingleEvaluationTest, OtherCases) {
void ThrowAnInteger() {
throw 1;
}
void ThrowAnException(const char* what) { throw std::runtime_error(what); }
// Tests that assertion arguments are evaluated exactly once.
TEST_F(SingleEvaluationTest, ExceptionTests) {
@ -3371,26 +3370,6 @@ TEST_F(SingleEvaluationTest, ExceptionTests) {
// failed EXPECT_ANY_THROW
EXPECT_NONFATAL_FAILURE(EXPECT_ANY_THROW(a_++), "it doesn't");
EXPECT_EQ(7, a_);
// failed EXPECT_THROW std::exception, throws different
EXPECT_NONFATAL_FAILURE(EXPECT_THROW(
{ // NOLINT
a_++;
ThrowAnInteger();
},
std::exception),
"throws a different type");
EXPECT_EQ(8, a_);
// failed EXPECT_THROW, throws std::exception
EXPECT_NONFATAL_FAILURE(EXPECT_THROW(
{ // NOLINT
a_++;
ThrowAnException("blablubb");
},
bool),
"throws a different type with message: blablubb");
EXPECT_EQ(9, a_);
}
#endif // GTEST_HAS_EXCEPTIONS
@ -3823,11 +3802,6 @@ TEST(AssertionTest, ASSERT_THROW) {
ASSERT_THROW(ThrowNothing(), bool),
"Expected: ThrowNothing() throws an exception of type bool.\n"
" Actual: it throws nothing.");
EXPECT_FATAL_FAILURE(
ASSERT_THROW(ThrowAnException("b"), bool),
"Expected: ThrowAnException(\"b\") throws an exception of type bool.\n"
" Actual: it throws a different type with message: b");
}
// Tests ASSERT_NO_THROW.
@ -3836,9 +3810,6 @@ TEST(AssertionTest, ASSERT_NO_THROW) {
EXPECT_FATAL_FAILURE(ASSERT_NO_THROW(ThrowAnInteger()),
"Expected: ThrowAnInteger() doesn't throw an exception."
"\n Actual: it throws.");
EXPECT_FATAL_FAILURE(ASSERT_NO_THROW(ThrowAnException("blablubb")),
"Expected: ThrowAnException(\"blablubb\") doesn't throw"
" an exception.\n Actual: it throws: blablubb");
}
// Tests ASSERT_ANY_THROW.
@ -4565,17 +4536,13 @@ TEST(ExpectTest, EXPECT_GT) {
// Tests EXPECT_THROW.
TEST(ExpectTest, EXPECT_THROW) {
EXPECT_THROW(ThrowAnInteger(), int);
EXPECT_THROW(ThrowAnException(""), std::exception);
EXPECT_NONFATAL_FAILURE(EXPECT_THROW(ThrowAnInteger(), bool),
"Expected: ThrowAnInteger() throws an exception of "
"type bool.\n Actual: it throws a different type.");
EXPECT_NONFATAL_FAILURE(EXPECT_THROW(ThrowNothing(), bool),
"Expected: ThrowNothing() throws an exception of "
"type bool.\n Actual: it throws nothing.");
EXPECT_NONFATAL_FAILURE(EXPECT_THROW(ThrowAnException("buuh"), bool),
"Expected: ThrowAnException(\"buuh\") throws an "
"exception of type bool.\n Actual: "
"it throws a different type with message: buuh");
EXPECT_NONFATAL_FAILURE(
EXPECT_THROW(ThrowNothing(), bool),
"Expected: ThrowNothing() throws an exception of type bool.\n"
" Actual: it throws nothing.");
}
// Tests EXPECT_NO_THROW.
@ -4584,9 +4551,6 @@ TEST(ExpectTest, EXPECT_NO_THROW) {
EXPECT_NONFATAL_FAILURE(EXPECT_NO_THROW(ThrowAnInteger()),
"Expected: ThrowAnInteger() doesn't throw an "
"exception.\n Actual: it throws.");
EXPECT_NONFATAL_FAILURE(EXPECT_NO_THROW(ThrowAnException("blah")),
"Expected: ThrowAnException(\"blah\") doesn't "
"throw an exception.\n Actual: it throws: blah");
}
// Tests EXPECT_ANY_THROW.