mirror of
https://github.com/google/googletest.git
synced 2026-10-28 18:07:18 +08:00
Previously, non-Abseil builds of GoogleTest used either the POSIX <regex.h> header, or a hand-rolled bare-bones regex engine in GoogleTest.
This commit removes the custom regex engine and switches to the C++11 <regex> header instead, which primarily affects Windows builds. Correspondingly, the GTEST_USES_SIMPLE_RE macro is removed and GTEST_USES_STD_RE is defined in its place, so users that depend on the macro should update their code accordingly.
This commit may break on any exotic toolchains or platforms that lack all of these libraries, but these have been long unsupported, as GoogleTest requires C++17.
Note: MSVC's engine can be prone to overflowing the stack on some patterns and inputs. As a trivial example:
#include <regex>
int main() {
std::string corpus;
for (size_t i = 0; i < 1000; ++i) {
corpus += "a\n";
}
// Stack overflow
std::regex_match(corpus, std::regex("(\n|.)*", std::regex_constants::ECMAScript));
}
In such cases, it is recommended to use alternative patterns accomplishing the same goal, such as checking for pieces of a pattern independently.
PiperOrigin-RevId: 978659894
Change-Id: I4594285e696af12a008e1e4cee300f292bbdbf32
|
||
|---|---|---|
| .. | ||
| cmake | ||
| docs | ||
| include/gmock | ||
| src | ||
| test | ||
| CMakeLists.txt | ||
| README.md | ||
Googletest Mocking (gMock) Framework
Overview
Google's framework for writing and using C++ mock classes. It can help you derive better designs of your system and write better tests.
It is inspired by:
It is designed with C++'s specifics in mind.
gMock:
- Provides a declarative syntax for defining mocks.
- Can define partial (hybrid) mocks, which are a cross of real and mock objects.
- Handles functions of arbitrary types and overloaded functions.
- Comes with a rich set of matchers for validating function arguments.
- Uses an intuitive syntax for controlling the behavior of a mock.
- Does automatic verification of expectations (no record-and-replay needed).
- Allows arbitrary (partial) ordering constraints on function calls to be expressed.
- Lets a user extend it by defining new matchers and actions.
- Does not use exceptions.
- Is easy to learn and use.
Details and examples can be found here:
GoogleMock is a part of GoogleTest C++ testing framework and a subject to the same requirements.