Skip to content

Commit 56249b0

Browse files
nodejs-github-botruyadorno
authored andcommittedSep 12, 2023
deps: update googletest to ec4fed9
PR-URL: #48538 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
1 parent 0c38184 commit 56249b0

24 files changed

+693
-583
lines changed
 

‎deps/googletest/include/gtest/gtest-assertion-result.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ class GTEST_API_ AssertionResult {
181181
// assertion's expectation). When nothing has been streamed into the
182182
// object, returns an empty string.
183183
const char* message() const {
184-
return message_.get() != nullptr ? message_->c_str() : "";
184+
return message_ != nullptr ? message_->c_str() : "";
185185
}
186186
// Deprecated; please use message() instead.
187187
const char* failure_message() const { return message(); }
@@ -204,7 +204,7 @@ class GTEST_API_ AssertionResult {
204204
private:
205205
// Appends the contents of message to message_.
206206
void AppendMessage(const Message& a_message) {
207-
if (message_.get() == nullptr) message_.reset(new ::std::string);
207+
if (message_ == nullptr) message_ = ::std::make_unique<::std::string>();
208208
message_->append(a_message.GetString().c_str());
209209
}
210210

‎deps/googletest/include/gtest/gtest-death-test.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ GTEST_DECLARE_string_(death_test_style);
5151

5252
namespace testing {
5353

54-
#if GTEST_HAS_DEATH_TEST
54+
#ifdef GTEST_HAS_DEATH_TEST
5555

5656
namespace internal {
5757

@@ -203,7 +203,7 @@ class GTEST_API_ ExitedWithCode {
203203
const int exit_code_;
204204
};
205205

206-
#if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA
206+
#if !defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_FUCHSIA)
207207
// Tests that an exit code describes an exit due to termination by a
208208
// given signal.
209209
class GTEST_API_ KilledBySignal {
@@ -328,7 +328,7 @@ class GTEST_API_ KilledBySignal {
328328
// death tests are supported; otherwise they just issue a warning. This is
329329
// useful when you are combining death test assertions with normal test
330330
// assertions in one test.
331-
#if GTEST_HAS_DEATH_TEST
331+
#ifdef GTEST_HAS_DEATH_TEST
332332
#define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
333333
EXPECT_DEATH(statement, regex)
334334
#define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \

‎deps/googletest/include/gtest/gtest-matchers.h

+22-55
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#define GOOGLETEST_INCLUDE_GTEST_GTEST_MATCHERS_H_
4141

4242
#include <atomic>
43+
#include <functional>
4344
#include <memory>
4445
#include <ostream>
4546
#include <string>
@@ -106,13 +107,13 @@ class MatchResultListener {
106107
MatchResultListener& operator=(const MatchResultListener&) = delete;
107108
};
108109

109-
inline MatchResultListener::~MatchResultListener() {}
110+
inline MatchResultListener::~MatchResultListener() = default;
110111

111112
// An instance of a subclass of this knows how to describe itself as a
112113
// matcher.
113114
class GTEST_API_ MatcherDescriberInterface {
114115
public:
115-
virtual ~MatcherDescriberInterface() {}
116+
virtual ~MatcherDescriberInterface() = default;
116117

117118
// Describes this matcher to an ostream. The function should print
118119
// a verb phrase that describes the property a value matching this
@@ -178,43 +179,6 @@ class MatcherInterface : public MatcherDescriberInterface {
178179

179180
namespace internal {
180181

181-
struct AnyEq {
182-
template <typename A, typename B>
183-
bool operator()(const A& a, const B& b) const {
184-
return a == b;
185-
}
186-
};
187-
struct AnyNe {
188-
template <typename A, typename B>
189-
bool operator()(const A& a, const B& b) const {
190-
return a != b;
191-
}
192-
};
193-
struct AnyLt {
194-
template <typename A, typename B>
195-
bool operator()(const A& a, const B& b) const {
196-
return a < b;
197-
}
198-
};
199-
struct AnyGt {
200-
template <typename A, typename B>
201-
bool operator()(const A& a, const B& b) const {
202-
return a > b;
203-
}
204-
};
205-
struct AnyLe {
206-
template <typename A, typename B>
207-
bool operator()(const A& a, const B& b) const {
208-
return a <= b;
209-
}
210-
};
211-
struct AnyGe {
212-
template <typename A, typename B>
213-
bool operator()(const A& a, const B& b) const {
214-
return a >= b;
215-
}
216-
};
217-
218182
// A match result listener that ignores the explanation.
219183
class DummyMatchResultListener : public MatchResultListener {
220184
public:
@@ -530,7 +494,7 @@ template <>
530494
class GTEST_API_ Matcher<const std::string&>
531495
: public internal::MatcherBase<const std::string&> {
532496
public:
533-
Matcher() {}
497+
Matcher() = default;
534498

535499
explicit Matcher(const MatcherInterface<const std::string&>* impl)
536500
: internal::MatcherBase<const std::string&>(impl) {}
@@ -552,7 +516,7 @@ template <>
552516
class GTEST_API_ Matcher<std::string>
553517
: public internal::MatcherBase<std::string> {
554518
public:
555-
Matcher() {}
519+
Matcher() = default;
556520

557521
explicit Matcher(const MatcherInterface<const std::string&>* impl)
558522
: internal::MatcherBase<std::string>(impl) {}
@@ -580,7 +544,7 @@ template <>
580544
class GTEST_API_ Matcher<const internal::StringView&>
581545
: public internal::MatcherBase<const internal::StringView&> {
582546
public:
583-
Matcher() {}
547+
Matcher() = default;
584548

585549
explicit Matcher(const MatcherInterface<const internal::StringView&>* impl)
586550
: internal::MatcherBase<const internal::StringView&>(impl) {}
@@ -606,7 +570,7 @@ template <>
606570
class GTEST_API_ Matcher<internal::StringView>
607571
: public internal::MatcherBase<internal::StringView> {
608572
public:
609-
Matcher() {}
573+
Matcher() = default;
610574

611575
explicit Matcher(const MatcherInterface<const internal::StringView&>* impl)
612576
: internal::MatcherBase<internal::StringView>(impl) {}
@@ -758,50 +722,53 @@ class ComparisonBase {
758722
};
759723

760724
template <typename Rhs>
761-
class EqMatcher : public ComparisonBase<EqMatcher<Rhs>, Rhs, AnyEq> {
725+
class EqMatcher : public ComparisonBase<EqMatcher<Rhs>, Rhs, std::equal_to<>> {
762726
public:
763727
explicit EqMatcher(const Rhs& rhs)
764-
: ComparisonBase<EqMatcher<Rhs>, Rhs, AnyEq>(rhs) {}
728+
: ComparisonBase<EqMatcher<Rhs>, Rhs, std::equal_to<>>(rhs) {}
765729
static const char* Desc() { return "is equal to"; }
766730
static const char* NegatedDesc() { return "isn't equal to"; }
767731
};
768732
template <typename Rhs>
769-
class NeMatcher : public ComparisonBase<NeMatcher<Rhs>, Rhs, AnyNe> {
733+
class NeMatcher
734+
: public ComparisonBase<NeMatcher<Rhs>, Rhs, std::not_equal_to<>> {
770735
public:
771736
explicit NeMatcher(const Rhs& rhs)
772-
: ComparisonBase<NeMatcher<Rhs>, Rhs, AnyNe>(rhs) {}
737+
: ComparisonBase<NeMatcher<Rhs>, Rhs, std::not_equal_to<>>(rhs) {}
773738
static const char* Desc() { return "isn't equal to"; }
774739
static const char* NegatedDesc() { return "is equal to"; }
775740
};
776741
template <typename Rhs>
777-
class LtMatcher : public ComparisonBase<LtMatcher<Rhs>, Rhs, AnyLt> {
742+
class LtMatcher : public ComparisonBase<LtMatcher<Rhs>, Rhs, std::less<>> {
778743
public:
779744
explicit LtMatcher(const Rhs& rhs)
780-
: ComparisonBase<LtMatcher<Rhs>, Rhs, AnyLt>(rhs) {}
745+
: ComparisonBase<LtMatcher<Rhs>, Rhs, std::less<>>(rhs) {}
781746
static const char* Desc() { return "is <"; }
782747
static const char* NegatedDesc() { return "isn't <"; }
783748
};
784749
template <typename Rhs>
785-
class GtMatcher : public ComparisonBase<GtMatcher<Rhs>, Rhs, AnyGt> {
750+
class GtMatcher : public ComparisonBase<GtMatcher<Rhs>, Rhs, std::greater<>> {
786751
public:
787752
explicit GtMatcher(const Rhs& rhs)
788-
: ComparisonBase<GtMatcher<Rhs>, Rhs, AnyGt>(rhs) {}
753+
: ComparisonBase<GtMatcher<Rhs>, Rhs, std::greater<>>(rhs) {}
789754
static const char* Desc() { return "is >"; }
790755
static const char* NegatedDesc() { return "isn't >"; }
791756
};
792757
template <typename Rhs>
793-
class LeMatcher : public ComparisonBase<LeMatcher<Rhs>, Rhs, AnyLe> {
758+
class LeMatcher
759+
: public ComparisonBase<LeMatcher<Rhs>, Rhs, std::less_equal<>> {
794760
public:
795761
explicit LeMatcher(const Rhs& rhs)
796-
: ComparisonBase<LeMatcher<Rhs>, Rhs, AnyLe>(rhs) {}
762+
: ComparisonBase<LeMatcher<Rhs>, Rhs, std::less_equal<>>(rhs) {}
797763
static const char* Desc() { return "is <="; }
798764
static const char* NegatedDesc() { return "isn't <="; }
799765
};
800766
template <typename Rhs>
801-
class GeMatcher : public ComparisonBase<GeMatcher<Rhs>, Rhs, AnyGe> {
767+
class GeMatcher
768+
: public ComparisonBase<GeMatcher<Rhs>, Rhs, std::greater_equal<>> {
802769
public:
803770
explicit GeMatcher(const Rhs& rhs)
804-
: ComparisonBase<GeMatcher<Rhs>, Rhs, AnyGe>(rhs) {}
771+
: ComparisonBase<GeMatcher<Rhs>, Rhs, std::greater_equal<>>(rhs) {}
805772
static const char* Desc() { return "is >="; }
806773
static const char* NegatedDesc() { return "isn't >="; }
807774
};

‎deps/googletest/include/gtest/gtest-param-test.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,8 @@ internal::ParamConverterGenerator<T> ConvertGenerator(
449449

450450
#define TEST_P(test_suite_name, test_name) \
451451
class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \
452-
: public test_suite_name, private ::testing::internal::GTestNonCopyable {\
452+
: public test_suite_name, \
453+
private ::testing::internal::GTestNonCopyable { \
453454
public: \
454455
GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() {} \
455456
void TestBody() override; \

‎deps/googletest/include/gtest/gtest-printers.h

+20-12
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,13 @@ struct StreamPrinter {
206206
// Don't accept member pointers here. We'd print them via implicit
207207
// conversion to bool, which isn't useful.
208208
typename = typename std::enable_if<
209-
!std::is_member_pointer<T>::value>::type,
210-
// Only accept types for which we can find a streaming operator via
211-
// ADL (possibly involving implicit conversions).
212-
typename = decltype(std::declval<std::ostream&>()
213-
<< std::declval<const T&>())>
214-
static void PrintValue(const T& value, ::std::ostream* os) {
209+
!std::is_member_pointer<T>::value>::type>
210+
// Only accept types for which we can find a streaming operator via
211+
// ADL (possibly involving implicit conversions).
212+
// (Use SFINAE via return type, because it seems GCC < 12 doesn't handle name
213+
// lookup properly when we do it in the template parameter list.)
214+
static auto PrintValue(const T& value, ::std::ostream* os)
215+
-> decltype((void)(*os << value)) {
215216
// Call streaming operator found by ADL, possibly with implicit conversions
216217
// of the arguments.
217218
*os << value;
@@ -306,9 +307,10 @@ template <typename T>
306307
void PrintWithFallback(const T& value, ::std::ostream* os) {
307308
using Printer = typename FindFirstPrinter<
308309
T, void, ContainerPrinter, FunctionPointerPrinter, PointerPrinter,
310+
ProtobufPrinter,
309311
internal_stream_operator_without_lexical_name_lookup::StreamPrinter,
310-
ProtobufPrinter, ConvertibleToIntegerPrinter,
311-
ConvertibleToStringViewPrinter, RawBytesPrinter, FallbackPrinter>::type;
312+
ConvertibleToIntegerPrinter, ConvertibleToStringViewPrinter,
313+
RawBytesPrinter, FallbackPrinter>::type;
312314
Printer::PrintValue(value, os);
313315
}
314316

@@ -529,7 +531,10 @@ int AppropriateResolution(FloatType val) {
529531
} else if (val >= 0.0001) {
530532
mulfor6 = 1e9;
531533
}
532-
if (static_cast<int32_t>(val * mulfor6 + 0.5) / mulfor6 == val) return 6;
534+
if (static_cast<float>(static_cast<int32_t>(val * mulfor6 + 0.5)) /
535+
mulfor6 ==
536+
val)
537+
return 6;
533538
} else if (val < 1e10) {
534539
FloatType divfor6 = 1.0;
535540
if (val >= 1e9) { // 1,000,000,000 to 9,999,999,999
@@ -541,7 +546,10 @@ int AppropriateResolution(FloatType val) {
541546
} else if (val >= 1e6) { // 1,000,000 to 9,999,999
542547
divfor6 = 10;
543548
}
544-
if (static_cast<int32_t>(val / divfor6 + 0.5) * divfor6 == val) return 6;
549+
if (static_cast<float>(static_cast<int32_t>(val / divfor6 + 0.5)) *
550+
divfor6 ==
551+
val)
552+
return 6;
545553
}
546554
return full;
547555
}
@@ -850,7 +858,7 @@ class UniversalPrinter<Variant<T...>> {
850858
public:
851859
static void Print(const Variant<T...>& value, ::std::ostream* os) {
852860
*os << '(';
853-
#if GTEST_HAS_ABSL
861+
#ifdef GTEST_HAS_ABSL
854862
absl::visit(Visitor{os, value.index()}, value);
855863
#else
856864
std::visit(Visitor{os, value.index()}, value);
@@ -996,7 +1004,7 @@ template <>
9961004
class UniversalTersePrinter<char*> : public UniversalTersePrinter<const char*> {
9971005
};
9981006

999-
#ifdef __cpp_char8_t
1007+
#ifdef __cpp_lib_char8_t
10001008
template <>
10011009
class UniversalTersePrinter<const char8_t*> {
10021010
public:

‎deps/googletest/include/gtest/gtest-test-part.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ std::ostream& operator<<(std::ostream& os, const TestPartResult& result);
133133
// virtual.
134134
class GTEST_API_ TestPartResultArray {
135135
public:
136-
TestPartResultArray() {}
136+
TestPartResultArray() = default;
137137

138138
// Appends the given TestPartResult to the array.
139139
void Append(const TestPartResult& result);
@@ -154,7 +154,7 @@ class GTEST_API_ TestPartResultArray {
154154
// This interface knows how to report a test part result.
155155
class GTEST_API_ TestPartResultReporterInterface {
156156
public:
157-
virtual ~TestPartResultReporterInterface() {}
157+
virtual ~TestPartResultReporterInterface() = default;
158158

159159
virtual void ReportTestPartResult(const TestPartResult& result) = 0;
160160
};

‎deps/googletest/include/gtest/gtest-typed-test.h

+17-17
Original file line numberDiff line numberDiff line change
@@ -267,28 +267,28 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes);
267267
TYPED_TEST_SUITE_P
268268
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
269269

270-
#define TYPED_TEST_P(SuiteName, TestName) \
271-
namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \
272-
template <typename gtest_TypeParam_> \
273-
class TestName : public SuiteName<gtest_TypeParam_> { \
274-
private: \
275-
typedef SuiteName<gtest_TypeParam_> TestFixture; \
276-
typedef gtest_TypeParam_ TypeParam; \
277-
void TestBody() override; \
278-
}; \
279-
static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \
280-
GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).AddTestName( \
281-
__FILE__, __LINE__, GTEST_STRINGIFY_(SuiteName), \
282-
GTEST_STRINGIFY_(TestName)); \
283-
} \
284-
template <typename gtest_TypeParam_> \
285-
void GTEST_SUITE_NAMESPACE_( \
270+
#define TYPED_TEST_P(SuiteName, TestName) \
271+
namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \
272+
template <typename gtest_TypeParam_> \
273+
class TestName : public SuiteName<gtest_TypeParam_> { \
274+
private: \
275+
typedef SuiteName<gtest_TypeParam_> TestFixture; \
276+
typedef gtest_TypeParam_ TypeParam; \
277+
void TestBody() override; \
278+
}; \
279+
static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \
280+
GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).AddTestName( \
281+
__FILE__, __LINE__, GTEST_STRINGIFY_(SuiteName), \
282+
GTEST_STRINGIFY_(TestName)); \
283+
} \
284+
template <typename gtest_TypeParam_> \
285+
void GTEST_SUITE_NAMESPACE_( \
286286
SuiteName)::TestName<gtest_TypeParam_>::TestBody()
287287

288288
// Note: this won't work correctly if the trailing arguments are macros.
289289
#define REGISTER_TYPED_TEST_SUITE_P(SuiteName, ...) \
290290
namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \
291-
typedef ::testing::internal::Templates<__VA_ARGS__> gtest_AllTests_; \
291+
typedef ::testing::internal::Templates<__VA_ARGS__> gtest_AllTests_; \
292292
} \
293293
static const char* const GTEST_REGISTERED_TEST_NAMES_( \
294294
SuiteName) GTEST_ATTRIBUTE_UNUSED_ = \

‎deps/googletest/include/gtest/gtest.h

+37-34
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,7 @@ namespace testing {
166166

167167
// Silence C4100 (unreferenced formal parameter) and 4805
168168
// unsafe mix of type 'const int' and type 'const bool'
169-
#ifdef _MSC_VER
170-
#pragma warning(push)
171-
#pragma warning(disable : 4805)
172-
#pragma warning(disable : 4100)
173-
#endif
169+
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4805 4100)
174170

175171
// The upper limit for valid stack trace depths.
176172
const int kMaxStackTraceDepth = 100;
@@ -201,8 +197,8 @@ std::set<std::string>* GetIgnoredParameterizedTestSuites();
201197
class GTestNonCopyable {
202198
public:
203199
GTestNonCopyable() = default;
204-
GTestNonCopyable(const GTestNonCopyable &) = delete;
205-
GTestNonCopyable &operator=(const GTestNonCopyable &) = delete;
200+
GTestNonCopyable(const GTestNonCopyable&) = delete;
201+
GTestNonCopyable& operator=(const GTestNonCopyable&) = delete;
206202
~GTestNonCopyable() = default;
207203
};
208204

@@ -301,7 +297,13 @@ class GTEST_API_ Test {
301297
// SetUp/TearDown method of Environment objects registered with Google
302298
// Test) will be output as attributes of the <testsuites> element.
303299
static void RecordProperty(const std::string& key, const std::string& value);
304-
static void RecordProperty(const std::string& key, int64_t value);
300+
// We do not define a custom serialization except for values that can be
301+
// converted to int64_t, but other values could be logged in this way.
302+
template <typename T, std::enable_if_t<std::is_convertible<T, int64_t>::value,
303+
bool> = true>
304+
static void RecordProperty(const std::string& key, const T& value) {
305+
RecordProperty(key, (Message() << value).GetString());
306+
}
305307

306308
protected:
307309
// Creates a Test object.
@@ -549,14 +551,14 @@ class GTEST_API_ TestInfo {
549551
// Returns the name of the parameter type, or NULL if this is not a typed
550552
// or a type-parameterized test.
551553
const char* type_param() const {
552-
if (type_param_.get() != nullptr) return type_param_->c_str();
554+
if (type_param_ != nullptr) return type_param_->c_str();
553555
return nullptr;
554556
}
555557

556558
// Returns the text representation of the value parameter, or NULL if this
557559
// is not a value-parameterized test.
558560
const char* value_param() const {
559-
if (value_param_.get() != nullptr) return value_param_->c_str();
561+
if (value_param_ != nullptr) return value_param_->c_str();
560562
return nullptr;
561563
}
562564

@@ -598,7 +600,7 @@ class GTEST_API_ TestInfo {
598600
const TestResult* result() const { return &result_; }
599601

600602
private:
601-
#if GTEST_HAS_DEATH_TEST
603+
#ifdef GTEST_HAS_DEATH_TEST
602604
friend class internal::DefaultDeathTestFactory;
603605
#endif // GTEST_HAS_DEATH_TEST
604606
friend class Test;
@@ -695,7 +697,7 @@ class GTEST_API_ TestSuite {
695697
// Returns the name of the parameter type, or NULL if this is not a
696698
// type-parameterized test suite.
697699
const char* type_param() const {
698-
if (type_param_.get() != nullptr) return type_param_->c_str();
700+
if (type_param_ != nullptr) return type_param_->c_str();
699701
return nullptr;
700702
}
701703

@@ -892,7 +894,7 @@ class GTEST_API_ TestSuite {
892894
class Environment {
893895
public:
894896
// The d'tor is virtual as we need to subclass Environment.
895-
virtual ~Environment() {}
897+
virtual ~Environment() = default;
896898

897899
// Override this to define how to set up the environment.
898900
virtual void SetUp() {}
@@ -923,7 +925,7 @@ class GTEST_API_ AssertionException
923925
// the order the corresponding events are fired.
924926
class TestEventListener {
925927
public:
926-
virtual ~TestEventListener() {}
928+
virtual ~TestEventListener() = default;
927929

928930
// Fired before any test activity starts.
929931
virtual void OnTestProgramStart(const UnitTest& unit_test) = 0;
@@ -1053,6 +1055,10 @@ class GTEST_API_ TestEventListeners {
10531055
return default_xml_generator_;
10541056
}
10551057

1058+
// Controls whether events will be forwarded by the repeater to the
1059+
// listeners in the list.
1060+
void SuppressEventForwarding(bool);
1061+
10561062
private:
10571063
friend class TestSuite;
10581064
friend class TestInfo;
@@ -1082,7 +1088,6 @@ class GTEST_API_ TestEventListeners {
10821088
// Controls whether events will be forwarded by the repeater to the
10831089
// listeners in the list.
10841090
bool EventForwardingEnabled() const;
1085-
void SuppressEventForwarding();
10861091

10871092
// The actual list of listeners.
10881093
internal::TestEventRepeater* repeater_;
@@ -1669,7 +1674,7 @@ template <typename T>
16691674
class WithParamInterface {
16701675
public:
16711676
typedef T ParamType;
1672-
virtual ~WithParamInterface() {}
1677+
virtual ~WithParamInterface() = default;
16731678

16741679
// The current parameter value. Is also available in the test fixture's
16751680
// constructor.
@@ -1745,7 +1750,7 @@ class TestWithParam : public Test, public WithParamInterface<T> {};
17451750

17461751
// Define this macro to 1 to omit the definition of FAIL(), which is a
17471752
// generic name and clashes with some other libraries.
1748-
#if !GTEST_DONT_DEFINE_FAIL
1753+
#if !(defined(GTEST_DONT_DEFINE_FAIL) && GTEST_DONT_DEFINE_FAIL)
17491754
#define FAIL() GTEST_FAIL()
17501755
#endif
17511756

@@ -1754,7 +1759,7 @@ class TestWithParam : public Test, public WithParamInterface<T> {};
17541759

17551760
// Define this macro to 1 to omit the definition of SUCCEED(), which
17561761
// is a generic name and clashes with some other libraries.
1757-
#if !GTEST_DONT_DEFINE_SUCCEED
1762+
#if !(defined(GTEST_DONT_DEFINE_SUCCEED) && GTEST_DONT_DEFINE_SUCCEED)
17581763
#define SUCCEED() GTEST_SUCCEED()
17591764
#endif
17601765

@@ -1798,19 +1803,19 @@ class TestWithParam : public Test, public WithParamInterface<T> {};
17981803
// Define these macros to 1 to omit the definition of the corresponding
17991804
// EXPECT or ASSERT, which clashes with some users' own code.
18001805

1801-
#if !GTEST_DONT_DEFINE_EXPECT_TRUE
1806+
#if !(defined(GTEST_DONT_DEFINE_EXPECT_TRUE) && GTEST_DONT_DEFINE_EXPECT_TRUE)
18021807
#define EXPECT_TRUE(condition) GTEST_EXPECT_TRUE(condition)
18031808
#endif
18041809

1805-
#if !GTEST_DONT_DEFINE_EXPECT_FALSE
1810+
#if !(defined(GTEST_DONT_DEFINE_EXPECT_FALSE) && GTEST_DONT_DEFINE_EXPECT_FALSE)
18061811
#define EXPECT_FALSE(condition) GTEST_EXPECT_FALSE(condition)
18071812
#endif
18081813

1809-
#if !GTEST_DONT_DEFINE_ASSERT_TRUE
1814+
#if !(defined(GTEST_DONT_DEFINE_ASSERT_TRUE) && GTEST_DONT_DEFINE_ASSERT_TRUE)
18101815
#define ASSERT_TRUE(condition) GTEST_ASSERT_TRUE(condition)
18111816
#endif
18121817

1813-
#if !GTEST_DONT_DEFINE_ASSERT_FALSE
1818+
#if !(defined(GTEST_DONT_DEFINE_ASSERT_FALSE) && GTEST_DONT_DEFINE_ASSERT_FALSE)
18141819
#define ASSERT_FALSE(condition) GTEST_ASSERT_FALSE(condition)
18151820
#endif
18161821

@@ -1889,27 +1894,27 @@ class TestWithParam : public Test, public WithParamInterface<T> {};
18891894
// Define macro GTEST_DONT_DEFINE_ASSERT_XY to 1 to omit the definition of
18901895
// ASSERT_XY(), which clashes with some users' own code.
18911896

1892-
#if !GTEST_DONT_DEFINE_ASSERT_EQ
1897+
#if !(defined(GTEST_DONT_DEFINE_ASSERT_EQ) && GTEST_DONT_DEFINE_ASSERT_EQ)
18931898
#define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
18941899
#endif
18951900

1896-
#if !GTEST_DONT_DEFINE_ASSERT_NE
1901+
#if !(defined(GTEST_DONT_DEFINE_ASSERT_NE) && GTEST_DONT_DEFINE_ASSERT_NE)
18971902
#define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2)
18981903
#endif
18991904

1900-
#if !GTEST_DONT_DEFINE_ASSERT_LE
1905+
#if !(defined(GTEST_DONT_DEFINE_ASSERT_LE) && GTEST_DONT_DEFINE_ASSERT_LE)
19011906
#define ASSERT_LE(val1, val2) GTEST_ASSERT_LE(val1, val2)
19021907
#endif
19031908

1904-
#if !GTEST_DONT_DEFINE_ASSERT_LT
1909+
#if !(defined(GTEST_DONT_DEFINE_ASSERT_LT) && GTEST_DONT_DEFINE_ASSERT_LT)
19051910
#define ASSERT_LT(val1, val2) GTEST_ASSERT_LT(val1, val2)
19061911
#endif
19071912

1908-
#if !GTEST_DONT_DEFINE_ASSERT_GE
1913+
#if !(defined(GTEST_DONT_DEFINE_ASSERT_GE) && GTEST_DONT_DEFINE_ASSERT_GE)
19091914
#define ASSERT_GE(val1, val2) GTEST_ASSERT_GE(val1, val2)
19101915
#endif
19111916

1912-
#if !GTEST_DONT_DEFINE_ASSERT_GT
1917+
#if !(defined(GTEST_DONT_DEFINE_ASSERT_GT) && GTEST_DONT_DEFINE_ASSERT_GT)
19131918
#define ASSERT_GT(val1, val2) GTEST_ASSERT_GT(val1, val2)
19141919
#endif
19151920

@@ -1997,7 +2002,7 @@ GTEST_API_ AssertionResult FloatLE(const char* expr1, const char* expr2,
19972002
GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2,
19982003
double val1, double val2);
19992004

2000-
#if GTEST_OS_WINDOWS
2005+
#ifdef GTEST_OS_WINDOWS
20012006

20022007
// Macros that test for HRESULT failure and success, these are only useful
20032008
// on Windows, and rely on Windows SDK macros and APIs to compile.
@@ -2167,7 +2172,7 @@ constexpr bool StaticAssertTypeEq() noexcept {
21672172

21682173
// Define this macro to 1 to omit the definition of TEST(), which
21692174
// is a generic name and clashes with some other libraries.
2170-
#if !GTEST_DONT_DEFINE_TEST
2175+
#if !(defined(GTEST_DONT_DEFINE_TEST) && GTEST_DONT_DEFINE_TEST)
21712176
#define TEST(test_suite_name, test_name) GTEST_TEST(test_suite_name, test_name)
21722177
#endif
21732178

@@ -2199,7 +2204,7 @@ constexpr bool StaticAssertTypeEq() noexcept {
21992204
#define GTEST_TEST_F(test_fixture, test_name) \
22002205
GTEST_TEST_(test_fixture, test_name, test_fixture, \
22012206
::testing::internal::GetTypeId<test_fixture>())
2202-
#if !GTEST_DONT_DEFINE_TEST_F
2207+
#if !(defined(GTEST_DONT_DEFINE_TEST_F) && GTEST_DONT_DEFINE_TEST_F)
22032208
#define TEST_F(test_fixture, test_name) GTEST_TEST_F(test_fixture, test_name)
22042209
#endif
22052210

@@ -2214,9 +2219,7 @@ GTEST_API_ std::string TempDir();
22142219
// in it should be considered read-only.
22152220
GTEST_API_ std::string SrcDir();
22162221

2217-
#ifdef _MSC_VER
2218-
#pragma warning(pop)
2219-
#endif
2222+
GTEST_DISABLE_MSC_WARNINGS_POP_() // 4805 4100
22202223

22212224
// Dynamically registers a test with the framework.
22222225
//

‎deps/googletest/include/gtest/internal/gtest-death-test-internal.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const char kDeathTestStyleFlag[] = "death_test_style";
5757
const char kDeathTestUseFork[] = "death_test_use_fork";
5858
const char kInternalRunDeathTestFlag[] = "internal_run_death_test";
5959

60-
#if GTEST_HAS_DEATH_TEST
60+
#ifdef GTEST_HAS_DEATH_TEST
6161

6262
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
6363
/* class A needs to have dll-interface to be used by clients of class B */)
@@ -88,7 +88,7 @@ class GTEST_API_ DeathTest {
8888
static bool Create(const char* statement, Matcher<const std::string&> matcher,
8989
const char* file, int line, DeathTest** test);
9090
DeathTest();
91-
virtual ~DeathTest() {}
91+
virtual ~DeathTest() = default;
9292

9393
// A helper class that aborts a death test when it's deleted.
9494
class ReturnSentinel {
@@ -153,7 +153,7 @@ GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
153153
// Factory interface for death tests. May be mocked out for testing.
154154
class DeathTestFactory {
155155
public:
156-
virtual ~DeathTestFactory() {}
156+
virtual ~DeathTestFactory() = default;
157157
virtual bool Create(const char* statement,
158158
Matcher<const std::string&> matcher, const char* file,
159159
int line, DeathTest** test) = 0;
@@ -238,7 +238,7 @@ inline Matcher<const ::std::string&> MakeDeathTestMatcher(
238238
} \
239239
break; \
240240
case ::testing::internal::DeathTest::EXECUTE_TEST: { \
241-
::testing::internal::DeathTest::ReturnSentinel gtest_sentinel( \
241+
const ::testing::internal::DeathTest::ReturnSentinel gtest_sentinel( \
242242
gtest_dt); \
243243
GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, gtest_dt); \
244244
gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE); \

‎deps/googletest/include/gtest/internal/gtest-internal.h

+5-17
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
#include "gtest/internal/gtest-port.h"
4343

44-
#if GTEST_OS_LINUX
44+
#ifdef GTEST_OS_LINUX
4545
#include <stdlib.h>
4646
#include <sys/types.h>
4747
#include <sys/wait.h>
@@ -307,9 +307,6 @@ class FloatingPoint {
307307
// Returns the floating-point number that represent positive infinity.
308308
static RawType Infinity() { return ReinterpretBits(kExponentBitMask); }
309309

310-
// Returns the maximum representable finite floating-point number.
311-
static RawType Max();
312-
313310
// Non-static methods
314311

315312
// Returns the bits that represents this number.
@@ -390,17 +387,6 @@ class FloatingPoint {
390387
FloatingPointUnion u_;
391388
};
392389

393-
// We cannot use std::numeric_limits<T>::max() as it clashes with the max()
394-
// macro defined by <windows.h>.
395-
template <>
396-
inline float FloatingPoint<float>::Max() {
397-
return FLT_MAX;
398-
}
399-
template <>
400-
inline double FloatingPoint<double>::Max() {
401-
return DBL_MAX;
402-
}
403-
404390
// Typedefs the instances of the FloatingPoint template class that we
405391
// care to use.
406392
typedef FloatingPoint<float> Float;
@@ -449,7 +435,7 @@ GTEST_API_ TypeId GetTestTypeId();
449435
// of a Test object.
450436
class TestFactoryBase {
451437
public:
452-
virtual ~TestFactoryBase() {}
438+
virtual ~TestFactoryBase() = default;
453439

454440
// Creates a test instance to run. The instance is both created and destroyed
455441
// within TestInfoImpl::Run()
@@ -471,7 +457,7 @@ class TestFactoryImpl : public TestFactoryBase {
471457
Test* CreateTest() override { return new TestClass; }
472458
};
473459

474-
#if GTEST_OS_WINDOWS
460+
#ifdef GTEST_OS_WINDOWS
475461

476462
// Predicate-formatters for implementing the HRESULT checking macros
477463
// {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED}
@@ -914,8 +900,10 @@ class HasDebugStringAndShortDebugString {
914900
HasDebugStringType::value && HasShortDebugStringType::value;
915901
};
916902

903+
#ifdef GTEST_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL
917904
template <typename T>
918905
constexpr bool HasDebugStringAndShortDebugString<T>::value;
906+
#endif
919907

920908
// When the compiler sees expression IsContainerTest<C>(0), if C is an
921909
// STL-style container class, the first overload of IsContainerTest

‎deps/googletest/include/gtest/internal/gtest-param-util.h

+16-21
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class ParamGenerator;
9797
template <typename T>
9898
class ParamIteratorInterface {
9999
public:
100-
virtual ~ParamIteratorInterface() {}
100+
virtual ~ParamIteratorInterface() = default;
101101
// A pointer to the base generator instance.
102102
// Used only for the purposes of iterator comparison
103103
// to make sure that two iterators belong to the same generator.
@@ -171,7 +171,7 @@ class ParamGeneratorInterface {
171171
public:
172172
typedef T ParamType;
173173

174-
virtual ~ParamGeneratorInterface() {}
174+
virtual ~ParamGeneratorInterface() = default;
175175

176176
// Generator interface definition
177177
virtual ParamIteratorInterface<T>* Begin() const = 0;
@@ -215,7 +215,7 @@ class RangeGenerator : public ParamGeneratorInterface<T> {
215215
end_(end),
216216
step_(step),
217217
end_index_(CalculateEndIndex(begin, end, step)) {}
218-
~RangeGenerator() override {}
218+
~RangeGenerator() override = default;
219219

220220
ParamIteratorInterface<T>* Begin() const override {
221221
return new Iterator(this, begin_, 0, step_);
@@ -230,7 +230,7 @@ class RangeGenerator : public ParamGeneratorInterface<T> {
230230
Iterator(const ParamGeneratorInterface<T>* base, T value, int index,
231231
IncrementT step)
232232
: base_(base), value_(value), index_(index), step_(step) {}
233-
~Iterator() override {}
233+
~Iterator() override = default;
234234

235235
const ParamGeneratorInterface<T>* BaseGenerator() const override {
236236
return base_;
@@ -299,7 +299,7 @@ class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> {
299299
template <typename ForwardIterator>
300300
ValuesInIteratorRangeGenerator(ForwardIterator begin, ForwardIterator end)
301301
: container_(begin, end) {}
302-
~ValuesInIteratorRangeGenerator() override {}
302+
~ValuesInIteratorRangeGenerator() override = default;
303303

304304
ParamIteratorInterface<T>* Begin() const override {
305305
return new Iterator(this, container_.begin());
@@ -316,7 +316,7 @@ class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> {
316316
Iterator(const ParamGeneratorInterface<T>* base,
317317
typename ContainerType::const_iterator iterator)
318318
: base_(base), iterator_(iterator) {}
319-
~Iterator() override {}
319+
~Iterator() override = default;
320320

321321
const ParamGeneratorInterface<T>* BaseGenerator() const override {
322322
return base_;
@@ -420,7 +420,7 @@ class ParameterizedTestFactory : public TestFactoryBase {
420420
template <class ParamType>
421421
class TestMetaFactoryBase {
422422
public:
423-
virtual ~TestMetaFactoryBase() {}
423+
virtual ~TestMetaFactoryBase() = default;
424424

425425
virtual TestFactoryBase* CreateTestFactory(ParamType parameter) = 0;
426426
};
@@ -439,7 +439,7 @@ class TestMetaFactory
439439
public:
440440
using ParamType = typename TestSuite::ParamType;
441441

442-
TestMetaFactory() {}
442+
TestMetaFactory() = default;
443443

444444
TestFactoryBase* CreateTestFactory(ParamType parameter) override {
445445
return new ParameterizedTestFactory<TestSuite>(parameter);
@@ -462,7 +462,7 @@ class TestMetaFactory
462462
// and calls RegisterTests() on each of them when asked.
463463
class ParameterizedTestSuiteInfoBase {
464464
public:
465-
virtual ~ParameterizedTestSuiteInfoBase() {}
465+
virtual ~ParameterizedTestSuiteInfoBase() = default;
466466

467467
// Base part of test suite name for display purposes.
468468
virtual const std::string& GetTestSuiteName() const = 0;
@@ -691,7 +691,7 @@ using ParameterizedTestCaseInfo = ParameterizedTestSuiteInfo<TestCase>;
691691
// ParameterizedTestSuiteInfo descriptors.
692692
class ParameterizedTestSuiteRegistry {
693693
public:
694-
ParameterizedTestSuiteRegistry() {}
694+
ParameterizedTestSuiteRegistry() = default;
695695
~ParameterizedTestSuiteRegistry() {
696696
for (auto& test_suite_info : test_suite_infos_) {
697697
delete test_suite_info;
@@ -794,10 +794,7 @@ internal::ParamGenerator<typename Container::value_type> ValuesIn(
794794
namespace internal {
795795
// Used in the Values() function to provide polymorphic capabilities.
796796

797-
#ifdef _MSC_VER
798-
#pragma warning(push)
799-
#pragma warning(disable : 4100)
800-
#endif
797+
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4100)
801798

802799
template <typename... Ts>
803800
class ValueArray {
@@ -818,9 +815,7 @@ class ValueArray {
818815
FlatTuple<Ts...> v_;
819816
};
820817

821-
#ifdef _MSC_VER
822-
#pragma warning(pop)
823-
#endif
818+
GTEST_DISABLE_MSC_WARNINGS_POP_() // 4100
824819

825820
template <typename... T>
826821
class CartesianProductGenerator
@@ -830,7 +825,7 @@ class CartesianProductGenerator
830825

831826
CartesianProductGenerator(const std::tuple<ParamGenerator<T>...>& g)
832827
: generators_(g) {}
833-
~CartesianProductGenerator() override {}
828+
~CartesianProductGenerator() override = default;
834829

835830
ParamIteratorInterface<ParamType>* Begin() const override {
836831
return new Iterator(this, generators_, false);
@@ -855,7 +850,7 @@ class CartesianProductGenerator
855850
current_(is_end ? end_ : begin_) {
856851
ComputeCurrentValue();
857852
}
858-
~IteratorImpl() override {}
853+
~IteratorImpl() override = default;
859854

860855
const ParamGeneratorInterface<ParamType>* BaseGenerator() const override {
861856
return base_;
@@ -956,7 +951,7 @@ class CartesianProductHolder {
956951
template <typename From, typename To>
957952
class ParamGeneratorConverter : public ParamGeneratorInterface<To> {
958953
public:
959-
ParamGeneratorConverter(ParamGenerator<From> gen) // NOLINT
954+
ParamGeneratorConverter(ParamGenerator<From> gen) // NOLINT
960955
: generator_(std::move(gen)) {}
961956

962957
ParamIteratorInterface<To>* Begin() const override {
@@ -974,7 +969,7 @@ class ParamGeneratorConverter : public ParamGeneratorInterface<To> {
974969
: base_(base), it_(it), end_(end) {
975970
if (it_ != end_) value_ = std::make_shared<To>(static_cast<To>(*it_));
976971
}
977-
~Iterator() override {}
972+
~Iterator() override = default;
978973

979974
const ParamGeneratorInterface<To>* BaseGenerator() const override {
980975
return base_;

‎deps/googletest/include/gtest/internal/gtest-port.h

+183-114
Large diffs are not rendered by default.

‎deps/googletest/include/gtest/internal/gtest-string.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class GTEST_API_ String {
7373
// memory using malloc().
7474
static const char* CloneCString(const char* c_str);
7575

76-
#if GTEST_OS_WINDOWS_MOBILE
76+
#ifdef GTEST_OS_WINDOWS_MOBILE
7777
// Windows CE does not have the 'ANSI' versions of Win32 APIs. To be
7878
// able to pass strings to Win32 APIs on CE we need to convert them
7979
// to 'Unicode', UTF-16.

‎deps/googletest/include/gtest/internal/gtest-type-util.h

+30
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,22 @@ inline std::string CanonicalizeForStdLibVersioning(std::string s) {
6767
s.erase(strlen("std"), end - strlen("std"));
6868
}
6969
}
70+
71+
// Strip redundant spaces in typename to match MSVC
72+
// For example, std::pair<int, bool> -> std::pair<int,bool>
73+
static const char to_search[] = ", ";
74+
static const char replace_str[] = ",";
75+
size_t pos = 0;
76+
while (true) {
77+
// Get the next occurrence from the current position
78+
pos = s.find(to_search, pos);
79+
if (pos == std::string::npos) {
80+
break;
81+
}
82+
// Replace this occurrence of substring
83+
s.replace(pos, strlen(to_search), replace_str);
84+
pos += strlen(replace_str);
85+
}
7086
return s;
7187
}
7288

@@ -85,6 +101,20 @@ inline std::string GetTypeName(const std::type_info& type) {
85101
const std::string name_str(status == 0 ? readable_name : name);
86102
free(readable_name);
87103
return CanonicalizeForStdLibVersioning(name_str);
104+
#elif defined(_MSC_VER)
105+
// Strip struct and class due to differences between
106+
// MSVC and other compilers. std::pair<int,bool> is printed as
107+
// "struct std::pair<int,bool>" when using MSVC vs "std::pair<int, bool>" with
108+
// other compilers.
109+
std::string s = name;
110+
// Only strip the leading "struct " and "class ", so uses rfind == 0 to
111+
// ensure that
112+
if (s.rfind("struct ", 0) == 0) {
113+
s = s.substr(strlen("struct "));
114+
} else if (s.rfind("class ", 0) == 0) {
115+
s = s.substr(strlen("class "));
116+
}
117+
return s;
88118
#else
89119
return name;
90120
#endif // GTEST_HAS_CXXABI_H_ || __HP_aCC

‎deps/googletest/src/gtest-assertion-result.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace testing {
4444
// Used in EXPECT_TRUE/FALSE(assertion_result).
4545
AssertionResult::AssertionResult(const AssertionResult& other)
4646
: success_(other.success_),
47-
message_(other.message_.get() != nullptr
47+
message_(other.message_ != nullptr
4848
? new ::std::string(*other.message_)
4949
: static_cast< ::std::string*>(nullptr)) {}
5050

@@ -58,7 +58,7 @@ void AssertionResult::swap(AssertionResult& other) {
5858
// Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.
5959
AssertionResult AssertionResult::operator!() const {
6060
AssertionResult negation(!success_);
61-
if (message_.get() != nullptr) negation << *message_;
61+
if (message_ != nullptr) negation << *message_;
6262
return negation;
6363
}
6464

‎deps/googletest/src/gtest-death-test.cc

+63-98
Original file line numberDiff line numberDiff line change
@@ -33,39 +33,43 @@
3333
#include "gtest/gtest-death-test.h"
3434

3535
#include <functional>
36+
#include <memory>
37+
#include <sstream>
38+
#include <string>
3639
#include <utility>
40+
#include <vector>
3741

3842
#include "gtest/internal/custom/gtest.h"
3943
#include "gtest/internal/gtest-port.h"
4044

41-
#if GTEST_HAS_DEATH_TEST
45+
#ifdef GTEST_HAS_DEATH_TEST
4246

43-
#if GTEST_OS_MAC
47+
#ifdef GTEST_OS_MAC
4448
#include <crt_externs.h>
4549
#endif // GTEST_OS_MAC
4650

4751
#include <errno.h>
4852
#include <fcntl.h>
4953
#include <limits.h>
5054

51-
#if GTEST_OS_LINUX
55+
#ifdef GTEST_OS_LINUX
5256
#include <signal.h>
5357
#endif // GTEST_OS_LINUX
5458

5559
#include <stdarg.h>
5660

57-
#if GTEST_OS_WINDOWS
61+
#ifdef GTEST_OS_WINDOWS
5862
#include <windows.h>
5963
#else
6064
#include <sys/mman.h>
6165
#include <sys/wait.h>
6266
#endif // GTEST_OS_WINDOWS
6367

64-
#if GTEST_OS_QNX
68+
#ifdef GTEST_OS_QNX
6569
#include <spawn.h>
6670
#endif // GTEST_OS_QNX
6771

68-
#if GTEST_OS_FUCHSIA
72+
#ifdef GTEST_OS_FUCHSIA
6973
#include <lib/fdio/fd.h>
7074
#include <lib/fdio/io.h>
7175
#include <lib/fdio/spawn.h>
@@ -131,13 +135,13 @@ GTEST_DEFINE_string_(
131135

132136
namespace testing {
133137

134-
#if GTEST_HAS_DEATH_TEST
138+
#ifdef GTEST_HAS_DEATH_TEST
135139

136140
namespace internal {
137141

138142
// Valid only for fast death tests. Indicates the code is running in the
139143
// child process of a fast style death test.
140-
#if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA
144+
#if !defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_FUCHSIA)
141145
static bool g_in_fast_death_test_child = false;
142146
#endif
143147

@@ -147,7 +151,7 @@ static bool g_in_fast_death_test_child = false;
147151
// tests. IMPORTANT: This is an internal utility. Using it may break the
148152
// implementation of death tests. User code MUST NOT use it.
149153
bool InDeathTestChild() {
150-
#if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA
154+
#if defined(GTEST_OS_WINDOWS) || defined(GTEST_OS_FUCHSIA)
151155

152156
// On Windows and Fuchsia, death tests are thread-safe regardless of the value
153157
// of the death_test_style flag.
@@ -169,7 +173,7 @@ ExitedWithCode::ExitedWithCode(int exit_code) : exit_code_(exit_code) {}
169173

170174
// ExitedWithCode function-call operator.
171175
bool ExitedWithCode::operator()(int exit_status) const {
172-
#if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA
176+
#if defined(GTEST_OS_WINDOWS) || defined(GTEST_OS_FUCHSIA)
173177

174178
return exit_status == exit_code_;
175179

@@ -180,7 +184,7 @@ bool ExitedWithCode::operator()(int exit_status) const {
180184
#endif // GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA
181185
}
182186

183-
#if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA
187+
#if !defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_FUCHSIA)
184188
// KilledBySignal constructor.
185189
KilledBySignal::KilledBySignal(int signum) : signum_(signum) {}
186190

@@ -207,7 +211,7 @@ namespace internal {
207211
static std::string ExitSummary(int exit_code) {
208212
Message m;
209213

210-
#if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA
214+
#if defined(GTEST_OS_WINDOWS) || defined(GTEST_OS_FUCHSIA)
211215

212216
m << "Exited with exit status " << exit_code;
213217

@@ -234,7 +238,7 @@ bool ExitedUnsuccessfully(int exit_status) {
234238
return !ExitedWithCode(0)(exit_status);
235239
}
236240

237-
#if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA
241+
#if !defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_FUCHSIA)
238242
// Generates a textual failure message when a death test finds more than
239243
// one thread running, or cannot determine the number of threads, prior
240244
// to executing the given statement. It is the responsibility of the
@@ -263,7 +267,7 @@ static const char kDeathTestReturned = 'R';
263267
static const char kDeathTestThrew = 'T';
264268
static const char kDeathTestInternalError = 'I';
265269

266-
#if GTEST_OS_FUCHSIA
270+
#ifdef GTEST_OS_FUCHSIA
267271

268272
// File descriptor used for the pipe in the child process.
269273
static const int kFuchsiaReadPipeFd = 3;
@@ -621,7 +625,21 @@ bool DeathTestImpl::Passed(bool status_ok) {
621625
return success;
622626
}
623627

624-
#if GTEST_OS_WINDOWS
628+
#ifndef GTEST_OS_WINDOWS
629+
// Note: The return value points into args, so the return value's lifetime is
630+
// bound to that of args.
631+
static std::unique_ptr<char*[]> CreateArgvFromArgs(
632+
std::vector<std::string>& args) {
633+
auto result = std::make_unique<char*[]>(args.size() + 1);
634+
for (size_t i = 0; i < args.size(); ++i) {
635+
result[i] = &args[i][0];
636+
}
637+
result[args.size()] = nullptr; // extra null terminator
638+
return result;
639+
}
640+
#endif
641+
642+
#ifdef GTEST_OS_WINDOWS
625643
// WindowsDeathTest implements death tests on Windows. Due to the
626644
// specifics of starting new processes on Windows, death tests there are
627645
// always threadsafe, and Google Test considers the
@@ -808,7 +826,7 @@ DeathTest::TestRole WindowsDeathTest::AssumeRole() {
808826
return OVERSEE_TEST;
809827
}
810828

811-
#elif GTEST_OS_FUCHSIA
829+
#elif defined(GTEST_OS_FUCHSIA)
812830

813831
class FuchsiaDeathTest : public DeathTestImpl {
814832
public:
@@ -836,36 +854,6 @@ class FuchsiaDeathTest : public DeathTestImpl {
836854
zx::socket stderr_socket_;
837855
};
838856

839-
// Utility class for accumulating command-line arguments.
840-
class Arguments {
841-
public:
842-
Arguments() { args_.push_back(nullptr); }
843-
844-
~Arguments() {
845-
for (std::vector<char*>::iterator i = args_.begin(); i != args_.end();
846-
++i) {
847-
free(*i);
848-
}
849-
}
850-
void AddArgument(const char* argument) {
851-
args_.insert(args_.end() - 1, posix::StrDup(argument));
852-
}
853-
854-
template <typename Str>
855-
void AddArguments(const ::std::vector<Str>& arguments) {
856-
for (typename ::std::vector<Str>::const_iterator i = arguments.begin();
857-
i != arguments.end(); ++i) {
858-
args_.insert(args_.end() - 1, posix::StrDup(i->c_str()));
859-
}
860-
}
861-
char* const* Argv() { return &args_[0]; }
862-
863-
int size() { return static_cast<int>(args_.size()) - 1; }
864-
865-
private:
866-
std::vector<char*> args_;
867-
};
868-
869857
// Waits for the child in a death test to exit, returning its exit
870858
// status, or 0 if no child process exists. As a side effect, sets the
871859
// outcome data member.
@@ -986,10 +974,10 @@ DeathTest::TestRole FuchsiaDeathTest::AssumeRole() {
986974
kInternalRunDeathTestFlag + "=" + file_ +
987975
"|" + StreamableToString(line_) + "|" +
988976
StreamableToString(death_test_index);
989-
Arguments args;
990-
args.AddArguments(GetInjectableArgvs());
991-
args.AddArgument(filter_flag.c_str());
992-
args.AddArgument(internal_flag.c_str());
977+
978+
std::vector<std::string> args = GetInjectableArgvs();
979+
args.push_back(filter_flag);
980+
args.push_back(internal_flag);
993981

994982
// Build the pipe for communication with the child.
995983
zx_status_t status;
@@ -1041,8 +1029,14 @@ DeathTest::TestRole FuchsiaDeathTest::AssumeRole() {
10411029
GTEST_DEATH_TEST_CHECK_(status == ZX_OK);
10421030

10431031
// Spawn the child process.
1044-
status = fdio_spawn_etc(child_job, FDIO_SPAWN_CLONE_ALL, args.Argv()[0],
1045-
args.Argv(), nullptr, 2, spawn_actions,
1032+
// Note: The test component must have `fuchsia.process.Launcher` declared
1033+
// in its manifest. (Fuchsia integration tests require creating a
1034+
// "Fuchsia Test Component" which contains a "Fuchsia Component Manifest")
1035+
// Launching processes is a privileged operation in Fuchsia, and the
1036+
// declaration indicates that the ability is required for the component.
1037+
std::unique_ptr<char*[]> argv = CreateArgvFromArgs(args);
1038+
status = fdio_spawn_etc(child_job, FDIO_SPAWN_CLONE_ALL, argv[0], argv.get(),
1039+
nullptr, 2, spawn_actions,
10461040
child_process_.reset_and_get_address(), nullptr);
10471041
GTEST_DEATH_TEST_CHECK_(status == ZX_OK);
10481042

@@ -1134,7 +1128,7 @@ DeathTest::TestRole NoExecDeathTest::AssumeRole() {
11341128
LogToStderr();
11351129
// Event forwarding to the listeners of event listener API mush be shut
11361130
// down in death test subprocesses.
1137-
GetUnitTestImpl()->listeners()->SuppressEventForwarding();
1131+
GetUnitTestImpl()->listeners()->SuppressEventForwarding(true);
11381132
g_in_fast_death_test_child = true;
11391133
return EXECUTE_TEST;
11401134
} else {
@@ -1173,42 +1167,14 @@ class ExecDeathTest : public ForkingDeathTest {
11731167
const int line_;
11741168
};
11751169

1176-
// Utility class for accumulating command-line arguments.
1177-
class Arguments {
1178-
public:
1179-
Arguments() { args_.push_back(nullptr); }
1180-
1181-
~Arguments() {
1182-
for (std::vector<char*>::iterator i = args_.begin(); i != args_.end();
1183-
++i) {
1184-
free(*i);
1185-
}
1186-
}
1187-
void AddArgument(const char* argument) {
1188-
args_.insert(args_.end() - 1, posix::StrDup(argument));
1189-
}
1190-
1191-
template <typename Str>
1192-
void AddArguments(const ::std::vector<Str>& arguments) {
1193-
for (typename ::std::vector<Str>::const_iterator i = arguments.begin();
1194-
i != arguments.end(); ++i) {
1195-
args_.insert(args_.end() - 1, posix::StrDup(i->c_str()));
1196-
}
1197-
}
1198-
char* const* Argv() { return &args_[0]; }
1199-
1200-
private:
1201-
std::vector<char*> args_;
1202-
};
1203-
12041170
// A struct that encompasses the arguments to the child process of a
12051171
// threadsafe-style death test process.
12061172
struct ExecDeathTestArgs {
12071173
char* const* argv; // Command-line arguments for the child's call to exec
12081174
int close_fd; // File descriptor to close; the read end of a pipe
12091175
};
12101176

1211-
#if GTEST_OS_QNX
1177+
#ifdef GTEST_OS_QNX
12121178
extern "C" char** environ;
12131179
#else // GTEST_OS_QNX
12141180
// The main function for a threadsafe-style death test child process.
@@ -1289,7 +1255,7 @@ static pid_t ExecDeathTestSpawnChild(char* const* argv, int close_fd) {
12891255
ExecDeathTestArgs args = {argv, close_fd};
12901256
pid_t child_pid = -1;
12911257

1292-
#if GTEST_OS_QNX
1258+
#ifdef GTEST_OS_QNX
12931259
// Obtains the current directory and sets it to be closed in the child
12941260
// process.
12951261
const int cwd_fd = open(".", O_RDONLY);
@@ -1320,7 +1286,7 @@ static pid_t ExecDeathTestSpawnChild(char* const* argv, int close_fd) {
13201286
GTEST_DEATH_TEST_CHECK_SYSCALL_(close(cwd_fd));
13211287

13221288
#else // GTEST_OS_QNX
1323-
#if GTEST_OS_LINUX
1289+
#ifdef GTEST_OS_LINUX
13241290
// When a SIGPROF signal is received while fork() or clone() are executing,
13251291
// the process may hang. To avoid this, we ignore SIGPROF here and re-enable
13261292
// it after the call to fork()/clone() is complete.
@@ -1367,11 +1333,10 @@ static pid_t ExecDeathTestSpawnChild(char* const* argv, int close_fd) {
13671333
#endif // GTEST_HAS_CLONE
13681334

13691335
if (use_fork && (child_pid = fork()) == 0) {
1370-
ExecDeathTestChildMain(&args);
1371-
_exit(0);
1336+
_exit(ExecDeathTestChildMain(&args));
13721337
}
13731338
#endif // GTEST_OS_QNX
1374-
#if GTEST_OS_LINUX
1339+
#ifdef GTEST_OS_LINUX
13751340
GTEST_DEATH_TEST_CHECK_SYSCALL_(
13761341
sigaction(SIGPROF, &saved_sigprof_action, nullptr));
13771342
#endif // GTEST_OS_LINUX
@@ -1410,10 +1375,9 @@ DeathTest::TestRole ExecDeathTest::AssumeRole() {
14101375
StreamableToString(line_) + "|" +
14111376
StreamableToString(death_test_index) + "|" +
14121377
StreamableToString(pipe_fd[1]);
1413-
Arguments args;
1414-
args.AddArguments(GetArgvsForDeathTestChildProcess());
1415-
args.AddArgument(filter_flag.c_str());
1416-
args.AddArgument(internal_flag.c_str());
1378+
std::vector<std::string> args = GetArgvsForDeathTestChildProcess();
1379+
args.push_back(filter_flag);
1380+
args.push_back(internal_flag);
14171381

14181382
DeathTest::set_last_death_test_message("");
14191383

@@ -1422,7 +1386,8 @@ DeathTest::TestRole ExecDeathTest::AssumeRole() {
14221386
// is necessary.
14231387
FlushInfoLog();
14241388

1425-
const pid_t child_pid = ExecDeathTestSpawnChild(args.Argv(), pipe_fd[0]);
1389+
std::unique_ptr<char*[]> argv = CreateArgvFromArgs(args);
1390+
const pid_t child_pid = ExecDeathTestSpawnChild(argv.get(), pipe_fd[0]);
14261391
GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[1]));
14271392
set_child_pid(child_pid);
14281393
set_read_fd(pipe_fd[0]);
@@ -1463,14 +1428,14 @@ bool DefaultDeathTestFactory::Create(const char* statement,
14631428
}
14641429
}
14651430

1466-
#if GTEST_OS_WINDOWS
1431+
#ifdef GTEST_OS_WINDOWS
14671432

14681433
if (GTEST_FLAG_GET(death_test_style) == "threadsafe" ||
14691434
GTEST_FLAG_GET(death_test_style) == "fast") {
14701435
*test = new WindowsDeathTest(statement, std::move(matcher), file, line);
14711436
}
14721437

1473-
#elif GTEST_OS_FUCHSIA
1438+
#elif defined(GTEST_OS_FUCHSIA)
14741439

14751440
if (GTEST_FLAG_GET(death_test_style) == "threadsafe" ||
14761441
GTEST_FLAG_GET(death_test_style) == "fast") {
@@ -1497,7 +1462,7 @@ bool DefaultDeathTestFactory::Create(const char* statement,
14971462
return true;
14981463
}
14991464

1500-
#if GTEST_OS_WINDOWS
1465+
#ifdef GTEST_OS_WINDOWS
15011466
// Recreates the pipe and event handles from the provided parameters,
15021467
// signals the event, and returns a file descriptor wrapped around the pipe
15031468
// handle. This function is called in the child process only.
@@ -1564,7 +1529,7 @@ static int GetStatusFileDescriptor(unsigned int parent_process_id,
15641529
// initialized from the GTEST_FLAG(internal_run_death_test) flag if
15651530
// the flag is specified; otherwise returns NULL.
15661531
InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() {
1567-
if (GTEST_FLAG_GET(internal_run_death_test) == "") return nullptr;
1532+
if (GTEST_FLAG_GET(internal_run_death_test).empty()) return nullptr;
15681533

15691534
// GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we
15701535
// can use it here.
@@ -1574,7 +1539,7 @@ InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() {
15741539
SplitString(GTEST_FLAG_GET(internal_run_death_test), '|', &fields);
15751540
int write_fd = -1;
15761541

1577-
#if GTEST_OS_WINDOWS
1542+
#ifdef GTEST_OS_WINDOWS
15781543

15791544
unsigned int parent_process_id = 0;
15801545
size_t write_handle_as_size_t = 0;
@@ -1591,7 +1556,7 @@ InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() {
15911556
write_fd = GetStatusFileDescriptor(parent_process_id, write_handle_as_size_t,
15921557
event_handle_as_size_t);
15931558

1594-
#elif GTEST_OS_FUCHSIA
1559+
#elif defined(GTEST_OS_FUCHSIA)
15951560

15961561
if (fields.size() != 3 || !ParseNaturalNumber(fields[1], &line) ||
15971562
!ParseNaturalNumber(fields[2], &index)) {

‎deps/googletest/src/gtest-filepath.cc

+28-26
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@
3131

3232
#include <stdlib.h>
3333

34+
#include <iterator>
35+
#include <string>
36+
3437
#include "gtest/gtest-message.h"
3538
#include "gtest/internal/gtest-port.h"
3639

37-
#if GTEST_OS_WINDOWS_MOBILE
40+
#ifdef GTEST_OS_WINDOWS_MOBILE
3841
#include <windows.h>
39-
#elif GTEST_OS_WINDOWS
42+
#elif defined(GTEST_OS_WINDOWS)
4043
#include <direct.h>
4144
#include <io.h>
4245
#else
@@ -47,7 +50,7 @@
4750

4851
#include "gtest/internal/gtest-string.h"
4952

50-
#if GTEST_OS_WINDOWS
53+
#ifdef GTEST_OS_WINDOWS
5154
#define GTEST_PATH_MAX_ _MAX_PATH
5255
#elif defined(PATH_MAX)
5356
#define GTEST_PATH_MAX_ PATH_MAX
@@ -62,15 +65,15 @@
6265
namespace testing {
6366
namespace internal {
6467

65-
#if GTEST_OS_WINDOWS
68+
#ifdef GTEST_OS_WINDOWS
6669
// On Windows, '\\' is the standard path separator, but many tools and the
6770
// Windows API also accept '/' as an alternate path separator. Unless otherwise
6871
// noted, a file path can contain either kind of path separators, or a mixture
6972
// of them.
7073
const char kPathSeparator = '\\';
7174
const char kAlternatePathSeparator = '/';
7275
const char kAlternatePathSeparatorString[] = "/";
73-
#if GTEST_OS_WINDOWS_MOBILE
76+
#ifdef GTEST_OS_WINDOWS_MOBILE
7477
// Windows CE doesn't have a current directory. You should not use
7578
// the current directory in tests on Windows CE, but this at least
7679
// provides a reasonable fallback.
@@ -96,19 +99,20 @@ static bool IsPathSeparator(char c) {
9699

97100
// Returns the current working directory, or "" if unsuccessful.
98101
FilePath FilePath::GetCurrentDir() {
99-
#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || \
100-
GTEST_OS_WINDOWS_RT || GTEST_OS_ESP8266 || GTEST_OS_ESP32 || \
101-
GTEST_OS_XTENSA || GTEST_OS_QURT
102+
#if defined(GTEST_OS_WINDOWS_MOBILE) || defined(GTEST_OS_WINDOWS_PHONE) || \
103+
defined(GTEST_OS_WINDOWS_RT) || defined(GTEST_OS_ESP8266) || \
104+
defined(GTEST_OS_ESP32) || defined(GTEST_OS_XTENSA) || \
105+
defined(GTEST_OS_QURT)
102106
// These platforms do not have a current directory, so we just return
103107
// something reasonable.
104108
return FilePath(kCurrentDirectoryString);
105-
#elif GTEST_OS_WINDOWS
109+
#elif defined(GTEST_OS_WINDOWS)
106110
char cwd[GTEST_PATH_MAX_ + 1] = {'\0'};
107111
return FilePath(_getcwd(cwd, sizeof(cwd)) == nullptr ? "" : cwd);
108112
#else
109113
char cwd[GTEST_PATH_MAX_ + 1] = {'\0'};
110114
char* result = getcwd(cwd, sizeof(cwd));
111-
#if GTEST_OS_NACL
115+
#ifdef GTEST_OS_NACL
112116
// getcwd will likely fail in NaCl due to the sandbox, so return something
113117
// reasonable. The user may have provided a shim implementation for getcwd,
114118
// however, so fallback only when failure is detected.
@@ -148,20 +152,19 @@ const char* FilePath::FindLastPathSeparator() const {
148152
}
149153

150154
size_t FilePath::CalculateRootLength() const {
151-
const auto &path = pathname_;
155+
const auto& path = pathname_;
152156
auto s = path.begin();
153157
auto end = path.end();
154-
#if GTEST_OS_WINDOWS
155-
if (end - s >= 2 && s[1] == ':' &&
156-
(end - s == 2 || IsPathSeparator(s[2])) &&
158+
#ifdef GTEST_OS_WINDOWS
159+
if (end - s >= 2 && s[1] == ':' && (end - s == 2 || IsPathSeparator(s[2])) &&
157160
(('A' <= s[0] && s[0] <= 'Z') || ('a' <= s[0] && s[0] <= 'z'))) {
158161
// A typical absolute path like "C:\Windows" or "D:"
159162
s += 2;
160163
if (s != end) {
161164
++s;
162165
}
163-
} else if (end - s >= 3 && IsPathSeparator(*s) && IsPathSeparator(*(s + 1))
164-
&& !IsPathSeparator(*(s + 2))) {
166+
} else if (end - s >= 3 && IsPathSeparator(*s) && IsPathSeparator(*(s + 1)) &&
167+
!IsPathSeparator(*(s + 2))) {
165168
// Move past the "\\" prefix in a UNC path like "\\Server\Share\Folder"
166169
s += 2;
167170
// Skip 2 components and their following separators ("Server\" and "Share\")
@@ -245,7 +248,7 @@ FilePath FilePath::ConcatPaths(const FilePath& directory,
245248
// Returns true if pathname describes something findable in the file-system,
246249
// either a file, directory, or whatever.
247250
bool FilePath::FileOrDirectoryExists() const {
248-
#if GTEST_OS_WINDOWS_MOBILE
251+
#ifdef GTEST_OS_WINDOWS_MOBILE
249252
LPCWSTR unicode = String::AnsiToUtf16(pathname_.c_str());
250253
const DWORD attributes = GetFileAttributes(unicode);
251254
delete[] unicode;
@@ -260,7 +263,7 @@ bool FilePath::FileOrDirectoryExists() const {
260263
// that exists.
261264
bool FilePath::DirectoryExists() const {
262265
bool result = false;
263-
#if GTEST_OS_WINDOWS
266+
#ifdef GTEST_OS_WINDOWS
264267
// Don't strip off trailing separator if path is a root directory on
265268
// Windows (like "C:\\").
266269
const FilePath& path(IsRootDirectory() ? *this
@@ -269,7 +272,7 @@ bool FilePath::DirectoryExists() const {
269272
const FilePath& path(*this);
270273
#endif
271274

272-
#if GTEST_OS_WINDOWS_MOBILE
275+
#ifdef GTEST_OS_WINDOWS_MOBILE
273276
LPCWSTR unicode = String::AnsiToUtf16(path.c_str());
274277
const DWORD attributes = GetFileAttributes(unicode);
275278
delete[] unicode;
@@ -295,9 +298,7 @@ bool FilePath::IsRootDirectory() const {
295298
}
296299

297300
// Returns true if pathname describes an absolute path.
298-
bool FilePath::IsAbsolutePath() const {
299-
return CalculateRootLength() > 0;
300-
}
301+
bool FilePath::IsAbsolutePath() const { return CalculateRootLength() > 0; }
301302

302303
// Returns a pathname for a file that does not currently exist. The pathname
303304
// will be directory/base_name.extension or
@@ -347,14 +348,15 @@ bool FilePath::CreateDirectoriesRecursively() const {
347348
// directory for any reason, including if the parent directory does not
348349
// exist. Not named "CreateDirectory" because that's a macro on Windows.
349350
bool FilePath::CreateFolder() const {
350-
#if GTEST_OS_WINDOWS_MOBILE
351+
#ifdef GTEST_OS_WINDOWS_MOBILE
351352
FilePath removed_sep(this->RemoveTrailingPathSeparator());
352353
LPCWSTR unicode = String::AnsiToUtf16(removed_sep.c_str());
353354
int result = CreateDirectory(unicode, nullptr) ? 0 : -1;
354355
delete[] unicode;
355-
#elif GTEST_OS_WINDOWS
356+
#elif defined(GTEST_OS_WINDOWS)
356357
int result = _mkdir(pathname_.c_str());
357-
#elif GTEST_OS_ESP8266 || GTEST_OS_XTENSA || GTEST_OS_QURT
358+
#elif defined(GTEST_OS_ESP8266) || defined(GTEST_OS_XTENSA) || \
359+
defined(GTEST_OS_QURT)
358360
// do nothing
359361
int result = 0;
360362
#else
@@ -383,7 +385,7 @@ void FilePath::Normalize() {
383385
auto out = pathname_.begin();
384386

385387
auto i = pathname_.cbegin();
386-
#if GTEST_OS_WINDOWS
388+
#ifdef GTEST_OS_WINDOWS
387389
// UNC paths are treated specially
388390
if (pathname_.end() - i >= 3 && IsPathSeparator(*i) &&
389391
IsPathSeparator(*(i + 1)) && !IsPathSeparator(*(i + 2))) {

‎deps/googletest/src/gtest-internal-inl.h

+15-14
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
#include <netdb.h> // NOLINT
5656
#endif
5757

58-
#if GTEST_OS_WINDOWS
58+
#ifdef GTEST_OS_WINDOWS
5959
#include <windows.h> // NOLINT
6060
#endif // GTEST_OS_WINDOWS
6161

@@ -92,7 +92,8 @@ GTEST_API_ TimeInMillis GetTimeInMillis();
9292
// Returns true if and only if Google Test should use colors in the output.
9393
GTEST_API_ bool ShouldUseColor(bool stdout_is_tty);
9494

95-
// Formats the given time in milliseconds as seconds.
95+
// Formats the given time in milliseconds as seconds. If the input is an exact N
96+
// seconds, the output has a trailing decimal point (e.g., "N." instead of "N").
9697
GTEST_API_ std::string FormatTimeInMillisAsSeconds(TimeInMillis ms);
9798

9899
// Converts the given time in milliseconds to a date string in the ISO 8601
@@ -383,7 +384,7 @@ class GTEST_API_ UnitTestOptions {
383384
static bool FilterMatchesTest(const std::string& test_suite_name,
384385
const std::string& test_name);
385386

386-
#if GTEST_OS_WINDOWS
387+
#ifdef GTEST_OS_WINDOWS
387388
// Function for supporting the gtest_catch_exception flag.
388389

389390
// Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the
@@ -406,8 +407,8 @@ GTEST_API_ FilePath GetCurrentExecutableName();
406407
// The role interface for getting the OS stack trace as a string.
407408
class OsStackTraceGetterInterface {
408409
public:
409-
OsStackTraceGetterInterface() {}
410-
virtual ~OsStackTraceGetterInterface() {}
410+
OsStackTraceGetterInterface() = default;
411+
virtual ~OsStackTraceGetterInterface() = default;
411412

412413
// Returns the current OS stack trace as an std::string. Parameters:
413414
//
@@ -435,13 +436,13 @@ class OsStackTraceGetterInterface {
435436
// A working implementation of the OsStackTraceGetterInterface interface.
436437
class OsStackTraceGetter : public OsStackTraceGetterInterface {
437438
public:
438-
OsStackTraceGetter() {}
439+
OsStackTraceGetter() = default;
439440

440441
std::string CurrentStackTrace(int max_depth, int skip_count) override;
441442
void UponLeavingGTest() override;
442443

443444
private:
444-
#if GTEST_HAS_ABSL
445+
#ifdef GTEST_HAS_ABSL
445446
Mutex mutex_; // Protects all internal state.
446447

447448
// We save the stack frame below the frame that calls user code.
@@ -671,7 +672,7 @@ class GTEST_API_ UnitTestImpl {
671672
void AddTestInfo(internal::SetUpTestSuiteFunc set_up_tc,
672673
internal::TearDownTestSuiteFunc tear_down_tc,
673674
TestInfo* test_info) {
674-
#if GTEST_HAS_DEATH_TEST
675+
#ifdef GTEST_HAS_FILE_SYSTEM
675676
// In order to support thread-safe death tests, we need to
676677
// remember the original working directory when the test program
677678
// was first invoked. We cannot do this in RUN_ALL_TESTS(), as
@@ -684,7 +685,7 @@ class GTEST_API_ UnitTestImpl {
684685
GTEST_CHECK_(!original_working_dir_.IsEmpty())
685686
<< "Failed to get the current working directory.";
686687
}
687-
#endif // GTEST_HAS_DEATH_TEST
688+
#endif // GTEST_HAS_FILE_SYSTEM
688689

689690
GetTestSuite(test_info->test_suite_name(), test_info->type_param(),
690691
set_up_tc, tear_down_tc)
@@ -777,7 +778,7 @@ class GTEST_API_ UnitTestImpl {
777778
return gtest_trace_stack_.get();
778779
}
779780

780-
#if GTEST_HAS_DEATH_TEST
781+
#ifdef GTEST_HAS_DEATH_TEST
781782
void InitDeathTestSubprocessControlInfo() {
782783
internal_run_death_test_flag_.reset(ParseInternalRunDeathTestFlag());
783784
}
@@ -942,7 +943,7 @@ class GTEST_API_ UnitTestImpl {
942943
// How long the test took to run, in milliseconds.
943944
TimeInMillis elapsed_time_;
944945

945-
#if GTEST_HAS_DEATH_TEST
946+
#ifdef GTEST_HAS_DEATH_TEST
946947
// The decomposed components of the gtest_internal_run_death_test flag,
947948
// parsed when RUN_ALL_TESTS is called.
948949
std::unique_ptr<InternalRunDeathTestFlag> internal_run_death_test_flag_;
@@ -966,7 +967,7 @@ inline UnitTestImpl* GetUnitTestImpl() {
966967
return UnitTest::GetInstance()->impl();
967968
}
968969

969-
#if GTEST_USES_SIMPLE_RE
970+
#ifdef GTEST_USES_SIMPLE_RE
970971

971972
// Internal helper functions for implementing the simple regular
972973
// expression matcher.
@@ -992,7 +993,7 @@ GTEST_API_ bool MatchRegexAnywhere(const char* regex, const char* str);
992993
GTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, char** argv);
993994
GTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv);
994995

995-
#if GTEST_HAS_DEATH_TEST
996+
#ifdef GTEST_HAS_DEATH_TEST
996997

997998
// Returns the message describing the last system error, regardless of the
998999
// platform.
@@ -1063,7 +1064,7 @@ class StreamingListener : public EmptyTestEventListener {
10631064
// Abstract base class for writing strings to a socket.
10641065
class AbstractSocketWriter {
10651066
public:
1066-
virtual ~AbstractSocketWriter() {}
1067+
virtual ~AbstractSocketWriter() = default;
10671068

10681069
// Sends a string to the socket.
10691070
virtual void Send(const std::string& message) = 0;

‎deps/googletest/src/gtest-port.cc

+54-56
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,12 @@
3737
#include <cstdint>
3838
#include <fstream>
3939
#include <memory>
40+
#include <ostream>
41+
#include <string>
42+
#include <utility>
43+
#include <vector>
4044

41-
#if GTEST_OS_WINDOWS
45+
#ifdef GTEST_OS_WINDOWS
4246
#include <io.h>
4347
#include <sys/stat.h>
4448
#include <windows.h>
@@ -51,32 +55,34 @@
5155
#include <unistd.h>
5256
#endif // GTEST_OS_WINDOWS
5357

54-
#if GTEST_OS_MAC
58+
#ifdef GTEST_OS_MAC
5559
#include <mach/mach_init.h>
5660
#include <mach/task.h>
5761
#include <mach/vm_map.h>
5862
#endif // GTEST_OS_MAC
5963

60-
#if GTEST_OS_DRAGONFLY || GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD || \
61-
GTEST_OS_NETBSD || GTEST_OS_OPENBSD
64+
#if defined(GTEST_OS_DRAGONFLY) || defined(GTEST_OS_FREEBSD) || \
65+
defined(GTEST_OS_GNU_KFREEBSD) || defined(GTEST_OS_NETBSD) || \
66+
defined(GTEST_OS_OPENBSD)
6267
#include <sys/sysctl.h>
63-
#if GTEST_OS_DRAGONFLY || GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD
68+
#if defined(GTEST_OS_DRAGONFLY) || defined(GTEST_OS_FREEBSD) || \
69+
defined(GTEST_OS_GNU_KFREEBSD)
6470
#include <sys/user.h>
6571
#endif
6672
#endif
6773

68-
#if GTEST_OS_QNX
74+
#ifdef GTEST_OS_QNX
6975
#include <devctl.h>
7076
#include <fcntl.h>
7177
#include <sys/procfs.h>
7278
#endif // GTEST_OS_QNX
7379

74-
#if GTEST_OS_AIX
80+
#ifdef GTEST_OS_AIX
7581
#include <procinfo.h>
7682
#include <sys/types.h>
7783
#endif // GTEST_OS_AIX
7884

79-
#if GTEST_OS_FUCHSIA
85+
#ifdef GTEST_OS_FUCHSIA
8086
#include <zircon/process.h>
8187
#include <zircon/syscalls.h>
8288
#endif // GTEST_OS_FUCHSIA
@@ -90,7 +96,7 @@
9096
namespace testing {
9197
namespace internal {
9298

93-
#if GTEST_OS_LINUX || GTEST_OS_GNU_HURD
99+
#if defined(GTEST_OS_LINUX) || defined(GTEST_OS_GNU_HURD)
94100

95101
namespace {
96102
template <typename T>
@@ -113,7 +119,7 @@ size_t GetThreadCount() {
113119
return ReadProcFileField<size_t>(filename, 19);
114120
}
115121

116-
#elif GTEST_OS_MAC
122+
#elif defined(GTEST_OS_MAC)
117123

118124
size_t GetThreadCount() {
119125
const task_t task = mach_task_self();
@@ -131,20 +137,20 @@ size_t GetThreadCount() {
131137
}
132138
}
133139

134-
#elif GTEST_OS_DRAGONFLY || GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD || \
135-
GTEST_OS_NETBSD
140+
#elif defined(GTEST_OS_DRAGONFLY) || defined(GTEST_OS_FREEBSD) || \
141+
defined(GTEST_OS_GNU_KFREEBSD) || defined(GTEST_OS_NETBSD)
136142

137-
#if GTEST_OS_NETBSD
143+
#ifdef GTEST_OS_NETBSD
138144
#undef KERN_PROC
139145
#define KERN_PROC KERN_PROC2
140146
#define kinfo_proc kinfo_proc2
141147
#endif
142148

143-
#if GTEST_OS_DRAGONFLY
149+
#ifdef GTEST_OS_DRAGONFLY
144150
#define KP_NLWP(kp) (kp.kp_nthreads)
145-
#elif GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD
151+
#elif defined(GTEST_OS_FREEBSD) || defined(GTEST_OS_GNU_KFREEBSD)
146152
#define KP_NLWP(kp) (kp.ki_numthreads)
147-
#elif GTEST_OS_NETBSD
153+
#elif defined(GTEST_OS_NETBSD)
148154
#define KP_NLWP(kp) (kp.p_nlwps)
149155
#endif
150156

@@ -156,7 +162,7 @@ size_t GetThreadCount() {
156162
KERN_PROC,
157163
KERN_PROC_PID,
158164
getpid(),
159-
#if GTEST_OS_NETBSD
165+
#ifdef GTEST_OS_NETBSD
160166
sizeof(struct kinfo_proc),
161167
1,
162168
#endif
@@ -169,7 +175,7 @@ size_t GetThreadCount() {
169175
}
170176
return static_cast<size_t>(KP_NLWP(info));
171177
}
172-
#elif GTEST_OS_OPENBSD
178+
#elif defined(GTEST_OS_OPENBSD)
173179

174180
// Returns the number of threads running in the process, or 0 to indicate that
175181
// we cannot detect it.
@@ -193,8 +199,8 @@ size_t GetThreadCount() {
193199
mib[5] = static_cast<int>(size / static_cast<size_t>(mib[4]));
194200

195201
// populate array of structs
196-
struct kinfo_proc info[mib[5]];
197-
if (sysctl(mib, miblen, &info, &size, NULL, 0)) {
202+
std::vector<struct kinfo_proc> info(mib[5]);
203+
if (sysctl(mib, miblen, info.data(), &size, NULL, 0)) {
198204
return 0;
199205
}
200206

@@ -206,7 +212,7 @@ size_t GetThreadCount() {
206212
return nthreads;
207213
}
208214

209-
#elif GTEST_OS_QNX
215+
#elif defined(GTEST_OS_QNX)
210216

211217
// Returns the number of threads running in the process, or 0 to indicate that
212218
// we cannot detect it.
@@ -226,7 +232,7 @@ size_t GetThreadCount() {
226232
}
227233
}
228234

229-
#elif GTEST_OS_AIX
235+
#elif defined(GTEST_OS_AIX)
230236

231237
size_t GetThreadCount() {
232238
struct procentry64 entry;
@@ -239,7 +245,7 @@ size_t GetThreadCount() {
239245
}
240246
}
241247

242-
#elif GTEST_OS_FUCHSIA
248+
#elif defined(GTEST_OS_FUCHSIA)
243249

244250
size_t GetThreadCount() {
245251
int dummy_buffer;
@@ -264,7 +270,7 @@ size_t GetThreadCount() {
264270

265271
#endif // GTEST_OS_LINUX
266272

267-
#if GTEST_IS_THREADSAFE && GTEST_OS_WINDOWS
273+
#if defined(GTEST_IS_THREADSAFE) && defined(GTEST_OS_WINDOWS)
268274

269275
AutoHandle::AutoHandle() : handle_(INVALID_HANDLE_VALUE) {}
270276

@@ -655,7 +661,7 @@ void ThreadLocalRegistry::OnThreadLocalDestroyed(
655661

656662
#endif // GTEST_IS_THREADSAFE && GTEST_OS_WINDOWS
657663

658-
#if GTEST_USES_POSIX_RE
664+
#ifdef GTEST_USES_POSIX_RE
659665

660666
// Implements RE. Currently only needed for death tests.
661667

@@ -668,7 +674,6 @@ RE::~RE() {
668674
regfree(&partial_regex_);
669675
regfree(&full_regex_);
670676
}
671-
free(const_cast<char*>(pattern_));
672677
}
673678

674679
// Returns true if and only if regular expression re matches the entire str.
@@ -690,7 +695,7 @@ bool RE::PartialMatch(const char* str, const RE& re) {
690695

691696
// Initializes an RE from its string representation.
692697
void RE::Init(const char* regex) {
693-
pattern_ = posix::StrDup(regex);
698+
pattern_ = regex;
694699

695700
// Reserves enough bytes to hold the regular expression used for a
696701
// full match.
@@ -718,7 +723,7 @@ void RE::Init(const char* regex) {
718723
delete[] full_pattern;
719724
}
720725

721-
#elif GTEST_USES_SIMPLE_RE
726+
#elif defined(GTEST_USES_SIMPLE_RE)
722727

723728
// Returns true if and only if ch appears anywhere in str (excluding the
724729
// terminating '\0' character).
@@ -920,27 +925,26 @@ bool MatchRegexAnywhere(const char* regex, const char* str) {
920925

921926
// Implements the RE class.
922927

923-
RE::~RE() {
924-
free(const_cast<char*>(pattern_));
925-
free(const_cast<char*>(full_pattern_));
926-
}
928+
RE::~RE() = default;
927929

928930
// Returns true if and only if regular expression re matches the entire str.
929931
bool RE::FullMatch(const char* str, const RE& re) {
930-
return re.is_valid_ && MatchRegexAnywhere(re.full_pattern_, str);
932+
return re.is_valid_ && MatchRegexAnywhere(re.full_pattern_.c_str(), str);
931933
}
932934

933935
// Returns true if and only if regular expression re matches a substring of
934936
// str (including str itself).
935937
bool RE::PartialMatch(const char* str, const RE& re) {
936-
return re.is_valid_ && MatchRegexAnywhere(re.pattern_, str);
938+
return re.is_valid_ && MatchRegexAnywhere(re.pattern_.c_str(), str);
937939
}
938940

939941
// Initializes an RE from its string representation.
940942
void RE::Init(const char* regex) {
941-
pattern_ = full_pattern_ = nullptr;
943+
full_pattern_.clear();
944+
pattern_.clear();
945+
942946
if (regex != nullptr) {
943-
pattern_ = posix::StrDup(regex);
947+
pattern_ = regex;
944948
}
945949

946950
is_valid_ = ValidateRegex(regex);
@@ -949,25 +953,19 @@ void RE::Init(const char* regex) {
949953
return;
950954
}
951955

952-
const size_t len = strlen(regex);
953956
// Reserves enough bytes to hold the regular expression used for a
954-
// full match: we need space to prepend a '^', append a '$', and
955-
// terminate the string with '\0'.
956-
char* buffer = static_cast<char*>(malloc(len + 3));
957-
full_pattern_ = buffer;
957+
// full match: we need space to prepend a '^' and append a '$'.
958+
full_pattern_.reserve(pattern_.size() + 2);
958959

959-
if (*regex != '^')
960-
*buffer++ = '^'; // Makes sure full_pattern_ starts with '^'.
961-
962-
// We don't use snprintf or strncpy, as they trigger a warning when
963-
// compiled with VC++ 8.0.
964-
memcpy(buffer, regex, len);
965-
buffer += len;
960+
if (pattern_.empty() || pattern_.front() != '^') {
961+
full_pattern_.push_back('^'); // Makes sure full_pattern_ starts with '^'.
962+
}
966963

967-
if (len == 0 || regex[len - 1] != '$')
968-
*buffer++ = '$'; // Makes sure full_pattern_ ends with '$'.
964+
full_pattern_.append(pattern_);
969965

970-
*buffer = '\0';
966+
if (pattern_.empty() || pattern_.back() != '$') {
967+
full_pattern_.push_back('$'); // Makes sure full_pattern_ ends with '$'.
968+
}
971969
}
972970

973971
#endif // GTEST_USES_POSIX_RE
@@ -1035,7 +1033,7 @@ class CapturedStream {
10351033
public:
10361034
// The ctor redirects the stream to a temporary file.
10371035
explicit CapturedStream(int fd) : fd_(fd), uncaptured_fd_(dup(fd)) {
1038-
#if GTEST_OS_WINDOWS
1036+
#ifdef GTEST_OS_WINDOWS
10391037
char temp_dir_path[MAX_PATH + 1] = {'\0'}; // NOLINT
10401038
char temp_file_path[MAX_PATH + 1] = {'\0'}; // NOLINT
10411039

@@ -1054,7 +1052,7 @@ class CapturedStream {
10541052
// directory, so we create the temporary file in a temporary directory.
10551053
std::string name_template;
10561054

1057-
#if GTEST_OS_LINUX_ANDROID
1055+
#ifdef GTEST_OS_LINUX_ANDROID
10581056
// Note: Android applications are expected to call the framework's
10591057
// Context.getExternalStorageDirectory() method through JNI to get
10601058
// the location of the world-writable SD Card directory. However,
@@ -1067,7 +1065,7 @@ class CapturedStream {
10671065
// '/sdcard' and other variants cannot be relied on, as they are not
10681066
// guaranteed to be mounted, or may have a delay in mounting.
10691067
name_template = "/data/local/tmp/";
1070-
#elif GTEST_OS_IOS
1068+
#elif defined(GTEST_OS_IOS)
10711069
char user_temp_dir[PATH_MAX + 1];
10721070

10731071
// Documented alternative to NSTemporaryDirectory() (for obtaining creating
@@ -1227,7 +1225,7 @@ std::string ReadEntireFile(FILE* file) {
12271225
return content;
12281226
}
12291227

1230-
#if GTEST_HAS_DEATH_TEST
1228+
#ifdef GTEST_HAS_DEATH_TEST
12311229
static const std::vector<std::string>* g_injected_test_argvs =
12321230
nullptr; // Owned.
12331231

@@ -1254,7 +1252,7 @@ void ClearInjectableArgvs() {
12541252
}
12551253
#endif // GTEST_HAS_DEATH_TEST
12561254

1257-
#if GTEST_OS_WINDOWS_MOBILE
1255+
#ifdef GTEST_OS_WINDOWS_MOBILE
12581256
namespace posix {
12591257
void Abort() {
12601258
DebugBreak();

‎deps/googletest/src/gtest-printers.cc

+3-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
#include <cctype>
4848
#include <cstdint>
4949
#include <cwchar>
50+
#include <iomanip>
51+
#include <ios>
5052
#include <ostream> // NOLINT
5153
#include <string>
5254
#include <type_traits>
@@ -528,7 +530,7 @@ void PrintStringTo(const ::std::string& s, ostream* os) {
528530
}
529531
}
530532

531-
#ifdef __cpp_char8_t
533+
#ifdef __cpp_lib_char8_t
532534
void PrintU8StringTo(const ::std::u8string& s, ostream* os) {
533535
PrintCharsAsStringTo(s.data(), s.size(), os);
534536
}

‎deps/googletest/src/gtest-test-part.cc

+3-2
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@
3232

3333
#include "gtest/gtest-test-part.h"
3434

35+
#include <ostream>
36+
#include <string>
37+
3538
#include "gtest/internal/gtest-port.h"
3639
#include "src/gtest-internal-inl.h"
3740

3841
namespace testing {
3942

40-
using internal::GetUnitTestImpl;
41-
4243
// Gets the summary of the failure message by omitting the stack trace
4344
// in it.
4445
std::string TestPartResult::ExtractSummary(const char* message) {

‎deps/googletest/src/gtest-typed-test.cc

+5-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929

3030
#include "gtest/gtest-typed-test.h"
3131

32+
#include <set>
33+
#include <string>
34+
#include <vector>
35+
3236
#include "gtest/gtest.h"
3337

3438
namespace testing {
@@ -90,7 +94,7 @@ const char* TypedTestSuitePState::VerifyRegisteredTestNames(
9094
}
9195

9296
const std::string& errors_str = errors.GetString();
93-
if (errors_str != "") {
97+
if (!errors_str.empty()) {
9498
fprintf(stderr, "%s %s", FormatFileLocation(file, line).c_str(),
9599
errors_str.c_str());
96100
fflush(stderr);

‎deps/googletest/src/gtest.cc

+172-96
Large diffs are not rendered by default.

‎deps/googletest/src/gtest_main.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,22 @@
3131

3232
#include "gtest/gtest.h"
3333

34-
#if GTEST_OS_ESP8266 || GTEST_OS_ESP32
34+
#if defined(GTEST_OS_ESP8266) || defined(GTEST_OS_ESP32)
3535
// Arduino-like platforms: program entry points are setup/loop instead of main.
3636

37-
#if GTEST_OS_ESP8266
37+
#ifdef GTEST_OS_ESP8266
3838
extern "C" {
3939
#endif
4040

4141
void setup() { testing::InitGoogleTest(); }
4242

4343
void loop() { RUN_ALL_TESTS(); }
4444

45-
#if GTEST_OS_ESP8266
45+
#ifdef GTEST_OS_ESP8266
4646
}
4747
#endif
4848

49-
#elif GTEST_OS_QURT
49+
#elif defined(GTEST_OS_QURT)
5050
// QuRT: program entry point is main, but argc/argv are unusable.
5151

5252
GTEST_API_ int main() {

0 commit comments

Comments
 (0)
Please sign in to comment.