aboutsummaryrefslogtreecommitdiff
path: root/googletest/test/gtest_stress_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'googletest/test/gtest_stress_test.cc')
-rw-r--r--googletest/test/gtest_stress_test.cc31
1 files changed, 14 insertions, 17 deletions
diff --git a/googletest/test/gtest_stress_test.cc b/googletest/test/gtest_stress_test.cc
index 84348191..af8e757d 100644
--- a/googletest/test/gtest_stress_test.cc
+++ b/googletest/test/gtest_stress_test.cc
@@ -27,17 +27,18 @@
// (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 <algorithm>
+#include <memory>
+#include <string>
#include <vector>
+#include "gtest/gtest.h"
#include "src/gtest-internal-inl.h"
-#if GTEST_IS_THREADSAFE
+#ifdef GTEST_IS_THREADSAFE
namespace testing {
namespace {
@@ -66,8 +67,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 +121,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] = std::make_unique<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 +147,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 +194,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 +224,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 +236,7 @@ int main(int argc, char **argv) {
#else
TEST(StressTest,
- DISABLED_ThreadSafetyTestsAreSkippedWhenGoogleTestIsNotThreadSafe) {
-}
+ DISABLED_ThreadSafetyTestsAreSkippedWhenGoogleTestIsNotThreadSafe) {}
int main(int argc, char **argv) {
testing::InitGoogleTest(&argc, argv);