From 2491710524094dc3b77cfa4e8eda2ba8edb0d91c Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 24 Jan 2023 11:09:35 -0800 Subject: Fix formatting of C++ files PiperOrigin-RevId: 504325204 Change-Id: Iaa1d6d0ab1dccaaeef26f9cb109d530835499240 --- googlemock/include/gmock/gmock-actions.h | 52 +++++++++++----------- googlemock/include/gmock/gmock-function-mocker.h | 5 ++- googlemock/include/gmock/gmock-matchers.h | 7 ++- googlemock/include/gmock/gmock-more-actions.h | 21 ++++----- googlemock/test/gmock-actions_test.cc | 4 +- googlemock/test/gmock-matchers-misc_test.cc | 4 +- googlemock/test/gmock-matchers_test.h | 6 +-- googletest/include/gtest/gtest-param-test.h | 3 +- googletest/include/gtest/gtest-typed-test.h | 34 +++++++------- googletest/include/gtest/gtest.h | 4 +- .../include/gtest/internal/gtest-param-util.h | 2 +- googletest/include/gtest/internal/gtest-port.h | 2 +- googletest/src/gtest-filepath.cc | 13 +++--- googletest/src/gtest.cc | 6 +-- googletest/test/googletest-printers-test.cc | 6 +-- 15 files changed, 84 insertions(+), 85 deletions(-) diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h index aad07d5..a6c2489 100644 --- a/googlemock/include/gmock/gmock-actions.h +++ b/googlemock/include/gmock/gmock-actions.h @@ -1420,19 +1420,19 @@ struct WithArgsAction { // providing a call operator because even with a particular set of arguments // they don't have a fixed return type. - template >...)>>::value, - int>::type = 0> + template < + typename R, typename... Args, + typename std::enable_if< + std::is_convertible>...)>>::value, + int>::type = 0> operator OnceAction() && { // NOLINT struct OA { OnceAction> inner_action; @@ -1447,19 +1447,19 @@ struct WithArgsAction { return OA{std::move(inner_action)}; } - template >...)>>::value, - int>::type = 0> + template < + typename R, typename... Args, + typename std::enable_if< + std::is_convertible>...)>>::value, + int>::type = 0> operator Action() const { // NOLINT Action> converted(inner_action); diff --git a/googlemock/include/gmock/gmock-function-mocker.h b/googlemock/include/gmock/gmock-function-mocker.h index 7306549..1a1f126 100644 --- a/googlemock/include/gmock/gmock-function-mocker.h +++ b/googlemock/include/gmock/gmock-function-mocker.h @@ -180,8 +180,9 @@ using internal::FunctionMocker; _Signature)>::Result \ GMOCK_INTERNAL_EXPAND(_CallType) \ _MethodName(GMOCK_PP_REPEAT(GMOCK_INTERNAL_PARAMETER, _Signature, _N)) \ - GMOCK_PP_IF(_Constness, const, ) _RefSpec _NoexceptSpec \ - GMOCK_PP_IF(_Override, override, ) GMOCK_PP_IF(_Final, final, ) { \ + GMOCK_PP_IF(_Constness, const, ) \ + _RefSpec _NoexceptSpec GMOCK_PP_IF(_Override, override, ) \ + GMOCK_PP_IF(_Final, final, ) { \ GMOCK_MOCKER_(_N, _Constness, _MethodName) \ .SetOwnerAndName(this, #_MethodName); \ return GMOCK_MOCKER_(_N, _Constness, _MethodName) \ diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index 9e634f7..fc00c35 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -3317,8 +3317,8 @@ class FieldsAreMatcherImpl> std::vector inner_listener(sizeof...(I)); VariadicExpand( - {failed_pos == ~size_t{}&& !std::get(matchers_).MatchAndExplain( - std::get(tuple), &inner_listener[I]) + {failed_pos == ~size_t{} && !std::get(matchers_).MatchAndExplain( + std::get(tuple), &inner_listener[I]) ? failed_pos = I : 0 ...}); if (failed_pos != ~size_t{}) { @@ -5474,8 +5474,7 @@ PolymorphicMatcher> ThrowsMessage( inline name##Matcher GMOCK_INTERNAL_WARNING_PUSH() \ GMOCK_INTERNAL_WARNING_CLANG(ignored, "-Wunused-function") \ GMOCK_INTERNAL_WARNING_CLANG(ignored, "-Wunused-member-function") \ - name \ - GMOCK_INTERNAL_WARNING_POP()() { \ + name GMOCK_INTERNAL_WARNING_POP()() { \ return {}; \ } \ template \ diff --git a/googlemock/include/gmock/gmock-more-actions.h b/googlemock/include/gmock/gmock-more-actions.h index 148ac01..78169b1 100644 --- a/googlemock/include/gmock/gmock-more-actions.h +++ b/googlemock/include/gmock/gmock-more-actions.h @@ -526,9 +526,10 @@ GMOCK_INTERNAL_LIST_##value_params)){}) \ GMOCK_ACTION_CLASS_(name, value_params)(const GMOCK_ACTION_CLASS_( \ name, value_params) &) noexcept GMOCK_INTERNAL_DEFN_COPY_ \ - ##value_params GMOCK_ACTION_CLASS_(name, value_params)( \ - GMOCK_ACTION_CLASS_(name, value_params) &&) noexcept \ - GMOCK_INTERNAL_DEFN_COPY_##value_params template \ + ##value_params \ + GMOCK_ACTION_CLASS_(name, value_params)(GMOCK_ACTION_CLASS_( \ + name, value_params) &&) noexcept GMOCK_INTERNAL_DEFN_COPY_ \ + ##value_params template \ operator ::testing::Action() const { \ return GMOCK_PP_IF( \ GMOCK_PP_IS_EMPTY(GMOCK_INTERNAL_COUNT_##value_params), \ @@ -602,13 +603,13 @@ template struct InvokeArgumentAction { template ::type> - auto operator()(Args&&... args) const -> decltype(internal::InvokeArgument( + auto operator()(Args &&...args) const -> decltype(internal::InvokeArgument( std::get(std::forward_as_tuple(std::forward(args)...)), - std::declval()...)) { - internal::FlatTuple args_tuple(FlatTupleConstructTag{}, - std::forward(args)...); - return params.Apply([&](const Params&... unpacked_params) { - auto&& callable = args_tuple.template Get(); + std::declval()...)) { + internal::FlatTuple args_tuple(FlatTupleConstructTag{}, + std::forward(args)...); + return params.Apply([&](const Params &...unpacked_params) { + auto &&callable = args_tuple.template Get(); return internal::InvokeArgument( std::forward(callable), unpacked_params...); }); @@ -648,7 +649,7 @@ struct InvokeArgumentAction { // later. template internal::InvokeArgumentAction::type...> -InvokeArgument(Params&&... params) { +InvokeArgument(Params &&...params) { return {internal::FlatTuple::type...>( internal::FlatTupleConstructTag{}, std::forward(params)...)}; } diff --git a/googlemock/test/gmock-actions_test.cc b/googlemock/test/gmock-actions_test.cc index 510d15c..295470e 100644 --- a/googlemock/test/gmock-actions_test.cc +++ b/googlemock/test/gmock-actions_test.cc @@ -1410,7 +1410,7 @@ TEST(DoAll, ProvidesLvalueReferencesToInitialActions) { void operator()(Obj&&) const { FAIL() << "Unexpected call"; } }; - MockFunction mock; + MockFunction mock; EXPECT_CALL(mock, Call) .WillOnce(DoAll(InitialAction{}, InitialAction{}, [](Obj&&) {})) .WillRepeatedly(DoAll(InitialAction{}, InitialAction{}, [](Obj&&) {})); @@ -1438,7 +1438,7 @@ TEST(DoAll, ProvidesLvalueReferencesToInitialActions) { void operator()(Obj&) && {} }; - MockFunction mock; + MockFunction mock; EXPECT_CALL(mock, Call) .WillOnce(DoAll(InitialAction{}, InitialAction{}, [](Obj&&) {})); diff --git a/googlemock/test/gmock-matchers-misc_test.cc b/googlemock/test/gmock-matchers-misc_test.cc index 42a0e44..f99bbf4 100644 --- a/googlemock/test/gmock-matchers-misc_test.cc +++ b/googlemock/test/gmock-matchers-misc_test.cc @@ -1792,8 +1792,8 @@ TEST(ThrowsPredicateCompilesTest, ExceptionMatcherAcceptsBroadType) { { Matcher inner = Eq(10); Matcher> matcher = Throws(inner); - EXPECT_TRUE(matcher.Matches([]() { throw(uint32_t) 10; })); - EXPECT_FALSE(matcher.Matches([]() { throw(uint32_t) 11; })); + EXPECT_TRUE(matcher.Matches([]() { throw (uint32_t)10; })); + EXPECT_FALSE(matcher.Matches([]() { throw (uint32_t)11; })); } } diff --git a/googlemock/test/gmock-matchers_test.h b/googlemock/test/gmock-matchers_test.h index 6c986e9..5695607 100644 --- a/googlemock/test/gmock-matchers_test.h +++ b/googlemock/test/gmock-matchers_test.h @@ -148,9 +148,9 @@ class GreaterThanMatcher : public MatcherInterface { }; // Names and instantiates a new instance of GTestMatcherTestP. -#define INSTANTIATE_GTEST_MATCHER_TEST_P(TestSuite) \ - using TestSuite##P = GTestMatcherTestP; \ - INSTANTIATE_TEST_SUITE_P(MatcherInterface, TestSuite##P, Values(false)); \ +#define INSTANTIATE_GTEST_MATCHER_TEST_P(TestSuite) \ + using TestSuite##P = GTestMatcherTestP; \ + INSTANTIATE_TEST_SUITE_P(MatcherInterface, TestSuite##P, Values(false)); \ INSTANTIATE_TEST_SUITE_P(GtestMatcher, TestSuite##P, Values(true)) class GTestMatcherTestP : public testing::TestWithParam { diff --git a/googletest/include/gtest/gtest-param-test.h b/googletest/include/gtest/gtest-param-test.h index 1adb9a7..49a47ea 100644 --- a/googletest/include/gtest/gtest-param-test.h +++ b/googletest/include/gtest/gtest-param-test.h @@ -449,7 +449,8 @@ internal::ParamConverterGenerator ConvertGenerator( #define TEST_P(test_suite_name, test_name) \ class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \ - : public test_suite_name, private ::testing::internal::GTestNonCopyable {\ + : public test_suite_name, \ + private ::testing::internal::GTestNonCopyable { \ public: \ GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() {} \ void TestBody() override; \ diff --git a/googletest/include/gtest/gtest-typed-test.h b/googletest/include/gtest/gtest-typed-test.h index bd35a32..72de536 100644 --- a/googletest/include/gtest/gtest-typed-test.h +++ b/googletest/include/gtest/gtest-typed-test.h @@ -267,28 +267,28 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes); TYPED_TEST_SUITE_P #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ -#define TYPED_TEST_P(SuiteName, TestName) \ - namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \ - template \ - class TestName : public SuiteName { \ - private: \ - typedef SuiteName TestFixture; \ - typedef gtest_TypeParam_ TypeParam; \ - void TestBody() override; \ - }; \ - static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \ - GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).AddTestName( \ - __FILE__, __LINE__, GTEST_STRINGIFY_(SuiteName), \ - GTEST_STRINGIFY_(TestName)); \ - } \ - template \ - void GTEST_SUITE_NAMESPACE_( \ +#define TYPED_TEST_P(SuiteName, TestName) \ + namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \ + template \ + class TestName : public SuiteName { \ + private: \ + typedef SuiteName TestFixture; \ + typedef gtest_TypeParam_ TypeParam; \ + void TestBody() override; \ + }; \ + static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \ + GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).AddTestName( \ + __FILE__, __LINE__, GTEST_STRINGIFY_(SuiteName), \ + GTEST_STRINGIFY_(TestName)); \ + } \ + template \ + void GTEST_SUITE_NAMESPACE_( \ SuiteName)::TestName::TestBody() // Note: this won't work correctly if the trailing arguments are macros. #define REGISTER_TYPED_TEST_SUITE_P(SuiteName, ...) \ namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \ - typedef ::testing::internal::Templates<__VA_ARGS__> gtest_AllTests_; \ + typedef ::testing::internal::Templates<__VA_ARGS__> gtest_AllTests_; \ } \ static const char* const GTEST_REGISTERED_TEST_NAMES_( \ SuiteName) GTEST_ATTRIBUTE_UNUSED_ = \ diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index 3e452a5..c4e01ad 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -201,8 +201,8 @@ std::set* GetIgnoredParameterizedTestSuites(); class GTestNonCopyable { public: GTestNonCopyable() = default; - GTestNonCopyable(const GTestNonCopyable &) = delete; - GTestNonCopyable &operator=(const GTestNonCopyable &) = delete; + GTestNonCopyable(const GTestNonCopyable&) = delete; + GTestNonCopyable& operator=(const GTestNonCopyable&) = delete; ~GTestNonCopyable() = default; }; diff --git a/googletest/include/gtest/internal/gtest-param-util.h b/googletest/include/gtest/internal/gtest-param-util.h index 7092d10..358ef72 100644 --- a/googletest/include/gtest/internal/gtest-param-util.h +++ b/googletest/include/gtest/internal/gtest-param-util.h @@ -956,7 +956,7 @@ class CartesianProductHolder { template class ParamGeneratorConverter : public ParamGeneratorInterface { public: - ParamGeneratorConverter(ParamGenerator gen) // NOLINT + ParamGeneratorConverter(ParamGenerator gen) // NOLINT : generator_(std::move(gen)) {} ParamIteratorInterface* Begin() const override { diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 6db191b..b4fa3f0 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -712,7 +712,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; #define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) \ __attribute__((format(__MINGW_PRINTF_FORMAT, string_index, first_to_check))) #elif GTEST_HAVE_ATTRIBUTE_(format) -#define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) \ +#define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) \ __attribute__((format(printf, string_index, first_to_check))) #else #define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) diff --git a/googletest/src/gtest-filepath.cc b/googletest/src/gtest-filepath.cc index 9d79ea4..940585d 100644 --- a/googletest/src/gtest-filepath.cc +++ b/googletest/src/gtest-filepath.cc @@ -148,20 +148,19 @@ const char* FilePath::FindLastPathSeparator() const { } size_t FilePath::CalculateRootLength() const { - const auto &path = pathname_; + const auto& path = pathname_; auto s = path.begin(); auto end = path.end(); #if GTEST_OS_WINDOWS - if (end - s >= 2 && s[1] == ':' && - (end - s == 2 || IsPathSeparator(s[2])) && + if (end - s >= 2 && s[1] == ':' && (end - s == 2 || IsPathSeparator(s[2])) && (('A' <= s[0] && s[0] <= 'Z') || ('a' <= s[0] && s[0] <= 'z'))) { // A typical absolute path like "C:\Windows" or "D:" s += 2; if (s != end) { ++s; } - } else if (end - s >= 3 && IsPathSeparator(*s) && IsPathSeparator(*(s + 1)) - && !IsPathSeparator(*(s + 2))) { + } else if (end - s >= 3 && IsPathSeparator(*s) && IsPathSeparator(*(s + 1)) && + !IsPathSeparator(*(s + 2))) { // Move past the "\\" prefix in a UNC path like "\\Server\Share\Folder" s += 2; // Skip 2 components and their following separators ("Server\" and "Share\") @@ -295,9 +294,7 @@ bool FilePath::IsRootDirectory() const { } // Returns true if pathname describes an absolute path. -bool FilePath::IsAbsolutePath() const { - return CalculateRootLength() > 0; -} +bool FilePath::IsAbsolutePath() const { return CalculateRootLength() > 0; } // Returns a pathname for a file that does not currently exist. The pathname // will be directory/base_name.extension or diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index a64e887..19acb1c 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -1134,8 +1134,8 @@ class Timer { // Return time elapsed in milliseconds since the timer was created. TimeInMillis Elapsed() { - return std::chrono::duration_cast( - clock::now() - start_) + return std::chrono::duration_cast(clock::now() - + start_) .count(); } @@ -6172,7 +6172,7 @@ void UnitTestImpl::ListTestsMatchingFilter() { } } fflush(stdout); - #if GTEST_HAS_FILE_SYSTEM +#if GTEST_HAS_FILE_SYSTEM const std::string& output_format = UnitTestOptions::GetOutputFormat(); if (output_format == "xml" || output_format == "json") { FILE* fileout = OpenFileForWriting( diff --git a/googletest/test/googletest-printers-test.cc b/googletest/test/googletest-printers-test.cc index 8a7db25..34aa924 100644 --- a/googletest/test/googletest-printers-test.cc +++ b/googletest/test/googletest-printers-test.cc @@ -461,10 +461,10 @@ TEST(PrintBuiltInTypeTest, FloatingPoints) { // float (32-bit precision) EXPECT_EQ("1.5", Print(1.5f)); - EXPECT_EQ("1.0999999", Print(1.09999990f)); - EXPECT_EQ("1.1", Print(1.10000002f)); + EXPECT_EQ("1.0999999", Print(1.09999990f)); + EXPECT_EQ("1.1", Print(1.10000002f)); EXPECT_EQ("1.10000014", Print(1.10000014f)); - EXPECT_EQ("9e+09", Print(9e9f)); + EXPECT_EQ("9e+09", Print(9e9f)); // double EXPECT_EQ("-2.5", Print(-2.5)); // double -- cgit v0.12