summaryrefslogtreecommitdiffstats
path: root/googletest/test/gtest_stress_test.cc
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2022-03-15 20:41:41 (GMT)
committerCopybara-Service <copybara-worker@google.com>2022-03-15 20:42:11 (GMT)
commitb007c54f2944e193ac44fba1bc997cb65826a0b9 (patch)
tree3ea747410f93a40da0df6f8777e2ba551761cf8c /googletest/test/gtest_stress_test.cc
parent8a422b8398dd7e2b6b3e1fcbfbceb43ead2a5761 (diff)
downloadgoogletest-b007c54f2944e193ac44fba1bc997cb65826a0b9.zip
googletest-b007c54f2944e193ac44fba1bc997cb65826a0b9.tar.gz
googletest-b007c54f2944e193ac44fba1bc997cb65826a0b9.tar.bz2
Running clang-format over all of GoogleTest
A few tests are examining code locations and looking af the resulting line numbers to verify that GoogleTest shows those to users correctly. Some of those locations change when clang-format is run. For those locations, I've wrapped portions in: // clang-format off ... // clang-format on There may be other locations that are currently not tickled by running clang-format. PiperOrigin-RevId: 434844712 Change-Id: I3a9f0a6f39eff741c576b6de389bef9b1d11139d
Diffstat (limited to 'googletest/test/gtest_stress_test.cc')
-rw-r--r--googletest/test/gtest_stress_test.cc26
1 files changed, 10 insertions, 16 deletions
diff --git a/googletest/test/gtest_stress_test.cc b/googletest/test/gtest_stress_test.cc
index 8434819..24b173f 100644
--- a/googletest/test/gtest_stress_test.cc
+++ b/googletest/test/gtest_stress_test.cc
@@ -27,14 +27,12 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
// Tests that SCOPED_TRACE() and various Google Test assertions can be
// used in a large number of threads concurrently.
-#include "gtest/gtest.h"
-
#include <vector>
+#include "gtest/gtest.h"
#include "src/gtest-internal-inl.h"
#if GTEST_IS_THREADSAFE
@@ -66,8 +64,7 @@ std::string IdToString(int id) {
}
void ExpectKeyAndValueWereRecordedForId(
- const std::vector<TestProperty>& properties,
- int id, const char* suffix) {
+ const std::vector<TestProperty>& properties, int id, const char* suffix) {
TestPropertyKeyIs matches_key(IdToKey(id, suffix).c_str());
const std::vector<TestProperty>::const_iterator property =
std::find_if(properties.begin(), properties.end(), matches_key);
@@ -121,15 +118,13 @@ TEST(StressTest, CanUseScopedTraceAndAssertionsInManyThreads) {
std::unique_ptr<ThreadWithParam<int> > threads[kThreadCount];
Notification threads_can_start;
for (int i = 0; i != kThreadCount; i++)
- threads[i].reset(new ThreadWithParam<int>(&ManyAsserts,
- i,
- &threads_can_start));
+ threads[i].reset(
+ new ThreadWithParam<int>(&ManyAsserts, i, &threads_can_start));
threads_can_start.Notify();
// Blocks until all the threads are done.
- for (int i = 0; i != kThreadCount; i++)
- threads[i]->Join();
+ for (int i = 0; i != kThreadCount; i++) threads[i]->Join();
}
// Ensures that kThreadCount*kThreadCount failures have been reported.
@@ -149,7 +144,7 @@ TEST(StressTest, CanUseScopedTraceAndAssertionsInManyThreads) {
ExpectKeyAndValueWereRecordedForId(properties, i, "string");
ExpectKeyAndValueWereRecordedForId(properties, i, "int");
}
- CheckTestFailureCount(kThreadCount*kThreadCount);
+ CheckTestFailureCount(kThreadCount * kThreadCount);
}
void FailingThread(bool is_fatal) {
@@ -196,8 +191,8 @@ TEST(FatalFailureTest, ExpectFatalFailureIgnoresFailuresInOtherThreads) {
TEST(FatalFailureOnAllThreadsTest, ExpectFatalFailureOnAllThreads) {
// This statement should succeed, because failures in all threads are
// considered.
- EXPECT_FATAL_FAILURE_ON_ALL_THREADS(
- GenerateFatalFailureInAnotherThread(true), "expected");
+ EXPECT_FATAL_FAILURE_ON_ALL_THREADS(GenerateFatalFailureInAnotherThread(true),
+ "expected");
CheckTestFailureCount(0);
// We need to add a failure, because main() checks that there are failures.
// But when only this test is run, we shouldn't have any failures.
@@ -226,7 +221,7 @@ TEST(NonFatalFailureOnAllThreadsTest, ExpectNonFatalFailureOnAllThreads) {
} // namespace
} // namespace testing
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
const int result = RUN_ALL_TESTS(); // Expected to fail.
@@ -238,8 +233,7 @@ int main(int argc, char **argv) {
#else
TEST(StressTest,
- DISABLED_ThreadSafetyTestsAreSkippedWhenGoogleTestIsNotThreadSafe) {
-}
+ DISABLED_ThreadSafetyTestsAreSkippedWhenGoogleTestIsNotThreadSafe) {}
int main(int argc, char **argv) {
testing::InitGoogleTest(&argc, argv);