Merge branch 'master' into patch-1
This commit is contained in:
commit
7e7e3a6f45
3
.gitignore
vendored
3
.gitignore
vendored
@ -38,3 +38,6 @@ googletest/m4/lt~obsolete.m4
|
||||
# Ignore generated directories.
|
||||
googlemock/fused-src/
|
||||
googletest/fused-src/
|
||||
|
||||
# macOS files
|
||||
.DS_Store
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Build matrix / environment variable are explained on:
|
||||
# http://about.travis-ci.org/docs/user/build-configuration/
|
||||
# https://docs.travis-ci.com/user/customizing-the-build/
|
||||
# This file can be validated on:
|
||||
# http://lint.travis-ci.org/
|
||||
|
||||
|
39
BUILD.bazel
39
BUILD.bazel
@ -38,7 +38,7 @@ licenses(["notice"])
|
||||
|
||||
config_setting(
|
||||
name = "windows",
|
||||
values = { "cpu": "x64_windows" },
|
||||
values = {"cpu": "x64_windows"},
|
||||
)
|
||||
|
||||
config_setting(
|
||||
@ -51,7 +51,6 @@ config_setting(
|
||||
values = {"define": "absl=1"},
|
||||
)
|
||||
|
||||
|
||||
# Google Test including Google Mock
|
||||
cc_library(
|
||||
name = "gtest",
|
||||
@ -70,7 +69,7 @@ cc_library(
|
||||
"googlemock/src/gmock_main.cc",
|
||||
],
|
||||
),
|
||||
hdrs =glob([
|
||||
hdrs = glob([
|
||||
"googletest/include/gtest/*.h",
|
||||
"googlemock/include/gmock/*.h",
|
||||
]),
|
||||
@ -81,6 +80,14 @@ cc_library(
|
||||
"//conditions:default": ["-pthread"],
|
||||
},
|
||||
),
|
||||
defines = select(
|
||||
{
|
||||
":has_absl": [
|
||||
"GTEST_HAS_ABSL=1",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
},
|
||||
),
|
||||
includes = [
|
||||
"googlemock",
|
||||
"googlemock/include",
|
||||
@ -94,21 +101,19 @@ cc_library(
|
||||
"-pthread",
|
||||
],
|
||||
}),
|
||||
defines = select ({
|
||||
":has_absl": [
|
||||
"GTEST_HAS_ABSL=1",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}
|
||||
deps = select(
|
||||
{
|
||||
":has_absl": [
|
||||
"@com_google_absl//absl/debugging:failure_signal_handler",
|
||||
"@com_google_absl//absl/debugging:stacktrace",
|
||||
"@com_google_absl//absl/debugging:symbolize",
|
||||
"@com_google_absl//absl/strings",
|
||||
"@com_google_absl//absl/types:optional",
|
||||
"@com_google_absl//absl/types:variant",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
},
|
||||
),
|
||||
deps = select ({
|
||||
":has_absl": [
|
||||
"@com_google_absl//absl/types:optional",
|
||||
"@com_google_absl//absl/strings"
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
cc_library(
|
||||
|
@ -4,6 +4,12 @@
|
||||
[](https://travis-ci.org/google/googletest)
|
||||
[](https://ci.appveyor.com/project/GoogleTestAppVeyor/googletest/branch/master)
|
||||
|
||||
**Future Plans**:
|
||||
* 1.8.x Release - the 1.8.x will be the last release that works with pre-C++11 compilers. The 1.8.1 will not accept any requests for any new features and any bugfix requests will only be accepted if proven "critical"
|
||||
* Post 1.8.x - work to improve/cleanup/pay technical debt. When this work is completed there will be a 1.9.x tagged release
|
||||
* Post 1.9.x googletest will follow [Abseil Live at Head philosophy](https://abseil.io/about/philosophy)
|
||||
|
||||
|
||||
Welcome to **Google Test**, Google's C++ test framework!
|
||||
|
||||
This repository is a merger of the formerly separate GoogleTest and
|
||||
|
@ -128,13 +128,13 @@ if(INSTALL_GMOCK)
|
||||
# configure and install pkgconfig files
|
||||
configure_file(
|
||||
cmake/gmock.pc.in
|
||||
"${CMAKE_BINARY_DIR}/gmock.pc"
|
||||
"${gmock_BINARY_DIR}/gmock.pc"
|
||||
@ONLY)
|
||||
configure_file(
|
||||
cmake/gmock_main.pc.in
|
||||
"${CMAKE_BINARY_DIR}/gmock_main.pc"
|
||||
"${gmock_BINARY_DIR}/gmock_main.pc"
|
||||
@ONLY)
|
||||
install(FILES "${CMAKE_BINARY_DIR}/gmock.pc" "${CMAKE_BINARY_DIR}/gmock_main.pc"
|
||||
install(FILES "${gmock_BINARY_DIR}/gmock.pc" "${gmock_BINARY_DIR}/gmock_main.pc"
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||
endif()
|
||||
|
||||
|
@ -2247,7 +2247,7 @@ enum class AccessLevel { kInternal, kPublic };
|
||||
|
||||
class Buzz {
|
||||
public:
|
||||
explicit Buzz(AccessLevel access) { … }
|
||||
explicit Buzz(AccessLevel access) { ... }
|
||||
...
|
||||
};
|
||||
|
||||
@ -2320,7 +2320,7 @@ Note that `ByMove()` is essential here - if you drop it, the code won’t compil
|
||||
|
||||
Quiz time! What do you think will happen if a `Return(ByMove(...))` action is
|
||||
performed more than once (e.g. you write
|
||||
`….WillRepeatedly(Return(ByMove(...)));`)? Come think of it, after the first
|
||||
`.WillRepeatedly(Return(ByMove(...)));`)? Come think of it, after the first
|
||||
time the action runs, the source value will be consumed (since it’s a move-only
|
||||
value), so the next time around, there’s no value to move from -- you’ll get a
|
||||
run-time error that `Return(ByMove(...))` can only be run once.
|
||||
|
@ -170,7 +170,7 @@ Admittedly, this test is contrived and doesn't do much. You can easily achieve t
|
||||
|
||||
## Using Google Mock with Any Testing Framework ##
|
||||
If you want to use something other than Google Test (e.g. [CppUnit](http://sourceforge.net/projects/cppunit/) or
|
||||
[CxxTest](http://cxxtest.tigris.org/)) as your testing framework, just change the `main()` function in the previous section to:
|
||||
[CxxTest](https://cxxtest.com/)) as your testing framework, just change the `main()` function in the previous section to:
|
||||
```
|
||||
int main(int argc, char** argv) {
|
||||
// The following line causes Google Mock to throw an exception on failure,
|
||||
|
@ -528,7 +528,7 @@ interface, which then can be easily mocked. It's a bit of work
|
||||
initially, but usually pays for itself quickly.
|
||||
|
||||
This Google Testing Blog
|
||||
[post](http://googletesting.blogspot.com/2008/06/defeat-static-cling.html)
|
||||
[post](https://testing.googleblog.com/2008/06/defeat-static-cling.html)
|
||||
says it excellently. Check it out.
|
||||
|
||||
## My mock object needs to do complex stuff. It's a lot of pain to specify the actions. Google Mock sucks! ##
|
||||
|
@ -26,13 +26,14 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
// This file implements some commonly used actions.
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
|
||||
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
@ -35,6 +34,8 @@
|
||||
// cardinalities can be defined by the user implementing the
|
||||
// CardinalityInterface interface if necessary.
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
|
||||
|
||||
|
@ -30,13 +30,14 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
// This file implements some commonly used variadic actions.
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
|
||||
|
||||
@ -213,8 +214,7 @@ class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6> > {
|
||||
get<2>(args), get<3>(args), get<4>(args), get<5>(args));
|
||||
}
|
||||
|
||||
// There is no InvokeCallback() for 6-tuples, as google3 callbacks
|
||||
// support 5 arguments at most.
|
||||
// There is no InvokeCallback() for 6-tuples
|
||||
};
|
||||
|
||||
template <typename R, typename A1, typename A2, typename A3, typename A4,
|
||||
@ -238,8 +238,7 @@ class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7> > {
|
||||
get<6>(args));
|
||||
}
|
||||
|
||||
// There is no InvokeCallback() for 7-tuples, as google3 callbacks
|
||||
// support 5 arguments at most.
|
||||
// There is no InvokeCallback() for 7-tuples
|
||||
};
|
||||
|
||||
template <typename R, typename A1, typename A2, typename A3, typename A4,
|
||||
@ -264,8 +263,7 @@ class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8> > {
|
||||
get<6>(args), get<7>(args));
|
||||
}
|
||||
|
||||
// There is no InvokeCallback() for 8-tuples, as google3 callbacks
|
||||
// support 5 arguments at most.
|
||||
// There is no InvokeCallback() for 8-tuples
|
||||
};
|
||||
|
||||
template <typename R, typename A1, typename A2, typename A3, typename A4,
|
||||
@ -290,8 +288,7 @@ class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> > {
|
||||
get<6>(args), get<7>(args), get<8>(args));
|
||||
}
|
||||
|
||||
// There is no InvokeCallback() for 9-tuples, as google3 callbacks
|
||||
// support 5 arguments at most.
|
||||
// There is no InvokeCallback() for 9-tuples
|
||||
};
|
||||
|
||||
template <typename R, typename A1, typename A2, typename A3, typename A4,
|
||||
@ -318,8 +315,7 @@ class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
|
||||
get<6>(args), get<7>(args), get<8>(args), get<9>(args));
|
||||
}
|
||||
|
||||
// There is no InvokeCallback() for 10-tuples, as google3 callbacks
|
||||
// support 5 arguments at most.
|
||||
// There is no InvokeCallback() for 10-tuples
|
||||
};
|
||||
|
||||
// Implements the Invoke(callback) action.
|
||||
|
@ -32,13 +32,14 @@ $$}} This meta comment fixes auto-indentation in editors.
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
// This file implements some commonly used variadic actions.
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
|
||||
|
||||
@ -86,8 +87,7 @@ $if i <= max_callback_arity [[
|
||||
return callback->Run($gets);
|
||||
}
|
||||
]] $else [[
|
||||
// There is no InvokeCallback() for $i-tuples, as google3 callbacks
|
||||
// support $max_callback_arity arguments at most.
|
||||
// There is no InvokeCallback() for $i-tuples
|
||||
]]
|
||||
|
||||
};
|
||||
|
@ -30,13 +30,14 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
// This file implements function mockers of various arities.
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
|
||||
|
||||
@ -352,21 +353,21 @@ class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> : public
|
||||
//
|
||||
// class MockClass {
|
||||
// // Overload 1
|
||||
// MockSpec<string&()> gmock_GetName() { … }
|
||||
// MockSpec<string&()> gmock_GetName() { ... }
|
||||
// // Overload 2. Declared const so that the compiler will generate an
|
||||
// // error when trying to resolve between this and overload 4 in
|
||||
// // 'gmock_GetName(WithoutMatchers(), nullptr)'.
|
||||
// MockSpec<string&()> gmock_GetName(
|
||||
// const WithoutMatchers&, const Function<string&()>*) const {
|
||||
// const WithoutMatchers&, const Function<string&()>*) const {
|
||||
// // Removes const from this, calls overload 1
|
||||
// return AdjustConstness_(this)->gmock_GetName();
|
||||
// }
|
||||
//
|
||||
// // Overload 3
|
||||
// const string& gmock_GetName() const { … }
|
||||
// const string& gmock_GetName() const { ... }
|
||||
// // Overload 4
|
||||
// MockSpec<const string&()> gmock_GetName(
|
||||
// const WithoutMatchers&, const Function<const string&()>*) const {
|
||||
// const WithoutMatchers&, const Function<const string&()>*) const {
|
||||
// // Does not remove const, calls overload 3
|
||||
// return AdjustConstness_const(this)->gmock_GetName();
|
||||
// }
|
||||
|
@ -31,13 +31,14 @@ $var n = 10 $$ The maximum arity we support.
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
// This file implements function mockers of various arities.
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_
|
||||
|
||||
@ -114,21 +115,21 @@ class FunctionMocker<R($As)> : public
|
||||
//
|
||||
// class MockClass {
|
||||
// // Overload 1
|
||||
// MockSpec<string&()> gmock_GetName() { … }
|
||||
// MockSpec<string&()> gmock_GetName() { ... }
|
||||
// // Overload 2. Declared const so that the compiler will generate an
|
||||
// // error when trying to resolve between this and overload 4 in
|
||||
// // 'gmock_GetName(WithoutMatchers(), nullptr)'.
|
||||
// MockSpec<string&()> gmock_GetName(
|
||||
// const WithoutMatchers&, const Function<string&()>*) const {
|
||||
// const WithoutMatchers&, const Function<string&()>*) const {
|
||||
// // Removes const from this, calls overload 1
|
||||
// return AdjustConstness_(this)->gmock_GetName();
|
||||
// }
|
||||
//
|
||||
// // Overload 3
|
||||
// const string& gmock_GetName() const { … }
|
||||
// const string& gmock_GetName() const { ... }
|
||||
// // Overload 4
|
||||
// MockSpec<const string&()> gmock_GetName(
|
||||
// const WithoutMatchers&, const Function<const string&()>*) const {
|
||||
// const WithoutMatchers&, const Function<const string&()>*) const {
|
||||
// // Does not remove const, calls overload 3
|
||||
// return AdjustConstness_const(this)->gmock_GetName();
|
||||
// }
|
||||
@ -139,7 +140,7 @@ const MockType* AdjustConstness_const(const MockType* mock) {
|
||||
return mock;
|
||||
}
|
||||
|
||||
// Removes const from and returns the given pointer; this is a helper for the
|
||||
// Removes const from and returns the given pointer; this is a helper for the
|
||||
// expectation setter method for parameterless matchers.
|
||||
template <typename MockType>
|
||||
MockType* AdjustConstness_(const MockType* mock) {
|
||||
|
@ -35,6 +35,8 @@
|
||||
//
|
||||
// This file implements some commonly used variadic matchers.
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
|
||||
|
||||
|
@ -37,6 +37,8 @@ $$ }} This line fixes auto-indentation of the following code in Emacs.
|
||||
//
|
||||
// This file implements some commonly used variadic matchers.
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
|
||||
|
||||
|
@ -30,8 +30,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Implements class templates NiceMock, NaggyMock, and StrictMock.
|
||||
//
|
||||
@ -63,6 +62,8 @@
|
||||
// In particular, nesting NiceMock, NaggyMock, and StrictMock is NOT
|
||||
// supported.
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
|
||||
|
||||
|
@ -31,8 +31,7 @@ $var n = 10 $$ The maximum arity we support.
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Implements class templates NiceMock, NaggyMock, and StrictMock.
|
||||
//
|
||||
@ -64,6 +63,8 @@ $var n = 10 $$ The maximum arity we support.
|
||||
// In particular, nesting NiceMock, NaggyMock, and StrictMock is NOT
|
||||
// supported.
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_
|
||||
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
@ -35,6 +34,8 @@
|
||||
// matchers can be defined by the user implementing the
|
||||
// MatcherInterface<T> interface if necessary.
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_
|
||||
|
||||
@ -72,7 +73,7 @@ namespace testing {
|
||||
// MatchResultListener is an abstract class. Its << operator can be
|
||||
// used by a matcher to explain why a value matches or doesn't match.
|
||||
//
|
||||
// TODO(wan@google.com): add method
|
||||
// FIXME: add method
|
||||
// bool InterestedInWhy(bool result) const;
|
||||
// to indicate whether the listener is interested in why the match
|
||||
// result is 'result'.
|
||||
@ -921,7 +922,7 @@ class TuplePrefix {
|
||||
GTEST_REFERENCE_TO_CONST_(Value) value = get<N - 1>(values);
|
||||
StringMatchResultListener listener;
|
||||
if (!matcher.MatchAndExplain(value, &listener)) {
|
||||
// TODO(wan): include in the message the name of the parameter
|
||||
// FIXME: include in the message the name of the parameter
|
||||
// as used in MOCK_METHOD*() when possible.
|
||||
*os << " Expected arg #" << N - 1 << ": ";
|
||||
get<N - 1>(matchers).DescribeTo(os);
|
||||
@ -2419,7 +2420,7 @@ class WhenDynamicCastToMatcher : public WhenDynamicCastToMatcherBase<To> {
|
||||
|
||||
template <typename From>
|
||||
bool MatchAndExplain(From from, MatchResultListener* listener) const {
|
||||
// TODO(sbenza): Add more detail on failures. ie did the dyn_cast fail?
|
||||
// FIXME: Add more detail on failures. ie did the dyn_cast fail?
|
||||
To to = dynamic_cast<To>(from);
|
||||
return MatchPrintAndExplain(to, this->matcher_, listener);
|
||||
}
|
||||
@ -4529,6 +4530,20 @@ Property(PropertyType (Class::*property)() const &,
|
||||
property,
|
||||
MatcherCast<GTEST_REFERENCE_TO_CONST_(PropertyType)>(matcher)));
|
||||
}
|
||||
|
||||
// Three-argument form for reference-qualified member functions.
|
||||
template <typename Class, typename PropertyType, typename PropertyMatcher>
|
||||
inline PolymorphicMatcher<internal::PropertyMatcher<
|
||||
Class, PropertyType, PropertyType (Class::*)() const &> >
|
||||
Property(const std::string& property_name,
|
||||
PropertyType (Class::*property)() const &,
|
||||
const PropertyMatcher& matcher) {
|
||||
return MakePolymorphicMatcher(
|
||||
internal::PropertyMatcher<Class, PropertyType,
|
||||
PropertyType (Class::*)() const &>(
|
||||
property_name, property,
|
||||
MatcherCast<GTEST_REFERENCE_TO_CONST_(PropertyType)>(matcher)));
|
||||
}
|
||||
#endif
|
||||
|
||||
// Creates a matcher that matches an object iff the result of applying
|
||||
@ -5165,13 +5180,17 @@ std::string DescribeMatcher(const M& matcher, bool negation = false) {
|
||||
// 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<Args...> AllOf(const Args&... matchers) {
|
||||
return internal::AllOfMatcher<Args...>(matchers...);
|
||||
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<Args...> AnyOf(const Args&... matchers) {
|
||||
return internal::AnyOfMatcher<Args...>(matchers...);
|
||||
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>
|
||||
|
@ -26,13 +26,14 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
// This file implements some actions that depend on gmock-generated-actions.h.
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_
|
||||
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: marcus.boerger@google.com (Marcus Boerger)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
@ -36,6 +35,8 @@
|
||||
// Note that tests are implemented in gmock-matchers_test.cc rather than
|
||||
// gmock-more-matchers-test.cc.
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_GMOCK_MORE_MATCHERS_H_
|
||||
#define GMOCK_GMOCK_MORE_MATCHERS_H_
|
||||
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
@ -57,6 +56,8 @@
|
||||
// where all clauses are optional, and .InSequence()/.After()/
|
||||
// .WillOnce() can appear any number of times.
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
|
||||
|
||||
@ -183,7 +184,7 @@ class GTEST_API_ UntypedFunctionMockerBase {
|
||||
// this information in the global mock registry. Will be called
|
||||
// whenever an EXPECT_CALL() or ON_CALL() is executed on this mock
|
||||
// method.
|
||||
// TODO(wan@google.com): rename to SetAndRegisterOwner().
|
||||
// FIXME: rename to SetAndRegisterOwner().
|
||||
void RegisterOwner(const void* mock_obj)
|
||||
GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
|
||||
|
||||
@ -1206,7 +1207,7 @@ class TypedExpectation : public ExpectationBase {
|
||||
mocker->DescribeDefaultActionTo(args, what);
|
||||
DescribeCallCountTo(why);
|
||||
|
||||
// TODO(wan@google.com): allow the user to control whether
|
||||
// FIXME: allow the user to control whether
|
||||
// unexpected calls should fail immediately or continue using a
|
||||
// flag --gmock_unexpected_calls_are_fatal.
|
||||
return NULL;
|
||||
@ -1854,22 +1855,22 @@ inline Expectation::Expectation(internal::ExpectationBase& exp) // NOLINT
|
||||
// parameter. This technique may only be used for non-overloaded methods.
|
||||
//
|
||||
// // These are the same:
|
||||
// ON_CALL(mock, NoArgsMethod()).WillByDefault(…);
|
||||
// ON_CALL(mock, NoArgsMethod).WillByDefault(…);
|
||||
// ON_CALL(mock, NoArgsMethod()).WillByDefault(...);
|
||||
// ON_CALL(mock, NoArgsMethod).WillByDefault(...);
|
||||
//
|
||||
// // As are these:
|
||||
// ON_CALL(mock, TwoArgsMethod(_, _)).WillByDefault(…);
|
||||
// ON_CALL(mock, TwoArgsMethod).WillByDefault(…);
|
||||
// ON_CALL(mock, TwoArgsMethod(_, _)).WillByDefault(...);
|
||||
// ON_CALL(mock, TwoArgsMethod).WillByDefault(...);
|
||||
//
|
||||
// // Can also specify args if you want, of course:
|
||||
// ON_CALL(mock, TwoArgsMethod(_, 45)).WillByDefault(…);
|
||||
// ON_CALL(mock, TwoArgsMethod(_, 45)).WillByDefault(...);
|
||||
//
|
||||
// // Overloads work as long as you specify parameters:
|
||||
// ON_CALL(mock, OverloadedMethod(_)).WillByDefault(…);
|
||||
// ON_CALL(mock, OverloadedMethod(_, _)).WillByDefault(…);
|
||||
// ON_CALL(mock, OverloadedMethod(_)).WillByDefault(...);
|
||||
// ON_CALL(mock, OverloadedMethod(_, _)).WillByDefault(...);
|
||||
//
|
||||
// // Oops! Which overload did you want?
|
||||
// ON_CALL(mock, OverloadedMethod).WillByDefault(…);
|
||||
// ON_CALL(mock, OverloadedMethod).WillByDefault(...);
|
||||
// => ERROR: call to member function 'gmock_OverloadedMethod' is ambiguous
|
||||
//
|
||||
// How this works: The mock class uses two overloads of the gmock_Method
|
||||
@ -1877,28 +1878,28 @@ inline Expectation::Expectation(internal::ExpectationBase& exp) // NOLINT
|
||||
// In the matcher list form, the macro expands to:
|
||||
//
|
||||
// // This statement:
|
||||
// ON_CALL(mock, TwoArgsMethod(_, 45))…
|
||||
// ON_CALL(mock, TwoArgsMethod(_, 45))...
|
||||
//
|
||||
// // …expands to:
|
||||
// mock.gmock_TwoArgsMethod(_, 45)(WithoutMatchers(), nullptr)…
|
||||
// // ...expands to:
|
||||
// mock.gmock_TwoArgsMethod(_, 45)(WithoutMatchers(), nullptr)...
|
||||
// |-------------v---------------||------------v-------------|
|
||||
// invokes first overload swallowed by operator()
|
||||
//
|
||||
// // …which is essentially:
|
||||
// mock.gmock_TwoArgsMethod(_, 45)…
|
||||
// // ...which is essentially:
|
||||
// mock.gmock_TwoArgsMethod(_, 45)...
|
||||
//
|
||||
// Whereas the form without a matcher list:
|
||||
//
|
||||
// // This statement:
|
||||
// ON_CALL(mock, TwoArgsMethod)…
|
||||
// ON_CALL(mock, TwoArgsMethod)...
|
||||
//
|
||||
// // …expands to:
|
||||
// mock.gmock_TwoArgsMethod(WithoutMatchers(), nullptr)…
|
||||
// // ...expands to:
|
||||
// mock.gmock_TwoArgsMethod(WithoutMatchers(), nullptr)...
|
||||
// |-----------------------v--------------------------|
|
||||
// invokes second overload
|
||||
//
|
||||
// // …which is essentially:
|
||||
// mock.gmock_TwoArgsMethod(_, _)…
|
||||
// // ...which is essentially:
|
||||
// mock.gmock_TwoArgsMethod(_, _)...
|
||||
//
|
||||
// The WithoutMatchers() argument is used to disambiguate overloads and to
|
||||
// block the caller from accidentally invoking the second overload directly. The
|
||||
|
@ -26,13 +26,14 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
// This is the main header file a user should include.
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_GMOCK_H_
|
||||
|
||||
|
16
googlemock/include/gmock/internal/custom/README.md
Normal file
16
googlemock/include/gmock/internal/custom/README.md
Normal file
@ -0,0 +1,16 @@
|
||||
# Customization Points
|
||||
|
||||
The custom directory is an injection point for custom user configurations.
|
||||
|
||||
## Header `gmock-port.h`
|
||||
|
||||
The following macros can be defined:
|
||||
|
||||
### Flag related macros:
|
||||
|
||||
* `GMOCK_DECLARE_bool_(name)`
|
||||
* `GMOCK_DECLARE_int32_(name)`
|
||||
* `GMOCK_DECLARE_string_(name)`
|
||||
* `GMOCK_DEFINE_bool_(name, default_val, doc)`
|
||||
* `GMOCK_DEFINE_int32_(name, default_val, doc)`
|
||||
* `GMOCK_DEFINE_string_(name, default_val, doc)`
|
@ -2,6 +2,8 @@
|
||||
// pump.py gmock-generated-actions.h.pump
|
||||
// DO NOT EDIT BY HAND!!!
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_
|
||||
|
||||
|
@ -4,6 +4,8 @@ $$ it to callback-actions.h.
|
||||
$$
|
||||
$var max_callback_arity = 5
|
||||
$$}} This meta comment fixes auto-indentation in editors.
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_
|
||||
|
||||
|
@ -27,12 +27,10 @@
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ============================================================
|
||||
// An installation-specific extension point for gmock-matchers.h.
|
||||
// ============================================================
|
||||
//
|
||||
// Adds google3 callback support to CallableTraits.
|
||||
// Injection point for custom user configurations. See README for details
|
||||
//
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_
|
||||
#endif // GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_
|
||||
|
@ -27,19 +27,12 @@
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Injection point for custom user configurations.
|
||||
// The following macros can be defined:
|
||||
//
|
||||
// Flag related macros:
|
||||
// GMOCK_DECLARE_bool_(name)
|
||||
// GMOCK_DECLARE_int32_(name)
|
||||
// GMOCK_DECLARE_string_(name)
|
||||
// GMOCK_DEFINE_bool_(name, default_val, doc)
|
||||
// GMOCK_DEFINE_int32_(name, default_val, doc)
|
||||
// GMOCK_DEFINE_string_(name, default_val, doc)
|
||||
// Injection point for custom user configurations. See README for details
|
||||
//
|
||||
// ** Custom implementation starts here **
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_
|
||||
|
||||
|
@ -30,14 +30,15 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
// This file contains template meta-programming utility classes needed
|
||||
// for implementing Google Mock.
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
|
||||
|
||||
|
@ -31,14 +31,15 @@ $var n = 10 $$ The maximum arity we support.
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
// This file contains template meta-programming utility classes needed
|
||||
// for implementing Google Mock.
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_
|
||||
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
@ -35,6 +34,8 @@
|
||||
// Mock. They are subject to change without notice, so please DO NOT
|
||||
// USE THEM IN USER CODE.
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_
|
||||
|
||||
@ -348,7 +349,7 @@ GTEST_API_ void Log(LogSeverity severity, const std::string& message,
|
||||
// correct overload. This must not be instantiable, to prevent client code from
|
||||
// accidentally resolving to the overload; for example:
|
||||
//
|
||||
// ON_CALL(mock, Method({}, nullptr))…
|
||||
// ON_CALL(mock, Method({}, nullptr))...
|
||||
//
|
||||
class WithoutMatchers {
|
||||
private:
|
||||
@ -359,7 +360,7 @@ class WithoutMatchers {
|
||||
// Internal use only: access the singleton instance of WithoutMatchers.
|
||||
GTEST_API_ WithoutMatchers GetWithoutMatchers();
|
||||
|
||||
// TODO(wan@google.com): group all type utilities together.
|
||||
// FIXME: group all type utilities together.
|
||||
|
||||
// Type traits.
|
||||
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: vadimb@google.com (Vadim Berman)
|
||||
|
||||
//
|
||||
// Low-level types and utilities for porting Google Mock to various
|
||||
// platforms. All macros ending with _ and symbols defined in an
|
||||
@ -36,6 +35,8 @@
|
||||
// end with _ are part of Google Mock's public API and can be used by
|
||||
// code outside Google Mock.
|
||||
|
||||
// GOOGLETEST_CM0002 DO NOT DELETE
|
||||
|
||||
#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
|
||||
#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_
|
||||
|
||||
|
@ -242,7 +242,7 @@ class AbstractRpcServer(object):
|
||||
The authentication process works as follows:
|
||||
1) We get a username and password from the user
|
||||
2) We use ClientLogin to obtain an AUTH token for the user
|
||||
(see http://code.google.com/apis/accounts/AuthForInstalledApps.html).
|
||||
(see https://developers.google.com/identity/protocols/AuthForInstalledApps).
|
||||
3) We pass the auth token to /_ah/login on the server to obtain an
|
||||
authentication cookie. If login was successful, it tries to redirect
|
||||
us to the URL we provided.
|
||||
@ -506,7 +506,7 @@ def EncodeMultipartFormData(fields, files):
|
||||
(content_type, body) ready for httplib.HTTP instance.
|
||||
|
||||
Source:
|
||||
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146306
|
||||
https://web.archive.org/web/20160116052001/code.activestate.com/recipes/146306
|
||||
"""
|
||||
BOUNDARY = '-M-A-G-I-C---B-O-U-N-D-A-R-Y-'
|
||||
CRLF = '\r\n'
|
||||
@ -807,7 +807,7 @@ class SubversionVCS(VersionControlSystem):
|
||||
# svn cat translates keywords but svn diff doesn't. As a result of this
|
||||
# behavior patching.PatchChunks() fails with a chunk mismatch error.
|
||||
# This part was originally written by the Review Board development team
|
||||
# who had the same problem (http://reviews.review-board.org/r/276/).
|
||||
# who had the same problem (https://reviews.reviewboard.org/r/276/).
|
||||
# Mapping of keywords to known aliases
|
||||
svn_keywords = {
|
||||
# Standard keywords
|
||||
@ -860,7 +860,7 @@ class SubversionVCS(VersionControlSystem):
|
||||
status_lines = status.splitlines()
|
||||
# If file is in a cl, the output will begin with
|
||||
# "\n--- Changelist 'cl_name':\n". See
|
||||
# http://svn.collab.net/repos/svn/trunk/notes/changelist-design.txt
|
||||
# https://web.archive.org/web/20090918234815/svn.collab.net/repos/svn/trunk/notes/changelist-design.txt
|
||||
if (len(status_lines) == 3 and
|
||||
not status_lines[0] and
|
||||
status_lines[1].startswith("--- Changelist")):
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
//
|
||||
// Google C++ Mocking Framework (Google Mock)
|
||||
//
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
@ -607,7 +606,7 @@ class MockObjectRegistry {
|
||||
if (it->second.leakable) // The user said it's fine to leak this object.
|
||||
continue;
|
||||
|
||||
// TODO(wan@google.com): Print the type of the leaked object.
|
||||
// FIXME: Print the type of the leaked object.
|
||||
// This can help the user identify the leaked object.
|
||||
std::cout << "\n";
|
||||
const MockObjectState& state = it->second;
|
||||
@ -783,7 +782,7 @@ void Mock::RegisterUseByOnCallOrExpectCall(const void* mock_obj,
|
||||
const TestInfo* const test_info =
|
||||
UnitTest::GetInstance()->current_test_info();
|
||||
if (test_info != NULL) {
|
||||
// TODO(wan@google.com): record the test case name when the
|
||||
// FIXME: record the test case name when the
|
||||
// ON_CALL or EXPECT_CALL is invoked from SetUpTestCase() or
|
||||
// TearDownTestCase().
|
||||
state.first_used_test_case = test_info->test_case_name();
|
||||
|
@ -26,15 +26,14 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "gmock/internal/gmock-port.h"
|
||||
|
||||
namespace testing {
|
||||
|
||||
// TODO(wan@google.com): support using environment variables to
|
||||
// FIXME: support using environment variables to
|
||||
// control the flag values, like what Google Test does.
|
||||
|
||||
GMOCK_DEFINE_bool_(catch_leaked_mocks, true,
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include "gmock/gmock.h"
|
||||
@ -37,7 +36,8 @@
|
||||
// causes a link error when _tmain is defined in a static library and UNICODE
|
||||
// is enabled. For this reason instead of _tmain, main function is used on
|
||||
// Windows. See the following link to track the current status of this bug:
|
||||
// http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=394464 // NOLINT
|
||||
// https://web.archive.org/web/20170912203238/connect.microsoft.com/VisualStudio/feedback/details/394464/wmain-link-error-in-the-static-library
|
||||
// // NOLINT
|
||||
#if GTEST_OS_WINDOWS_MOBILE
|
||||
# include <tchar.h> // NOLINT
|
||||
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
@ -88,10 +87,6 @@ using testing::tuple_element;
|
||||
using testing::SetErrnoAndReturn;
|
||||
#endif
|
||||
|
||||
#if GTEST_HAS_PROTOBUF_
|
||||
using testing::internal::TestMessage;
|
||||
#endif // GTEST_HAS_PROTOBUF_
|
||||
|
||||
// Tests that BuiltInDefaultValue<T*>::Get() returns NULL.
|
||||
TEST(BuiltInDefaultValueTest, IsNullForPointerTypes) {
|
||||
EXPECT_TRUE(BuiltInDefaultValue<int*>::Get() == NULL);
|
||||
@ -895,105 +890,6 @@ TEST(SetArgPointeeTest, AcceptsWideCharPointer) {
|
||||
# endif
|
||||
}
|
||||
|
||||
#if GTEST_HAS_PROTOBUF_
|
||||
|
||||
// Tests that SetArgPointee<N>(proto_buffer) sets the v1 protobuf
|
||||
// variable pointed to by the N-th (0-based) argument to proto_buffer.
|
||||
TEST(SetArgPointeeTest, SetsTheNthPointeeOfProtoBufferType) {
|
||||
TestMessage* const msg = new TestMessage;
|
||||
msg->set_member("yes");
|
||||
TestMessage orig_msg;
|
||||
orig_msg.CopyFrom(*msg);
|
||||
|
||||
Action<void(bool, TestMessage*)> a = SetArgPointee<1>(*msg);
|
||||
// SetArgPointee<N>(proto_buffer) makes a copy of proto_buffer
|
||||
// s.t. the action works even when the original proto_buffer has
|
||||
// died. We ensure this behavior by deleting msg before using the
|
||||
// action.
|
||||
delete msg;
|
||||
|
||||
TestMessage dest;
|
||||
EXPECT_FALSE(orig_msg.Equals(dest));
|
||||
a.Perform(make_tuple(true, &dest));
|
||||
EXPECT_TRUE(orig_msg.Equals(dest));
|
||||
}
|
||||
|
||||
// Tests that SetArgPointee<N>(proto_buffer) sets the
|
||||
// ::ProtocolMessage variable pointed to by the N-th (0-based)
|
||||
// argument to proto_buffer.
|
||||
TEST(SetArgPointeeTest, SetsTheNthPointeeOfProtoBufferBaseType) {
|
||||
TestMessage* const msg = new TestMessage;
|
||||
msg->set_member("yes");
|
||||
TestMessage orig_msg;
|
||||
orig_msg.CopyFrom(*msg);
|
||||
|
||||
Action<void(bool, ::ProtocolMessage*)> a = SetArgPointee<1>(*msg);
|
||||
// SetArgPointee<N>(proto_buffer) makes a copy of proto_buffer
|
||||
// s.t. the action works even when the original proto_buffer has
|
||||
// died. We ensure this behavior by deleting msg before using the
|
||||
// action.
|
||||
delete msg;
|
||||
|
||||
TestMessage dest;
|
||||
::ProtocolMessage* const dest_base = &dest;
|
||||
EXPECT_FALSE(orig_msg.Equals(dest));
|
||||
a.Perform(make_tuple(true, dest_base));
|
||||
EXPECT_TRUE(orig_msg.Equals(dest));
|
||||
}
|
||||
|
||||
// Tests that SetArgPointee<N>(proto2_buffer) sets the v2
|
||||
// protobuf variable pointed to by the N-th (0-based) argument to
|
||||
// proto2_buffer.
|
||||
TEST(SetArgPointeeTest, SetsTheNthPointeeOfProto2BufferType) {
|
||||
using testing::internal::FooMessage;
|
||||
FooMessage* const msg = new FooMessage;
|
||||
msg->set_int_field(2);
|
||||
msg->set_string_field("hi");
|
||||
FooMessage orig_msg;
|
||||
orig_msg.CopyFrom(*msg);
|
||||
|
||||
Action<void(bool, FooMessage*)> a = SetArgPointee<1>(*msg);
|
||||
// SetArgPointee<N>(proto2_buffer) makes a copy of
|
||||
// proto2_buffer s.t. the action works even when the original
|
||||
// proto2_buffer has died. We ensure this behavior by deleting msg
|
||||
// before using the action.
|
||||
delete msg;
|
||||
|
||||
FooMessage dest;
|
||||
dest.set_int_field(0);
|
||||
a.Perform(make_tuple(true, &dest));
|
||||
EXPECT_EQ(2, dest.int_field());
|
||||
EXPECT_EQ("hi", dest.string_field());
|
||||
}
|
||||
|
||||
// Tests that SetArgPointee<N>(proto2_buffer) sets the
|
||||
// proto2::Message variable pointed to by the N-th (0-based) argument
|
||||
// to proto2_buffer.
|
||||
TEST(SetArgPointeeTest, SetsTheNthPointeeOfProto2BufferBaseType) {
|
||||
using testing::internal::FooMessage;
|
||||
FooMessage* const msg = new FooMessage;
|
||||
msg->set_int_field(2);
|
||||
msg->set_string_field("hi");
|
||||
FooMessage orig_msg;
|
||||
orig_msg.CopyFrom(*msg);
|
||||
|
||||
Action<void(bool, ::proto2::Message*)> a = SetArgPointee<1>(*msg);
|
||||
// SetArgPointee<N>(proto2_buffer) makes a copy of
|
||||
// proto2_buffer s.t. the action works even when the original
|
||||
// proto2_buffer has died. We ensure this behavior by deleting msg
|
||||
// before using the action.
|
||||
delete msg;
|
||||
|
||||
FooMessage dest;
|
||||
dest.set_int_field(0);
|
||||
::proto2::Message* const dest_base = &dest;
|
||||
a.Perform(make_tuple(true, dest_base));
|
||||
EXPECT_EQ(2, dest.int_field());
|
||||
EXPECT_EQ("hi", dest.string_field());
|
||||
}
|
||||
|
||||
#endif // GTEST_HAS_PROTOBUF_
|
||||
|
||||
// Tests that SetArgumentPointee<N>(v) sets the variable pointed to by
|
||||
// the N-th (0-based) argument to v.
|
||||
TEST(SetArgumentPointeeTest, SetsTheNthPointee) {
|
||||
@ -1014,105 +910,6 @@ TEST(SetArgumentPointeeTest, SetsTheNthPointee) {
|
||||
EXPECT_EQ('a', ch);
|
||||
}
|
||||
|
||||
#if GTEST_HAS_PROTOBUF_
|
||||
|
||||
// Tests that SetArgumentPointee<N>(proto_buffer) sets the v1 protobuf
|
||||
// variable pointed to by the N-th (0-based) argument to proto_buffer.
|
||||
TEST(SetArgumentPointeeTest, SetsTheNthPointeeOfProtoBufferType) {
|
||||
TestMessage* const msg = new TestMessage;
|
||||
msg->set_member("yes");
|
||||
TestMessage orig_msg;
|
||||
orig_msg.CopyFrom(*msg);
|
||||
|
||||
Action<void(bool, TestMessage*)> a = SetArgumentPointee<1>(*msg);
|
||||
// SetArgumentPointee<N>(proto_buffer) makes a copy of proto_buffer
|
||||
// s.t. the action works even when the original proto_buffer has
|
||||
// died. We ensure this behavior by deleting msg before using the
|
||||
// action.
|
||||
delete msg;
|
||||
|
||||
TestMessage dest;
|
||||
EXPECT_FALSE(orig_msg.Equals(dest));
|
||||
a.Perform(make_tuple(true, &dest));
|
||||
EXPECT_TRUE(orig_msg.Equals(dest));
|
||||
}
|
||||
|
||||
// Tests that SetArgumentPointee<N>(proto_buffer) sets the
|
||||
// ::ProtocolMessage variable pointed to by the N-th (0-based)
|
||||
// argument to proto_buffer.
|
||||
TEST(SetArgumentPointeeTest, SetsTheNthPointeeOfProtoBufferBaseType) {
|
||||
TestMessage* const msg = new TestMessage;
|
||||
msg->set_member("yes");
|
||||
TestMessage orig_msg;
|
||||
orig_msg.CopyFrom(*msg);
|
||||
|
||||
Action<void(bool, ::ProtocolMessage*)> a = SetArgumentPointee<1>(*msg);
|
||||
// SetArgumentPointee<N>(proto_buffer) makes a copy of proto_buffer
|
||||
// s.t. the action works even when the original proto_buffer has
|
||||
// died. We ensure this behavior by deleting msg before using the
|
||||
// action.
|
||||
delete msg;
|
||||
|
||||
TestMessage dest;
|
||||
::ProtocolMessage* const dest_base = &dest;
|
||||
EXPECT_FALSE(orig_msg.Equals(dest));
|
||||
a.Perform(make_tuple(true, dest_base));
|
||||
EXPECT_TRUE(orig_msg.Equals(dest));
|
||||
}
|
||||
|
||||
// Tests that SetArgumentPointee<N>(proto2_buffer) sets the v2
|
||||
// protobuf variable pointed to by the N-th (0-based) argument to
|
||||
// proto2_buffer.
|
||||
TEST(SetArgumentPointeeTest, SetsTheNthPointeeOfProto2BufferType) {
|
||||
using testing::internal::FooMessage;
|
||||
FooMessage* const msg = new FooMessage;
|
||||
msg->set_int_field(2);
|
||||
msg->set_string_field("hi");
|
||||
FooMessage orig_msg;
|
||||
orig_msg.CopyFrom(*msg);
|
||||
|
||||
Action<void(bool, FooMessage*)> a = SetArgumentPointee<1>(*msg);
|
||||
// SetArgumentPointee<N>(proto2_buffer) makes a copy of
|
||||
// proto2_buffer s.t. the action works even when the original
|
||||
// proto2_buffer has died. We ensure this behavior by deleting msg
|
||||
// before using the action.
|
||||
delete msg;
|
||||
|
||||
FooMessage dest;
|
||||
dest.set_int_field(0);
|
||||
a.Perform(make_tuple(true, &dest));
|
||||
EXPECT_EQ(2, dest.int_field());
|
||||
EXPECT_EQ("hi", dest.string_field());
|
||||
}
|
||||
|
||||
// Tests that SetArgumentPointee<N>(proto2_buffer) sets the
|
||||
// proto2::Message variable pointed to by the N-th (0-based) argument
|
||||
// to proto2_buffer.
|
||||
TEST(SetArgumentPointeeTest, SetsTheNthPointeeOfProto2BufferBaseType) {
|
||||
using testing::internal::FooMessage;
|
||||
FooMessage* const msg = new FooMessage;
|
||||
msg->set_int_field(2);
|
||||
msg->set_string_field("hi");
|
||||
FooMessage orig_msg;
|
||||
orig_msg.CopyFrom(*msg);
|
||||
|
||||
Action<void(bool, ::proto2::Message*)> a = SetArgumentPointee<1>(*msg);
|
||||
// SetArgumentPointee<N>(proto2_buffer) makes a copy of
|
||||
// proto2_buffer s.t. the action works even when the original
|
||||
// proto2_buffer has died. We ensure this behavior by deleting msg
|
||||
// before using the action.
|
||||
delete msg;
|
||||
|
||||
FooMessage dest;
|
||||
dest.set_int_field(0);
|
||||
::proto2::Message* const dest_base = &dest;
|
||||
a.Perform(make_tuple(true, dest_base));
|
||||
EXPECT_EQ(2, dest.int_field());
|
||||
EXPECT_EQ("hi", dest.string_field());
|
||||
}
|
||||
|
||||
#endif // GTEST_HAS_PROTOBUF_
|
||||
|
||||
// Sample functions and functors for testing Invoke() and etc.
|
||||
int Nullary() { return 1; }
|
||||
|
||||
@ -1546,7 +1343,7 @@ TEST(FunctorActionTest, UnusedArguments) {
|
||||
}
|
||||
|
||||
// Test that basic built-in actions work with move-only arguments.
|
||||
// TODO(rburny): Currently, almost all ActionInterface-based actions will not
|
||||
// FIXME: Currently, almost all ActionInterface-based actions will not
|
||||
// work, even if they only try to use other, copyable arguments. Implement them
|
||||
// if necessary (but note that DoAll cannot work on non-copyable types anyway -
|
||||
// so maybe it's better to make users use lambdas instead.
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
@ -2680,7 +2679,7 @@ TEST(AllOfTest, ExplainsResult) {
|
||||
}
|
||||
|
||||
// Helper to allow easy testing of AnyOf matchers with num parameters.
|
||||
void AnyOfMatches(int num, const Matcher<int>& m) {
|
||||
static void AnyOfMatches(int num, const Matcher<int>& m) {
|
||||
SCOPED_TRACE(Describe(m));
|
||||
EXPECT_FALSE(m.Matches(0));
|
||||
for (int i = 1; i <= num; ++i) {
|
||||
@ -2689,6 +2688,18 @@ void AnyOfMatches(int num, const Matcher<int>& m) {
|
||||
EXPECT_FALSE(m.Matches(num + 1));
|
||||
}
|
||||
|
||||
#if GTEST_LANG_CXX11
|
||||
static void AnyOfStringMatches(int num, const Matcher<std::string>& m) {
|
||||
SCOPED_TRACE(Describe(m));
|
||||
EXPECT_FALSE(m.Matches(std::to_string(0)));
|
||||
|
||||
for (int i = 1; i <= num; ++i) {
|
||||
EXPECT_TRUE(m.Matches(std::to_string(i)));
|
||||
}
|
||||
EXPECT_FALSE(m.Matches(std::to_string(num + 1)));
|
||||
}
|
||||
#endif
|
||||
|
||||
// Tests that AnyOf(m1, ..., mn) matches any value that matches at
|
||||
// least one of the given matchers.
|
||||
TEST(AnyOfTest, MatchesWhenAnyMatches) {
|
||||
@ -2746,6 +2757,12 @@ TEST(AnyOfTest, VariadicMatchesWhenAnyMatches) {
|
||||
21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
|
||||
31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
|
||||
41, 42, 43, 44, 45, 46, 47, 48, 49, 50));
|
||||
AnyOfStringMatches(
|
||||
50, AnyOf("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12",
|
||||
"13", "14", "15", "16", "17", "18", "19", "20", "21", "22",
|
||||
"23", "24", "25", "26", "27", "28", "29", "30", "31", "32",
|
||||
"33", "34", "35", "36", "37", "38", "39", "40", "41", "42",
|
||||
"43", "44", "45", "46", "47", "48", "49", "50"));
|
||||
}
|
||||
|
||||
// Tests the variadic version of the ElementsAreMatcher
|
||||
@ -4220,13 +4237,17 @@ TEST(PropertyTest, WorksForReferenceToConstProperty) {
|
||||
// ref-qualified.
|
||||
TEST(PropertyTest, WorksForRefQualifiedProperty) {
|
||||
Matcher<const AClass&> m = Property(&AClass::s_ref, StartsWith("hi"));
|
||||
Matcher<const AClass&> m_with_name =
|
||||
Property("s", &AClass::s_ref, StartsWith("hi"));
|
||||
|
||||
AClass a;
|
||||
a.set_s("hill");
|
||||
EXPECT_TRUE(m.Matches(a));
|
||||
EXPECT_TRUE(m_with_name.Matches(a));
|
||||
|
||||
a.set_s("hole");
|
||||
EXPECT_FALSE(m.Matches(a));
|
||||
EXPECT_FALSE(m_with_name.Matches(a));
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -4570,7 +4591,7 @@ TEST(ResultOfTest, WorksForFunctors) {
|
||||
}
|
||||
|
||||
// Tests that ResultOf(f, ...) compiles and works as expected when f is a
|
||||
// functor with more then one operator() defined. ResultOf() must work
|
||||
// functor with more than one operator() defined. ResultOf() must work
|
||||
// for each defined operator().
|
||||
struct PolymorphicFunctor {
|
||||
typedef int result_type;
|
||||
@ -6764,4 +6785,3 @@ TEST(NotTest, WorksOnMoveOnlyType) {
|
||||
|
||||
} // namespace gmock_matchers_test
|
||||
} // namespace testing
|
||||
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
#include "gmock/gmock-generated-nice-strict.h"
|
||||
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: vladl@google.com (Vlad Losev)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
@ -1176,7 +1175,7 @@ TEST(UnexpectedCallTest, UnsatisifiedPrerequisites) {
|
||||
TEST(UndefinedReturnValueTest,
|
||||
ReturnValueIsMandatoryWhenNotDefaultConstructible) {
|
||||
MockA a;
|
||||
// TODO(wan@google.com): We should really verify the output message,
|
||||
// FIXME: We should really verify the output message,
|
||||
// but we cannot yet due to that EXPECT_DEATH only captures stderr
|
||||
// while Google Mock logs to stdout.
|
||||
#if GTEST_HAS_EXCEPTIONS
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
//
|
||||
// Tests for Google C++ Mocking Framework (Google Mock)
|
||||
//
|
||||
|
@ -26,17 +26,18 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Tests Google Mock's functionality that depends on exceptions.
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#if GTEST_HAS_EXCEPTIONS
|
||||
namespace {
|
||||
|
||||
using testing::HasSubstr;
|
||||
|
||||
using testing::internal::GoogleTestFailureException;
|
||||
|
||||
// A type that cannot be default constructed.
|
||||
@ -52,8 +53,6 @@ class MockFoo {
|
||||
MOCK_METHOD0(GetNonDefaultConstructible, NonDefaultConstructible());
|
||||
};
|
||||
|
||||
#if GTEST_HAS_EXCEPTIONS
|
||||
|
||||
TEST(DefaultValueTest, ThrowsRuntimeErrorWhenNoDefaultValue) {
|
||||
MockFoo mock;
|
||||
try {
|
||||
@ -76,6 +75,6 @@ TEST(DefaultValueTest, ThrowsRuntimeErrorWhenNoDefaultValue) {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // unnamed namespace
|
||||
#endif
|
||||
|
@ -31,12 +31,8 @@
|
||||
|
||||
"""Tests that leaked mock objects can be caught be Google Mock."""
|
||||
|
||||
__author__ = 'wan@google.com (Zhanyong Wan)'
|
||||
|
||||
|
||||
import gmock_test_utils
|
||||
|
||||
|
||||
PROGRAM_PATH = gmock_test_utils.GetTestExecutablePath('gmock_leak_test_')
|
||||
TEST_WITH_EXPECT_CALL = [PROGRAM_PATH, '--gtest_filter=*ExpectCall*']
|
||||
TEST_WITH_ON_CALL = [PROGRAM_PATH, '--gtest_filter=*OnCall*']
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan), vladl@google.com (Vlad Losev)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan), vladl@google.com (Vlad Losev)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: vladl@google.com (Vlad Losev)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
|
@ -29,21 +29,19 @@
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""Tests the text output of Google C++ Mocking Framework.
|
||||
r"""Tests the text output of Google C++ Mocking Framework.
|
||||
|
||||
To update the golden file:
|
||||
gmock_output_test.py --build_dir=BUILD/DIR --gengolden
|
||||
# where BUILD/DIR contains the built gmock_output_test_ file.
|
||||
where BUILD/DIR contains the built gmock_output_test_ file.
|
||||
gmock_output_test.py --gengolden
|
||||
gmock_output_test.py
|
||||
"""
|
||||
|
||||
__author__ = 'wan@google.com (Zhanyong Wan)'
|
||||
"""
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
import gmock_test_utils
|
||||
|
||||
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Tests Google Mock's output in various scenarios. This ensures that
|
||||
// Google Mock's messages are readable and useful.
|
||||
|
@ -26,20 +26,18 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Tests that Google Mock constructs can be used in a large number of
|
||||
// threads concurrently.
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace testing {
|
||||
namespace {
|
||||
|
||||
// From "gtest/internal/gtest-port.h".
|
||||
// From gtest-port.h.
|
||||
using ::testing::internal::ThreadWithParam;
|
||||
|
||||
// The maximum number of test threads (not including helper threads)
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Mock - a framework for writing C++ mock classes.
|
||||
//
|
||||
|
@ -29,8 +29,6 @@
|
||||
|
||||
"""Unit test utilities for Google C++ Mocking Framework."""
|
||||
|
||||
__author__ = 'wan@google.com (Zhanyong Wan)'
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
@ -86,7 +86,7 @@ include_directories(
|
||||
if (MSVC AND MSVC_VERSION EQUAL 1700)
|
||||
add_definitions(/D _VARIADIC_MAX=10)
|
||||
endif()
|
||||
|
||||
|
||||
########################################################################
|
||||
#
|
||||
# Defines the gtest & gtest_main libraries. User tests should link
|
||||
@ -121,13 +121,13 @@ if(INSTALL_GTEST)
|
||||
# configure and install pkgconfig files
|
||||
configure_file(
|
||||
cmake/gtest.pc.in
|
||||
"${CMAKE_BINARY_DIR}/gtest.pc"
|
||||
"${gtest_BINARY_DIR}/gtest.pc"
|
||||
@ONLY)
|
||||
configure_file(
|
||||
cmake/gtest_main.pc.in
|
||||
"${CMAKE_BINARY_DIR}/gtest_main.pc"
|
||||
"${gtest_BINARY_DIR}/gtest_main.pc"
|
||||
@ONLY)
|
||||
install(FILES "${CMAKE_BINARY_DIR}/gtest.pc" "${CMAKE_BINARY_DIR}/gtest_main.pc"
|
||||
install(FILES "${gtest_BINARY_DIR}/gtest.pc" "${gtest_BINARY_DIR}/gtest_main.pc"
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||
endif()
|
||||
|
||||
@ -171,28 +171,28 @@ if (gtest_build_tests)
|
||||
############################################################
|
||||
# C++ tests built with standard compiler flags.
|
||||
|
||||
cxx_test(gtest-death-test_test gtest_main)
|
||||
cxx_test(googletest-death-test-test gtest_main)
|
||||
cxx_test(gtest_environment_test gtest)
|
||||
cxx_test(gtest-filepath_test gtest_main)
|
||||
cxx_test(gtest-linked_ptr_test gtest_main)
|
||||
cxx_test(gtest-listener_test gtest_main)
|
||||
cxx_test(googletest-filepath-test gtest_main)
|
||||
cxx_test(googletest-linked-ptr-test gtest_main)
|
||||
cxx_test(googletest-listener-test gtest_main)
|
||||
cxx_test(gtest_main_unittest gtest_main)
|
||||
cxx_test(gtest-message_test gtest_main)
|
||||
cxx_test(googletest-message-test gtest_main)
|
||||
cxx_test(gtest_no_test_unittest gtest)
|
||||
cxx_test(gtest-options_test gtest_main)
|
||||
cxx_test(gtest-param-test_test gtest
|
||||
test/gtest-param-test2_test.cc)
|
||||
cxx_test(gtest-port_test gtest_main)
|
||||
cxx_test(googletest-options-test gtest_main)
|
||||
cxx_test(googletest-param-test-test gtest
|
||||
test/googletest-param-test2-test.cc)
|
||||
cxx_test(googletest-port-test gtest_main)
|
||||
cxx_test(gtest_pred_impl_unittest gtest_main)
|
||||
cxx_test(gtest_premature_exit_test gtest
|
||||
test/gtest_premature_exit_test.cc)
|
||||
cxx_test(gtest-printers_test gtest_main)
|
||||
cxx_test(googletest-printers-test gtest_main)
|
||||
cxx_test(gtest_prod_test gtest_main
|
||||
test/production.cc)
|
||||
cxx_test(gtest_repeat_test gtest)
|
||||
cxx_test(gtest_sole_header_test gtest_main)
|
||||
cxx_test(gtest_stress_test gtest)
|
||||
cxx_test(gtest-test-part_test gtest_main)
|
||||
cxx_test(googletest-test-part-test gtest_main)
|
||||
cxx_test(gtest_throw_on_failure_ex_test gtest)
|
||||
cxx_test(gtest-typed-test_test gtest_main
|
||||
test/gtest-typed-test2_test.cc)
|
||||
@ -214,10 +214,10 @@ if (gtest_build_tests)
|
||||
|
||||
cxx_test_with_flags(gtest-death-test_ex_nocatch_test
|
||||
"${cxx_exception} -DGTEST_ENABLE_CATCH_EXCEPTIONS_=0"
|
||||
gtest test/gtest-death-test_ex_test.cc)
|
||||
gtest test/googletest-death-test_ex_test.cc)
|
||||
cxx_test_with_flags(gtest-death-test_ex_catch_test
|
||||
"${cxx_exception} -DGTEST_ENABLE_CATCH_EXCEPTIONS_=1"
|
||||
gtest test/gtest-death-test_ex_test.cc)
|
||||
gtest test/googletest-death-test_ex_test.cc)
|
||||
|
||||
cxx_test_with_flags(gtest_no_rtti_unittest "${cxx_no_rtti}"
|
||||
gtest_main_no_rtti test/gtest_unittest.cc)
|
||||
@ -238,75 +238,75 @@ if (gtest_build_tests)
|
||||
cxx_library(gtest_main_use_own_tuple "${cxx_use_own_tuple}"
|
||||
src/gtest-all.cc src/gtest_main.cc)
|
||||
|
||||
cxx_test_with_flags(gtest-tuple_test "${cxx_use_own_tuple}"
|
||||
gtest_main_use_own_tuple test/gtest-tuple_test.cc)
|
||||
cxx_test_with_flags(googletest-tuple-test "${cxx_use_own_tuple}"
|
||||
gtest_main_use_own_tuple test/googletest-tuple-test.cc)
|
||||
|
||||
cxx_test_with_flags(gtest_use_own_tuple_test "${cxx_use_own_tuple}"
|
||||
gtest_main_use_own_tuple
|
||||
test/gtest-param-test_test.cc test/gtest-param-test2_test.cc)
|
||||
test/googletest-param-test-test.cc test/googletest-param-test2-test.cc)
|
||||
endif()
|
||||
|
||||
############################################################
|
||||
# Python tests.
|
||||
|
||||
cxx_executable(gtest_break_on_failure_unittest_ test gtest)
|
||||
py_test(gtest_break_on_failure_unittest)
|
||||
cxx_executable(googletest-break-on-failure-unittest_ test gtest)
|
||||
py_test(googletest-break-on-failure-unittest)
|
||||
|
||||
# Visual Studio .NET 2003 does not support STL with exceptions disabled.
|
||||
if (NOT MSVC OR MSVC_VERSION GREATER 1310) # 1310 is Visual Studio .NET 2003
|
||||
cxx_executable_with_flags(
|
||||
gtest_catch_exceptions_no_ex_test_
|
||||
googletest-catch-exceptions-no-ex-test_
|
||||
"${cxx_no_exception}"
|
||||
gtest_main_no_exception
|
||||
test/gtest_catch_exceptions_test_.cc)
|
||||
test/googletest-catch-exceptions-test_.cc)
|
||||
endif()
|
||||
|
||||
cxx_executable_with_flags(
|
||||
gtest_catch_exceptions_ex_test_
|
||||
googletest-catch-exceptions-ex-test_
|
||||
"${cxx_exception}"
|
||||
gtest_main
|
||||
test/gtest_catch_exceptions_test_.cc)
|
||||
py_test(gtest_catch_exceptions_test)
|
||||
test/googletest-catch-exceptions-test_.cc)
|
||||
py_test(googletest-catch-exceptions-test)
|
||||
|
||||
cxx_executable(gtest_color_test_ test gtest)
|
||||
py_test(gtest_color_test)
|
||||
cxx_executable(googletest-color-test_ test gtest)
|
||||
py_test(googletest-color-test)
|
||||
|
||||
cxx_executable(gtest_env_var_test_ test gtest)
|
||||
py_test(gtest_env_var_test)
|
||||
cxx_executable(googletest-env-var-test_ test gtest)
|
||||
py_test(googletest-env-var-test)
|
||||
|
||||
cxx_executable(gtest_filter_unittest_ test gtest)
|
||||
py_test(gtest_filter_unittest)
|
||||
cxx_executable(googletest-filter-unittest_ test gtest)
|
||||
py_test(googletest-filter-unittest)
|
||||
|
||||
cxx_executable(gtest_help_test_ test gtest_main)
|
||||
py_test(gtest_help_test)
|
||||
|
||||
cxx_executable(gtest_list_tests_unittest_ test gtest)
|
||||
py_test(gtest_list_tests_unittest)
|
||||
cxx_executable(googletest-list-tests-unittest_ test gtest)
|
||||
py_test(googletest-list-tests-unittest)
|
||||
|
||||
cxx_executable(gtest_output_test_ test gtest)
|
||||
py_test(gtest_output_test)
|
||||
cxx_executable(googletest-output-test_ test gtest)
|
||||
py_test(googletest-output-test --no_stacktrace_support)
|
||||
|
||||
cxx_executable(gtest_shuffle_test_ test gtest)
|
||||
py_test(gtest_shuffle_test)
|
||||
cxx_executable(googletest-shuffle-test_ test gtest)
|
||||
py_test(googletest-shuffle-test)
|
||||
|
||||
# MSVC 7.1 does not support STL with exceptions disabled.
|
||||
if (NOT MSVC OR MSVC_VERSION GREATER 1310)
|
||||
cxx_executable(gtest_throw_on_failure_test_ test gtest_no_exception)
|
||||
set_target_properties(gtest_throw_on_failure_test_
|
||||
cxx_executable(googletest-throw-on-failure-test_ test gtest_no_exception)
|
||||
set_target_properties(googletest-throw-on-failure-test_
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "${cxx_no_exception}")
|
||||
py_test(gtest_throw_on_failure_test)
|
||||
py_test(googletest-throw-on-failure-test)
|
||||
endif()
|
||||
|
||||
cxx_executable(gtest_uninitialized_test_ test gtest)
|
||||
py_test(gtest_uninitialized_test)
|
||||
cxx_executable(googletest-uninitialized-test_ test gtest)
|
||||
py_test(googletest-uninitialized-test)
|
||||
|
||||
cxx_executable(gtest_xml_outfile1_test_ test gtest_main)
|
||||
cxx_executable(gtest_xml_outfile2_test_ test gtest_main)
|
||||
py_test(gtest_xml_outfiles_test)
|
||||
py_test(gtest_json_outfiles_test)
|
||||
py_test(googletest-json-outfiles-test)
|
||||
|
||||
cxx_executable(gtest_xml_output_unittest_ test gtest)
|
||||
py_test(gtest_xml_output_unittest)
|
||||
py_test(gtest_json_output_unittest)
|
||||
py_test(gtest_xml_output_unittest --no_stacktrace_support)
|
||||
py_test(googletest-json-output-unittest --no_stacktrace_support)
|
||||
endif()
|
||||
|
@ -53,40 +53,40 @@ EXTRA_DIST += \
|
||||
test/gtest-listener_test.cc \
|
||||
test/gtest-message_test.cc \
|
||||
test/gtest-options_test.cc \
|
||||
test/gtest-param-test2_test.cc \
|
||||
test/gtest-param-test2_test.cc \
|
||||
test/gtest-param-test_test.cc \
|
||||
test/gtest-param-test_test.cc \
|
||||
test/googletest-param-test2-test.cc \
|
||||
test/googletest-param-test2-test.cc \
|
||||
test/googletest-param-test-test.cc \
|
||||
test/googletest-param-test-test.cc \
|
||||
test/gtest-param-test_test.h \
|
||||
test/gtest-port_test.cc \
|
||||
test/gtest_premature_exit_test.cc \
|
||||
test/gtest-printers_test.cc \
|
||||
test/gtest-test-part_test.cc \
|
||||
test/gtest-tuple_test.cc \
|
||||
test/googletest-tuple-test.cc \
|
||||
test/gtest-typed-test2_test.cc \
|
||||
test/gtest-typed-test_test.cc \
|
||||
test/gtest-typed-test_test.h \
|
||||
test/gtest-unittest-api_test.cc \
|
||||
test/gtest_break_on_failure_unittest_.cc \
|
||||
test/gtest_catch_exceptions_test_.cc \
|
||||
test/gtest_color_test_.cc \
|
||||
test/gtest_env_var_test_.cc \
|
||||
test/googletest-break-on-failure-unittest_.cc \
|
||||
test/googletest-catch-exceptions-test_.cc \
|
||||
test/googletest-color-test_.cc \
|
||||
test/googletest-env-var-test_.cc \
|
||||
test/gtest_environment_test.cc \
|
||||
test/gtest_filter_unittest_.cc \
|
||||
test/googletest-filter-unittest_.cc \
|
||||
test/gtest_help_test_.cc \
|
||||
test/gtest_list_tests_unittest_.cc \
|
||||
test/googletest-list-tests-unittest_.cc \
|
||||
test/gtest_main_unittest.cc \
|
||||
test/gtest_no_test_unittest.cc \
|
||||
test/gtest_output_test_.cc \
|
||||
test/googletest-output-test_.cc \
|
||||
test/gtest_pred_impl_unittest.cc \
|
||||
test/gtest_prod_test.cc \
|
||||
test/gtest_repeat_test.cc \
|
||||
test/gtest_shuffle_test_.cc \
|
||||
test/googletest-shuffle-test_.cc \
|
||||
test/gtest_sole_header_test.cc \
|
||||
test/gtest_stress_test.cc \
|
||||
test/gtest_throw_on_failure_ex_test.cc \
|
||||
test/gtest_throw_on_failure_test_.cc \
|
||||
test/gtest_uninitialized_test_.cc \
|
||||
test/googletest-throw-on-failure-test_.cc \
|
||||
test/googletest-uninitialized-test_.cc \
|
||||
test/gtest_unittest.cc \
|
||||
test/gtest_unittest.cc \
|
||||
test/gtest_xml_outfile1_test_.cc \
|
||||
@ -97,19 +97,19 @@ EXTRA_DIST += \
|
||||
|
||||
# Python tests that we don't run.
|
||||
EXTRA_DIST += \
|
||||
test/gtest_break_on_failure_unittest.py \
|
||||
test/gtest_catch_exceptions_test.py \
|
||||
test/gtest_color_test.py \
|
||||
test/gtest_env_var_test.py \
|
||||
test/gtest_filter_unittest.py \
|
||||
test/googletest-break-on-failure-unittest.py \
|
||||
test/googletest-catch-exceptions-test.py \
|
||||
test/googletest-color-test.py \
|
||||
test/googletest-env-var-test.py \
|
||||
test/googletest-filter-unittest.py \
|
||||
test/gtest_help_test.py \
|
||||
test/gtest_list_tests_unittest.py \
|
||||
test/gtest_output_test.py \
|
||||
test/gtest_output_test_golden_lin.txt \
|
||||
test/gtest_shuffle_test.py \
|
||||
test/googletest-list-tests-unittest.py \
|
||||
test/googletest-output-test.py \
|
||||
test/googletest-output-test_golden_lin.txt \
|
||||
test/googletest-shuffle-test.py \
|
||||
test/gtest_test_utils.py \
|
||||
test/gtest_throw_on_failure_test.py \
|
||||
test/gtest_uninitialized_test.py \
|
||||
test/googletest-throw-on-failure-test.py \
|
||||
test/googletest-uninitialized-test.py \
|
||||
test/gtest_xml_outfiles_test.py \
|
||||
test/gtest_xml_output_unittest.py \
|
||||
test/gtest_xml_test_utils.py
|
||||
|
@ -20,7 +20,7 @@ macro(fix_default_compiler_settings_)
|
||||
if (MSVC)
|
||||
# For MSVC, CMake sets certain flags to defaults we want to override.
|
||||
# This replacement code is taken from sample in the CMake Wiki at
|
||||
# http://www.cmake.org/Wiki/CMake_FAQ#Dynamic_Replace.
|
||||
# https://gitlab.kitware.com/cmake/community/wikis/FAQ#dynamic-replace.
|
||||
foreach (flag_var
|
||||
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
||||
@ -230,7 +230,7 @@ find_package(PythonInterp)
|
||||
# from the given source files with the given compiler flags.
|
||||
function(cxx_test_with_flags name cxx_flags libs)
|
||||
cxx_executable_with_flags(${name} "${cxx_flags}" "${libs}" ${ARGN})
|
||||
add_test(${name} ${name})
|
||||
add_test(NAME ${name} COMMAND ${name})
|
||||
endfunction()
|
||||
|
||||
# cxx_test(name libs srcs...)
|
||||
@ -257,14 +257,14 @@ function(py_test name)
|
||||
add_test(
|
||||
NAME ${name}
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py
|
||||
--build_dir=${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>)
|
||||
--build_dir=${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG> ${ARGN})
|
||||
else (CMAKE_CONFIGURATION_TYPES)
|
||||
# Single-configuration build generators like Makefile generators
|
||||
# don't have subdirs below CMAKE_CURRENT_BINARY_DIR.
|
||||
add_test(
|
||||
NAME ${name}
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py
|
||||
--build_dir=${CMAKE_CURRENT_BINARY_DIR})
|
||||
--build_dir=${CMAKE_CURRENT_BINARY_DIR} ${ARGN})
|
||||
endif (CMAKE_CONFIGURATION_TYPES)
|
||||
else (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1)
|
||||
# ${CMAKE_CURRENT_BINARY_DIR} is known at configuration time, so we can
|
||||
@ -274,7 +274,7 @@ function(py_test name)
|
||||
add_test(
|
||||
${name}
|
||||
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py
|
||||
--build_dir=${CMAKE_CURRENT_BINARY_DIR}/\${CTEST_CONFIGURATION_TYPE})
|
||||
--build_dir=${CMAKE_CURRENT_BINARY_DIR}/\${CTEST_CONFIGURATION_TYPE} ${ARGN})
|
||||
endif (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1)
|
||||
endif(PYTHONINTERP_FOUND)
|
||||
endfunction()
|
||||
|
@ -6,7 +6,7 @@ This guide will explain how to use the Google Testing Framework in your Xcode pr
|
||||
|
||||
Here is the quick guide for using Google Test in your Xcode project.
|
||||
|
||||
1. Download the source from the [website](http://code.google.com/p/googletest) using this command: `svn checkout http://googletest.googlecode.com/svn/trunk/ googletest-read-only`.
|
||||
1. Download the source from the [website](https://github.com/google/googletest) using this command: `svn checkout http://googletest.googlecode.com/svn/trunk/ googletest-read-only`.
|
||||
1. Open up the `gtest.xcodeproj` in the `googletest-read-only/xcode/` directory and build the gtest.framework.
|
||||
1. Create a new "Shell Tool" target in your Xcode project called something like "UnitTests".
|
||||
1. Add the gtest.framework to your project and add it to the "Link Binary with Libraries" build phase of "UnitTests".
|
||||
@ -18,7 +18,7 @@ The following sections further explain each of the steps listed above in depth,
|
||||
|
||||
# Get the Source #
|
||||
|
||||
Currently, the gtest.framework discussed here isn't available in a tagged release of Google Test, it is only available in the trunk. As explained at the Google Test [site](http://code.google.com/p/googletest/source/checkout">svn), you can get the code from anonymous SVN with this command:
|
||||
Currently, the gtest.framework discussed here isn't available in a tagged release of Google Test, it is only available in the trunk. As explained at the Google Test [site](https://github.com/google/googletest), you can get the code from anonymous SVN with this command:
|
||||
|
||||
```
|
||||
svn checkout http://googletest.googlecode.com/svn/trunk/ googletest-read-only
|
||||
@ -28,7 +28,7 @@ Alternatively, if you are working with Subversion in your own code base, you can
|
||||
|
||||
To use `svn:externals`, decide where you would like to have the external source reside. You might choose to put the external source inside the trunk, because you want it to be part of the branch when you make a release. However, keeping it outside the trunk in a version-tagged directory called something like `third-party/googletest/1.0.1`, is another option. Once the location is established, use `svn propedit svn:externals _directory_` to set the svn:externals property on a directory in your repository. This directory won't contain the code, but be its versioned parent directory.
|
||||
|
||||
The command `svn propedit` will bring up your Subversion editor, making editing the long, (potentially multi-line) property simpler. This same method can be used to check out a tagged branch, by using the appropriate URL (e.g. `http://googletest.googlecode.com/svn/tags/release-1.0.1`). Additionally, the svn:externals property allows the specification of a particular revision of the trunk with the `-r_##_` option (e.g. `externals/src/googletest -r60 http://googletest.googlecode.com/svn/trunk`).
|
||||
The command `svn propedit` will bring up your Subversion editor, making editing the long, (potentially multi-line) property simpler. This same method can be used to check out a tagged branch, by using the appropriate URL (e.g. `https://github.com/google/googletest/releases/tag/release-1.0.1`). Additionally, the svn:externals property allows the specification of a particular revision of the trunk with the `-r_##_` option (e.g. `externals/src/googletest -r60 http://googletest.googlecode.com/svn/trunk`).
|
||||
|
||||
Here is an example of using the svn:externals properties on a trunk (read via `svn propget`) of a project. This value checks out a copy of Google Test into the `trunk/externals/src/googletest/` directory.
|
||||
|
||||
@ -90,4 +90,4 @@ The Debugger has exited with status 0.
|
||||
|
||||
# Summary #
|
||||
|
||||
Unit testing is a valuable way to ensure your data model stays valid even during rapid development or refactoring. The Google Testing Framework is a great unit testing framework for C and C++ which integrates well with an Xcode development environment.
|
||||
Unit testing is a valuable way to ensure your data model stays valid even during rapid development or refactoring. The Google Testing Framework is a great unit testing framework for C and C++ which integrates well with an Xcode development environment.
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,132 +1,127 @@
|
||||
# Googletest Primer
|
||||
|
||||
|
||||
# Introduction: Why Google C++ Testing Framework? #
|
||||
## Introduction: Why googletest?
|
||||
|
||||
_Google C++ Testing Framework_ helps you write better C++ tests.
|
||||
*googletest* helps you write better C++ tests.
|
||||
|
||||
No matter whether you work on Linux, Windows, or a Mac, if you write C++ code,
|
||||
Google Test can help you.
|
||||
googletest is a testing framework developed by the Testing
|
||||
Technology team with Google's specific
|
||||
requirements and constraints in mind. No matter whether you work on Linux,
|
||||
Windows, or a Mac, if you write C++ code, googletest can help you. And it
|
||||
supports *any* kind of tests, not just unit tests.
|
||||
|
||||
So what makes a good test, and how does Google C++ Testing Framework fit in? We believe:
|
||||
1. Tests should be _independent_ and _repeatable_. It's a pain to debug a test that succeeds or fails as a result of other tests. Google C++ Testing Framework isolates the tests by running each of them on a different object. When a test fails, Google C++ Testing Framework allows you to run it in isolation for quick debugging.
|
||||
1. Tests should be well _organized_ and reflect the structure of the tested code. Google C++ Testing Framework groups related tests into test cases that can share data and subroutines. This common pattern is easy to recognize and makes tests easy to maintain. Such consistency is especially helpful when people switch projects and start to work on a new code base.
|
||||
1. Tests should be _portable_ and _reusable_. The open-source community has a lot of code that is platform-neutral, its tests should also be platform-neutral. Google C++ Testing Framework works on different OSes, with different compilers (gcc, MSVC, and others), with or without exceptions, so Google C++ Testing Framework tests can easily work with a variety of configurations. (Note that the current release only contains build scripts for Linux - we are actively working on scripts for other platforms.)
|
||||
1. When tests fail, they should provide as much _information_ about the problem as possible. Google C++ Testing Framework doesn't stop at the first test failure. Instead, it only stops the current test and continues with the next. You can also set up tests that report non-fatal failures after which the current test continues. Thus, you can detect and fix multiple bugs in a single run-edit-compile cycle.
|
||||
1. The testing framework should liberate test writers from housekeeping chores and let them focus on the test _content_. Google C++ Testing Framework automatically keeps track of all tests defined, and doesn't require the user to enumerate them in order to run them.
|
||||
1. Tests should be _fast_. With Google C++ Testing Framework, you can reuse shared resources across tests and pay for the set-up/tear-down only once, without making tests depend on each other.
|
||||
So what makes a good test, and how does googletest fit in? We believe:
|
||||
|
||||
Since Google C++ Testing Framework is based on the popular xUnit
|
||||
architecture, you'll feel right at home if you've used JUnit or PyUnit before.
|
||||
If not, it will take you about 10 minutes to learn the basics and get started.
|
||||
So let's go!
|
||||
1. Tests should be *independent* and *repeatable*. It's a pain to debug a test
|
||||
that succeeds or fails as a result of other tests. googletest isolates the
|
||||
tests by running each of them on a different object. When a test fails,
|
||||
googletest allows you to run it in isolation for quick debugging.
|
||||
1. Tests should be well *organized* and reflect the structure of the tested
|
||||
code. googletest groups related tests into test cases that can share data
|
||||
and subroutines. This common pattern is easy to recognize and makes tests
|
||||
easy to maintain. Such consistency is especially helpful when people switch
|
||||
projects and start to work on a new code base.
|
||||
1. Tests should be *portable* and *reusable*. Google has a lot of code that is
|
||||
platform-neutral, its tests should also be platform-neutral. googletest
|
||||
works on different OSes, with different compilers (gcc, icc, and MSVC), with
|
||||
or without exceptions, so googletest tests can easily work with a variety of
|
||||
configurations.
|
||||
1. When tests fail, they should provide as much *information* about the problem
|
||||
as possible. googletest doesn't stop at the first test failure. Instead, it
|
||||
only stops the current test and continues with the next. You can also set up
|
||||
tests that report non-fatal failures after which the current test continues.
|
||||
Thus, you can detect and fix multiple bugs in a single run-edit-compile
|
||||
cycle.
|
||||
1. The testing framework should liberate test writers from housekeeping chores
|
||||
and let them focus on the test *content*. googletest automatically keeps
|
||||
track of all tests defined, and doesn't require the user to enumerate them
|
||||
in order to run them.
|
||||
1. Tests should be *fast*. With googletest, you can reuse shared resources
|
||||
across tests and pay for the set-up/tear-down only once, without making
|
||||
tests depend on each other.
|
||||
|
||||
_Note:_ We sometimes refer to Google C++ Testing Framework informally
|
||||
as _Google Test_.
|
||||
Since googletest is based on the popular xUnit architecture, you'll feel right
|
||||
at home if you've used JUnit or PyUnit before. If not, it will take you about 10
|
||||
minutes to learn the basics and get started. So let's go!
|
||||
|
||||
# Beware of the nomenclature #
|
||||
## Beware of the nomenclature
|
||||
|
||||
_Note:_ There might be some confusion of idea due to different
|
||||
definitions of the terms _Test_, _Test Case_ and _Test Suite_, so beware
|
||||
of misunderstanding these.
|
||||
|
||||
Historically, the Google C++ Testing Framework started to use the term
|
||||
_Test Case_ for grouping related tests, whereas current publications
|
||||
including the International Software Testing Qualifications Board
|
||||
([ISTQB](http://www.istqb.org/)) and various textbooks on Software
|
||||
Quality use the term _[Test
|
||||
Historically, googletest started to use the term _Test Case_ for grouping
|
||||
related tests, whereas current publications including the International Software
|
||||
Testing Qualifications Board ([ISTQB](http://www.istqb.org/)) and various
|
||||
textbooks on Software Quality use the term _[Test
|
||||
Suite](http://glossary.istqb.org/search/test%20suite)_ for this.
|
||||
|
||||
The related term _Test_, as it is used in the Google C++ Testing
|
||||
Framework, is corresponding to the term _[Test
|
||||
Case](http://glossary.istqb.org/search/test%20case)_ of ISTQB and
|
||||
others.
|
||||
The related term _Test_, as it is used in the googletest, is corresponding to
|
||||
the term _[Test Case](http://glossary.istqb.org/search/test%20case)_ of ISTQB
|
||||
and others.
|
||||
|
||||
The term _Test_ is commonly of broad enough sense, including ISTQB's
|
||||
definition of _Test Case_, so it's not much of a problem here. But the
|
||||
term _Test Case_ as used in Google Test is of contradictory sense and thus confusing.
|
||||
|
||||
Unfortunately replacing the term _Test Case_ by _Test Suite_ throughout
|
||||
the Google C++ Testing Framework is not easy without breaking dependent
|
||||
projects, as `TestCase` is part of the public API at various places.
|
||||
Unfortunately replacing the term _Test Case_ by _Test Suite_ throughout the
|
||||
googletest is not easy without breaking dependent projects, as `TestCase` is
|
||||
part of the public API at various places.
|
||||
|
||||
So for the time being, please be aware of the different definitions of
|
||||
the terms:
|
||||
|
||||
Meaning | Google Test Term | [ISTQB](http://www.istqb.org/) Term
|
||||
------- | ---------------- | -----------------------------------
|
||||
Exercise a particular program path with specific input values and verify the results | [TEST()](#simple-tests) | [Test Case](http://glossary.istqb.org/search/test%20case)
|
||||
A set of several tests related to one component | [Test Case](#basic-concepts) | [Test Suite](http://glossary.istqb.org/search/test%20suite)
|
||||
Meaning | googletest Term | [ISTQB](http://www.istqb.org/) Term
|
||||
:----------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------- | :----------------------------------
|
||||
Exercise a particular program path with specific input values and verify the results | [TEST()](#simple-tests) | [Test Case](http://glossary.istqb.org/search/test%20case)
|
||||
A set of several tests related to one component | [TestCase](#basic-concepts) | [TestSuite](http://glossary.istqb.org/search/test%20suite)
|
||||
|
||||
# Setting up a New Test Project #
|
||||
## Basic Concepts
|
||||
|
||||
To write a test program using Google Test, you need to compile Google
|
||||
Test into a library and link your test with it. We provide build
|
||||
files for some popular build systems: `msvc/` for Visual Studio,
|
||||
`xcode/` for Mac Xcode, `make/` for GNU make, `codegear/` for Borland
|
||||
C++ Builder, and the autotools script (deprecated) and
|
||||
`CMakeLists.txt` for CMake (recommended) in the Google Test root
|
||||
directory. If your build system is not on this list, you can take a
|
||||
look at `make/Makefile` to learn how Google Test should be compiled
|
||||
(basically you want to compile `src/gtest-all.cc` with `GTEST_ROOT`
|
||||
and `GTEST_ROOT/include` in the header search path, where `GTEST_ROOT`
|
||||
is the Google Test root directory).
|
||||
When using googletest, you start by writing *assertions*, which are statements
|
||||
that check whether a condition is true. An assertion's result can be *success*,
|
||||
*nonfatal failure*, or *fatal failure*. If a fatal failure occurs, it aborts the
|
||||
current function; otherwise the program continues normally.
|
||||
|
||||
Once you are able to compile the Google Test library, you should
|
||||
create a project or build target for your test program. Make sure you
|
||||
have `GTEST_ROOT/include` in the header search path so that the
|
||||
compiler can find `"gtest/gtest.h"` when compiling your test. Set up
|
||||
your test project to link with the Google Test library (for example,
|
||||
in Visual Studio, this is done by adding a dependency on
|
||||
`gtest.vcproj`).
|
||||
*Tests* use assertions to verify the tested code's behavior. If a test crashes
|
||||
or has a failed assertion, then it *fails*; otherwise it *succeeds*.
|
||||
|
||||
If you still have questions, take a look at how Google Test's own
|
||||
tests are built and use them as examples.
|
||||
|
||||
# Basic Concepts #
|
||||
|
||||
When using Google Test, you start by writing _assertions_, which are statements
|
||||
that check whether a condition is true. An assertion's result can be _success_,
|
||||
_nonfatal failure_, or _fatal failure_. If a fatal failure occurs, it aborts
|
||||
the current function; otherwise the program continues normally.
|
||||
|
||||
_Tests_ use assertions to verify the tested code's behavior. If a test crashes
|
||||
or has a failed assertion, then it _fails_; otherwise it _succeeds_.
|
||||
|
||||
A _test case_ contains one or many tests. You should group your tests into test
|
||||
A *test case* contains one or many tests. You should group your tests into test
|
||||
cases that reflect the structure of the tested code. When multiple tests in a
|
||||
test case need to share common objects and subroutines, you can put them into a
|
||||
_test fixture_ class.
|
||||
*test fixture* class.
|
||||
|
||||
A _test program_ can contain multiple test cases.
|
||||
A *test program* can contain multiple test cases.
|
||||
|
||||
We'll now explain how to write a test program, starting at the individual
|
||||
assertion level and building up to tests and test cases.
|
||||
|
||||
# Assertions #
|
||||
## Assertions
|
||||
|
||||
Google Test assertions are macros that resemble function calls. You test a
|
||||
class or function by making assertions about its behavior. When an assertion
|
||||
fails, Google Test prints the assertion's source file and line number location,
|
||||
along with a failure message. You may also supply a custom failure message
|
||||
which will be appended to Google Test's message.
|
||||
googletest assertions are macros that resemble function calls. You test a class
|
||||
or function by making assertions about its behavior. When an assertion fails,
|
||||
googletest prints the assertion's source file and line number location, along
|
||||
with a failure message. You may also supply a custom failure message which will
|
||||
be appended to googletest's message.
|
||||
|
||||
The assertions come in pairs that test the same thing but have different
|
||||
effects on the current function. `ASSERT_*` versions generate fatal failures
|
||||
when they fail, and **abort the current function**. `EXPECT_*` versions generate
|
||||
nonfatal failures, which don't abort the current function. Usually `EXPECT_*`
|
||||
are preferred, as they allow more than one failures to be reported in a test.
|
||||
However, you should use `ASSERT_*` if it doesn't make sense to continue when
|
||||
the assertion in question fails.
|
||||
The assertions come in pairs that test the same thing but have different effects
|
||||
on the current function. `ASSERT_*` versions generate fatal failures when they
|
||||
fail, and **abort the current function**. `EXPECT_*` versions generate nonfatal
|
||||
failures, which don't abort the current function. Usually `EXPECT_*` are
|
||||
preferred, as they allow more than one failure to be reported in a test.
|
||||
However, you should use `ASSERT_*` if it doesn't make sense to continue when the
|
||||
assertion in question fails.
|
||||
|
||||
Since a failed `ASSERT_*` returns from the current function immediately,
|
||||
possibly skipping clean-up code that comes after it, it may cause a space leak.
|
||||
Depending on the nature of the leak, it may or may not be worth fixing - so
|
||||
keep this in mind if you get a heap checker error in addition to assertion
|
||||
errors.
|
||||
Depending on the nature of the leak, it may or may not be worth fixing - so keep
|
||||
this in mind if you get a heap checker error in addition to assertion errors.
|
||||
|
||||
To provide a custom failure message, simply stream it into the macro using the
|
||||
`<<` operator, or a sequence of such operators. An example:
|
||||
```
|
||||
|
||||
```c++
|
||||
ASSERT_EQ(x.size(), y.size()) << "Vectors x and y are of unequal length";
|
||||
|
||||
for (int i = 0; i < x.size(); ++i) {
|
||||
@ -139,50 +134,53 @@ macro--in particular, C strings and `string` objects. If a wide string
|
||||
(`wchar_t*`, `TCHAR*` in `UNICODE` mode on Windows, or `std::wstring`) is
|
||||
streamed to an assertion, it will be translated to UTF-8 when printed.
|
||||
|
||||
## Basic Assertions ##
|
||||
### Basic Assertions
|
||||
|
||||
These assertions do basic true/false condition testing.
|
||||
|
||||
| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |
|
||||
|:--------------------|:-----------------------|:-------------|
|
||||
| `ASSERT_TRUE(`_condition_`)`; | `EXPECT_TRUE(`_condition_`)`; | _condition_ is true |
|
||||
| `ASSERT_FALSE(`_condition_`)`; | `EXPECT_FALSE(`_condition_`)`; | _condition_ is false |
|
||||
Fatal assertion | Nonfatal assertion | Verifies
|
||||
-------------------------- | -------------------------- | --------------------
|
||||
`ASSERT_TRUE(condition);` | `EXPECT_TRUE(condition);` | `condition` is true
|
||||
`ASSERT_FALSE(condition);` | `EXPECT_FALSE(condition);` | `condition` is false
|
||||
|
||||
Remember, when they fail, `ASSERT_*` yields a fatal failure and
|
||||
returns from the current function, while `EXPECT_*` yields a nonfatal
|
||||
failure, allowing the function to continue running. In either case, an
|
||||
assertion failure means its containing test fails.
|
||||
Remember, when they fail, `ASSERT_*` yields a fatal failure and returns from the
|
||||
current function, while `EXPECT_*` yields a nonfatal failure, allowing the
|
||||
function to continue running. In either case, an assertion failure means its
|
||||
containing test fails.
|
||||
|
||||
_Availability_: Linux, Windows, Mac.
|
||||
**Availability**: Linux, Windows, Mac.
|
||||
|
||||
## Binary Comparison ##
|
||||
### Binary Comparison
|
||||
|
||||
This section describes assertions that compare two values.
|
||||
|
||||
| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |
|
||||
|:--------------------|:-----------------------|:-------------|
|
||||
|`ASSERT_EQ(`_val1_`, `_val2_`);`|`EXPECT_EQ(`_val1_`, `_val2_`);`| _val1_ `==` _val2_ |
|
||||
|`ASSERT_NE(`_val1_`, `_val2_`);`|`EXPECT_NE(`_val1_`, `_val2_`);`| _val1_ `!=` _val2_ |
|
||||
|`ASSERT_LT(`_val1_`, `_val2_`);`|`EXPECT_LT(`_val1_`, `_val2_`);`| _val1_ `<` _val2_ |
|
||||
|`ASSERT_LE(`_val1_`, `_val2_`);`|`EXPECT_LE(`_val1_`, `_val2_`);`| _val1_ `<=` _val2_ |
|
||||
|`ASSERT_GT(`_val1_`, `_val2_`);`|`EXPECT_GT(`_val1_`, `_val2_`);`| _val1_ `>` _val2_ |
|
||||
|`ASSERT_GE(`_val1_`, `_val2_`);`|`EXPECT_GE(`_val1_`, `_val2_`);`| _val1_ `>=` _val2_ |
|
||||
Fatal assertion | Nonfatal assertion | Verifies
|
||||
------------------------ | ------------------------ | --------------
|
||||
`ASSERT_EQ(val1, val2);` | `EXPECT_EQ(val1, val2);` | `val1 == val2`
|
||||
`ASSERT_NE(val1, val2);` | `EXPECT_NE(val1, val2);` | `val1 != val2`
|
||||
`ASSERT_LT(val1, val2);` | `EXPECT_LT(val1, val2);` | `val1 < val2`
|
||||
`ASSERT_LE(val1, val2);` | `EXPECT_LE(val1, val2);` | `val1 <= val2`
|
||||
`ASSERT_GT(val1, val2);` | `EXPECT_GT(val1, val2);` | `val1 > val2`
|
||||
`ASSERT_GE(val1, val2);` | `EXPECT_GE(val1, val2);` | `val1 >= val2`
|
||||
|
||||
In the event of a failure, Google Test prints both _val1_ and _val2_.
|
||||
|
||||
Value arguments must be comparable by the assertion's comparison
|
||||
operator or you'll get a compiler error. We used to require the
|
||||
arguments to support the `<<` operator for streaming to an `ostream`,
|
||||
but it's no longer necessary since v1.6.0 (if `<<` is supported, it
|
||||
will be called to print the arguments when the assertion fails;
|
||||
otherwise Google Test will attempt to print them in the best way it
|
||||
can. For more details and how to customize the printing of the
|
||||
arguments, see this Google Mock [recipe](../../googlemock/docs/CookBook.md#teaching-google-mock-how-to-print-your-values).).
|
||||
Value arguments must be comparable by the assertion's comparison operator or
|
||||
you'll get a compiler error. We used to require the arguments to support the
|
||||
`<<` operator for streaming to an `ostream`, but it's no longer necessary. If
|
||||
`<<` is supported, it will be called to print the arguments when the assertion
|
||||
fails; otherwise googletest will attempt to print them in the best way it can.
|
||||
For more details and how to customize the printing of the arguments, see
|
||||
gMock [recipe](../../googlemock/docs/CookBook.md#teaching-google-mock-how-to-print-your-values).).
|
||||
|
||||
These assertions can work with a user-defined type, but only if you define the
|
||||
corresponding comparison operator (e.g. `==`, `<`, etc). If the corresponding
|
||||
operator is defined, prefer using the `ASSERT_*()` macros because they will
|
||||
print out not only the result of the comparison, but the two operands as well.
|
||||
corresponding comparison operator (e.g. `==`, `<`, etc). Since this is
|
||||
discouraged by the Google [C++ Style
|
||||
Guide](https://google.github.io/styleguide/cppguide.html#Operator_Overloading),
|
||||
you may need to use `ASSERT_TRUE()` or `EXPECT_TRUE()` to assert the equality of
|
||||
two objects of a user-defined type.
|
||||
|
||||
However, when possible, `ASSERT_EQ(actual, expected)` is preferred to
|
||||
`ASSERT_TRUE(actual == expected)`, since it tells you `actual` and `expected`'s
|
||||
values on failure.
|
||||
|
||||
Arguments are always evaluated exactly once. Therefore, it's OK for the
|
||||
arguments to have side effects. However, as with any ordinary C/C++ function,
|
||||
@ -193,117 +191,147 @@ evaluation order.
|
||||
`ASSERT_EQ()` does pointer equality on pointers. If used on two C strings, it
|
||||
tests if they are in the same memory location, not if they have the same value.
|
||||
Therefore, if you want to compare C strings (e.g. `const char*`) by value, use
|
||||
`ASSERT_STREQ()` , which will be described later on. In particular, to assert
|
||||
that a C string is `NULL`, use `ASSERT_STREQ(NULL, c_string)` . However, to
|
||||
compare two `string` objects, you should use `ASSERT_EQ`.
|
||||
`ASSERT_STREQ()`, which will be described later on. In particular, to assert
|
||||
that a C string is `NULL`, use `ASSERT_STREQ(c_string, NULL)`. Consider use
|
||||
`ASSERT_EQ(c_string, nullptr)` if c++11 is supported. To compare two `string`
|
||||
objects, you should use `ASSERT_EQ`.
|
||||
|
||||
When doing pointer comparisons use `*_EQ(ptr, nullptr)` and `*_NE(ptr, nullptr)`
|
||||
instead of `*_EQ(ptr, NULL)` and `*_NE(ptr, NULL)`. This is because `nullptr` is
|
||||
typed while `NULL` is not. See [FAQ](faq.md#why-does-google-test-support-expect_eqnull-ptr-and-assert_eqnull-ptr-but-not-expect_nenull-ptr-and-assert_nenull-ptr)
|
||||
for more details.
|
||||
|
||||
If you're working with floating point numbers, you may want to use the floating
|
||||
point variations of some of these macros in order to avoid problems caused by
|
||||
rounding. See [Advanced googletest Topics](advanced.md) for details.
|
||||
|
||||
Macros in this section work with both narrow and wide string objects (`string`
|
||||
and `wstring`).
|
||||
|
||||
_Availability_: Linux, Windows, Mac.
|
||||
**Availability**: Linux, Windows, Mac.
|
||||
|
||||
_Historical note_: Before February 2016 `*_EQ` had a convention of calling it as
|
||||
`ASSERT_EQ(expected, actual)`, so lots of existing code uses this order.
|
||||
Now `*_EQ` treats both parameters in the same way.
|
||||
**Historical note**: Before February 2016 `*_EQ` had a convention of calling it
|
||||
as `ASSERT_EQ(expected, actual)`, so lots of existing code uses this order. Now
|
||||
`*_EQ` treats both parameters in the same way.
|
||||
|
||||
## String Comparison ##
|
||||
### String Comparison
|
||||
|
||||
The assertions in this group compare two **C strings**. If you want to compare
|
||||
two `string` objects, use `EXPECT_EQ`, `EXPECT_NE`, and etc instead.
|
||||
|
||||
| **Fatal assertion** | **Nonfatal assertion** | **Verifies** |
|
||||
|:--------------------|:-----------------------|:-------------|
|
||||
| `ASSERT_STREQ(`_str1_`, `_str2_`);` | `EXPECT_STREQ(`_str1_`, `_str2_`);` | the two C strings have the same content |
|
||||
| `ASSERT_STRNE(`_str1_`, `_str2_`);` | `EXPECT_STRNE(`_str1_`, `_str2_`);` | the two C strings have different content |
|
||||
| `ASSERT_STRCASEEQ(`_str1_`, `_str2_`);`| `EXPECT_STRCASEEQ(`_str1_`, `_str2_`);` | the two C strings have the same content, ignoring case |
|
||||
| `ASSERT_STRCASENE(`_str1_`, `_str2_`);`| `EXPECT_STRCASENE(`_str1_`, `_str2_`);` | the two C strings have different content, ignoring case |
|
||||
| Fatal assertion | Nonfatal assertion | Verifies |
|
||||
| ------------------------------- | ------------------------------- | -------------------------------------------------------- |
|
||||
| `ASSERT_STREQ(str1, str2);` | `EXPECT_STREQ(str1, str2);` | the two C strings have the same content |
|
||||
| `ASSERT_STRNE(str1, str2);` | `EXPECT_STRNE(str1, str2);` | the two C strings have different contents |
|
||||
| `ASSERT_STRCASEEQ(str1, str2);` | `EXPECT_STRCASEEQ(str1, str2);` | the two C strings have the same content, ignoring case |
|
||||
| `ASSERT_STRCASENE(str1, str2);` | `EXPECT_STRCASENE(str1, str2);` | the two C strings have different contents, ignoring case |
|
||||
|
||||
Note that "CASE" in an assertion name means that case is ignored.
|
||||
Note that "CASE" in an assertion name means that case is ignored. A `NULL`
|
||||
pointer and an empty string are considered *different*.
|
||||
|
||||
`*STREQ*` and `*STRNE*` also accept wide C strings (`wchar_t*`). If a
|
||||
comparison of two wide strings fails, their values will be printed as UTF-8
|
||||
narrow strings.
|
||||
`*STREQ*` and `*STRNE*` also accept wide C strings (`wchar_t*`). If a comparison
|
||||
of two wide strings fails, their values will be printed as UTF-8 narrow strings.
|
||||
|
||||
A `NULL` pointer and an empty string are considered _different_.
|
||||
**Availability**: Linux, Windows, Mac.
|
||||
|
||||
_Availability_: Linux, Windows, Mac.
|
||||
**See also**: For more string comparison tricks (substring, prefix, suffix, and
|
||||
regular expression matching, for example), see
|
||||
[this](https://github.com/google/googletest/blob/master/googletest/docs/advanced.md)
|
||||
in the Advanced googletest Guide.
|
||||
|
||||
See also: For more string comparison tricks (substring, prefix, suffix, and
|
||||
regular expression matching, for example), see the [Advanced Google Test Guide](advanced.md).
|
||||
|
||||
# Simple Tests #
|
||||
## Simple Tests
|
||||
|
||||
To create a test:
|
||||
1. Use the `TEST()` macro to define and name a test function, These are ordinary C++ functions that don't return a value.
|
||||
1. In this function, along with any valid C++ statements you want to include, use the various Google Test assertions to check values.
|
||||
1. The test's result is determined by the assertions; if any assertion in the test fails (either fatally or non-fatally), or if the test crashes, the entire test fails. Otherwise, it succeeds.
|
||||
|
||||
```
|
||||
TEST(testCaseName, testName) {
|
||||
... test body ...
|
||||
1. Use the `TEST()` macro to define and name a test function, These are
|
||||
ordinary C++ functions that don't return a value.
|
||||
1. In this function, along with any valid C++ statements you want to include,
|
||||
use the various googletest assertions to check values.
|
||||
1. The test's result is determined by the assertions; if any assertion in the
|
||||
test fails (either fatally or non-fatally), or if the test crashes, the
|
||||
entire test fails. Otherwise, it succeeds.
|
||||
|
||||
```c++
|
||||
TEST(TestCaseName, TestName) {
|
||||
... test body ...
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
`TEST()` arguments go from general to specific. The _first_ argument is the
|
||||
name of the test case, and the _second_ argument is the test's name within the
|
||||
test case. Both names must be valid C++ identifiers, and they should not contain underscore (`_`). A test's _full name_ consists of its containing test case and its
|
||||
individual name. Tests from different test cases can have the same individual
|
||||
name.
|
||||
`TEST()` arguments go from general to specific. The *first* argument is the name
|
||||
of the test case, and the *second* argument is the test's name within the test
|
||||
case. Both names must be valid C++ identifiers, and they should not contain
|
||||
underscore (`_`). A test's *full name* consists of its containing test case and
|
||||
its individual name. Tests from different test cases can have the same
|
||||
individual name.
|
||||
|
||||
For example, let's take a simple integer function:
|
||||
```
|
||||
int Factorial(int n); // Returns the factorial of n
|
||||
|
||||
```c++
|
||||
int Factorial(int n); // Returns the factorial of n
|
||||
```
|
||||
|
||||
A test case for this function might look like:
|
||||
```
|
||||
|
||||
```c++
|
||||
// Tests factorial of 0.
|
||||
TEST(FactorialTest, HandlesZeroInput) {
|
||||
EXPECT_EQ(1, Factorial(0));
|
||||
EXPECT_EQ(Factorial(0), 1);
|
||||
}
|
||||
|
||||
// Tests factorial of positive numbers.
|
||||
TEST(FactorialTest, HandlesPositiveInput) {
|
||||
EXPECT_EQ(1, Factorial(1));
|
||||
EXPECT_EQ(2, Factorial(2));
|
||||
EXPECT_EQ(6, Factorial(3));
|
||||
EXPECT_EQ(40320, Factorial(8));
|
||||
EXPECT_EQ(Factorial(1), 1);
|
||||
EXPECT_EQ(Factorial(2), 2);
|
||||
EXPECT_EQ(Factorial(3), 6);
|
||||
EXPECT_EQ(Factorial(8), 40320);
|
||||
}
|
||||
```
|
||||
|
||||
Google Test groups the test results by test cases, so logically-related tests
|
||||
googletest groups the test results by test cases, so logically-related tests
|
||||
should be in the same test case; in other words, the first argument to their
|
||||
`TEST()` should be the same. In the above example, we have two tests,
|
||||
`HandlesZeroInput` and `HandlesPositiveInput`, that belong to the same test
|
||||
case `FactorialTest`.
|
||||
`HandlesZeroInput` and `HandlesPositiveInput`, that belong to the same test case
|
||||
`FactorialTest`.
|
||||
|
||||
_Availability_: Linux, Windows, Mac.
|
||||
When naming your test cases and tests, you should follow the same convention as
|
||||
for [naming functions and
|
||||
classes](https://google.github.io/styleguide/cppguide.html#Function_Names).
|
||||
|
||||
# Test Fixtures: Using the Same Data Configuration for Multiple Tests #
|
||||
**Availability**: Linux, Windows, Mac.
|
||||
|
||||
If you find yourself writing two or more tests that operate on similar data,
|
||||
you can use a _test fixture_. It allows you to reuse the same configuration of
|
||||
## Test Fixtures: Using the Same Data Configuration for Multiple Tests
|
||||
|
||||
If you find yourself writing two or more tests that operate on similar data, you
|
||||
can use a *test fixture*. It allows you to reuse the same configuration of
|
||||
objects for several different tests.
|
||||
|
||||
To create a fixture, just:
|
||||
1. Derive a class from `::testing::Test` . Start its body with `protected:` or `public:` as we'll want to access fixture members from sub-classes.
|
||||
1. Inside the class, declare any objects you plan to use.
|
||||
1. If necessary, write a default constructor or `SetUp()` function to prepare the objects for each test. A common mistake is to spell `SetUp()` as `Setup()` with a small `u` - don't let that happen to you.
|
||||
1. If necessary, write a destructor or `TearDown()` function to release any resources you allocated in `SetUp()` . To learn when you should use the constructor/destructor and when you should use `SetUp()/TearDown()`, read this [FAQ entry](faq.md#should-i-use-the-constructordestructor-of-the-test-fixture-or-the-set-uptear-down-function).
|
||||
1. If needed, define subroutines for your tests to share.
|
||||
To create a fixture:
|
||||
|
||||
1. Derive a class from `::testing::Test` . Start its body with `protected:` as
|
||||
we'll want to access fixture members from sub-classes.
|
||||
1. Inside the class, declare any objects you plan to use.
|
||||
1. If necessary, write a default constructor or `SetUp()` function to prepare
|
||||
the objects for each test. A common mistake is to spell `SetUp()` as
|
||||
**`Setup()`** with a small `u` - Use `override` in C++11 to make sure you
|
||||
spelled it correctly
|
||||
1. If necessary, write a destructor or `TearDown()` function to release any
|
||||
resources you allocated in `SetUp()` . To learn when you should use the
|
||||
constructor/destructor and when you should use `SetUp()/TearDown()`, read
|
||||
this [FAQ](faq.md#should-i-use-the-constructordestructor-of-the-test-fixture-or-the-set-uptear-down-function) entry.
|
||||
1. If needed, define subroutines for your tests to share.
|
||||
|
||||
When using a fixture, use `TEST_F()` instead of `TEST()` as it allows you to
|
||||
access objects and subroutines in the test fixture:
|
||||
```
|
||||
TEST_F(test_case_name, test_name) {
|
||||
... test body ...
|
||||
|
||||
```c++
|
||||
TEST_F(TestCaseName, TestName) {
|
||||
... test body ...
|
||||
}
|
||||
```
|
||||
|
||||
Like `TEST()`, the first argument is the test case name, but for `TEST_F()`
|
||||
this must be the name of the test fixture class. You've probably guessed: `_F`
|
||||
is for fixture.
|
||||
Like `TEST()`, the first argument is the test case name, but for `TEST_F()` this
|
||||
must be the name of the test fixture class. You've probably guessed: `_F` is for
|
||||
fixture.
|
||||
|
||||
Unfortunately, the C++ macro system does not allow us to create a single macro
|
||||
that can handle both types of tests. Using the wrong macro causes a compiler
|
||||
@ -313,22 +341,24 @@ Also, you must first define a test fixture class before using it in a
|
||||
`TEST_F()`, or you'll get the compiler error "`virtual outside class
|
||||
declaration`".
|
||||
|
||||
For each test defined with `TEST_F()`, Google Test will:
|
||||
1. Create a _fresh_ test fixture at runtime
|
||||
1. Immediately initialize it via `SetUp()`
|
||||
1. Run the test
|
||||
1. Clean up by calling `TearDown()`
|
||||
1. Delete the test fixture. Note that different tests in the same test case have different test fixture objects, and Google Test always deletes a test fixture before it creates the next one. Google Test does not reuse the same test fixture for multiple tests. Any changes one test makes to the fixture do not affect other tests.
|
||||
For each test defined with `TEST_F()` , googletest will create a *fresh* test
|
||||
fixture at runtime, immediately initialize it via `SetUp()` , run the test,
|
||||
clean up by calling `TearDown()` , and then delete the test fixture. Note that
|
||||
different tests in the same test case have different test fixture objects, and
|
||||
googletest always deletes a test fixture before it creates the next one.
|
||||
googletest does **not** reuse the same test fixture for multiple tests. Any
|
||||
changes one test makes to the fixture do not affect other tests.
|
||||
|
||||
As an example, let's write tests for a FIFO queue class named `Queue`, which
|
||||
has the following interface:
|
||||
```
|
||||
template <typename E> // E is the element type.
|
||||
As an example, let's write tests for a FIFO queue class named `Queue`, which has
|
||||
the following interface:
|
||||
|
||||
```c++
|
||||
template <typename E> // E is the element type.
|
||||
class Queue {
|
||||
public:
|
||||
Queue();
|
||||
void Enqueue(const E& element);
|
||||
E* Dequeue(); // Returns NULL if the queue is empty.
|
||||
E* Dequeue(); // Returns NULL if the queue is empty.
|
||||
size_t size() const;
|
||||
...
|
||||
};
|
||||
@ -336,16 +366,17 @@ class Queue {
|
||||
|
||||
First, define a fixture class. By convention, you should give it the name
|
||||
`FooTest` where `Foo` is the class being tested.
|
||||
```
|
||||
|
||||
```c++
|
||||
class QueueTest : public ::testing::Test {
|
||||
protected:
|
||||
virtual void SetUp() {
|
||||
q1_.Enqueue(1);
|
||||
q2_.Enqueue(2);
|
||||
q2_.Enqueue(3);
|
||||
void SetUp() override {
|
||||
q1_.Enqueue(1);
|
||||
q2_.Enqueue(2);
|
||||
q2_.Enqueue(3);
|
||||
}
|
||||
|
||||
// virtual void TearDown() {}
|
||||
// void TearDown() override {}
|
||||
|
||||
Queue<int> q0_;
|
||||
Queue<int> q1_;
|
||||
@ -357,85 +388,102 @@ In this case, `TearDown()` is not needed since we don't have to clean up after
|
||||
each test, other than what's already done by the destructor.
|
||||
|
||||
Now we'll write tests using `TEST_F()` and this fixture.
|
||||
```
|
||||
|
||||
```c++
|
||||
TEST_F(QueueTest, IsEmptyInitially) {
|
||||
EXPECT_EQ(0, q0_.size());
|
||||
EXPECT_EQ(q0_.size(), 0);
|
||||
}
|
||||
|
||||
TEST_F(QueueTest, DequeueWorks) {
|
||||
int* n = q0_.Dequeue();
|
||||
EXPECT_EQ(NULL, n);
|
||||
EXPECT_EQ(n, nullptr);
|
||||
|
||||
n = q1_.Dequeue();
|
||||
ASSERT_TRUE(n != NULL);
|
||||
EXPECT_EQ(1, *n);
|
||||
EXPECT_EQ(0, q1_.size());
|
||||
ASSERT_NE(n, nullptr);
|
||||
EXPECT_EQ(*n, 1);
|
||||
EXPECT_EQ(q1_.size(), 0);
|
||||
delete n;
|
||||
|
||||
n = q2_.Dequeue();
|
||||
ASSERT_TRUE(n != NULL);
|
||||
EXPECT_EQ(2, *n);
|
||||
EXPECT_EQ(1, q2_.size());
|
||||
ASSERT_NE(n, nullptr);
|
||||
EXPECT_EQ(*n, 2);
|
||||
EXPECT_EQ(q2_.size(), 1);
|
||||
delete n;
|
||||
}
|
||||
```
|
||||
|
||||
The above uses both `ASSERT_*` and `EXPECT_*` assertions. The rule of thumb is
|
||||
to use `EXPECT_*` when you want the test to continue to reveal more errors
|
||||
after the assertion failure, and use `ASSERT_*` when continuing after failure
|
||||
doesn't make sense. For example, the second assertion in the `Dequeue` test is
|
||||
`ASSERT_TRUE(n != NULL)`, as we need to dereference the pointer `n` later,
|
||||
which would lead to a segfault when `n` is `NULL`.
|
||||
to use `EXPECT_*` when you want the test to continue to reveal more errors after
|
||||
the assertion failure, and use `ASSERT_*` when continuing after failure doesn't
|
||||
make sense. For example, the second assertion in the `Dequeue` test is
|
||||
=ASSERT_NE(nullptr, n)=, as we need to dereference the pointer `n` later, which
|
||||
would lead to a segfault when `n` is `NULL`.
|
||||
|
||||
When these tests run, the following happens:
|
||||
1. Google Test constructs a `QueueTest` object (let's call it `t1` ).
|
||||
1. `t1.SetUp()` initializes `t1` .
|
||||
1. The first test ( `IsEmptyInitially` ) runs on `t1` .
|
||||
1. `t1.TearDown()` cleans up after the test finishes.
|
||||
1. `t1` is destructed.
|
||||
1. The above steps are repeated on another `QueueTest` object, this time running the `DequeueWorks` test.
|
||||
|
||||
_Availability_: Linux, Windows, Mac.
|
||||
1. googletest constructs a `QueueTest` object (let's call it `t1` ).
|
||||
1. `t1.SetUp()` initializes `t1` .
|
||||
1. The first test ( `IsEmptyInitially` ) runs on `t1` .
|
||||
1. `t1.TearDown()` cleans up after the test finishes.
|
||||
1. `t1` is destructed.
|
||||
1. The above steps are repeated on another `QueueTest` object, this time
|
||||
running the `DequeueWorks` test.
|
||||
|
||||
_Note_: Google Test automatically saves all _Google Test_ flags when a test
|
||||
object is constructed, and restores them when it is destructed.
|
||||
**Availability**: Linux, Windows, Mac.
|
||||
|
||||
# Invoking the Tests #
|
||||
|
||||
`TEST()` and `TEST_F()` implicitly register their tests with Google Test. So, unlike with many other C++ testing frameworks, you don't have to re-list all your defined tests in order to run them.
|
||||
## Invoking the Tests
|
||||
|
||||
After defining your tests, you can run them with `RUN_ALL_TESTS()` , which returns `0` if all the tests are successful, or `1` otherwise. Note that `RUN_ALL_TESTS()` runs _all tests_ in your link unit -- they can be from different test cases, or even different source files.
|
||||
`TEST()` and `TEST_F()` implicitly register their tests with googletest. So,
|
||||
unlike with many other C++ testing frameworks, you don't have to re-list all
|
||||
your defined tests in order to run them.
|
||||
|
||||
After defining your tests, you can run them with `RUN_ALL_TESTS()` , which
|
||||
returns `0` if all the tests are successful, or `1` otherwise. Note that
|
||||
`RUN_ALL_TESTS()` runs *all tests* in your link unit -- they can be from
|
||||
different test cases, or even different source files.
|
||||
|
||||
When invoked, the `RUN_ALL_TESTS()` macro:
|
||||
1. Saves the state of all Google Test flags.
|
||||
1. Creates a test fixture object for the first test.
|
||||
1. Initializes it via `SetUp()`.
|
||||
1. Runs the test on the fixture object.
|
||||
1. Cleans up the fixture via `TearDown()`.
|
||||
1. Deletes the fixture.
|
||||
1. Restores the state of all Google Test flags.
|
||||
1. Repeats the above steps for the next test, until all tests have run.
|
||||
|
||||
In addition, if the test fixture's constructor generates a fatal failure in
|
||||
step 2, there is no point for step 3 - 5 and they are thus skipped. Similarly,
|
||||
if step 3 generates a fatal failure, step 4 will be skipped.
|
||||
1. Saves the state of all googletest flags
|
||||
|
||||
_Important_: You must not ignore the return value of `RUN_ALL_TESTS()`, or `gcc`
|
||||
will give you a compiler error. The rationale for this design is that the
|
||||
automated testing service determines whether a test has passed based on its
|
||||
exit code, not on its stdout/stderr output; thus your `main()` function must
|
||||
return the value of `RUN_ALL_TESTS()`.
|
||||
* Creates a test fixture object for the first test.
|
||||
|
||||
Also, you should call `RUN_ALL_TESTS()` only **once**. Calling it more than once
|
||||
conflicts with some advanced Google Test features (e.g. thread-safe death
|
||||
tests) and thus is not supported.
|
||||
* Initializes it via `SetUp()`.
|
||||
|
||||
_Availability_: Linux, Windows, Mac.
|
||||
* Runs the test on the fixture object.
|
||||
|
||||
# Writing the main() Function #
|
||||
* Cleans up the fixture via `TearDown()`.
|
||||
|
||||
* Deletes the fixture.
|
||||
|
||||
* Restores the state of all googletest flags
|
||||
|
||||
* Repeats the above steps for the next test, until all tests have run.
|
||||
|
||||
If a fatal failure happens the subsequent steps will be skipped.
|
||||
|
||||
> IMPORTANT: You must **not** ignore the return value of `RUN_ALL_TESTS()`, or
|
||||
> you will get a compiler error. The rationale for this design is that the
|
||||
> automated testing service determines whether a test has passed based on its
|
||||
> exit code, not on its stdout/stderr output; thus your `main()` function must
|
||||
> return the value of `RUN_ALL_TESTS()`.
|
||||
>
|
||||
> Also, you should call `RUN_ALL_TESTS()` only **once**. Calling it more than
|
||||
> once conflicts with some advanced googletest features (e.g. thread-safe [death
|
||||
> tests](advanced#death-tests)) and thus is not supported.
|
||||
|
||||
**Availability**: Linux, Windows, Mac.
|
||||
|
||||
## Writing the main() Function
|
||||
|
||||
In `google3`, the simplest approach is to use the default main() function
|
||||
provided by linking in `"//testing/base/public:gtest_main"`. If that doesn't
|
||||
cover what you need, you should write your own main() function, which should
|
||||
return the value of `RUN_ALL_TESTS()`. Link to `"//testing/base/public:gunit"`.
|
||||
You can start from this boilerplate:
|
||||
```
|
||||
|
||||
```c++
|
||||
#include "this/package/foo.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
@ -448,24 +496,24 @@ class FooTest : public ::testing::Test {
|
||||
// is empty.
|
||||
|
||||
FooTest() {
|
||||
// You can do set-up work for each test here.
|
||||
// You can do set-up work for each test here.
|
||||
}
|
||||
|
||||
virtual ~FooTest() {
|
||||
// You can do clean-up work that doesn't throw exceptions here.
|
||||
~FooTest() override {
|
||||
// You can do clean-up work that doesn't throw exceptions here.
|
||||
}
|
||||
|
||||
// If the constructor and destructor are not enough for setting up
|
||||
// and cleaning up each test, you can define the following methods:
|
||||
|
||||
virtual void SetUp() {
|
||||
// Code here will be called immediately after the constructor (right
|
||||
// before each test).
|
||||
void SetUp() override {
|
||||
// Code here will be called immediately after the constructor (right
|
||||
// before each test).
|
||||
}
|
||||
|
||||
virtual void TearDown() {
|
||||
// Code here will be called immediately after each test (right
|
||||
// before the destructor).
|
||||
void TearDown() override {
|
||||
// Code here will be called immediately after each test (right
|
||||
// before the destructor).
|
||||
}
|
||||
|
||||
// Objects declared here can be used by all tests in the test case for Foo.
|
||||
@ -473,10 +521,10 @@ class FooTest : public ::testing::Test {
|
||||
|
||||
// Tests that the Foo::Bar() method does Abc.
|
||||
TEST_F(FooTest, MethodBarDoesAbc) {
|
||||
const string input_filepath = "this/package/testdata/myinputfile.dat";
|
||||
const string output_filepath = "this/package/testdata/myoutputfile.dat";
|
||||
const std::string input_filepath = "this/package/testdata/myinputfile.dat";
|
||||
const std::string output_filepath = "this/package/testdata/myoutputfile.dat";
|
||||
Foo f;
|
||||
EXPECT_EQ(0, f.Bar(input_filepath, output_filepath));
|
||||
EXPECT_EQ(f.Bar(input_filepath, output_filepath), 0);
|
||||
}
|
||||
|
||||
// Tests that Foo does Xyz.
|
||||
@ -492,45 +540,30 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
```
|
||||
|
||||
The `::testing::InitGoogleTest()` function parses the command line for Google
|
||||
Test flags, and removes all recognized flags. This allows the user to control a
|
||||
test program's behavior via various flags, which we'll cover in [AdvancedGuide](advanced.md).
|
||||
You must call this function before calling `RUN_ALL_TESTS()`, or the flags
|
||||
won't be properly initialized.
|
||||
|
||||
The `::testing::InitGoogleTest()` function parses the command line for
|
||||
googletest flags, and removes all recognized flags. This allows the user to
|
||||
control a test program's behavior via various flags, which we'll cover in
|
||||
[AdvancedGuide](advanced.md). You **must** call this function before calling
|
||||
`RUN_ALL_TESTS()`, or the flags won't be properly initialized.
|
||||
|
||||
On Windows, `InitGoogleTest()` also works with wide strings, so it can be used
|
||||
in programs compiled in `UNICODE` mode as well.
|
||||
|
||||
But maybe you think that writing all those main() functions is too much work? We agree with you completely and that's why Google Test provides a basic implementation of main(). If it fits your needs, then just link your test with gtest\_main library and you are good to go.
|
||||
But maybe you think that writing all those main() functions is too much work? We
|
||||
agree with you completely and that's why Google Test provides a basic
|
||||
implementation of main(). If it fits your needs, then just link your test with
|
||||
gtest\_main library and you are good to go.
|
||||
|
||||
## Important note for Visual C++ users ##
|
||||
If you put your tests into a library and your `main()` function is in a different library or in your .exe file, those tests will not run. The reason is a [bug](https://connect.microsoft.com/feedback/viewfeedback.aspx?FeedbackID=244410&siteid=210) in Visual C++. When you define your tests, Google Test creates certain static objects to register them. These objects are not referenced from elsewhere but their constructors are still supposed to run. When Visual C++ linker sees that nothing in the library is referenced from other places it throws the library out. You have to reference your library with tests from your main program to keep the linker from discarding it. Here is how to do it. Somewhere in your library code declare a function:
|
||||
```
|
||||
__declspec(dllexport) int PullInMyLibrary() { return 0; }
|
||||
```
|
||||
If you put your tests in a static library (not DLL) then `__declspec(dllexport)` is not required. Now, in your main program, write a code that invokes that function:
|
||||
```
|
||||
int PullInMyLibrary();
|
||||
static int dummy = PullInMyLibrary();
|
||||
```
|
||||
This will keep your tests referenced and will make them register themselves at startup.
|
||||
NOTE: `ParseGUnitFlags()` is deprecated in favor of `InitGoogleTest()`.
|
||||
|
||||
In addition, if you define your tests in a static library, add `/OPT:NOREF` to your main program linker options. If you use MSVC++ IDE, go to your .exe project properties/Configuration Properties/Linker/Optimization and set References setting to `Keep Unreferenced Data (/OPT:NOREF)`. This will keep Visual C++ linker from discarding individual symbols generated by your tests from the final executable.
|
||||
|
||||
There is one more pitfall, though. If you use Google Test as a static library (that's how it is defined in gtest.vcproj) your tests must also reside in a static library. If you have to have them in a DLL, you _must_ change Google Test to build into a DLL as well. Otherwise your tests will not run correctly or will not run at all. The general conclusion here is: make your life easier - do not write your tests in libraries!
|
||||
## Known Limitations
|
||||
|
||||
# Where to Go from Here #
|
||||
|
||||
Congratulations! You've learned the Google Test basics. You can start writing
|
||||
and running Google Test tests, read some [samples](samples.md), or continue with
|
||||
[AdvancedGuide](advanced.md), which describes many more useful Google Test features.
|
||||
|
||||
# Known Limitations #
|
||||
|
||||
Google Test is designed to be thread-safe. The implementation is
|
||||
thread-safe on systems where the `pthreads` library is available. It
|
||||
is currently _unsafe_ to use Google Test assertions from two threads
|
||||
concurrently on other systems (e.g. Windows). In most tests this is
|
||||
not an issue as usually the assertions are done in the main thread. If
|
||||
you want to help, you can volunteer to implement the necessary
|
||||
synchronization primitives in `gtest-port.h` for your platform.
|
||||
* Google Test is designed to be thread-safe. The implementation is thread-safe
|
||||
on systems where the `pthreads` library is available. It is currently
|
||||
_unsafe_ to use Google Test assertions from two threads concurrently on
|
||||
other systems (e.g. Windows). In most tests this is not an issue as usually
|
||||
the assertions are done in the main thread. If you want to help, you can
|
||||
volunteer to implement the necessary synchronization primitives in
|
||||
`gtest-port.h` for your platform.
|
||||
|
@ -1,14 +1,22 @@
|
||||
If you're like us, you'd like to look at some Google Test sample code. The
|
||||
[samples folder](../samples) has a number of well-commented samples showing how to use a
|
||||
variety of Google Test features.
|
||||
# Googletest Samples {#samples}
|
||||
|
||||
* [Sample #1](../samples/sample1_unittest.cc) shows the basic steps of using Google Test to test C++ functions.
|
||||
* [Sample #2](../samples/sample2_unittest.cc) shows a more complex unit test for a class with multiple member functions.
|
||||
* [Sample #3](../samples/sample3_unittest.cc) uses a test fixture.
|
||||
* [Sample #4](../samples/sample4_unittest.cc) is another basic example of using Google Test.
|
||||
* [Sample #5](../samples/sample5_unittest.cc) teaches how to reuse a test fixture in multiple test cases by deriving sub-fixtures from it.
|
||||
* [Sample #6](../samples/sample6_unittest.cc) demonstrates type-parameterized tests.
|
||||
* [Sample #7](../samples/sample7_unittest.cc) teaches the basics of value-parameterized tests.
|
||||
* [Sample #8](../samples/sample8_unittest.cc) shows using `Combine()` in value-parameterized tests.
|
||||
* [Sample #9](../samples/sample9_unittest.cc) shows use of the listener API to modify Google Test's console output and the use of its reflection API to inspect test results.
|
||||
* [Sample #10](../samples/sample10_unittest.cc) shows use of the listener API to implement a primitive memory leak checker.
|
||||
If you're like us, you'd like to look at [googletest
|
||||
samples.](https://github.com/google/googletest/tree/master/googletest/samples)
|
||||
The sample directory has a number of well-commented samples showing how to use a
|
||||
variety of googletest features.
|
||||
|
||||
* Sample #1 shows the basic steps of using googletest to test C++ functions.
|
||||
* Sample #2 shows a more complex unit test for a class with multiple member
|
||||
functions.
|
||||
* Sample #3 uses a test fixture.
|
||||
* Sample #4 teaches you how to use googletest and `googletest.h` together to
|
||||
get the best of both libraries.
|
||||
* Sample #5 puts shared testing logic in a base test fixture, and reuses it in
|
||||
derived fixtures.
|
||||
* Sample #6 demonstrates type-parameterized tests.
|
||||
* Sample #7 teaches the basics of value-parameterized tests.
|
||||
* Sample #8 shows using `Combine()` in value-parameterized tests.
|
||||
* Sample #9 shows use of the listener API to modify Google Test's console
|
||||
output and the use of its reflection API to inspect test results.
|
||||
* Sample #10 shows use of the listener API to implement a primitive memory
|
||||
leak checker.
|
||||
|
@ -26,14 +26,14 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
//
|
||||
// The Google C++ Testing and Mocking Framework (Google Test)
|
||||
//
|
||||
// This header file defines the public API for death tests. It is
|
||||
// #included by gtest.h so a user doesn't need to include this
|
||||
// directly.
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
|
||||
#define GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
|
||||
@ -99,6 +99,7 @@ GTEST_API_ bool InDeathTestChild();
|
||||
//
|
||||
// On the regular expressions used in death tests:
|
||||
//
|
||||
// GOOGLETEST_CM0005 DO NOT DELETE
|
||||
// On POSIX-compliant systems (*nix), we use the <regex.h> library,
|
||||
// which uses the POSIX extended regex syntax.
|
||||
//
|
||||
@ -160,7 +161,7 @@ GTEST_API_ bool InDeathTestChild();
|
||||
// is rarely a problem as people usually don't put the test binary
|
||||
// directory in PATH.
|
||||
//
|
||||
// TODO(wan@google.com): make thread-safe death tests search the PATH.
|
||||
// FIXME: make thread-safe death tests search the PATH.
|
||||
|
||||
// Asserts that a given statement causes the program to exit, with an
|
||||
// integer exit status that satisfies predicate, and emitting error output
|
||||
@ -201,6 +202,7 @@ class GTEST_API_ ExitedWithCode {
|
||||
# if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA
|
||||
// Tests that an exit code describes an exit due to termination by a
|
||||
// given signal.
|
||||
// GOOGLETEST_CM0006 DO NOT DELETE
|
||||
class GTEST_API_ KilledBySignal {
|
||||
public:
|
||||
explicit KilledBySignal(int signum);
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
//
|
||||
// The Google C++ Testing and Mocking Framework (Google Test)
|
||||
//
|
||||
@ -43,6 +42,8 @@
|
||||
// to CHANGE WITHOUT NOTICE. Therefore DO NOT DEPEND ON IT in a user
|
||||
// program!
|
||||
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
|
||||
#define GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
|
||||
|
||||
|
@ -31,13 +31,12 @@
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Authors: vladl@google.com (Vlad Losev)
|
||||
//
|
||||
// Macros and functions for implementing parameterized tests
|
||||
// in Google C++ Testing and Mocking Framework (Google Test)
|
||||
//
|
||||
// This file is generated by a SCRIPT. DO NOT EDIT BY HAND!
|
||||
//
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
|
||||
#define GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
|
||||
|
@ -30,13 +30,12 @@ $var maxtuple = 10 $$ Maximum number of Combine arguments we want to support.
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Authors: vladl@google.com (Vlad Losev)
|
||||
//
|
||||
// Macros and functions for implementing parameterized tests
|
||||
// in Google C++ Testing and Mocking Framework (Google Test)
|
||||
//
|
||||
// This file is generated by a SCRIPT. DO NOT EDIT BY HAND!
|
||||
//
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
#ifndef GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
|
||||
#define GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
|
||||
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Google Test - The Google C++ Testing and Mocking Framework
|
||||
//
|
||||
@ -96,6 +95,8 @@
|
||||
// being defined as many user-defined container types don't have
|
||||
// value_type.
|
||||
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
|
||||
#define GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_
|
||||
|
||||
@ -114,6 +115,7 @@
|
||||
#if GTEST_HAS_ABSL
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "absl/types/variant.h"
|
||||
#endif // GTEST_HAS_ABSL
|
||||
|
||||
namespace testing {
|
||||
@ -787,6 +789,28 @@ class UniversalPrinter<::absl::optional<T>> {
|
||||
}
|
||||
};
|
||||
|
||||
// Printer for absl::variant
|
||||
|
||||
template <typename... T>
|
||||
class UniversalPrinter<::absl::variant<T...>> {
|
||||
public:
|
||||
static void Print(const ::absl::variant<T...>& value, ::std::ostream* os) {
|
||||
*os << '(';
|
||||
absl::visit(Visitor{os}, value);
|
||||
*os << ')';
|
||||
}
|
||||
|
||||
private:
|
||||
struct Visitor {
|
||||
template <typename U>
|
||||
void operator()(const U& u) const {
|
||||
*os << "'" << GetTypeName<U>() << "' with value ";
|
||||
UniversalPrint(u, os);
|
||||
}
|
||||
::std::ostream* os;
|
||||
};
|
||||
};
|
||||
|
||||
#endif // GTEST_HAS_ABSL
|
||||
|
||||
// UniversalPrintArray(begin, len, os) prints an array of 'len'
|
||||
@ -802,7 +826,7 @@ void UniversalPrintArray(const T* begin, size_t len, ::std::ostream* os) {
|
||||
// If the array has more than kThreshold elements, we'll have to
|
||||
// omit some details by printing only the first and the last
|
||||
// kChunkSize elements.
|
||||
// TODO(wan@google.com): let the user control the threshold using a flag.
|
||||
// FIXME: let the user control the threshold using a flag.
|
||||
if (len <= kThreshold) {
|
||||
PrintRawArrayTo(begin, len, os);
|
||||
} else {
|
||||
|
@ -26,12 +26,13 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
//
|
||||
// Utilities for testing Google Test itself and code that uses Google Test
|
||||
// (e.g. frameworks built on top of Google Test).
|
||||
|
||||
// GOOGLETEST_CM0004 DO NOT DELETE
|
||||
|
||||
#ifndef GTEST_INCLUDE_GTEST_GTEST_SPI_H_
|
||||
#define GTEST_INCLUDE_GTEST_GTEST_SPI_H_
|
||||
|
||||
|
@ -27,8 +27,7 @@
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: mheule@google.com (Markus Heule)
|
||||
//
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
|
||||
#define GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_
|
||||
|
@ -26,8 +26,9 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
|
||||
#define GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
|
||||
|
@ -26,8 +26,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
//
|
||||
// The Google C++ Testing and Mocking Framework (Google Test)
|
||||
//
|
||||
@ -48,6 +47,8 @@
|
||||
// registration from Barthelemy Dagenais' (barthelemy@prologique.com)
|
||||
// easyUnit framework.
|
||||
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GTEST_INCLUDE_GTEST_GTEST_H_
|
||||
#define GTEST_INCLUDE_GTEST_GTEST_H_
|
||||
|
||||
@ -314,7 +315,7 @@ class GTEST_API_ AssertionResult {
|
||||
const char* message() const {
|
||||
return message_.get() != NULL ? message_->c_str() : "";
|
||||
}
|
||||
// TODO(vladl@google.com): Remove this after making sure no clients use it.
|
||||
// FIXME: Remove this after making sure no clients use it.
|
||||
// Deprecated; please use message() instead.
|
||||
const char* failure_message() const { return message(); }
|
||||
|
||||
@ -620,7 +621,7 @@ class GTEST_API_ TestResult {
|
||||
|
||||
// Adds a failure if the key is a reserved attribute of Google Test
|
||||
// testcase tags. Returns true if the property is valid.
|
||||
// TODO(russr): Validate attribute names are legal and human readable.
|
||||
// FIXME: Validate attribute names are legal and human readable.
|
||||
static bool ValidateTestProperty(const std::string& xml_element,
|
||||
const TestProperty& test_property);
|
||||
|
||||
|
@ -32,6 +32,8 @@
|
||||
//
|
||||
// Implements a family of generic predicate assertion macros.
|
||||
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
|
||||
#define GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_
|
||||
|
||||
|
@ -26,10 +26,10 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
//
|
||||
// Google C++ Testing and Mocking Framework definitions useful in production code.
|
||||
// GOOGLETEST_CM0003 DO NOT DELETE
|
||||
|
||||
#ifndef GTEST_INCLUDE_GTEST_GTEST_PROD_H_
|
||||
#define GTEST_INCLUDE_GTEST_GTEST_PROD_H_
|
||||
|
56
googletest/include/gtest/internal/custom/README.md
Normal file
56
googletest/include/gtest/internal/custom/README.md
Normal file
@ -0,0 +1,56 @@
|
||||
# Customization Points
|
||||
|
||||
The custom directory is an injection point for custom user configurations.
|
||||
|
||||
## Header `gtest.h`
|
||||
|
||||
### The following macros can be defined:
|
||||
|
||||
* `GTEST_OS_STACK_TRACE_GETTER_` - The name of an implementation of
|
||||
`OsStackTraceGetterInterface`.
|
||||
* `GTEST_CUSTOM_TEMPDIR_FUNCTION_` - An override for `testing::TempDir()`. See
|
||||
`testing::TempDir` for semantics and signature.
|
||||
|
||||
## Header `gtest-port.h`
|
||||
|
||||
The following macros can be defined:
|
||||
|
||||
### Flag related macros:
|
||||
|
||||
* `GTEST_FLAG(flag_name)`
|
||||
* `GTEST_USE_OWN_FLAGFILE_FLAG_` - Define to 0 when the system provides its
|
||||
own flagfile flag parsing.
|
||||
* `GTEST_DECLARE_bool_(name)`
|
||||
* `GTEST_DECLARE_int32_(name)`
|
||||
* `GTEST_DECLARE_string_(name)`
|
||||
* `GTEST_DEFINE_bool_(name, default_val, doc)`
|
||||
* `GTEST_DEFINE_int32_(name, default_val, doc)`
|
||||
* `GTEST_DEFINE_string_(name, default_val, doc)`
|
||||
|
||||
### Logging:
|
||||
|
||||
* `GTEST_LOG_(severity)`
|
||||
* `GTEST_CHECK_(condition)`
|
||||
* Functions `LogToStderr()` and `FlushInfoLog()` have to be provided too.
|
||||
|
||||
### Threading:
|
||||
|
||||
* `GTEST_HAS_NOTIFICATION_` - Enabled if Notification is already provided.
|
||||
* `GTEST_HAS_MUTEX_AND_THREAD_LOCAL_` - Enabled if `Mutex` and `ThreadLocal`
|
||||
are already provided. Must also provide `GTEST_DECLARE_STATIC_MUTEX_(mutex)`
|
||||
and `GTEST_DEFINE_STATIC_MUTEX_(mutex)`
|
||||
* `GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)`
|
||||
* `GTEST_LOCK_EXCLUDED_(locks)`
|
||||
|
||||
### Underlying library support features
|
||||
|
||||
* `GTEST_HAS_CXXABI_H_`
|
||||
|
||||
### Exporting API symbols:
|
||||
|
||||
* `GTEST_API_` - Specifier for exported symbols.
|
||||
|
||||
## Header `gtest-printers.h`
|
||||
|
||||
* See documentation at `gtest/gtest-printers.h` for details on how to define a
|
||||
custom printer.
|
@ -27,40 +27,7 @@
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Injection point for custom user configurations.
|
||||
// The following macros can be defined:
|
||||
//
|
||||
// Flag related macros:
|
||||
// GTEST_FLAG(flag_name)
|
||||
// GTEST_USE_OWN_FLAGFILE_FLAG_ - Define to 0 when the system provides its
|
||||
// own flagfile flag parsing.
|
||||
// GTEST_DECLARE_bool_(name)
|
||||
// GTEST_DECLARE_int32_(name)
|
||||
// GTEST_DECLARE_string_(name)
|
||||
// GTEST_DEFINE_bool_(name, default_val, doc)
|
||||
// GTEST_DEFINE_int32_(name, default_val, doc)
|
||||
// GTEST_DEFINE_string_(name, default_val, doc)
|
||||
//
|
||||
// Logging:
|
||||
// GTEST_LOG_(severity)
|
||||
// GTEST_CHECK_(condition)
|
||||
// Functions LogToStderr() and FlushInfoLog() have to be provided too.
|
||||
//
|
||||
// Threading:
|
||||
// GTEST_HAS_NOTIFICATION_ - Enabled if Notification is already provided.
|
||||
// GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ - Enabled if Mutex and ThreadLocal are
|
||||
// already provided.
|
||||
// Must also provide GTEST_DECLARE_STATIC_MUTEX_(mutex) and
|
||||
// GTEST_DEFINE_STATIC_MUTEX_(mutex)
|
||||
//
|
||||
// GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)
|
||||
// GTEST_LOCK_EXCLUDED_(locks)
|
||||
//
|
||||
// Underlying library support features:
|
||||
// GTEST_HAS_CXXABI_H_
|
||||
//
|
||||
// Exporting API symbols:
|
||||
// GTEST_API_ - Specifier for exported symbols.
|
||||
// Injection point for custom user configurations. See README for details
|
||||
//
|
||||
// ** Custom implementation starts here **
|
||||
|
||||
|
@ -31,8 +31,8 @@
|
||||
// installation of gTest.
|
||||
// It will be included from gtest-printers.h and the overrides in this file
|
||||
// will be visible to everyone.
|
||||
// See documentation at gtest/gtest-printers.h for details on how to define a
|
||||
// custom printer.
|
||||
//
|
||||
// Injection point for custom user configurations. See README for details
|
||||
//
|
||||
// ** Custom implementation starts here **
|
||||
|
||||
|
@ -27,15 +27,7 @@
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Injection point for custom user configurations.
|
||||
// The following macros can be defined:
|
||||
//
|
||||
// GTEST_OS_STACK_TRACE_GETTER_ - The name of an implementation of
|
||||
// OsStackTraceGetterInterface.
|
||||
//
|
||||
// GTEST_CUSTOM_TEMPDIR_FUNCTION_ - An override for testing::TempDir().
|
||||
// See testing::TempDir for semantics and
|
||||
// signature.
|
||||
// Injection point for custom user configurations. See README for details
|
||||
//
|
||||
// ** Custom implementation starts here **
|
||||
|
||||
|
@ -27,11 +27,11 @@
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//
|
||||
// The Google C++ Testing and Mocking Framework (Google Test)
|
||||
//
|
||||
// This header file defines internal utilities needed for implementing
|
||||
// death tests. They are subject to change without notice.
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
|
||||
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
|
||||
|
@ -27,7 +27,6 @@
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//
|
||||
// Google Test filepath utilities
|
||||
//
|
||||
// This header file declares classes and functions used internally by
|
||||
@ -36,6 +35,8 @@
|
||||
// This file is #included in gtest/internal/gtest-internal.h.
|
||||
// Do not include this header file separately!
|
||||
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
|
||||
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
|
||||
|
||||
|
@ -27,12 +27,13 @@
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//
|
||||
// The Google C++ Testing and Mocking Framework (Google Test)
|
||||
//
|
||||
// This header file declares functions and macros used internally by
|
||||
// Google Test. They are subject to change without notice.
|
||||
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
|
||||
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
|
||||
|
||||
|
@ -27,8 +27,6 @@
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Authors: Dan Egnor (egnor@google.com)
|
||||
//
|
||||
// A "smart" pointer type with reference tracking. Every pointer to a
|
||||
// particular object is kept on a circular linked list. When the last pointer
|
||||
// to an object is destroyed or reassigned, the object is deleted.
|
||||
@ -62,9 +60,11 @@
|
||||
// raw pointer (e.g. via get()) concurrently, and
|
||||
// - it's safe to write to two linked_ptrs that point to the same
|
||||
// shared object concurrently.
|
||||
// TODO(wan@google.com): rename this to safe_linked_ptr to avoid
|
||||
// FIXME: rename this to safe_linked_ptr to avoid
|
||||
// confusion with normal linked_ptr.
|
||||
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_LINKED_PTR_H_
|
||||
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_LINKED_PTR_H_
|
||||
|
||||
|
@ -30,8 +30,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: vladl@google.com (Vlad Losev)
|
||||
|
||||
|
||||
// Type and function utilities for implementing parameterized tests.
|
||||
// This file is generated by a SCRIPT. DO NOT EDIT BY HAND!
|
||||
@ -43,6 +42,8 @@
|
||||
// by the maximum arity of the implementation of tuple which is
|
||||
// currently set at 10.
|
||||
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
|
||||
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
|
||||
|
||||
|
@ -29,8 +29,7 @@ $var maxtuple = 10 $$ Maximum number of Combine arguments we want to support.
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: vladl@google.com (Vlad Losev)
|
||||
|
||||
|
||||
// Type and function utilities for implementing parameterized tests.
|
||||
// This file is generated by a SCRIPT. DO NOT EDIT BY HAND!
|
||||
@ -42,6 +41,8 @@ $var maxtuple = 10 $$ Maximum number of Combine arguments we want to support.
|
||||
// by the maximum arity of the implementation of tuple which is
|
||||
// currently set at $maxtuple.
|
||||
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
|
||||
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_
|
||||
|
||||
|
@ -26,11 +26,12 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: vladl@google.com (Vlad Losev)
|
||||
|
||||
|
||||
// Type and function utilities for implementing parameterized tests.
|
||||
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
|
||||
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_
|
||||
|
||||
|
@ -27,8 +27,6 @@
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Authors: wan@google.com (Zhanyong Wan)
|
||||
//
|
||||
// Low-level types and utilities for porting Google Test to various
|
||||
// platforms. All macros ending with _ and symbols defined in an
|
||||
// internal namespace are subject to change without notice. Code
|
||||
@ -40,6 +38,8 @@
|
||||
// files are expected to #include this. Therefore, it cannot #include
|
||||
// any other Google Test header.
|
||||
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
|
||||
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
|
||||
|
||||
@ -178,6 +178,7 @@
|
||||
// GTEST_HAS_TYPED_TEST - typed tests
|
||||
// GTEST_HAS_TYPED_TEST_P - type-parameterized tests
|
||||
// GTEST_IS_THREADSAFE - Google Test is thread-safe.
|
||||
// GOOGLETEST_CM0007 DO NOT DELETE
|
||||
// GTEST_USES_POSIX_RE - enhanced POSIX regex is used. Do not confuse with
|
||||
// GTEST_HAS_POSIX_RE (see above) which users can
|
||||
// define themselves.
|
||||
@ -229,6 +230,7 @@
|
||||
// Regular expressions:
|
||||
// RE - a simple regular expression class using the POSIX
|
||||
// Extended Regular Expression syntax on UNIX-like platforms
|
||||
// GOOGLETEST_CM0008 DO NOT DELETE
|
||||
// or a reduced regular exception syntax on other
|
||||
// platforms, including Windows.
|
||||
// Logging:
|
||||
@ -313,7 +315,7 @@
|
||||
// GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 4385)
|
||||
// /* code that triggers warnings C4800 and C4385 */
|
||||
// GTEST_DISABLE_MSC_WARNINGS_POP_()
|
||||
#if _MSC_VER >= 1500
|
||||
#if _MSC_VER >= 1400
|
||||
# define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings) \
|
||||
__pragma(warning(push)) \
|
||||
__pragma(warning(disable: warnings))
|
||||
@ -325,6 +327,22 @@
|
||||
# define GTEST_DISABLE_MSC_WARNINGS_POP_()
|
||||
#endif
|
||||
|
||||
// Clang on Windows does not understand MSVC's pragma warning.
|
||||
// We need clang-specific way to disable function deprecation warning.
|
||||
#ifdef __clang__
|
||||
# define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
|
||||
_Pragma("clang diagnostic push") \
|
||||
_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \
|
||||
_Pragma("clang diagnostic ignored \"-Wdeprecated-implementations\"")
|
||||
#define GTEST_DISABLE_MSC_DEPRECATED_POP_() \
|
||||
_Pragma("clang diagnostic pop")
|
||||
#else
|
||||
# define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
|
||||
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
|
||||
# define GTEST_DISABLE_MSC_DEPRECATED_POP_() \
|
||||
GTEST_DISABLE_MSC_WARNINGS_POP_()
|
||||
#endif
|
||||
|
||||
#ifndef GTEST_LANG_CXX11
|
||||
// gcc and clang define __GXX_EXPERIMENTAL_CXX0X__ when
|
||||
// -std={c,gnu}++{0x,11} is passed. The C++11 standard specifies a
|
||||
@ -379,7 +397,8 @@
|
||||
#if GTEST_LANG_CXX11
|
||||
# define GTEST_HAS_STD_TUPLE_ 1
|
||||
# if defined(__clang__)
|
||||
// Inspired by http://clang.llvm.org/docs/LanguageExtensions.html#__has_include
|
||||
// Inspired by
|
||||
// https://clang.llvm.org/docs/LanguageExtensions.html#include-file-checking-macros
|
||||
# if defined(__has_include) && !__has_include(<tuple>)
|
||||
# undef GTEST_HAS_STD_TUPLE_
|
||||
# endif
|
||||
@ -391,7 +410,7 @@
|
||||
# elif defined(__GLIBCXX__)
|
||||
// Inspired by boost/config/stdlib/libstdcpp3.hpp,
|
||||
// http://gcc.gnu.org/gcc-4.2/changes.html and
|
||||
// http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt01ch01.html#manual.intro.status.standard.200x
|
||||
// https://web.archive.org/web/20140227044429/gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt01ch01.html#manual.intro.status.standard.200x
|
||||
# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 2)
|
||||
# undef GTEST_HAS_STD_TUPLE_
|
||||
# endif
|
||||
@ -522,17 +541,13 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||
#endif // !defined(GTEST_HAS_STD_STRING)
|
||||
|
||||
#ifndef GTEST_HAS_GLOBAL_STRING
|
||||
// The user didn't tell us whether ::string is available, so we need
|
||||
// to figure it out.
|
||||
|
||||
# define GTEST_HAS_GLOBAL_STRING 0
|
||||
|
||||
#endif // GTEST_HAS_GLOBAL_STRING
|
||||
|
||||
#ifndef GTEST_HAS_STD_WSTRING
|
||||
// The user didn't tell us whether ::std::wstring is available, so we need
|
||||
// to figure it out.
|
||||
// TODO(wan@google.com): uses autoconf to detect whether ::std::wstring
|
||||
// FIXME: uses autoconf to detect whether ::std::wstring
|
||||
// is available.
|
||||
|
||||
// Cygwin 1.7 and below doesn't support ::std::wstring.
|
||||
@ -744,7 +759,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||
// Until version 4.3.2, gcc has a bug that causes <tr1/functional>,
|
||||
// which is #included by <tr1/tuple>, to not compile when RTTI is
|
||||
// disabled. _TR1_FUNCTIONAL is the header guard for
|
||||
// <tr1/functional>. Hence the following #define is a hack to prevent
|
||||
// <tr1/functional>. Hence the following #define is used to prevent
|
||||
// <tr1/functional> from being included.
|
||||
# define _TR1_FUNCTIONAL 1
|
||||
# include <tr1/tuple>
|
||||
@ -1218,7 +1233,7 @@ class scoped_ptr {
|
||||
// Defines RE.
|
||||
|
||||
#if GTEST_USES_PCRE
|
||||
using ::RE;
|
||||
// if used, PCRE is injected by custom/gtest-port.h
|
||||
#elif GTEST_USES_POSIX_RE || GTEST_USES_SIMPLE_RE
|
||||
|
||||
// A simple C++ wrapper for <regex.h>. It uses the POSIX Extended
|
||||
@ -1249,7 +1264,7 @@ class GTEST_API_ RE {
|
||||
// PartialMatch(str, re) returns true iff regular expression re
|
||||
// matches a substring of str (including str itself).
|
||||
//
|
||||
// TODO(wan@google.com): make FullMatch() and PartialMatch() work
|
||||
// FIXME: make FullMatch() and PartialMatch() work
|
||||
// when str contains NUL characters.
|
||||
static bool FullMatch(const ::std::string& str, const RE& re) {
|
||||
return FullMatch(str.c_str(), re);
|
||||
@ -1276,7 +1291,7 @@ class GTEST_API_ RE {
|
||||
void Init(const char* regex);
|
||||
|
||||
// We use a const char* instead of an std::string, as Google Test used to be
|
||||
// used where std::string is not available. TODO(wan@google.com): change to
|
||||
// used where std::string is not available. FIXME: change to
|
||||
// std::string.
|
||||
const char* pattern_;
|
||||
bool is_valid_;
|
||||
@ -1803,7 +1818,7 @@ class GTEST_API_ Mutex {
|
||||
// Initializes owner_thread_id_ and critical_section_ in static mutexes.
|
||||
void ThreadSafeLazyInit();
|
||||
|
||||
// Per http://blogs.msdn.com/b/oldnewthing/archive/2004/02/23/78395.aspx,
|
||||
// Per https://blogs.msdn.microsoft.com/oldnewthing/20040223-00/?p=40503,
|
||||
// we assume that 0 is an invalid value for thread IDs.
|
||||
unsigned int owner_thread_id_;
|
||||
|
||||
@ -2483,7 +2498,7 @@ inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }
|
||||
|
||||
// Functions deprecated by MSVC 8.0.
|
||||
|
||||
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996 /* deprecated function */)
|
||||
GTEST_DISABLE_MSC_DEPRECATED_PUSH_()
|
||||
|
||||
inline const char* StrNCpy(char* dest, const char* src, size_t n) {
|
||||
return strncpy(dest, src, n);
|
||||
@ -2531,7 +2546,7 @@ inline const char* GetEnv(const char* name) {
|
||||
#endif
|
||||
}
|
||||
|
||||
GTEST_DISABLE_MSC_WARNINGS_POP_()
|
||||
GTEST_DISABLE_MSC_DEPRECATED_POP_()
|
||||
|
||||
#if GTEST_OS_WINDOWS_MOBILE
|
||||
// Windows CE has no C library. The abort() function is used in
|
||||
@ -2669,7 +2684,7 @@ typedef TypeWithSize<8>::Int TimeInMillis; // Represents time in milliseconds.
|
||||
// Parses 'str' for a 32-bit signed integer. If successful, writes the result
|
||||
// to *value and returns true; otherwise leaves *value unchanged and returns
|
||||
// false.
|
||||
// TODO(chandlerc): Find a better way to refactor flag and environment parsing
|
||||
// FIXME: Find a better way to refactor flag and environment parsing
|
||||
// out of both gtest-port.cc and gtest.cc to avoid exporting this utility
|
||||
// function.
|
||||
bool ParseInt32(const Message& src_text, const char* str, Int32* value);
|
||||
|
@ -27,17 +27,17 @@
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//
|
||||
// The Google C++ Testing and Mocking Framework (Google Test)
|
||||
//
|
||||
// This header file declares the String class and functions used internally by
|
||||
// Google Test. They are subject to change without notice. They should not used
|
||||
// by code external to Google Test.
|
||||
//
|
||||
// This header file is #included by
|
||||
// gtest/internal/gtest-internal.h.
|
||||
// This header file is #included by gtest-internal.h.
|
||||
// It should not be #included by other files.
|
||||
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
|
||||
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
|
||||
|
||||
|
@ -30,11 +30,12 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Implements a subset of TR1 tuple needed by Google Test and Google Mock.
|
||||
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
|
||||
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
|
||||
|
||||
@ -42,7 +43,7 @@
|
||||
|
||||
// The compiler used in Symbian has a bug that prevents us from declaring the
|
||||
// tuple template as a friend (it complains that tuple is redefined). This
|
||||
// hack bypasses the bug by declaring the members that should otherwise be
|
||||
// bypasses the bug by declaring the members that should otherwise be
|
||||
// private as public.
|
||||
// Sun Studio versions < 12 also have the above bug.
|
||||
#if defined(__SYMBIAN32__) || (defined(__SUNPRO_CC) && __SUNPRO_CC < 0x590)
|
||||
|
@ -29,11 +29,12 @@ $$ This meta comment fixes auto-indentation in Emacs. }}
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Implements a subset of TR1 tuple needed by Google Test and Google Mock.
|
||||
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
|
||||
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
|
||||
|
||||
@ -41,7 +42,7 @@ $$ This meta comment fixes auto-indentation in Emacs. }}
|
||||
|
||||
// The compiler used in Symbian has a bug that prevents us from declaring the
|
||||
// tuple template as a friend (it complains that tuple is redefined). This
|
||||
// hack bypasses the bug by declaring the members that should otherwise be
|
||||
// bypasses the bug by declaring the members that should otherwise be
|
||||
// private as public.
|
||||
// Sun Studio versions < 12 also have the above bug.
|
||||
#if defined(__SYMBIAN32__) || (defined(__SUNPRO_CC) && __SUNPRO_CC < 0x590)
|
||||
|
@ -30,8 +30,7 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Type utilities needed for implementing typed and type-parameterized
|
||||
// tests. This file is generated by a SCRIPT. DO NOT EDIT BY HAND!
|
||||
@ -41,6 +40,8 @@
|
||||
// Please contact googletestframework@googlegroups.com if you need
|
||||
// more.
|
||||
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
|
||||
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
|
||||
|
||||
|
@ -28,8 +28,7 @@ $var n = 50 $$ Maximum length of type lists we want to support.
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
|
||||
|
||||
// Type utilities needed for implementing typed and type-parameterized
|
||||
// tests. This file is generated by a SCRIPT. DO NOT EDIT BY HAND!
|
||||
@ -39,6 +38,8 @@ $var n = 50 $$ Maximum length of type lists we want to support.
|
||||
// Please contact googletestframework@googlegroups.com if you need
|
||||
// more.
|
||||
|
||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||
|
||||
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
|
||||
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
|
||||
|
||||
|
@ -26,9 +26,8 @@
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Author: wan@google.com (Zhanyong Wan)
|
||||
// Author: vladl@google.com (Vlad Losev)
|
||||
|
||||
|
||||
|
||||
// This provides interface PrimeTable that determines whether a number is a
|
||||
// prime and determines a next prime number. This interface is used
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user