@ -170,6 +170,7 @@
// GTEST_HAS_TYPED_TEST - typed tests
// GTEST_HAS_TYPED_TEST_P - type-parameterized tests
// GTEST_IS_THREADSAFE - Google Test is thread-safe.
// GTEST_USES_RE2 - the RE2 regular expression library is used
// GTEST_USES_POSIX_RE - enhanced POSIX regex is used. Do not confuse with
// GTEST_HAS_POSIX_RE (see above) which users can
// define themselves.
@ -215,10 +216,13 @@
// - synchronization primitives.
//
// Regular expressions:
// RE - a simple regular expression class using the POSIX
// Extended Regular Expression syntax on UNIX-like platforms
// or a reduced regular exception syntax on other
// platforms, including Windows.
// RE - a simple regular expression class using
// 1) the RE2 syntax on all platforms when built with RE2
// and Abseil as dependencies
// 2) the POSIX Extended Regular Expression syntax on
// UNIX-like platforms,
// 3) A reduced regular exception syntax on other platforms,
// including Windows.
// Logging:
// GTEST_LOG_() - logs messages at the specified severity level.
// LogToStderr() - directs all log messages to stderr.
@ -385,32 +389,19 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
# endif
# endif
# if GTEST_USES_PCRE
// The appropriate headers have already been included.
// Select the regular expression implementation.
# if GTEST_HAS_ABSL
// When using Abseil, RE2 is required.
# include "absl/strings/string_view.h"
# include "re2/re2.h"
# define GTEST_USES_RE2 1
# elif GTEST_HAS_POSIX_RE
// On some platforms, <regex.h> needs someone to define size_t, and
// won't compile otherwise. We can #include it here as we already
// included <stdlib.h>, which is guaranteed to define size_t through
// <stddef.h>.
# include <regex.h> // NOLINT
# define GTEST_USES_POSIX_RE 1
# elif GTEST_OS_WINDOWS
// <regex.h> is not available on Windows. Use our own simple regex
// implementation instead.
# define GTEST_USES_SIMPLE_RE 1
# else
// <regex.h> may not be available on this platform. Use our own
// simple regex implementation instead.
// Use our own simple regex implementation.
# define GTEST_USES_SIMPLE_RE 1
# endif // GTEST_USES_PCRE
# endif
# ifndef GTEST_HAS_EXCEPTIONS
// The user didn't tell us whether exceptions are enabled, so we need
@ -868,8 +859,31 @@ GTEST_API_ bool IsTrue(bool condition);
// Defines RE.
# if GTEST_USES_PCRE
// if used, PCRE is injected by custom/gtest-port.h
# if GTEST_USES_RE2
// This is almost `using RE = ::RE2`, except it is copy-constructible, and it
// needs to disambiguate the `std::string`, `absl::string_view`, and `const
// char*` constructors.
class GTEST_API_ RE {
public :
RE ( absl : : string_view regex ) : regex_ ( regex ) { } // NOLINT
RE ( const char * regex ) : RE ( absl : : string_view ( regex ) ) { } // NOLINT
RE ( const std : : string & regex ) : RE ( absl : : string_view ( regex ) ) { } // NOLINT
RE ( const RE & other ) : RE ( other . pattern ( ) ) { }
const std : : string & pattern ( ) const { return regex_ . pattern ( ) ; }
static bool FullMatch ( absl : : string_view str , const RE & re ) {
return RE2 : : FullMatch ( str , re . regex_ ) ;
}
static bool PartialMatch ( absl : : string_view str , const RE & re ) {
return RE2 : : PartialMatch ( str , re . regex_ ) ;
}
private :
RE2 regex_ ;
} ;
# elif GTEST_USES_POSIX_RE || GTEST_USES_SIMPLE_RE
// A simple C++ wrapper for <regex.h>. It uses the POSIX Extended
@ -920,7 +934,7 @@ class GTEST_API_ RE {
# endif
} ;
# endif // GTEST_USES_PCRE
# endif // ::testing::internal::RE implementation
// 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.