Compare commits

...

6 Commits

Author SHA1 Message Date
Harry Saunders
ddf8da84f7
Merge 8d24b1552bb723d36f006cce2d64861496b29377 into c6f04243ed7036f130a3ece4e2aa1067e8554236 2026-07-29 00:16:33 +08:00
Abseil Team
c6f04243ed Automated Code Change
PiperOrigin-RevId: 955021426
Change-Id: I3ab06e960011d1d0cd44ea00595a5067aaa7f30b
2026-07-27 22:07:28 -07:00
Abseil Team
af4c3cfcb3 Automated Code Change
PiperOrigin-RevId: 955017590
Change-Id: I5125f56376603462fb63796fec1fbc50fd4d935f
2026-07-27 21:57:20 -07:00
Abseil Team
ecb18f0b03 Automated Code Change
PiperOrigin-RevId: 955003621
Change-Id: I83518a7f947d9f7d9b89fe14e1219d32bcdc95a3
2026-07-27 21:17:32 -07:00
Abseil Team
b78aa5ee64 Automated Code Change
PiperOrigin-RevId: 953750672
Change-Id: I9314622e998cb9d17eec0dc1baeb6d8bc8a801fd
2026-07-24 23:56:31 -07:00
Harry Saunders
8d24b1552b
Do not print skipped test's messages in brief mode 2025-07-04 14:09:01 +01:00
11 changed files with 37 additions and 19 deletions

View File

@ -1243,16 +1243,16 @@ TEST(InvokeWithoutArgsTest, Function) {
TEST(InvokeWithoutArgsTest, Functor) {
GTEST_DISABLE_DEPRECATED_PUSH_()
// As an action that takes no argument.
Action<int()> a = InvokeWithoutArgs(NullaryFunctor()); // NOLINT
Action<int()> a = NullaryFunctor(); // NOLINT
EXPECT_EQ(2, a.Perform(std::make_tuple()));
// As an action that takes three arguments.
Action<int(int, double, char)> a2 = // NOLINT
InvokeWithoutArgs(NullaryFunctor());
NullaryFunctor();
EXPECT_EQ(2, a2.Perform(std::make_tuple(3, 3.5, 'a')));
// As an action that returns void.
Action<void()> a3 = InvokeWithoutArgs(VoidNullaryFunctor());
Action<void()> a3 = VoidNullaryFunctor();
g_done = false;
a3.Perform(std::make_tuple());
EXPECT_TRUE(g_done);

View File

@ -340,7 +340,7 @@ TEST(LinkTest, TestInvokeWithoutArgs) {
GTEST_DISABLE_DEPRECATED_PUSH_()
EXPECT_CALL(mock, VoidFromString(_))
.WillOnce(InvokeWithoutArgs(&InvokeHelper::StaticVoidFromVoid))
.WillOnce(&InvokeHelper::StaticVoidFromVoid)
.WillOnce(
InvokeWithoutArgs(&test_invoke_helper, &InvokeHelper::VoidFromVoid));
GTEST_DISABLE_DEPRECATED_POP_()

View File

@ -30,6 +30,8 @@
// Tests that Google Mock constructs can be used in a large number of
// threads concurrently.
#include <iterator>
#include "gmock/gmock.h"
#include "gtest/gtest.h"
@ -188,7 +190,7 @@ TEST(StressTest, CanUseGMockWithThreads) {
&TestPartiallyOrderedExpectationsWithThreads,
};
const int kRoutines = sizeof(test_routines) / sizeof(test_routines[0]);
const int kRoutines = std::size(test_routines);
const int kCopiesOfEachRoutine = kMaxTestThreads / kRoutines;
const int kTestThreads = kCopiesOfEachRoutine * kRoutines;
ThreadWithParam<Dummy>* threads[kTestThreads] = {};

View File

@ -39,6 +39,8 @@
#include "sample2.h"
#include <iterator>
#include "gtest/gtest.h"
namespace {
// In this example, we test the MyString class (a simple string).
@ -78,7 +80,7 @@ const char kHelloString[] = "Hello, world!";
TEST(MyString, ConstructorFromCString) {
const MyString s(kHelloString);
EXPECT_EQ(0, strcmp(s.c_string(), kHelloString));
EXPECT_EQ(sizeof(kHelloString) / sizeof(kHelloString[0]) - 1, s.Length());
EXPECT_EQ(std::size(kHelloString) - 1, s.Length());
}
// Tests the copy c'tor.

View File

@ -2489,7 +2489,7 @@ void TestResult::Clear() {
elapsed_time_ = 0;
}
// Returns true off the test part was skipped.
// Returns true if the test part was skipped.
static bool TestPartSkipped(const TestPartResult& result) {
return result.skipped();
}
@ -3782,6 +3782,8 @@ void BriefUnitTestResultPrinter::OnTestPartResult(
// If the test part succeeded, we don't need to do anything.
case TestPartResult::kSuccess:
return;
case TestPartResult::kSkip:
return;
default:
// Print failure message from the assertion
// (e.g. expected this and got that).

View File

@ -32,6 +32,7 @@
// This file verifies Google Test event listeners receive events at the
// right times.
#include <iterator>
#include <string>
#include <vector>
@ -498,8 +499,7 @@ int main(int argc, char** argv) {
"1st.OnTestProgramEnd"};
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
VerifyResults(events, expected_events,
sizeof(expected_events) / sizeof(expected_events[0]));
VerifyResults(events, expected_events, std::size(expected_events));
// We need to check manually for ad hoc test failures that happen after
// RUN_ALL_TESTS finishes.

View File

@ -36,6 +36,7 @@
#include <stdlib.h>
#include <algorithm>
#include <iterator>
#include <string>
#include "gtest/gtest-spi.h"
@ -149,7 +150,7 @@ TEST(LoggingTest, InterleavingLoggingAndAssertions) {
static const int a[4] = {3, 9, 2, 6};
printf("(expecting 2 failures on (3) >= (a[i]))\n");
for (int i = 0; i < static_cast<int>(sizeof(a) / sizeof(*a)); i++) {
for (int i = 0; i < static_cast<int>(std::size(a)); i++) {
printf("i == %d\n", i);
EXPECT_GE(3, a[i]);
}

View File

@ -39,6 +39,7 @@
#include <cstdint>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <set>
#include <sstream>
@ -737,10 +738,7 @@ const int test_generation_params[] = {36, 42, 72};
class TestGenerationTest : public TestWithParam<int> {
public:
enum {
PARAMETER_COUNT =
sizeof(test_generation_params) / sizeof(test_generation_params[0])
};
enum { PARAMETER_COUNT = std::size(test_generation_params) };
typedef TestGenerationEnvironment<PARAMETER_COUNT> Environment;

View File

@ -39,6 +39,7 @@
#include <deque>
#include <forward_list>
#include <functional>
#include <iterator>
#include <limits>
#include <list>
#include <map>
@ -1784,7 +1785,7 @@ TEST(IsValidUTF8Test, IllFormedUTF8) {
// too.
{"\xEE\x80\x80", "\"\\xEE\\x80\\x80\"\n As Text: \"\""}};
for (int i = 0; i < int(sizeof(kTestdata) / sizeof(kTestdata[0])); ++i) {
for (int i = 0; i < int(std::size(kTestdata)); ++i) {
EXPECT_PRINT_TO_STRING_(kTestdata[i][0], kTestdata[i][1]);
}
}

View File

@ -37,7 +37,7 @@ import re
from googletest.test import gtest_test_utils
# Path to the gtest_skip_in_environment_setup_test binary
# Path to the gtest_skip_test binary
EXE_PATH = gtest_test_utils.GetTestExecutablePath('gtest_skip_test')
OUTPUT = gtest_test_utils.Subprocess([EXE_PATH]).output
@ -55,6 +55,17 @@ class SkipEntireEnvironmentTest(gtest_test_utils.TestCase):
)
self.assertNotIn('FAILED', OUTPUT)
def testSkipTestWithBriefFlag(self):
brief_output = gtest_test_utils.Subprocess([EXE_PATH, "--gtest_brief=1"]).output
self.assertNotIn('Skipped\nskipping single test\n', brief_output)
skip_fixture = 'Skipped\nskipping all tests for this fixture\n'
self.assertIsNone(
re.search(skip_fixture + '.*' + skip_fixture, brief_output, flags=re.DOTALL),
repr(brief_output),
)
self.assertIn('SKIPPED', brief_output)
self.assertNotIn('FAILED', brief_output)
if __name__ == '__main__':
gtest_test_utils.Main()

View File

@ -33,6 +33,8 @@
#include "gtest/gtest.h"
#include <iterator>
// Verifies that the command line flag variables can be accessed in
// code once "gtest.h" has been #included.
// Do not move it after other gtest #includes.
@ -5853,9 +5855,8 @@ class ParseFlagsTest : public Test {
// to specify the array sizes.
#define GTEST_TEST_PARSING_FLAGS_(argv1, argv2, expected, should_print_help) \
TestParsingFlags(sizeof(argv1) / sizeof(*argv1) - 1, argv1, \
sizeof(argv2) / sizeof(*argv2) - 1, argv2, expected, \
should_print_help)
TestParsingFlags(std::size(argv1) - 1, argv1, std::size(argv2) - 1, argv2, \
expected, should_print_help)
};
// Tests parsing an empty command line.