Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 4 additions & 48 deletions deps/googletest/include/gtest/gtest-death-test.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,54 +105,10 @@ GTEST_API_ bool InDeathTestChild();
//
// On the regular expressions used in death tests:
//
// On POSIX-compliant systems (*nix), we use the <regex.h> library,
// which uses the POSIX extended regex syntax.
//
// On other platforms (e.g. Windows or Mac), we only support a simple regex
// syntax implemented as part of Google Test. This limited
// implementation should be enough most of the time when writing
// death tests; though it lacks many features you can find in PCRE
// or POSIX extended regex syntax. For example, we don't support
// union ("x|y"), grouping ("(xy)"), brackets ("[xy]"), and
// repetition count ("x{5,7}"), among others.
//
// Below is the syntax that we do support. We chose it to be a
// subset of both PCRE and POSIX extended regex, so it's easy to
// learn wherever you come from. In the following: 'A' denotes a
// literal character, period (.), or a single \\ escape sequence;
// 'x' and 'y' denote regular expressions; 'm' and 'n' are for
// natural numbers.
//
// c matches any literal character c
// \\d matches any decimal digit
// \\D matches any character that's not a decimal digit
// \\f matches \f
// \\n matches \n
// \\r matches \r
// \\s matches any ASCII whitespace, including \n
// \\S matches any character that's not a whitespace
// \\t matches \t
// \\v matches \v
// \\w matches any letter, _, or decimal digit
// \\W matches any character that \\w doesn't match
// \\c matches any literal character c, which must be a punctuation
// . matches any single character except \n
// A? matches 0 or 1 occurrences of A
// A* matches 0 or many occurrences of A
// A+ matches 1 or many occurrences of A
// ^ matches the beginning of a string (not that of each line)
// $ matches the end of a string (not that of each line)
// xy matches x followed by y
//
// If you accidentally use PCRE or POSIX extended regex features
// not implemented by us, you will get a run-time failure. In that
// case, please try to rewrite your regular expression within the
// above syntax.
//
// This implementation is *not* meant to be as highly tuned or robust
// as a compiled regex library, but should perform well enough for a
// death test, which already incurs significant overhead by launching
// a child process.
// Depending on the platform, this may use RE2, the POSIX <regex.h> library,
// the C++11 standard library's <regex> engine with ECMAScript syntax, or
// another similar engine. Regular expressions should be simple and portable
// enough to work across the engines of interest.
//
// Known caveats:
//
Expand Down
32 changes: 17 additions & 15 deletions deps/googletest/include/gtest/internal/gtest-port.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
// GTEST_USES_POSIX_RE - enhanced POSIX regex is used. Do not confuse with
// GTEST_HAS_POSIX_RE (see above) which users can
// define themselves.
// GTEST_USES_SIMPLE_RE - our own simple regex is used;
// GTEST_USES_STD_RE - std::regex from the C++ standard library is used;
// the above RE\b(s) are mutually exclusive.
// GTEST_HAS_ABSL - Google Test is compiled with Abseil.

Expand Down Expand Up @@ -438,8 +438,9 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
#include <regex.h> // NOLINT
#define GTEST_USES_POSIX_RE 1
#else
// Use our own simple regex implementation.
#define GTEST_USES_SIMPLE_RE 1
// Use std::regex from the C++ standard library.
#include <regex> // NOLINT
#define GTEST_USES_STD_RE 1
#endif

#ifndef GTEST_HAS_EXCEPTIONS
Expand Down Expand Up @@ -992,12 +993,11 @@ class GTEST_API_ [[nodiscard]] RE {
RE2 regex_;
};

#elif defined(GTEST_USES_POSIX_RE) || defined(GTEST_USES_SIMPLE_RE)
#elif defined(GTEST_USES_POSIX_RE) || defined(GTEST_USES_STD_RE)
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
/* class A needs to have dll-interface to be used by clients of class B */)

// A simple C++ wrapper for <regex.h>. It uses the POSIX Extended
// Regular Expression syntax.
// A simple C++ wrapper for <regex.h> or <regex>.
class GTEST_API_ [[nodiscard]] RE {
public:
// A copy constructor is required by the Standard to initialize object
Expand Down Expand Up @@ -1037,9 +1037,9 @@ class GTEST_API_ [[nodiscard]] RE {
regex_t full_regex_; // For FullMatch().
regex_t partial_regex_; // For PartialMatch().

#else // GTEST_USES_SIMPLE_RE
#else // GTEST_USES_STD_RE

std::string full_pattern_; // For FullMatch();
std::regex regex_;

#endif
};
Expand Down Expand Up @@ -1755,14 +1755,16 @@ class [[nodiscard]] MutexBase {
#define GTEST_DECLARE_STATIC_MUTEX_(mutex) \
extern ::testing::internal::MutexBase mutex

#if defined(PTHREAD_NULL)
#define GTEST_INTERNAL_PTHREAD_NULL PTHREAD_NULL
#else
#define GTEST_INTERNAL_PTHREAD_NULL (pthread_t{})
#endif

// Defines and statically (i.e. at link time) initializes a static mutex.
// The initialization list here does not explicitly initialize each field,
// instead relying on default initialization for the unspecified fields. In
// particular, the owner_ field (a pthread_t) is not explicitly initialized.
// This allows initialization to work whether pthread_t is a scalar or struct.
// The flag -Wmissing-field-initializers must not be specified for this to work.
#define GTEST_DEFINE_STATIC_MUTEX_(mutex) \
::testing::internal::MutexBase mutex = {PTHREAD_MUTEX_INITIALIZER, false, 0}
#define GTEST_DEFINE_STATIC_MUTEX_(mutex) \
::testing::internal::MutexBase mutex = {PTHREAD_MUTEX_INITIALIZER, false, \
GTEST_INTERNAL_PTHREAD_NULL}

// The Mutex class can only be used for mutexes created at runtime. It
// shares its API with MutexBase otherwise.
Expand Down
21 changes: 1 addition & 20 deletions deps/googletest/src/gtest-internal-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -980,26 +980,7 @@ inline UnitTestImpl* GetUnitTestImpl() {
return UnitTest::GetInstance()->impl();
}

#ifdef GTEST_USES_SIMPLE_RE

// Internal helper functions for implementing the simple regular
// expression matcher.
GTEST_API_ bool IsInSet(char ch, const char* str);
GTEST_API_ bool IsAsciiDigit(char ch);
GTEST_API_ bool IsAsciiPunct(char ch);
GTEST_API_ bool IsRepeat(char ch);
GTEST_API_ bool IsAsciiWhiteSpace(char ch);
GTEST_API_ bool IsAsciiWordChar(char ch);
GTEST_API_ bool IsValidEscape(char ch);
GTEST_API_ bool AtomMatchesChar(bool escaped, char pattern, char ch);
GTEST_API_ bool ValidateRegex(const char* regex);
GTEST_API_ bool MatchRegexAtHead(const char* regex, const char* str);
GTEST_API_ bool MatchRepetitionAndRegexAtHead(bool escaped, char ch,
char repeat, const char* regex,
const char* str);
GTEST_API_ bool MatchRegexAnywhere(const char* regex, const char* str);

#endif // GTEST_USES_SIMPLE_RE


// Parses the command line for Google Test flags, without initializing
// other parts of Google Test.
Expand Down
Loading
Loading