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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions googlemock/include/gmock/gmock-matchers.h
Original file line number Diff line number Diff line change
Expand Up @@ -5777,7 +5777,7 @@ PolymorphicMatcher<internal::ExceptionMatcherImpl<Err>> ThrowsMessage(
} \
template <typename arg_type> \
bool name##Matcher::gmock_Impl<arg_type>::MatchAndExplain( \
const arg_type& arg, \
[[maybe_unused]] const arg_type& arg, \
[[maybe_unused]] ::testing::MatchResultListener* result_listener) const

#define MATCHER_P(name, p0, description) \
Expand Down Expand Up @@ -5862,7 +5862,7 @@ PolymorphicMatcher<internal::ExceptionMatcherImpl<Err>> ThrowsMessage(
template <typename arg_type> \
bool full_name<GMOCK_INTERNAL_MATCHER_TYPE_PARAMS(args)>:: \
gmock_Impl<arg_type>::MatchAndExplain( \
const arg_type& arg, \
[[maybe_unused]] const arg_type& arg, \
[[maybe_unused]] ::testing::MatchResultListener* result_listener) \
const

Expand Down
4 changes: 4 additions & 0 deletions googlemock/src/gmock-matchers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ void UnorderedElementsAreMatcherImplBase::DescribeToImpl(
case UnorderedMatcherRequire::Subset:
*os << "an injection from elements to requirements exists such that:\n";
break;
default:
break;
}

const char* sep = "";
Expand Down Expand Up @@ -343,6 +345,8 @@ void UnorderedElementsAreMatcherImplBase::DescribeNegationToImpl(
case UnorderedMatcherRequire::Subset:
*os << "no injection from elements to requirements exists such that:\n";
break;
default:
break;
}
const char* sep = "";
for (size_t i = 0; i != matcher_describers_.size(); ++i) {
Expand Down
1 change: 1 addition & 0 deletions googlemock/src/gmock-spec-builders.cc
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ void ReportUninterestingCall(CallReaction reaction, const std::string& msg) {
"knowing-when-to-expect-useoncall for details.\n",
stack_frames_to_skip);
break;
case kFail:
default: // FAIL
Expect(false, nullptr, -1, msg);
}
Expand Down
2 changes: 1 addition & 1 deletion googlemock/test/gmock-function-mocker_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class TemplatedCopyable {
TemplatedCopyable() = default;

template <typename U>
TemplatedCopyable(const U& other) {} // NOLINT
TemplatedCopyable(const U&) {} // NOLINT
};

class FooInterface {
Expand Down
2 changes: 2 additions & 0 deletions googlemock/test/gmock-matchers-containers_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2829,6 +2829,8 @@ class PredicateFormatterFromMatcherTest : public ::testing::Test {
// an "interested" listener; so this will return |true|, thus
// simulating a flaky matcher.
return listener->IsInterested();
default:
break;
}

GTEST_LOG_(FATAL) << "This should never be reached";
Expand Down
12 changes: 11 additions & 1 deletion googletest/cmake/internal_utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,17 @@ macro(config_compiler_and_linker)
endif()
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR
CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
set(cxx_base_flags "-Wall -Wshadow -Wconversion -Wundef")
set(cxx_base_flags "-Wall \
-Wshadow \
-Wconversion \
-Wundef \
-Wswitch-default \
-Wswitch-enum \
-Wextra \
-Wcast-align \
-Wunused \
-Wunreachable-code \
")
set(cxx_exception_flags "-fexceptions")
set(cxx_no_exception_flags "-fno-exceptions")
set(cxx_strict_flags "-W -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wunused-parameter -Wcast-align -Winline -Wredundant-decls")
Expand Down
2 changes: 2 additions & 0 deletions googletest/include/gtest/internal/gtest-death-test-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ GTEST_API_ bool ExitedUnsuccessfully(int exit_status);
gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE); \
break; \
} \
default: \
break; \
} \
} \
} else \
Expand Down
9 changes: 9 additions & 0 deletions googletest/src/gtest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1471,6 +1471,8 @@ class Hunk {
++adds_;
hunk_adds_.push_back(std::make_pair('+', line));
break;
default:
break;
}
}

Expand Down Expand Up @@ -3281,6 +3283,7 @@ static const char* GetAnsiColorCode(GTestColor color) {
return "2";
case GTestColor::kYellow:
return "3";
case GTestColor::kDefault:
default:
assert(false);
return "9";
Expand Down Expand Up @@ -3537,6 +3540,9 @@ void PrettyUnitTestResultPrinter::OnTestPartResult(
// If the test part succeeded, we don't need to do anything.
case TestPartResult::kSuccess:
return;
case TestPartResult::kNonFatalFailure:
case TestPartResult::kFatalFailure:
case TestPartResult::kSkip:
default:
// Print failure message from the assertion
// (e.g. expected this and got that).
Expand Down Expand Up @@ -3755,6 +3761,9 @@ void BriefUnitTestResultPrinter::OnTestPartResult(
// If the test part succeeded, we don't need to do anything.
case TestPartResult::kSuccess:
return;
case TestPartResult::kNonFatalFailure:
case TestPartResult::kFatalFailure:
case TestPartResult::kSkip:
default:
// Print failure message from the assertion
// (e.g. expected this and got that).
Expand Down
4 changes: 2 additions & 2 deletions googletest/test/googletest-death-test-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ TEST_F(TestForDeathTest, SwitchStatement) {
ASSERT_DEATH(_Exit(1), "") << "exit in default switch handler";

switch (0)
case 0:
default:
EXPECT_DEATH(_Exit(1), "") << "exit in switch case";

GTEST_DISABLE_MSC_WARNINGS_POP_()
Expand Down Expand Up @@ -1499,7 +1499,7 @@ TEST(ConditionalDeathMacrosSyntaxDeathTest, SwitchStatement) {
ASSERT_DEATH_IF_SUPPORTED(_Exit(1), "") << "exit in default switch handler";

switch (0)
case 0:
default:
EXPECT_DEATH_IF_SUPPORTED(_Exit(1), "") << "exit in switch case";

GTEST_DISABLE_MSC_WARNINGS_POP_()
Expand Down
2 changes: 1 addition & 1 deletion googletest/test/googletest-port-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ TEST(GtestCheckSyntaxTest, WorksWithSwitch) {
}

switch (0)
case 0:
default:
GTEST_CHECK_(true) << "Check failed in switch case";
}

Expand Down
1 change: 1 addition & 0 deletions googletest/test/gtest_environment_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class MyEnvironment : public testing::Environment {
case FATAL_FAILURE:
FAIL() << "Expected fatal failure in global set-up.";
break;
case NO_FAILURE:
default:
break;
}
Expand Down
4 changes: 2 additions & 2 deletions googletest/test/gtest_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4253,7 +4253,7 @@ TEST(AssertionSyntaxTest, WorksWithSwitch) {
}

switch (0)
case 0:
default:
EXPECT_FALSE(false) << "EXPECT_FALSE failed in switch case";

// Binary assertions are implemented using a different code path
Expand All @@ -4265,7 +4265,7 @@ TEST(AssertionSyntaxTest, WorksWithSwitch) {
}

switch (0)
case 0:
default:
EXPECT_NE(1, 2);
}

Expand Down