summaryrefslogtreecommitdiffstats
path: root/googletest
diff options
context:
space:
mode:
authorGennadiy Civil <gennadiycivil@users.noreply.github.com>2018-02-27 15:00:29 (GMT)
committerGitHub <noreply@github.com>2018-02-27 15:00:29 (GMT)
commitd4f77c1e3a340b37f5bed5e1e4de7d741f1d1199 (patch)
treefd25c57276fa42ec365f1ca05b4853ab459697e4 /googletest
parent3498a1ac52deb83f30b8170c78bfba9dc6227198 (diff)
parentac34e6c950925df7165e626becd3f9d64dcd584b (diff)
downloadgoogletest-d4f77c1e3a340b37f5bed5e1e4de7d741f1d1199.zip
googletest-d4f77c1e3a340b37f5bed5e1e4de7d741f1d1199.tar.gz
googletest-d4f77c1e3a340b37f5bed5e1e4de7d741f1d1199.tar.bz2
Merge branch 'master' into win-libcxx2refs/pull/1423/head
Diffstat (limited to 'googletest')
-rw-r--r--googletest/cmake/internal_utils.cmake3
-rw-r--r--googletest/docs/AdvancedGuide.md30
-rw-r--r--googletest/docs/Documentation.md2
-rw-r--r--googletest/docs/FAQ.md2
-rw-r--r--googletest/docs/Primer.md2
-rw-r--r--googletest/include/gtest/gtest-printers.h101
-rw-r--r--googletest/include/gtest/gtest.h16
-rw-r--r--googletest/include/gtest/gtest_prod.h11
-rw-r--r--googletest/include/gtest/internal/gtest-internal.h27
-rw-r--r--googletest/include/gtest/internal/gtest-port.h107
-rw-r--r--googletest/src/gtest-death-test.cc16
-rw-r--r--googletest/src/gtest-filepath.cc2
-rw-r--r--googletest/src/gtest-internal-inl.h4
-rw-r--r--googletest/src/gtest-port.cc8
-rw-r--r--googletest/src/gtest-printers.cc8
-rw-r--r--googletest/src/gtest-typed-test.cc1
-rw-r--r--googletest/src/gtest.cc37
-rw-r--r--googletest/test/BUILD.bazel17
-rw-r--r--googletest/test/gtest-death-test_test.cc6
-rw-r--r--googletest/test/gtest-param-test_test.cc63
-rw-r--r--googletest/test/gtest-printers_test.cc28
-rw-r--r--googletest/test/gtest_all_test.cc24
-rw-r--r--googletest/test/gtest_assert_by_exception_test.cc119
-rwxr-xr-xgoogletest/test/gtest_env_var_test.py2
-rw-r--r--googletest/test/gtest_env_var_test_.cc1
-rw-r--r--googletest/test/gtest_main_unittest.cc4
-rwxr-xr-xgoogletest/test/gtest_test_utils.py2
-rw-r--r--googletest/test/gtest_uninitialized_test_.cc2
-rw-r--r--googletest/test/gtest_unittest.cc189
-rwxr-xr-xgoogletest/xcode/Scripts/versiongenerate.py2
30 files changed, 592 insertions, 244 deletions
diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake
index acffe0c..3277cc5 100644
--- a/googletest/cmake/internal_utils.cmake
+++ b/googletest/cmake/internal_utils.cmake
@@ -95,6 +95,9 @@ macro(config_compiler_and_linker)
set(cxx_no_rtti_flags "-GR-")
elseif (CMAKE_COMPILER_IS_GNUCXX)
set(cxx_base_flags "-Wall -Wshadow -Werror")
+ if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0.0)
+ set(cxx_base_flags "${cxx_base_flags} -Wno-error=dangling-else")
+ endif()
set(cxx_exception_flags "-fexceptions")
set(cxx_no_exception_flags "-fno-exceptions")
# Until version 4.3.2, GCC doesn't define a macro to indicate
diff --git a/googletest/docs/AdvancedGuide.md b/googletest/docs/AdvancedGuide.md
index e1df20d..6605f44 100644
--- a/googletest/docs/AdvancedGuide.md
+++ b/googletest/docs/AdvancedGuide.md
@@ -872,13 +872,33 @@ TEST(FooTest, Bar) {
}
```
-Since we don't use exceptions, it is technically impossible to
-implement the intended behavior here. To alleviate this, Google Test
-provides two solutions. You could use either the
-`(ASSERT|EXPECT)_NO_FATAL_FAILURE` assertions or the
-`HasFatalFailure()` function. They are described in the following two
+To alleviate this, gUnit provides three different solutions. You could use
+either exceptions, the `(ASSERT|EXPECT)_NO_FATAL_FAILURE` assertions or the
+`HasFatalFailure()` function. They are described in the following two
subsections.
+#### Asserting on Subroutines with an exception
+
+The following code can turn ASSERT-failure into an exception:
+
+```c++
+class ThrowListener : public testing::EmptyTestEventListener {
+ void OnTestPartResult(const testing::TestPartResult& result) override {
+ if (result.type() == testing::TestPartResult::kFatalFailure) {
+ throw testing::AssertionException(result);
+ }
+ }
+};
+int main(int argc, char** argv) {
+ ...
+ testing::UnitTest::GetInstance()->listeners().Append(new ThrowListener);
+ return RUN_ALL_TESTS();
+}
+```
+
+This listener should be added after other listeners if you have any, otherwise
+they won't see failed `OnTestPartResult`.
+
### Asserting on Subroutines ###
As shown above, if your test calls a subroutine that has an `ASSERT_*`
diff --git a/googletest/docs/Documentation.md b/googletest/docs/Documentation.md
index 3784c8f..20f2503 100644
--- a/googletest/docs/Documentation.md
+++ b/googletest/docs/Documentation.md
@@ -12,5 +12,5 @@ the respective git branch/tag).**
To contribute code to Google Test, read:
- * [CONTRIBUTING](../CONTRIBUTING.md) -- read this _before_ writing your first patch.
+ * [CONTRIBUTING](../../CONTRIBUTING.md) -- read this _before_ writing your first patch.
* [PumpManual](PumpManual.md) -- how we generate some of Google Test's source files.
diff --git a/googletest/docs/FAQ.md b/googletest/docs/FAQ.md
index 1a216a1..bd9526d 100644
--- a/googletest/docs/FAQ.md
+++ b/googletest/docs/FAQ.md
@@ -460,7 +460,7 @@ following benefits:
You may still want to use `SetUp()/TearDown()` in the following rare cases:
* If the tear-down operation could throw an exception, you must use `TearDown()` as opposed to the destructor, as throwing in a destructor leads to undefined behavior and usually will kill your program right away. Note that many standard libraries (like STL) may throw when exceptions are enabled in the compiler. Therefore you should prefer `TearDown()` if you want to write portable tests that work with or without exceptions.
* The assertion macros throw an exception when flag `--gtest_throw_on_failure` is specified. Therefore, you shouldn't use Google Test assertions in a destructor if you plan to run your tests with this flag.
- * In a constructor or destructor, you cannot make a virtual function call on this object. (You can call a method declared as virtual, but it will be statically bound.) Therefore, if you need to call a method that will be overriden in a derived class, you have to use `SetUp()/TearDown()`.
+ * In a constructor or destructor, you cannot make a virtual function call on this object. (You can call a method declared as virtual, but it will be statically bound.) Therefore, if you need to call a method that will be overridden in a derived class, you have to use `SetUp()/TearDown()`.
## The compiler complains "no matching function to call" when I use ASSERT\_PREDn. How do I fix it? ##
diff --git a/googletest/docs/Primer.md b/googletest/docs/Primer.md
index 384d4d6..5e8ee0c 100644
--- a/googletest/docs/Primer.md
+++ b/googletest/docs/Primer.md
@@ -239,7 +239,7 @@ To create a test:
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(test_case_name, test_name) {
+TEST(testCaseName, testName) {
... test body ...
}
```
diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h
index 38c63d2..2c83c3f 100644
--- a/googletest/include/gtest/gtest-printers.h
+++ b/googletest/include/gtest/gtest-printers.h
@@ -46,6 +46,10 @@
// 2. operator<<(ostream&, const T&) defined in either foo or the
// global namespace.
//
+// However if T is an STL-style container then it is printed element-wise
+// unless foo::PrintTo(const T&, ostream*) is defined. Note that
+// operator<<() is ignored for container types.
+//
// If none of the above is defined, it will print the debug string of
// the value if it is a protocol buffer, or print the raw bytes in the
// value otherwise.
@@ -107,6 +111,11 @@
# include <tuple>
#endif
+#if GTEST_HAS_ABSL
+#include "absl/strings/string_view.h"
+#include "absl/types/optional.h"
+#endif // GTEST_HAS_ABSL
+
namespace testing {
// Definitions in the 'internal' and 'internal2' name spaces are
@@ -125,7 +134,11 @@ enum TypeKind {
kProtobuf, // a protobuf type
kConvertibleToInteger, // a type implicitly convertible to BiggestInt
// (e.g. a named or unnamed enum type)
- kOtherType // anything else
+#if GTEST_HAS_ABSL
+ kConvertibleToStringView, // a type implicitly convertible to
+ // absl::string_view
+#endif
+ kOtherType // anything else
};
// TypeWithoutFormatter<T, kTypeKind>::PrintValue(value, os) is called
@@ -138,7 +151,7 @@ class TypeWithoutFormatter {
// This default version is called when kTypeKind is kOtherType.
static void PrintValue(const T& value, ::std::ostream* os) {
PrintBytesInObjectTo(static_cast<const unsigned char*>(
- reinterpret_cast<const void *>(&value)),
+ reinterpret_cast<const void*>(&value)),
sizeof(value), os);
}
};
@@ -176,6 +189,19 @@ class TypeWithoutFormatter<T, kConvertibleToInteger> {
}
};
+#if GTEST_HAS_ABSL
+template <typename T>
+class TypeWithoutFormatter<T, kConvertibleToStringView> {
+ public:
+ // Since T has neither operator<< nor PrintTo() but can be implicitly
+ // converted to absl::string_view, we print it as a absl::string_view.
+ //
+ // Note: the implementation is further below, as it depends on
+ // internal::PrintTo symbol which is defined later in the file.
+ static void PrintValue(const T& value, ::std::ostream* os);
+};
+#endif
+
// Prints the given value to the given ostream. If the value is a
// protocol message, its debug string is printed; if it's an enum or
// of a type implicitly convertible to BiggestInt, it's printed as an
@@ -203,10 +229,19 @@ class TypeWithoutFormatter<T, kConvertibleToInteger> {
template <typename Char, typename CharTraits, typename T>
::std::basic_ostream<Char, CharTraits>& operator<<(
::std::basic_ostream<Char, CharTraits>& os, const T& x) {
- TypeWithoutFormatter<T,
- (internal::IsAProtocolMessage<T>::value ? kProtobuf :
- internal::ImplicitlyConvertible<const T&, internal::BiggestInt>::value ?
- kConvertibleToInteger : kOtherType)>::PrintValue(x, &os);
+ TypeWithoutFormatter<T, (internal::IsAProtocolMessage<T>::value
+ ? kProtobuf
+ : internal::ImplicitlyConvertible<
+ const T&, internal::BiggestInt>::value
+ ? kConvertibleToInteger
+ :
+#if GTEST_HAS_ABSL
+ internal::ImplicitlyConvertible<
+ const T&, absl::string_view>::value
+ ? kConvertibleToStringView
+ :
+#endif
+ kOtherType)>::PrintValue(x, &os);
return os;
}
@@ -427,7 +462,8 @@ void DefaultPrintTo(WrapPrinterType<kPrintFunctionPointer> /* dummy */,
*os << "NULL";
} else {
// T is a function type, so '*os << p' doesn't do what we want
- // (it just prints p as bool). Cast p to const void* to print it.
+ // (it just prints p as bool). We want to print p as a const
+ // void*.
*os << reinterpret_cast<const void*>(p);
}
}
@@ -456,17 +492,15 @@ void PrintTo(const T& value, ::std::ostream* os) {
// DefaultPrintTo() is overloaded. The type of its first argument
// determines which version will be picked.
//
- // Note that we check for recursive and other container types here, prior
- // to we check for protocol message types in our operator<<. The rationale is:
+ // Note that we check for container types here, prior to we check
+ // for protocol message types in our operator<<. The rationale is:
//
// For protocol messages, we want to give people a chance to
// override Google Mock's format by defining a PrintTo() or
// operator<<. For STL containers, other formats can be
// incompatible with Google Mock's format for the container
// elements; therefore we check for container types here to ensure
- // that our format is used. To prevent an infinite runtime recursion
- // during the output of recursive container types, we check first for
- // those.
+ // that our format is used.
//
// Note that MSVC and clang-cl do allow an implicit conversion from
// pointer-to-function to pointer-to-object, but clang-cl warns on it.
@@ -484,8 +518,8 @@ void PrintTo(const T& value, ::std::ostream* os) {
#else
: !internal::ImplicitlyConvertible<T, const void*>::value
#endif
- ? kPrintFunctionPointer
- : kPrintPointer>(),
+ ? kPrintFunctionPointer
+ : kPrintPointer>(),
value, os);
}
@@ -593,6 +627,13 @@ inline void PrintTo(const ::std::wstring& s, ::std::ostream* os) {
}
#endif // GTEST_HAS_STD_WSTRING
+#if GTEST_HAS_ABSL
+// Overload for absl::string_view.
+inline void PrintTo(absl::string_view sp, ::std::ostream* os) {
+ PrintTo(::std::string(sp), os);
+}
+#endif // GTEST_HAS_ABSL
+
#if GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_
// Helper function for printing a tuple. T must be instantiated with
// a tuple type.
@@ -722,6 +763,26 @@ class UniversalPrinter {
GTEST_DISABLE_MSC_WARNINGS_POP_()
};
+#if GTEST_HAS_ABSL
+
+// Printer for absl::optional
+
+template <typename T>
+class UniversalPrinter<::absl::optional<T>> {
+ public:
+ static void Print(const ::absl::optional<T>& value, ::std::ostream* os) {
+ *os << '(';
+ if (!value) {
+ *os << "nullopt";
+ } else {
+ UniversalPrint(*value, os);
+ }
+ *os << ')';
+ }
+};
+
+#endif // GTEST_HAS_ABSL
+
// UniversalPrintArray(begin, len, os) prints an array of 'len'
// elements, starting at address 'begin'.
template <typename T>
@@ -868,7 +929,7 @@ void UniversalPrint(const T& value, ::std::ostream* os) {
UniversalPrinter<T1>::Print(value, os);
}
-typedef ::std::vector<string> Strings;
+typedef ::std::vector< ::std::string> Strings;
// TuplePolicy<TupleT> must provide:
// - tuple_size
@@ -988,6 +1049,16 @@ Strings UniversalTersePrintTupleFieldsToStrings(const Tuple& value) {
} // namespace internal
+#if GTEST_HAS_ABSL
+namespace internal2 {
+template <typename T>
+void TypeWithoutFormatter<T, kConvertibleToStringView>::PrintValue(
+ const T& value, ::std::ostream* os) {
+ internal::PrintTo(absl::string_view(value), os);
+}
+} // namespace internal2
+#endif
+
template <typename T>
::std::string PrintToString(const T& value) {
::std::stringstream ss;
diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h
index 01994e6..26e787d 100644
--- a/googletest/include/gtest/gtest.h
+++ b/googletest/include/gtest/gtest.h
@@ -138,7 +138,7 @@ GTEST_DECLARE_int32_(stack_trace_depth);
// When this flag is specified, a failed assertion will throw an
// exception if exceptions are enabled, or exit the program with a
-// non-zero code otherwise.
+// non-zero code otherwise. For use with an external test framework.
GTEST_DECLARE_bool_(throw_on_failure);
// When this flag is set with a "host:port" string, on supported
@@ -1004,6 +1004,18 @@ class Environment {
virtual Setup_should_be_spelled_SetUp* Setup() { return NULL; }
};
+#if GTEST_HAS_EXCEPTIONS
+
+// Exception which can be thrown from TestEventListener::OnTestPartResult.
+class GTEST_API_ AssertionException
+ : public internal::GoogleTestFailureException {
+ public:
+ explicit AssertionException(const TestPartResult& result)
+ : GoogleTestFailureException(result) {}
+};
+
+#endif // GTEST_HAS_EXCEPTIONS
+
// The interface for tracing execution of tests. The methods are organized in
// the order the corresponding events are fired.
class TestEventListener {
@@ -1032,6 +1044,8 @@ class TestEventListener {
virtual void OnTestStart(const TestInfo& test_info) = 0;
// Fired after a failed assertion or a SUCCEED() invocation.
+ // If you want to throw an exception from this function to skip to the next
+ // TEST, it must be AssertionException defined above, or inherited from it.
virtual void OnTestPartResult(const TestPartResult& test_part_result) = 0;
// Fired after the test ends.
diff --git a/googletest/include/gtest/gtest_prod.h b/googletest/include/gtest/gtest_prod.h
index da80ddc..d9ea685 100644
--- a/googletest/include/gtest/gtest_prod.h
+++ b/googletest/include/gtest/gtest_prod.h
@@ -40,17 +40,20 @@
//
// class MyClass {
// private:
-// void MyMethod();
-// FRIEND_TEST(MyClassTest, MyMethod);
+// void PrivateMethod();
+// FRIEND_TEST(MyClassTest, PrivateMethodWorks);
// };
//
// class MyClassTest : public testing::Test {
// // ...
// };
//
-// TEST_F(MyClassTest, MyMethod) {
-// // Can call MyClass::MyMethod() here.
+// TEST_F(MyClassTest, PrivateMethodWorks) {
+// // Can call MyClass::PrivateMethod() here.
// }
+//
+// Note: The test class must be in the same namespace as the class being tested.
+// For example, putting MyClassTest in an anonymous namespace will not work.
#define FRIEND_TEST(test_case_name, test_name)\
friend class test_case_name##_##test_name##_Test
diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h
index 843058f..db5a4ef 100644
--- a/googletest/include/gtest/internal/gtest-internal.h
+++ b/googletest/include/gtest/internal/gtest-internal.h
@@ -803,31 +803,6 @@ struct RemoveConst<T[N]> {
#define GTEST_REMOVE_REFERENCE_AND_CONST_(T) \
GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(T))
-// Adds reference to a type if it is not a reference type,
-// otherwise leaves it unchanged. This is the same as
-// tr1::add_reference, which is not widely available yet.
-template <typename T>
-struct AddReference { typedef T& type; }; // NOLINT
-template <typename T>
-struct AddReference<T&> { typedef T& type; }; // NOLINT
-
-// A handy wrapper around AddReference that works when the argument T
-// depends on template parameters.
-#define GTEST_ADD_REFERENCE_(T) \
- typename ::testing::internal::AddReference<T>::type
-
-// Adds a reference to const on top of T as necessary. For example,
-// it transforms
-//
-// char ==> const char&
-// const char ==> const char&
-// char& ==> const char&
-// const char& ==> const char&
-//
-// The argument T must depend on some template parameters.
-#define GTEST_REFERENCE_TO_CONST_(T) \
- GTEST_ADD_REFERENCE_(const GTEST_REMOVE_REFERENCE_(T))
-
// ImplicitlyConvertible<From, To>::value is a compile-time bool
// constant that's true iff type From can be implicitly converted to
// type To.
@@ -1075,7 +1050,7 @@ class NativeArray {
private:
enum {
kCheckTypeIsNotConstOrAReference = StaticAssertTypeEqHelper<
- Element, GTEST_REMOVE_REFERENCE_AND_CONST_(Element)>::value,
+ Element, GTEST_REMOVE_REFERENCE_AND_CONST_(Element)>::value
};
// Initializes this object with a copy of the input.
diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index 1a1d9dd..539fbee 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -73,11 +73,9 @@
// GTEST_HAS_EXCEPTIONS - Define it to 1/0 to indicate that exceptions
// are enabled.
// GTEST_HAS_GLOBAL_STRING - Define it to 1/0 to indicate that ::string
-// is/isn't available (some systems define
-// ::string, which is different to std::string).
-// GTEST_HAS_GLOBAL_WSTRING - Define it to 1/0 to indicate that ::string
-// is/isn't available (some systems define
-// ::wstring, which is different to std::wstring).
+// is/isn't available
+// GTEST_HAS_GLOBAL_WSTRING - Define it to 1/0 to indicate that ::wstring
+// is/isn't available
// GTEST_HAS_POSIX_RE - Define it to 1/0 to indicate that POSIX regular
// expressions are/aren't available.
// GTEST_HAS_PTHREAD - Define it to 1/0 to indicate that <pthread.h>
@@ -178,7 +176,7 @@
// GTEST_HAS_POSIX_RE (see above) which users can
// define themselves.
// GTEST_USES_SIMPLE_RE - our own simple regex is used;
-// the above two are mutually exclusive.
+// the above RE\b(s) are mutually exclusive.
// GTEST_CAN_COMPARE_NULL - accepts untyped NULL in EXPECT_EQ().
// Misc public macros
@@ -207,6 +205,7 @@
//
// C++11 feature wrappers:
//
+// testing::internal::forward - portability wrapper for std::forward.
// testing::internal::move - portability wrapper for std::move.
//
// Synchronization:
@@ -272,10 +271,12 @@
# include <TargetConditionals.h>
#endif
+// Brings in the definition of HAS_GLOBAL_STRING. This must be done
+// BEFORE we test HAS_GLOBAL_STRING.
+#include <string> // NOLINT
#include <algorithm> // NOLINT
#include <iostream> // NOLINT
#include <sstream> // NOLINT
-#include <string> // NOLINT
#include <utility>
#include <vector> // NOLINT
@@ -614,8 +615,8 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
//
// To disable threading support in Google Test, add -DGTEST_HAS_PTHREAD=0
// to your compiler flags.
-#define GTEST_HAS_PTHREAD \
- (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_HPUX || GTEST_OS_QNX || \
+#define GTEST_HAS_PTHREAD \
+ (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_HPUX || GTEST_OS_QNX || \
GTEST_OS_FREEBSD || GTEST_OS_NACL || GTEST_OS_NETBSD || GTEST_OS_FUCHSIA)
#endif // GTEST_HAS_PTHREAD
@@ -809,9 +810,9 @@ using ::std::tuple_size;
// Google Test does not support death tests for VC 7.1 and earlier as
// abort() in a VC 7.1 application compiled as GUI in debug config
// pops up a dialog window that cannot be suppressed programmatically.
-#if (GTEST_OS_LINUX || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \
- (GTEST_OS_MAC && !GTEST_OS_IOS) || \
- (GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400) || \
+#if (GTEST_OS_LINUX || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \
+ (GTEST_OS_MAC && !GTEST_OS_IOS) || \
+ (GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400) || \
GTEST_OS_WINDOWS_MINGW || GTEST_OS_AIX || GTEST_OS_HPUX || \
GTEST_OS_OPENBSD || GTEST_OS_QNX || GTEST_OS_FREEBSD || GTEST_OS_NETBSD)
# define GTEST_HAS_DEATH_TEST 1
@@ -827,9 +828,10 @@ using ::std::tuple_size;
# define GTEST_HAS_TYPED_TEST_P 1
#endif
-// Determines whether to support Combine().
-// The implementation doesn't work on Sun Studio since it doesn't
-// understand templated conversion operators.
+// Determines whether to support Combine(). This only makes sense when
+// value-parameterized tests are enabled. The implementation doesn't
+// work on Sun Studio since it doesn't understand templated conversion
+// operators.
#if (GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_) && !defined(__SUNPRO_CC)
# define GTEST_HAS_COMBINE 1
#endif
@@ -1129,6 +1131,16 @@ struct StaticAssertTypeEqHelper<T, T> {
enum { value = true };
};
+// Same as std::is_same<>.
+template <typename T, typename U>
+struct IsSame {
+ enum { value = false };
+};
+template <typename T>
+struct IsSame<T, T> {
+ enum { value = true };
+};
+
// Evaluates to the number of elements in 'array'.
#define GTEST_ARRAY_SIZE_(array) (sizeof(array) / sizeof(array[0]))
@@ -1192,6 +1204,10 @@ class scoped_ptr {
// Defines RE.
+#if GTEST_USES_PCRE
+using ::RE;
+#elif GTEST_USES_POSIX_RE || GTEST_USES_SIMPLE_RE
+
// A simple C++ wrapper for <regex.h>. It uses the POSIX Extended
// Regular Expression syntax.
class GTEST_API_ RE {
@@ -1203,11 +1219,11 @@ class GTEST_API_ RE {
// Constructs an RE from a string.
RE(const ::std::string& regex) { Init(regex.c_str()); } // NOLINT
-#if GTEST_HAS_GLOBAL_STRING
+# if GTEST_HAS_GLOBAL_STRING
RE(const ::string& regex) { Init(regex.c_str()); } // NOLINT
-#endif // GTEST_HAS_GLOBAL_STRING
+# endif // GTEST_HAS_GLOBAL_STRING
RE(const char* regex) { Init(regex); } // NOLINT
~RE();
@@ -1229,7 +1245,7 @@ class GTEST_API_ RE {
return PartialMatch(str.c_str(), re);
}
-#if GTEST_HAS_GLOBAL_STRING
+# if GTEST_HAS_GLOBAL_STRING
static bool FullMatch(const ::string& str, const RE& re) {
return FullMatch(str.c_str(), re);
@@ -1238,7 +1254,7 @@ class GTEST_API_ RE {
return PartialMatch(str.c_str(), re);
}
-#endif // GTEST_HAS_GLOBAL_STRING
+# endif // GTEST_HAS_GLOBAL_STRING
static bool FullMatch(const char* str, const RE& re);
static bool PartialMatch(const char* str, const RE& re);
@@ -1252,20 +1268,22 @@ class GTEST_API_ RE {
const char* pattern_;
bool is_valid_;
-#if GTEST_USES_POSIX_RE
+# if GTEST_USES_POSIX_RE
regex_t full_regex_; // For FullMatch().
regex_t partial_regex_; // For PartialMatch().
-#else // GTEST_USES_SIMPLE_RE
+# else // GTEST_USES_SIMPLE_RE
const char* full_pattern_; // For FullMatch();
-#endif
+# endif
GTEST_DISALLOW_ASSIGN_(RE);
};
+#endif // GTEST_USES_PCRE
+
// Formats a source file path and a line number as they would appear
// in an error message from the compiler used to compile this code.
GTEST_API_ ::std::string FormatFileLocation(const char* file, int line);
@@ -1351,13 +1369,57 @@ inline void FlushInfoLog() { fflush(NULL); }
GTEST_LOG_(FATAL) << #posix_call << "failed with error " \
<< gtest_error
+// Adds reference to a type if it is not a reference type,
+// otherwise leaves it unchanged. This is the same as
+// tr1::add_reference, which is not widely available yet.
+template <typename T>
+struct AddReference { typedef T& type; }; // NOLINT
+template <typename T>
+struct AddReference<T&> { typedef T& type; }; // NOLINT
+
+// A handy wrapper around AddReference that works when the argument T
+// depends on template parameters.
+#define GTEST_ADD_REFERENCE_(T) \
+ typename ::testing::internal::AddReference<T>::type
+
+// Transforms "T" into "const T&" according to standard reference collapsing
+// rules (this is only needed as a backport for C++98 compilers that do not
+// support reference collapsing). Specifically, it transforms:
+//
+// char ==> const char&
+// const char ==> const char&
+// char& ==> char&
+// const char& ==> const char&
+//
+// Note that the non-const reference will not have "const" added. This is
+// standard, and necessary so that "T" can always bind to "const T&".
+template <typename T>
+struct ConstRef { typedef const T& type; };
+template <typename T>
+struct ConstRef<T&> { typedef T& type; };
+
+// The argument T must depend on some template parameters.
+#define GTEST_REFERENCE_TO_CONST_(T) \
+ typename ::testing::internal::ConstRef<T>::type
+
#if GTEST_HAS_STD_MOVE_
+using std::forward;
using std::move;
+
+template <typename T>
+struct RvalueRef {
+ typedef T&& type;
+};
#else // GTEST_HAS_STD_MOVE_
template <typename T>
const T& move(const T& t) {
return t;
}
+
+template <typename T>
+struct RvalueRef {
+ typedef const T& type;
+};
#endif // GTEST_HAS_STD_MOVE_
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
@@ -1458,7 +1520,6 @@ GTEST_API_ void CaptureStderr();
GTEST_API_ std::string GetCapturedStderr();
#endif // GTEST_HAS_STREAM_REDIRECTION
-
// Returns the size (in bytes) of a file.
GTEST_API_ size_t GetFileSize(FILE* file);
diff --git a/googletest/src/gtest-death-test.cc b/googletest/src/gtest-death-test.cc
index 2bbb1bc..852912b 100644
--- a/googletest/src/gtest-death-test.cc
+++ b/googletest/src/gtest-death-test.cc
@@ -73,7 +73,7 @@ namespace testing {
// Constants.
// The default death test style.
-static const char kDefaultDeathTestStyle[] = "fast";
+static const char kDefaultDeathTestStyle[] = "threadsafe";
GTEST_DEFINE_string_(
death_test_style,
@@ -555,7 +555,13 @@ bool DeathTestImpl::Passed(bool status_ok) {
break;
case DIED:
if (status_ok) {
+# if GTEST_USES_PCRE
+ // PCRE regexes support embedded NULs.
+ // GTEST_USES_PCRE is defined only in google3 mode
+ const bool matched = RE::PartialMatch(error_message, *regex());
+# else
const bool matched = RE::PartialMatch(error_message.c_str(), *regex());
+# endif // GTEST_USES_PCRE
if (matched) {
success = true;
} else {
@@ -1219,11 +1225,11 @@ bool DefaultDeathTestFactory::Create(const char* statement, const RE* regex,
// signals the event, and returns a file descriptor wrapped around the pipe
// handle. This function is called in the child process only.
static int GetStatusFileDescriptor(unsigned int parent_process_id,
- size_t write_handle_as_size_t,
- size_t event_handle_as_size_t) {
+ size_t write_handle_as_size_t,
+ size_t event_handle_as_size_t) {
AutoHandle parent_process_handle(::OpenProcess(PROCESS_DUP_HANDLE,
- FALSE, // Non-inheritable.
- parent_process_id));
+ FALSE, // Non-inheritable.
+ parent_process_id));
if (parent_process_handle.Get() == INVALID_HANDLE_VALUE) {
DeathTestAbort("Unable to open parent process " +
StreamableToString(parent_process_id));
diff --git a/googletest/src/gtest-filepath.cc b/googletest/src/gtest-filepath.cc
index a1fc0e3..6b76ea0 100644
--- a/googletest/src/gtest-filepath.cc
+++ b/googletest/src/gtest-filepath.cc
@@ -128,7 +128,7 @@ FilePath FilePath::RemoveExtension(const char* extension) const {
return *this;
}
-// Returns a pointer to the last occurence of a valid path separator in
+// Returns a pointer to the last occurrence of a valid path separator in
// the FilePath. On Windows, for example, both '/' and '\' are valid path
// separators. Returns NULL if no path separator was found.
const char* FilePath::FindLastPathSeparator() const {
diff --git a/googletest/src/gtest-internal-inl.h b/googletest/src/gtest-internal-inl.h
index 099761a..e77c8b6 100644
--- a/googletest/src/gtest-internal-inl.h
+++ b/googletest/src/gtest-internal-inl.h
@@ -59,7 +59,7 @@
# include <windows.h> // NOLINT
#endif // GTEST_OS_WINDOWS
-#include "gtest/gtest.h" // NOLINT
+#include "gtest/gtest.h"
#include "gtest/gtest-spi.h"
namespace testing {
@@ -1024,7 +1024,7 @@ class TestResultAccessor {
#if GTEST_CAN_STREAM_RESULTS_
// Streams test results to the given port on the given host machine.
-class GTEST_API_ StreamingListener : public EmptyTestEventListener {
+class StreamingListener : public EmptyTestEventListener {
public:
// Abstract base class for writing strings to a socket.
class AbstractSocketWriter {
diff --git a/googletest/src/gtest-port.cc b/googletest/src/gtest-port.cc
index 01711fd..af0d120 100644
--- a/googletest/src/gtest-port.cc
+++ b/googletest/src/gtest-port.cc
@@ -915,6 +915,7 @@ GTestLog::~GTestLog() {
posix::Abort();
}
}
+
// Disable Microsoft deprecation warnings for POSIX functions called from
// this class (creat, dup, dup2, and close)
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
@@ -1007,8 +1008,7 @@ static CapturedStream* g_captured_stderr = NULL;
static CapturedStream* g_captured_stdout = NULL;
// Starts capturing an output stream (stdout/stderr).
-static void CaptureStream(int fd,
- const char* stream_name,
+static void CaptureStream(int fd, const char* stream_name,
CapturedStream** stream) {
if (*stream != NULL) {
GTEST_LOG_(FATAL) << "Only one " << stream_name
@@ -1049,6 +1049,10 @@ std::string GetCapturedStderr() {
#endif // GTEST_HAS_STREAM_REDIRECTION
+
+
+
+
size_t GetFileSize(FILE* file) {
fseek(file, 0, SEEK_END);
return static_cast<size_t>(ftell(file));
diff --git a/googletest/src/gtest-printers.cc b/googletest/src/gtest-printers.cc
index 1bdf243..d55a5e9 100644
--- a/googletest/src/gtest-printers.cc
+++ b/googletest/src/gtest-printers.cc
@@ -124,7 +124,7 @@ namespace internal {
// Depending on the value of a char (or wchar_t), we print it in one
// of three formats:
// - as is if it's a printable ASCII (e.g. 'a', '2', ' '),
-// - as a hexidecimal escape sequence (e.g. '\x7F'), or
+// - as a hexadecimal escape sequence (e.g. '\x7F'), or
// - as a special escape sequence (e.g. '\r', '\n').
enum CharFormat {
kAsIs,
@@ -231,7 +231,7 @@ void PrintCharAndCodeTo(Char c, ostream* os) {
return;
*os << " (" << static_cast<int>(c);
- // For more convenience, we print c's code again in hexidecimal,
+ // For more convenience, we print c's code again in hexadecimal,
// unless c was already printed in the form '\x##' or the code is in
// [1, 9].
if (format == kHexEscape || (1 <= c && c <= 9)) {
@@ -357,8 +357,10 @@ void PrintTo(const wchar_t* s, ostream* os) {
namespace {
bool ContainsUnprintableControlCodes(const char* str, size_t length) {
+ const unsigned char *s = reinterpret_cast<const unsigned char *>(str);
+
for (size_t i = 0; i < length; i++) {
- char ch = *str++;
+ unsigned char ch = *s++;
if (std::iscntrl(ch)) {
switch (ch) {
case '\t':
diff --git a/googletest/src/gtest-typed-test.cc b/googletest/src/gtest-typed-test.cc
index df1eef4..b358243 100644
--- a/googletest/src/gtest-typed-test.cc
+++ b/googletest/src/gtest-typed-test.cc
@@ -30,6 +30,7 @@
// Author: wan@google.com (Zhanyong Wan)
#include "gtest/gtest-typed-test.h"
+
#include "gtest/gtest.h"
namespace testing {
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 2c25f83..7afa5a9 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -293,7 +293,7 @@ GTEST_DEFINE_bool_(
internal::BoolFromGTestEnv("throw_on_failure", false),
"When this flag is specified, a failed assertion will throw an exception "
"if exceptions are enabled or exit the program with a non-zero code "
- "otherwise.");
+ "otherwise. For use with an external test framework.");
#if GTEST_USE_OWN_FLAGFILE_FLAG_
GTEST_DEFINE_string_(
@@ -1718,7 +1718,7 @@ AssertionResult IsHRESULTFailure(const char* expr, long hr) { // NOLINT
// Utility functions for encoding Unicode text (wide strings) in
// UTF-8.
-// A Unicode code-point can have upto 21 bits, and is encoded in UTF-8
+// A Unicode code-point can have up to 21 bits, and is encoded in UTF-8
// like this:
//
// Code-point length Encoding
@@ -2435,6 +2435,8 @@ Result HandleExceptionsInMethodIfSupported(
#if GTEST_HAS_EXCEPTIONS
try {
return HandleSehExceptionsInMethodIfSupported(object, method, location);
+ } catch (const AssertionException&) { // NOLINT
+ // This failure was reported already.
} catch (const internal::GoogleTestFailureException&) { // NOLINT
// This exception type can only be thrown by a failed Google
// Test assertion with the intention of letting another testing
@@ -2569,12 +2571,10 @@ void ReportInvalidTestCaseType(const char* test_case_name,
<< "probably rename one of the classes to put the tests into different\n"
<< "test cases.";
- GTEST_LOG_(ERROR)
- << FormatFileLocation(code_location.file.c_str(),
- code_location.line)
- << " " << errors.GetString();
+ GTEST_LOG_(ERROR) << FormatFileLocation(code_location.file.c_str(),
+ code_location.line)
+ << " " << errors.GetString();
}
-
} // namespace internal
namespace {
@@ -2896,7 +2896,7 @@ static int GetBitOffset(WORD color_mask) {
if (color_mask == 0) return 0;
int bitOffset = 0;
- while((color_mask & 1) == 0) {
+ while ((color_mask & 1) == 0) {
color_mask >>= 1;
++bitOffset;
}
@@ -3104,7 +3104,6 @@ void PrettyUnitTestResultPrinter::OnTestIterationStart(
"Note: Randomizing tests' orders with a seed of %d .\n",
unit_test.random_seed());
}
-
ColoredPrintf(COLOR_GREEN, "[==========] ");
printf("Running %s from %s.\n",
FormatTestCount(unit_test.test_to_run_count()).c_str(),
@@ -3471,8 +3470,8 @@ void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
// 3. To interpret the meaning of errno in a thread-safe way,
// we need the strerror_r() function, which is not available on
// Windows.
- GTEST_LOG_(FATAL) << "Unable to open file \""
- << output_file_ << "\"";
+
+ GTEST_LOG_(FATAL) << "Unable to open file \"" << output_file_ << "\"";
}
std::stringstream stream;
PrintXmlUnitTest(&stream, unit_test);
@@ -3771,6 +3770,7 @@ std::string XmlUnitTestResultPrinter::TestPropertiesAsXmlAttributes(
// End XmlUnitTestResultPrinter
+
#if GTEST_CAN_STREAM_RESULTS_
// Checks if str contains '=', '&', '%' or '\n' characters. If yes,
@@ -4399,8 +4399,7 @@ void UnitTestImpl::ConfigureXmlOutput() {
UnitTestOptions::GetAbsolutePathToOutputFile().c_str()));
} else if (output_format != "") {
GTEST_LOG_(WARNING) << "WARNING: unrecognized output format \""
- << output_format
- << "\" ignored.";
+ << output_format << "\" ignored.";
}
}
@@ -4415,8 +4414,7 @@ void UnitTestImpl::ConfigureStreamingOutput() {
listeners()->Append(new StreamingListener(target.substr(0, pos),
target.substr(pos+1)));
} else {
- GTEST_LOG_(WARNING) << "unrecognized streaming target \""
- << target
+ GTEST_LOG_(WARNING) << "unrecognized streaming target \"" << target
<< "\" ignored.";
}
}
@@ -5201,7 +5199,8 @@ static const char kColorEncodedHelpMessage[] =
" @G--" GTEST_FLAG_PREFIX_ "break_on_failure@D\n"
" Turn assertion failures into debugger break-points.\n"
" @G--" GTEST_FLAG_PREFIX_ "throw_on_failure@D\n"
-" Turn assertion failures into C++ exceptions.\n"
+" Turn assertion failures into C++ exceptions for use by an external\n"
+" test framework.\n"
" @G--" GTEST_FLAG_PREFIX_ "catch_exceptions=0@D\n"
" Do not report exceptions as test failures. Instead, allow them\n"
" to crash the program or throw a pop-up (on Windows).\n"
@@ -5252,8 +5251,7 @@ static bool ParseGoogleTestFlag(const char* const arg) {
static void LoadFlagsFromFile(const std::string& path) {
FILE* flagfile = posix::FOpen(path.c_str(), "r");
if (!flagfile) {
- GTEST_LOG_(FATAL) << "Unable to open file \""
- << GTEST_FLAG(flagfile)
+ GTEST_LOG_(FATAL) << "Unable to open file \"" << GTEST_FLAG(flagfile)
<< "\"";
}
std::string contents(ReadEntireFile(flagfile));
@@ -5384,8 +5382,9 @@ void InitGoogleTest(int* argc, wchar_t** argv) {
std::string TempDir() {
#if defined(GTEST_CUSTOM_TEMPDIR_FUNCTION_)
- return GTEST_CUSTOM_TEMPDIR_FUNCTION_();
+ return GTEST_CUSTOM_TEMPDIR_FUNCTION_();
#endif
+
#if GTEST_OS_WINDOWS_MOBILE
return "\\temp\\";
#elif GTEST_OS_WINDOWS
diff --git a/googletest/test/BUILD.bazel b/googletest/test/BUILD.bazel
index 3c700b1..6ea18ec 100644
--- a/googletest/test/BUILD.bazel
+++ b/googletest/test/BUILD.bazel
@@ -119,6 +119,16 @@ cc_test(
"//:gtest",
],
)
+
+cc_test(
+ name = "gtest_unittest",
+ size = "small",
+ srcs = ["gtest_unittest.cc"],
+ args = ["--heap_check=strict"],
+ shard_count = 2,
+ deps = ["//:gtest_main"],
+)
+
# Py tests
py_library(
@@ -219,6 +229,13 @@ py_test(
deps = [":gtest_test_utils"],
)
+cc_test(
+ name = "gtest_assert_by_exception_test",
+ size = "small",
+ srcs = ["gtest_assert_by_exception_test.cc"],
+ deps = ["//:gtest"],
+)
+
cc_binary(
name = "gtest_throw_on_failure_test_",
testonly = 1,
diff --git a/googletest/test/gtest-death-test_test.cc b/googletest/test/gtest-death-test_test.cc
index b7846b2..21573c7 100644
--- a/googletest/test/gtest-death-test_test.cc
+++ b/googletest/test/gtest-death-test_test.cc
@@ -617,7 +617,11 @@ TEST_F(TestForDeathTest, ReturnIsFailure) {
TEST_F(TestForDeathTest, TestExpectDebugDeath) {
int sideeffect = 0;
- EXPECT_DEBUG_DEATH(DieInDebugElse12(&sideeffect), "death.*DieInDebugElse12")
+ // Put the regex in a local variable to make sure we don't get an "unused"
+ // warning in opt mode.
+ const char* regex = "death.*DieInDebugElse12";
+
+ EXPECT_DEBUG_DEATH(DieInDebugElse12(&sideeffect), regex)
<< "Must accept a streamed message";
# ifdef NDEBUG
diff --git a/googletest/test/gtest-param-test_test.cc b/googletest/test/gtest-param-test_test.cc
index b0aa4f9..b21cb31 100644
--- a/googletest/test/gtest-param-test_test.cc
+++ b/googletest/test/gtest-param-test_test.cc
@@ -41,8 +41,8 @@
# include <sstream>
# include <string>
# include <vector>
-# include "src/gtest-internal-inl.h" // for UnitTestOptions
+# include "src/gtest-internal-inl.h" // for UnitTestOptions
# include "test/gtest-param-test_test.h"
using ::std::vector;
@@ -536,6 +536,51 @@ TEST(CombineTest, CombineWithMaxNumberOfParameters) {
VerifyGenerator(gen, expected_values);
}
+#if GTEST_LANG_CXX11
+
+class NonDefaultConstructAssignString {
+ public:
+ NonDefaultConstructAssignString(const std::string& s) : str_(s) {}
+
+ const std::string& str() const { return str_; }
+
+ private:
+ std::string str_;
+
+ // Not default constructible
+ NonDefaultConstructAssignString();
+ // Not assignable
+ void operator=(const NonDefaultConstructAssignString&);
+};
+
+TEST(CombineTest, NonDefaultConstructAssign) {
+ const ParamGenerator<tuple<int, NonDefaultConstructAssignString> > gen =
+ Combine(Values(0, 1), Values(NonDefaultConstructAssignString("A"),
+ NonDefaultConstructAssignString("B")));
+
+ ParamGenerator<tuple<int, NonDefaultConstructAssignString> >::iterator it =
+ gen.begin();
+
+ EXPECT_EQ(0, std::get<0>(*it));
+ EXPECT_EQ("A", std::get<1>(*it).str());
+ ++it;
+
+ EXPECT_EQ(0, std::get<0>(*it));
+ EXPECT_EQ("B", std::get<1>(*it).str());
+ ++it;
+
+ EXPECT_EQ(1, std::get<0>(*it));
+ EXPECT_EQ("A", std::get<1>(*it).str());
+ ++it;
+
+ EXPECT_EQ(1, std::get<0>(*it));
+ EXPECT_EQ("B", std::get<1>(*it).str());
+ ++it;
+
+ EXPECT_TRUE(it == gen.end());
+}
+
+#endif // GTEST_LANG_CXX11
# endif // GTEST_HAS_COMBINE
// Tests that an generator produces correct sequence after being
@@ -811,8 +856,8 @@ class CustomFunctorNamingTest : public TestWithParam<std::string> {};
TEST_P(CustomFunctorNamingTest, CustomTestNames) {}
struct CustomParamNameFunctor {
- std::string operator()(const ::testing::TestParamInfo<std::string>& info) {
- return info.param;
+ std::string operator()(const ::testing::TestParamInfo<std::string>& inf) {
+ return inf.param;
}
};
@@ -829,8 +874,8 @@ INSTANTIATE_TEST_CASE_P(AllAllowedCharacters,
CustomParamNameFunctor());
inline std::string CustomParamNameFunction(
- const ::testing::TestParamInfo<std::string>& info) {
- return info.param;
+ const ::testing::TestParamInfo<std::string>& inf) {
+ return inf.param;
}
class CustomFunctionNamingTest : public TestWithParam<std::string> {};
@@ -848,11 +893,10 @@ INSTANTIATE_TEST_CASE_P(CustomParamNameFunction,
class CustomLambdaNamingTest : public TestWithParam<std::string> {};
TEST_P(CustomLambdaNamingTest, CustomTestNames) {}
-INSTANTIATE_TEST_CASE_P(CustomParamNameLambda,
- CustomLambdaNamingTest,
+INSTANTIATE_TEST_CASE_P(CustomParamNameLambda, CustomLambdaNamingTest,
Values(std::string("LambdaName")),
- [](const ::testing::TestParamInfo<std::string>& tpinfo) {
- return tpinfo.param;
+ [](const ::testing::TestParamInfo<std::string>& inf) {
+ return inf.param;
});
#endif // GTEST_LANG_CXX11
@@ -1019,6 +1063,7 @@ TEST_F(ParameterizedDeathTest, GetParamDiesFromTestF) {
INSTANTIATE_TEST_CASE_P(RangeZeroToFive, ParameterizedDerivedTest, Range(0, 5));
+
int main(int argc, char **argv) {
// Used in TestGenerationTest test case.
AddGlobalTestEnvironment(TestGenerationTest::Environment::Instance());
diff --git a/googletest/test/gtest-printers_test.cc b/googletest/test/gtest-printers_test.cc
index e30ce7e..60a8d03 100644
--- a/googletest/test/gtest-printers_test.cc
+++ b/googletest/test/gtest-printers_test.cc
@@ -837,22 +837,22 @@ TEST(PrintTypeWithGenericStreamingTest, TypeImplicitlyConvertible) {
EXPECT_EQ("AllowsGenericStreamingAndImplicitConversionTemplate", Print(a));
}
-#if GTEST_HAS_STRING_PIECE_
+#if GTEST_HAS_ABSL
-// Tests printing StringPiece.
+// Tests printing ::absl::string_view.
-TEST(PrintStringPieceTest, SimpleStringPiece) {
- const StringPiece sp = "Hello";
+TEST(PrintStringViewTest, SimpleStringView) {
+ const ::absl::string_view sp = "Hello";
EXPECT_EQ("\"Hello\"", Print(sp));
}
-TEST(PrintStringPieceTest, UnprintableCharacters) {
+TEST(PrintStringViewTest, UnprintableCharacters) {
const char str[] = "NUL (\0) and \r\t";
- const StringPiece sp(str, sizeof(str) - 1);
+ const ::absl::string_view sp(str, sizeof(str) - 1);
EXPECT_EQ("\"NUL (\\0) and \\r\\t\"", Print(sp));
}
-#endif // GTEST_HAS_STRING_PIECE_
+#endif // GTEST_HAS_ABSL
// Tests printing STL containers.
@@ -1327,7 +1327,7 @@ TEST(FormatForComparisonFailureMessageTest, FormatsNonCharArrayAsPointer) {
}
// Tests formatting a char pointer when it's compared with another pointer.
-// In this case we want to print it as a raw pointer, as the comparision is by
+// In this case we want to print it as a raw pointer, as the comparison is by
// pointer.
// char pointer vs pointer
@@ -1765,5 +1765,17 @@ TEST(UniversalTersePrintTupleFieldsToStringsTestWithStd, PrintsTersely) {
#endif // GTEST_HAS_STD_TUPLE_
+#if GTEST_HAS_ABSL
+
+TEST(PrintOptionalTest, Basic) {
+ absl::optional<int> value;
+ EXPECT_EQ("(nullopt)", PrintToString(value));
+ value = {7};
+ EXPECT_EQ("(7)", PrintToString(value));
+ EXPECT_EQ("(1.1)", PrintToString(absl::optional<double>{1.1}));
+ EXPECT_EQ("(\"A\")", PrintToString(absl::optional<std::string>{"A"}));
+}
+#endif // GTEST_HAS_ABSL
+
} // namespace gtest_printers_test
} // namespace testing
diff --git a/googletest/test/gtest_all_test.cc b/googletest/test/gtest_all_test.cc
index 955aa62..e16ef53 100644
--- a/googletest/test/gtest_all_test.cc
+++ b/googletest/test/gtest_all_test.cc
@@ -33,15 +33,15 @@
//
// Sometimes it's desirable to build most of Google Test's own tests
// by compiling a single file. This file serves this purpose.
-#include "test/gtest-filepath_test.cc"
-#include "test/gtest-linked_ptr_test.cc"
-#include "test/gtest-message_test.cc"
-#include "test/gtest-options_test.cc"
-#include "test/gtest-port_test.cc"
-#include "test/gtest_pred_impl_unittest.cc"
-#include "test/gtest_prod_test.cc"
-#include "test/gtest-test-part_test.cc"
-#include "test/gtest-typed-test_test.cc"
-#include "test/gtest-typed-test2_test.cc"
-#include "test/gtest_unittest.cc"
-#include "test/production.cc"
+#include "gtest-filepath_test.cc"
+#include "gtest-linked_ptr_test.cc"
+#include "gtest-message_test.cc"
+#include "gtest-options_test.cc"
+#include "gtest-port_test.cc"
+#include "gtest_pred_impl_unittest.cc"
+#include "gtest_prod_test.cc"
+#include "gtest-test-part_test.cc"
+#include "gtest-typed-test_test.cc"
+#include "gtest-typed-test2_test.cc"
+#include "gtest_unittest.cc"
+#include "production.cc"
diff --git a/googletest/test/gtest_assert_by_exception_test.cc b/googletest/test/gtest_assert_by_exception_test.cc
new file mode 100644
index 0000000..2f0e34a
--- /dev/null
+++ b/googletest/test/gtest_assert_by_exception_test.cc
@@ -0,0 +1,119 @@
+// Copyright 2009, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// 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 Test's assert-by-exception mode with exceptions enabled.
+
+#include "gtest/gtest.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdexcept>
+
+class ThrowListener : public testing::EmptyTestEventListener {
+ void OnTestPartResult(const testing::TestPartResult& result) override {
+ if (result.type() == testing::TestPartResult::kFatalFailure) {
+ throw testing::AssertionException(result);
+ }
+ }
+};
+
+// Prints the given failure message and exits the program with
+// non-zero. We use this instead of a Google Test assertion to
+// indicate a failure, as the latter is been tested and cannot be
+// relied on.
+void Fail(const char* msg) {
+ printf("FAILURE: %s\n", msg);
+ fflush(stdout);
+ exit(1);
+}
+
+static void AssertFalse() {
+ ASSERT_EQ(2, 3) << "Expected failure";
+}
+
+// Tests that an assertion failure throws a subclass of
+// std::runtime_error.
+TEST(Test, Test) {
+ // A successful assertion shouldn't throw.
+ try {
+ EXPECT_EQ(3, 3);
+ } catch(...) {
+ Fail("A successful assertion wrongfully threw.");
+ }
+
+ // A successful assertion shouldn't throw.
+ try {
+ EXPECT_EQ(3, 4);
+ } catch(...) {
+ Fail("A failed non-fatal assertion wrongfully threw.");
+ }
+
+ // A failed assertion should throw.
+ try {
+ AssertFalse();
+ } catch(const testing::AssertionException& e) {
+ if (strstr(e.what(), "Expected failure") != NULL)
+ throw;
+
+ printf("%s",
+ "A failed assertion did throw an exception of the right type, "
+ "but the message is incorrect. Instead of containing \"Expected "
+ "failure\", it is:\n");
+ Fail(e.what());
+ } catch(...) {
+ Fail("A failed assertion threw the wrong type of exception.");
+ }
+ Fail("A failed assertion should've thrown but didn't.");
+}
+
+int kTestForContinuingTest = 0;
+
+TEST(Test, Test2) {
+ // FIXME(sokolov): how to force Test2 to be after Test?
+ kTestForContinuingTest = 1;
+}
+
+int main(int argc, char** argv) {
+ testing::InitGoogleTest(&argc, argv);
+ testing::UnitTest::GetInstance()->listeners().Append(new ThrowListener);
+
+ int result = RUN_ALL_TESTS();
+ if (result == 0) {
+ printf("RUN_ALL_TESTS returned %d\n", result);
+ Fail("Expected failure instead.");
+ }
+
+ if (kTestForContinuingTest == 0) {
+ Fail("Should have continued with other tests, but did not.");
+ }
+ return 0;
+}
diff --git a/googletest/test/gtest_env_var_test.py b/googletest/test/gtest_env_var_test.py
index 7af00ce..2fe9cd5 100755
--- a/googletest/test/gtest_env_var_test.py
+++ b/googletest/test/gtest_env_var_test.py
@@ -92,7 +92,7 @@ class GTestEnvVarTest(gtest_test_utils.TestCase):
TestFlag('print_time', '0', '1')
TestFlag('repeat', '999', '1')
TestFlag('throw_on_failure', '1', '0')
- TestFlag('death_test_style', 'threadsafe', 'fast')
+ TestFlag('death_test_style', 'fast', 'threadsafe')
TestFlag('catch_exceptions', '0', '1')
if IS_LINUX:
diff --git a/googletest/test/gtest_env_var_test_.cc b/googletest/test/gtest_env_var_test_.cc
index ed62372..9b668dc 100644
--- a/googletest/test/gtest_env_var_test_.cc
+++ b/googletest/test/gtest_env_var_test_.cc
@@ -35,6 +35,7 @@
#include "gtest/gtest.h"
#include <iostream>
+
#include "src/gtest-internal-inl.h"
using ::std::cout;
diff --git a/googletest/test/gtest_main_unittest.cc b/googletest/test/gtest_main_unittest.cc
index ecd9bb8..c979fce 100644
--- a/googletest/test/gtest_main_unittest.cc
+++ b/googletest/test/gtest_main_unittest.cc
@@ -41,5 +41,5 @@ TEST(GTestMainTest, ShouldSucceed) {
} // namespace
-// We are using the main() function defined in src/gtest_main.cc, so
-// we don't define it here.
+// We are using the main() function defined in gtest_main.cc, so we
+// don't define it here.
diff --git a/googletest/test/gtest_test_utils.py b/googletest/test/gtest_test_utils.py
index 7c48933..cc4ba64 100755
--- a/googletest/test/gtest_test_utils.py
+++ b/googletest/test/gtest_test_utils.py
@@ -227,7 +227,7 @@ class Subprocess:
combined in a string.
"""
- # The subprocess module is the preferrable way of running programs
+ # The subprocess module is the preferable way of running programs
# since it is available and behaves consistently on all platforms,
# including Windows. But it is only available starting in python 2.4.
# In earlier python versions, we revert to the popen2 module, which is
diff --git a/googletest/test/gtest_uninitialized_test_.cc b/googletest/test/gtest_uninitialized_test_.cc
index 502b0ad..2ba0e8b 100644
--- a/googletest/test/gtest_uninitialized_test_.cc
+++ b/googletest/test/gtest_uninitialized_test_.cc
@@ -34,7 +34,7 @@
TEST(DummyTest, Dummy) {
// This test doesn't verify anything. We just need it to create a
// realistic stage for testing the behavior of Google Test when
- // RUN_ALL_TESTS() is called without
+ // RUN_ALL_TESTS() is called without
// testing::InitGoogleTest() being called first.
}
diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc
index a45927d..11af9c9 100644
--- a/googletest/test/gtest_unittest.cc
+++ b/googletest/test/gtest_unittest.cc
@@ -538,7 +538,7 @@ TEST(CodePointToUtf8Test, CanEncode8To11Bits) {
// 101 0111 0110 => 110-10101 10-110110
// Some compilers (e.g., GCC on MinGW) cannot handle non-ASCII codepoints
- // in wide strings and wide chars. In order to accomodate them, we have to
+ // in wide strings and wide chars. In order to accommodate them, we have to
// introduce such character constants as integers.
EXPECT_EQ("\xD5\xB6",
CodePointToUtf8(static_cast<wchar_t>(0x576)));
@@ -1779,7 +1779,7 @@ TEST(Int32FromEnvOrDieDeathTest, AbortsOnFailure) {
}
// Tests that Int32FromEnvOrDie() aborts with an error message
-// if the variable cannot be represnted by an Int32.
+// if the variable cannot be represented by an Int32.
TEST(Int32FromEnvOrDieDeathTest, AbortsOnInt32Overflow) {
SetEnv(GTEST_FLAG_PREFIX_UPPER_ "VAR", "1234567891234567891234");
EXPECT_DEATH_IF_SUPPORTED(
@@ -2088,7 +2088,7 @@ class UnitTestRecordPropertyTestEnvironment : public Environment {
};
// This will test property recording outside of any test or test case.
-Environment* record_property_env GTEST_ATTRIBUTE_UNUSED_ =
+static Environment* record_property_env =
AddGlobalTestEnvironment(new UnitTestRecordPropertyTestEnvironment);
// This group of tests is for predicate assertions (ASSERT_PRED*, etc)
@@ -2421,9 +2421,8 @@ TEST(StringAssertionTest, ASSERT_STREQ) {
const char p2[] = "good";
ASSERT_STREQ(p1, p2);
- EXPECT_FATAL_FAILURE(
- ASSERT_STREQ("bad", "good"),
- "Expected equality of these values:\n \"bad\"\n \"good\"");
+ EXPECT_FATAL_FAILURE(ASSERT_STREQ("bad", "good"),
+ " \"bad\"\n \"good\"");
}
// Tests ASSERT_STREQ with NULL arguments.
@@ -3361,7 +3360,7 @@ class NoFatalFailureTest : public Test {
void DoAssertNoFatalFailureOnFails() {
ASSERT_NO_FATAL_FAILURE(Fails());
- ADD_FAILURE() << "shold not reach here.";
+ ADD_FAILURE() << "should not reach here.";
}
void DoExpectNoFatalFailureOnFails() {
@@ -3658,7 +3657,7 @@ TEST(AssertionTest, AssertFalseWithAssertionResult) {
}
#ifdef __BORLANDC__
-// Restores warnings after previous "#pragma option push" supressed them
+// Restores warnings after previous "#pragma option push" suppressed them
# pragma option pop
#endif
@@ -3813,7 +3812,7 @@ void TestEq1(int x) {
// Tests calling a test subroutine that's not part of a fixture.
TEST(AssertionTest, NonFixtureSubroutine) {
EXPECT_FATAL_FAILURE(TestEq1(2),
- "Which is: 2");
+ " x\n Which is: 2");
}
// An uncopyable class.
@@ -3952,13 +3951,13 @@ TEST(AssertionTest, AnonymousEnum) {
// ICE's in C++Builder.
EXPECT_FATAL_FAILURE(ASSERT_EQ(kCaseA, kCaseB),
- "kCaseB");
+ " kCaseB\n Which is: ");
EXPECT_FATAL_FAILURE(ASSERT_EQ(kCaseA, kCaseC),
- "Which is: 42");
+ "\n Which is: 42");
# endif
EXPECT_FATAL_FAILURE(ASSERT_EQ(kCaseA, kCaseC),
- "Which is: -1");
+ "\n Which is: -1");
}
#endif // !GTEST_OS_MAC && !defined(__SUNPRO_CC)
@@ -4384,7 +4383,7 @@ TEST(ExpectTest, ExpectFalseWithAssertionResult) {
}
#ifdef __BORLANDC__
-// Restores warnings after previous "#pragma option push" supressed them
+// Restores warnings after previous "#pragma option push" suppressed them
# pragma option pop
#endif
@@ -4426,7 +4425,7 @@ TEST(ExpectTest, EXPECT_EQ_NULL) {
// A failure.
int n = 0;
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(NULL, &n),
- "&n\n");
+ " &n\n Which is:");
}
#endif // GTEST_CAN_COMPARE_NULL
@@ -4442,7 +4441,7 @@ TEST(ExpectTest, EXPECT_EQ_0) {
// A failure.
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(0, 5.6),
- "Expected equality of these values:\n 0\n 5.6");
+ " 0\n 5.6");
}
// Tests EXPECT_NE.
@@ -4542,7 +4541,7 @@ TEST(ExpectTest, EXPECT_ANY_THROW) {
TEST(ExpectTest, ExpectPrecedence) {
EXPECT_EQ(1 < 2, true);
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(true, true && false),
- "true && false");
+ " true && false\n Which is: false");
}
@@ -4689,14 +4688,14 @@ TEST(EqAssertionTest, Bool) {
EXPECT_FATAL_FAILURE({
bool false_value = false;
ASSERT_EQ(false_value, true);
- }, "Which is: false");
+ }, " false_value\n Which is: false\n true");
}
// Tests using int values in {EXPECT|ASSERT}_EQ.
TEST(EqAssertionTest, Int) {
ASSERT_EQ(32, 32);
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(32, 33),
- "33");
+ " 32\n 33");
}
// Tests using time_t values in {EXPECT|ASSERT}_EQ.
@@ -4713,9 +4712,9 @@ TEST(EqAssertionTest, Char) {
ASSERT_EQ('z', 'z');
const char ch = 'b';
EXPECT_NONFATAL_FAILURE(EXPECT_EQ('\0', ch),
- "ch");
+ " ch\n Which is: 'b'");
EXPECT_NONFATAL_FAILURE(EXPECT_EQ('a', ch),
- "ch");
+ " ch\n Which is: 'b'");
}
// Tests using wchar_t values in {EXPECT|ASSERT}_EQ.
@@ -4735,7 +4734,7 @@ TEST(EqAssertionTest, WideChar) {
"wchar");
wchar = 0x8119;
EXPECT_FATAL_FAILURE(ASSERT_EQ(static_cast<wchar_t>(0x8120), wchar),
- "wchar");
+ " wchar\n Which is: L'");
}
// Tests using ::std::string values in {EXPECT|ASSERT}_EQ.
@@ -4764,8 +4763,7 @@ TEST(EqAssertionTest, StdString) {
static ::std::string str3(str1);
str3.at(2) = '\0';
EXPECT_FATAL_FAILURE(ASSERT_EQ(str1, str3),
- " str3\n"
- " Which is: \"A \\0 in the middle\"");
+ " str3\n Which is: \"A \\0 in the middle\"");
}
#if GTEST_HAS_STD_WSTRING
@@ -4885,9 +4883,9 @@ TEST(EqAssertionTest, CharPointer) {
ASSERT_EQ(p1, p1);
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p0, p2),
- "p2");
+ " p2\n Which is:");
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p1, p2),
- "p2");
+ " p2\n Which is:");
EXPECT_FATAL_FAILURE(ASSERT_EQ(reinterpret_cast<char*>(0x1234),
reinterpret_cast<char*>(0xABC0)),
"ABC0");
@@ -4907,9 +4905,9 @@ TEST(EqAssertionTest, WideCharPointer) {
EXPECT_EQ(p0, p0);
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p0, p2),
- "p2");
+ " p2\n Which is:");
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p1, p2),
- "p2");
+ " p2\n Which is:");
void* pv3 = (void*)0x1234; // NOLINT
void* pv4 = (void*)0xABC0; // NOLINT
const wchar_t* p3 = reinterpret_cast<const wchar_t*>(pv3);
@@ -5454,7 +5452,8 @@ TEST_F(SetUpTestCaseTest, Test2) {
EXPECT_STREQ("123", shared_resource_);
}
-// The InitGoogleTestTest test case tests testing::InitGoogleTest().
+
+// The ParseFlagsTest test case tests ParseGoogleTestFlagsOnly.
// The Flags struct stores a copy of all Google Test flags.
struct Flags {
@@ -5540,8 +5539,8 @@ struct Flags {
return flags;
}
- // Creates a Flags struct where the gtest_random_seed flag has
- // the given value.
+ // Creates a Flags struct where the gtest_random_seed flag has the given
+ // value.
static Flags RandomSeed(Int32 random_seed) {
Flags flags;
flags.random_seed = random_seed;
@@ -5556,8 +5555,8 @@ struct Flags {
return flags;
}
- // Creates a Flags struct where the gtest_shuffle flag has
- // the given value.
+ // Creates a Flags struct where the gtest_shuffle flag has the given
+ // value.
static Flags Shuffle(bool shuffle) {
Flags flags;
flags.shuffle = shuffle;
@@ -5605,8 +5604,8 @@ struct Flags {
bool throw_on_failure;
};
-// Fixture for testing InitGoogleTest().
-class InitGoogleTestTest : public Test {
+// Fixture for testing ParseGoogleTestFlagsOnly().
+class ParseFlagsTest : public Test {
protected:
// Clears the flags before each test.
virtual void SetUp() {
@@ -5667,16 +5666,16 @@ class InitGoogleTestTest : public Test {
const bool saved_help_flag = ::testing::internal::g_help_flag;
::testing::internal::g_help_flag = false;
-#if GTEST_HAS_STREAM_REDIRECTION
+# if GTEST_HAS_STREAM_REDIRECTION
CaptureStdout();
-#endif
+# endif
// Parses the command line.
internal::ParseGoogleTestFlagsOnly(&argc1, const_cast<CharType**>(argv1));
-#if GTEST_HAS_STREAM_REDIRECTION
+# if GTEST_HAS_STREAM_REDIRECTION
const std::string captured_stdout = GetCapturedStdout();
-#endif
+# endif
// Verifies the flag values.
CheckFlags(expected);
@@ -5689,7 +5688,7 @@ class InitGoogleTestTest : public Test {
// help message for the flags it recognizes.
EXPECT_EQ(should_print_help, ::testing::internal::g_help_flag);
-#if GTEST_HAS_STREAM_REDIRECTION
+# if GTEST_HAS_STREAM_REDIRECTION
const char* const expected_help_fragment =
"This program contains tests written using";
if (should_print_help) {
@@ -5698,7 +5697,7 @@ class InitGoogleTestTest : public Test {
EXPECT_PRED_FORMAT2(IsNotSubstring,
expected_help_fragment, captured_stdout);
}
-#endif // GTEST_HAS_STREAM_REDIRECTION
+# endif // GTEST_HAS_STREAM_REDIRECTION
::testing::internal::g_help_flag = saved_help_flag;
}
@@ -5706,14 +5705,14 @@ class InitGoogleTestTest : public Test {
// This macro wraps TestParsingFlags s.t. the user doesn't need
// to specify the array sizes.
-#define GTEST_TEST_PARSING_FLAGS_(argv1, argv2, expected, should_print_help) \
+# define GTEST_TEST_PARSING_FLAGS_(argv1, argv2, expected, should_print_help) \
TestParsingFlags(sizeof(argv1)/sizeof(*argv1) - 1, argv1, \
sizeof(argv2)/sizeof(*argv2) - 1, argv2, \
expected, should_print_help)
};
// Tests parsing an empty command line.
-TEST_F(InitGoogleTestTest, Empty) {
+TEST_F(ParseFlagsTest, Empty) {
const char* argv[] = {
NULL
};
@@ -5726,7 +5725,7 @@ TEST_F(InitGoogleTestTest, Empty) {
}
// Tests parsing a command line that has no flag.
-TEST_F(InitGoogleTestTest, NoFlag) {
+TEST_F(ParseFlagsTest, NoFlag) {
const char* argv[] = {
"foo.exe",
NULL
@@ -5741,7 +5740,7 @@ TEST_F(InitGoogleTestTest, NoFlag) {
}
// Tests parsing a bad --gtest_filter flag.
-TEST_F(InitGoogleTestTest, FilterBad) {
+TEST_F(ParseFlagsTest, FilterBad) {
const char* argv[] = {
"foo.exe",
"--gtest_filter",
@@ -5758,7 +5757,7 @@ TEST_F(InitGoogleTestTest, FilterBad) {
}
// Tests parsing an empty --gtest_filter flag.
-TEST_F(InitGoogleTestTest, FilterEmpty) {
+TEST_F(ParseFlagsTest, FilterEmpty) {
const char* argv[] = {
"foo.exe",
"--gtest_filter=",
@@ -5774,7 +5773,7 @@ TEST_F(InitGoogleTestTest, FilterEmpty) {
}
// Tests parsing a non-empty --gtest_filter flag.
-TEST_F(InitGoogleTestTest, FilterNonEmpty) {
+TEST_F(ParseFlagsTest, FilterNonEmpty) {
const char* argv[] = {
"foo.exe",
"--gtest_filter=abc",
@@ -5790,7 +5789,7 @@ TEST_F(InitGoogleTestTest, FilterNonEmpty) {
}
// Tests parsing --gtest_break_on_failure.
-TEST_F(InitGoogleTestTest, BreakOnFailureWithoutValue) {
+TEST_F(ParseFlagsTest, BreakOnFailureWithoutValue) {
const char* argv[] = {
"foo.exe",
"--gtest_break_on_failure",
@@ -5806,7 +5805,7 @@ TEST_F(InitGoogleTestTest, BreakOnFailureWithoutValue) {
}
// Tests parsing --gtest_break_on_failure=0.
-TEST_F(InitGoogleTestTest, BreakOnFailureFalse_0) {
+TEST_F(ParseFlagsTest, BreakOnFailureFalse_0) {
const char* argv[] = {
"foo.exe",
"--gtest_break_on_failure=0",
@@ -5822,7 +5821,7 @@ TEST_F(InitGoogleTestTest, BreakOnFailureFalse_0) {
}
// Tests parsing --gtest_break_on_failure=f.
-TEST_F(InitGoogleTestTest, BreakOnFailureFalse_f) {
+TEST_F(ParseFlagsTest, BreakOnFailureFalse_f) {
const char* argv[] = {
"foo.exe",
"--gtest_break_on_failure=f",
@@ -5838,7 +5837,7 @@ TEST_F(InitGoogleTestTest, BreakOnFailureFalse_f) {
}
// Tests parsing --gtest_break_on_failure=F.
-TEST_F(InitGoogleTestTest, BreakOnFailureFalse_F) {
+TEST_F(ParseFlagsTest, BreakOnFailureFalse_F) {
const char* argv[] = {
"foo.exe",
"--gtest_break_on_failure=F",
@@ -5855,7 +5854,7 @@ TEST_F(InitGoogleTestTest, BreakOnFailureFalse_F) {
// Tests parsing a --gtest_break_on_failure flag that has a "true"
// definition.
-TEST_F(InitGoogleTestTest, BreakOnFailureTrue) {
+TEST_F(ParseFlagsTest, BreakOnFailureTrue) {
const char* argv[] = {
"foo.exe",
"--gtest_break_on_failure=1",
@@ -5871,7 +5870,7 @@ TEST_F(InitGoogleTestTest, BreakOnFailureTrue) {
}
// Tests parsing --gtest_catch_exceptions.
-TEST_F(InitGoogleTestTest, CatchExceptions) {
+TEST_F(ParseFlagsTest, CatchExceptions) {
const char* argv[] = {
"foo.exe",
"--gtest_catch_exceptions",
@@ -5887,7 +5886,7 @@ TEST_F(InitGoogleTestTest, CatchExceptions) {
}
// Tests parsing --gtest_death_test_use_fork.
-TEST_F(InitGoogleTestTest, DeathTestUseFork) {
+TEST_F(ParseFlagsTest, DeathTestUseFork) {
const char* argv[] = {
"foo.exe",
"--gtest_death_test_use_fork",
@@ -5904,7 +5903,7 @@ TEST_F(InitGoogleTestTest, DeathTestUseFork) {
// Tests having the same flag twice with different values. The
// expected behavior is that the one coming last takes precedence.
-TEST_F(InitGoogleTestTest, DuplicatedFlags) {
+TEST_F(ParseFlagsTest, DuplicatedFlags) {
const char* argv[] = {
"foo.exe",
"--gtest_filter=a",
@@ -5921,7 +5920,7 @@ TEST_F(InitGoogleTestTest, DuplicatedFlags) {
}
// Tests having an unrecognized flag on the command line.
-TEST_F(InitGoogleTestTest, UnrecognizedFlag) {
+TEST_F(ParseFlagsTest, UnrecognizedFlag) {
const char* argv[] = {
"foo.exe",
"--gtest_break_on_failure",
@@ -5943,7 +5942,7 @@ TEST_F(InitGoogleTestTest, UnrecognizedFlag) {
}
// Tests having a --gtest_list_tests flag
-TEST_F(InitGoogleTestTest, ListTestsFlag) {
+TEST_F(ParseFlagsTest, ListTestsFlag) {
const char* argv[] = {
"foo.exe",
"--gtest_list_tests",
@@ -5959,7 +5958,7 @@ TEST_F(InitGoogleTestTest, ListTestsFlag) {
}
// Tests having a --gtest_list_tests flag with a "true" value
-TEST_F(InitGoogleTestTest, ListTestsTrue) {
+TEST_F(ParseFlagsTest, ListTestsTrue) {
const char* argv[] = {
"foo.exe",
"--gtest_list_tests=1",
@@ -5975,7 +5974,7 @@ TEST_F(InitGoogleTestTest, ListTestsTrue) {
}
// Tests having a --gtest_list_tests flag with a "false" value
-TEST_F(InitGoogleTestTest, ListTestsFalse) {
+TEST_F(ParseFlagsTest, ListTestsFalse) {
const char* argv[] = {
"foo.exe",
"--gtest_list_tests=0",
@@ -5991,7 +5990,7 @@ TEST_F(InitGoogleTestTest, ListTestsFalse) {
}
// Tests parsing --gtest_list_tests=f.
-TEST_F(InitGoogleTestTest, ListTestsFalse_f) {
+TEST_F(ParseFlagsTest, ListTestsFalse_f) {
const char* argv[] = {
"foo.exe",
"--gtest_list_tests=f",
@@ -6007,7 +6006,7 @@ TEST_F(InitGoogleTestTest, ListTestsFalse_f) {
}
// Tests parsing --gtest_list_tests=F.
-TEST_F(InitGoogleTestTest, ListTestsFalse_F) {
+TEST_F(ParseFlagsTest, ListTestsFalse_F) {
const char* argv[] = {
"foo.exe",
"--gtest_list_tests=F",
@@ -6023,7 +6022,7 @@ TEST_F(InitGoogleTestTest, ListTestsFalse_F) {
}
// Tests parsing --gtest_output (invalid).
-TEST_F(InitGoogleTestTest, OutputEmpty) {
+TEST_F(ParseFlagsTest, OutputEmpty) {
const char* argv[] = {
"foo.exe",
"--gtest_output",
@@ -6040,7 +6039,7 @@ TEST_F(InitGoogleTestTest, OutputEmpty) {
}
// Tests parsing --gtest_output=xml
-TEST_F(InitGoogleTestTest, OutputXml) {
+TEST_F(ParseFlagsTest, OutputXml) {
const char* argv[] = {
"foo.exe",
"--gtest_output=xml",
@@ -6056,7 +6055,7 @@ TEST_F(InitGoogleTestTest, OutputXml) {
}
// Tests parsing --gtest_output=xml:file
-TEST_F(InitGoogleTestTest, OutputXmlFile) {
+TEST_F(ParseFlagsTest, OutputXmlFile) {
const char* argv[] = {
"foo.exe",
"--gtest_output=xml:file",
@@ -6072,7 +6071,7 @@ TEST_F(InitGoogleTestTest, OutputXmlFile) {
}
// Tests parsing --gtest_output=xml:directory/path/
-TEST_F(InitGoogleTestTest, OutputXmlDirectory) {
+TEST_F(ParseFlagsTest, OutputXmlDirectory) {
const char* argv[] = {
"foo.exe",
"--gtest_output=xml:directory/path/",
@@ -6089,7 +6088,7 @@ TEST_F(InitGoogleTestTest, OutputXmlDirectory) {
}
// Tests having a --gtest_print_time flag
-TEST_F(InitGoogleTestTest, PrintTimeFlag) {
+TEST_F(ParseFlagsTest, PrintTimeFlag) {
const char* argv[] = {
"foo.exe",
"--gtest_print_time",
@@ -6105,7 +6104,7 @@ TEST_F(InitGoogleTestTest, PrintTimeFlag) {
}
// Tests having a --gtest_print_time flag with a "true" value
-TEST_F(InitGoogleTestTest, PrintTimeTrue) {
+TEST_F(ParseFlagsTest, PrintTimeTrue) {
const char* argv[] = {
"foo.exe",
"--gtest_print_time=1",
@@ -6121,7 +6120,7 @@ TEST_F(InitGoogleTestTest, PrintTimeTrue) {
}
// Tests having a --gtest_print_time flag with a "false" value
-TEST_F(InitGoogleTestTest, PrintTimeFalse) {
+TEST_F(ParseFlagsTest, PrintTimeFalse) {
const char* argv[] = {
"foo.exe",
"--gtest_print_time=0",
@@ -6137,7 +6136,7 @@ TEST_F(InitGoogleTestTest, PrintTimeFalse) {
}
// Tests parsing --gtest_print_time=f.
-TEST_F(InitGoogleTestTest, PrintTimeFalse_f) {
+TEST_F(ParseFlagsTest, PrintTimeFalse_f) {
const char* argv[] = {
"foo.exe",
"--gtest_print_time=f",
@@ -6153,7 +6152,7 @@ TEST_F(InitGoogleTestTest, PrintTimeFalse_f) {
}
// Tests parsing --gtest_print_time=F.
-TEST_F(InitGoogleTestTest, PrintTimeFalse_F) {
+TEST_F(ParseFlagsTest, PrintTimeFalse_F) {
const char* argv[] = {
"foo.exe",
"--gtest_print_time=F",
@@ -6169,7 +6168,7 @@ TEST_F(InitGoogleTestTest, PrintTimeFalse_F) {
}
// Tests parsing --gtest_random_seed=number
-TEST_F(InitGoogleTestTest, RandomSeed) {
+TEST_F(ParseFlagsTest, RandomSeed) {
const char* argv[] = {
"foo.exe",
"--gtest_random_seed=1000",
@@ -6185,7 +6184,7 @@ TEST_F(InitGoogleTestTest, RandomSeed) {
}
// Tests parsing --gtest_repeat=number
-TEST_F(InitGoogleTestTest, Repeat) {
+TEST_F(ParseFlagsTest, Repeat) {
const char* argv[] = {
"foo.exe",
"--gtest_repeat=1000",
@@ -6201,7 +6200,7 @@ TEST_F(InitGoogleTestTest, Repeat) {
}
// Tests having a --gtest_also_run_disabled_tests flag
-TEST_F(InitGoogleTestTest, AlsoRunDisabledTestsFlag) {
+TEST_F(ParseFlagsTest, AlsoRunDisabledTestsFlag) {
const char* argv[] = {
"foo.exe",
"--gtest_also_run_disabled_tests",
@@ -6218,7 +6217,7 @@ TEST_F(InitGoogleTestTest, AlsoRunDisabledTestsFlag) {
}
// Tests having a --gtest_also_run_disabled_tests flag with a "true" value
-TEST_F(InitGoogleTestTest, AlsoRunDisabledTestsTrue) {
+TEST_F(ParseFlagsTest, AlsoRunDisabledTestsTrue) {
const char* argv[] = {
"foo.exe",
"--gtest_also_run_disabled_tests=1",
@@ -6235,7 +6234,7 @@ TEST_F(InitGoogleTestTest, AlsoRunDisabledTestsTrue) {
}
// Tests having a --gtest_also_run_disabled_tests flag with a "false" value
-TEST_F(InitGoogleTestTest, AlsoRunDisabledTestsFalse) {
+TEST_F(ParseFlagsTest, AlsoRunDisabledTestsFalse) {
const char* argv[] = {
"foo.exe",
"--gtest_also_run_disabled_tests=0",
@@ -6252,7 +6251,7 @@ TEST_F(InitGoogleTestTest, AlsoRunDisabledTestsFalse) {
}
// Tests parsing --gtest_shuffle.
-TEST_F(InitGoogleTestTest, ShuffleWithoutValue) {
+TEST_F(ParseFlagsTest, ShuffleWithoutValue) {
const char* argv[] = {
"foo.exe",
"--gtest_shuffle",
@@ -6268,7 +6267,7 @@ TEST_F(InitGoogleTestTest, ShuffleWithoutValue) {
}
// Tests parsing --gtest_shuffle=0.
-TEST_F(InitGoogleTestTest, ShuffleFalse_0) {
+TEST_F(ParseFlagsTest, ShuffleFalse_0) {
const char* argv[] = {
"foo.exe",
"--gtest_shuffle=0",
@@ -6283,9 +6282,8 @@ TEST_F(InitGoogleTestTest, ShuffleFalse_0) {
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Shuffle(false), false);
}
-// Tests parsing a --gtest_shuffle flag that has a "true"
-// definition.
-TEST_F(InitGoogleTestTest, ShuffleTrue) {
+// Tests parsing a --gtest_shuffle flag that has a "true" definition.
+TEST_F(ParseFlagsTest, ShuffleTrue) {
const char* argv[] = {
"foo.exe",
"--gtest_shuffle=1",
@@ -6301,7 +6299,7 @@ TEST_F(InitGoogleTestTest, ShuffleTrue) {
}
// Tests parsing --gtest_stack_trace_depth=number.
-TEST_F(InitGoogleTestTest, StackTraceDepth) {
+TEST_F(ParseFlagsTest, StackTraceDepth) {
const char* argv[] = {
"foo.exe",
"--gtest_stack_trace_depth=5",
@@ -6316,7 +6314,7 @@ TEST_F(InitGoogleTestTest, StackTraceDepth) {
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::StackTraceDepth(5), false);
}
-TEST_F(InitGoogleTestTest, StreamResultTo) {
+TEST_F(ParseFlagsTest, StreamResultTo) {
const char* argv[] = {
"foo.exe",
"--gtest_stream_result_to=localhost:1234",
@@ -6333,7 +6331,7 @@ TEST_F(InitGoogleTestTest, StreamResultTo) {
}
// Tests parsing --gtest_throw_on_failure.
-TEST_F(InitGoogleTestTest, ThrowOnFailureWithoutValue) {
+TEST_F(ParseFlagsTest, ThrowOnFailureWithoutValue) {
const char* argv[] = {
"foo.exe",
"--gtest_throw_on_failure",
@@ -6349,7 +6347,7 @@ TEST_F(InitGoogleTestTest, ThrowOnFailureWithoutValue) {
}
// Tests parsing --gtest_throw_on_failure=0.
-TEST_F(InitGoogleTestTest, ThrowOnFailureFalse_0) {
+TEST_F(ParseFlagsTest, ThrowOnFailureFalse_0) {
const char* argv[] = {
"foo.exe",
"--gtest_throw_on_failure=0",
@@ -6366,7 +6364,7 @@ TEST_F(InitGoogleTestTest, ThrowOnFailureFalse_0) {
// Tests parsing a --gtest_throw_on_failure flag that has a "true"
// definition.
-TEST_F(InitGoogleTestTest, ThrowOnFailureTrue) {
+TEST_F(ParseFlagsTest, ThrowOnFailureTrue) {
const char* argv[] = {
"foo.exe",
"--gtest_throw_on_failure=1",
@@ -6381,9 +6379,9 @@ TEST_F(InitGoogleTestTest, ThrowOnFailureTrue) {
GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ThrowOnFailure(true), false);
}
-#if GTEST_OS_WINDOWS
+# if GTEST_OS_WINDOWS
// Tests parsing wide strings.
-TEST_F(InitGoogleTestTest, WideStrings) {
+TEST_F(ParseFlagsTest, WideStrings) {
const wchar_t* argv[] = {
L"foo.exe",
L"--gtest_filter=Foo*",
@@ -6409,10 +6407,10 @@ TEST_F(InitGoogleTestTest, WideStrings) {
# endif // GTEST_OS_WINDOWS
#if GTEST_USE_OWN_FLAGFILE_FLAG_
-class FlagfileTest : public InitGoogleTestTest {
+class FlagfileTest : public ParseFlagsTest {
public:
virtual void SetUp() {
- InitGoogleTestTest::SetUp();
+ ParseFlagsTest::SetUp();
testdata_path_.Set(internal::FilePath(
testing::TempDir() + internal::GetCurrentExecutableName().string() +
@@ -6423,7 +6421,7 @@ class FlagfileTest : public InitGoogleTestTest {
virtual void TearDown() {
testing::internal::posix::RmDir(testdata_path_.c_str());
- InitGoogleTestTest::TearDown();
+ ParseFlagsTest::TearDown();
}
internal::FilePath CreateFlagfile(const char* contents) {
@@ -6562,6 +6560,7 @@ TEST_F(CurrentTestInfoTest, WorksForSecondTestInATestCase) {
} // namespace testing
+
// These two lines test that we can define tests in a namespace that
// has the name "testing" and is nested in another namespace.
namespace my_namespace {
@@ -6642,7 +6641,7 @@ TEST(StreamingAssertionsTest, Truth2) {
}
#ifdef __BORLANDC__
-// Restores warnings after previous "#pragma option push" supressed them
+// Restores warnings after previous "#pragma option push" suppressed them
# pragma option pop
#endif
@@ -6892,14 +6891,6 @@ TEST(StaticAssertTypeEqTest, CompilesForEqualTypes) {
StaticAssertTypeEq<int*, IntAlias*>();
}
-TEST(GetCurrentOsStackTraceExceptTopTest, ReturnsTheStackTrace) {
- testing::UnitTest* const unit_test = testing::UnitTest::GetInstance();
-
- // We don't have a stack walker in Google Test yet.
- EXPECT_STREQ("", GetCurrentOsStackTraceExceptTop(unit_test, 0).c_str());
- EXPECT_STREQ("", GetCurrentOsStackTraceExceptTop(unit_test, 1).c_str());
-}
-
TEST(HasNonfatalFailureTest, ReturnsFalseWhenThereIsNoFailure) {
EXPECT_FALSE(HasNonfatalFailure());
}
@@ -7659,7 +7650,7 @@ TEST(NativeArrayTest, MethodsWork) {
EXPECT_EQ(0, *it);
++it;
EXPECT_EQ(1, *it);
- ++it;
+ it++;
EXPECT_EQ(2, *it);
++it;
EXPECT_EQ(na.end(), it);
diff --git a/googletest/xcode/Scripts/versiongenerate.py b/googletest/xcode/Scripts/versiongenerate.py
index 16791d2..bdd7541 100755
--- a/googletest/xcode/Scripts/versiongenerate.py
+++ b/googletest/xcode/Scripts/versiongenerate.py
@@ -29,7 +29,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.
-"""A script to prepare version informtion for use the gtest Info.plist file.
+"""A script to prepare version information for use the gtest Info.plist file.
This script extracts the version information from the configure.ac file and
uses it to generate a header file containing the same information. The