Ensure curly-braces around control-flow
[folly.git] / folly / test / RWSpinLockTest.cpp
index 2369eef09e2370bc5e7522298459de8dc2343872..385f2d2b8212665016ebc4c8e3b22f97d0a61c9a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 // @author xliu (xliux@fb.com)
 //
 
+#include <folly/RWSpinLock.h>
+
 #include <stdlib.h>
-#include <unistd.h>
-#include <vector>
 #include <thread>
+#include <vector>
 
-#include <gtest/gtest.h>
-#include <gflags/gflags.h>
 #include <glog/logging.h>
-#include "folly/RWSpinLock.h"
+
+#include <folly/portability/GFlags.h>
+#include <folly/portability/GTest.h>
+#include <folly/portability/Unistd.h>
 
 DEFINE_int32(num_threads, 8, "num threads");
 
@@ -36,7 +38,7 @@ static const int kMaxReaders = 50;
 static std::atomic<bool> stopThread;
 using namespace folly;
 
-template<typename RWSpinLockT> struct RWSpinLockTest: public testing::Test {
+template <typename RWSpinLockT> struct RWSpinLockTest: public testing::Test {
   typedef RWSpinLockT RWSpinLockType;
 };
 
@@ -51,7 +53,7 @@ typedef testing::Types<RWSpinLock
 
 TYPED_TEST_CASE(RWSpinLockTest, Implementations);
 
-template<typename RWSpinLockType>
+template <typename RWSpinLockType>
 static void run(RWSpinLockType* lock) {
   int64_t reads = 0;
   int64_t writes = 0;
@@ -226,7 +228,9 @@ TEST(RWSpinLock, concurrent_holder_test) {
   sleep(5);
   stop.store(true, std::memory_order_release);
 
-  for (auto& t : threads) t.join();
+  for (auto& t : threads) {
+    t.join();
+  }
 
   LOG(INFO) << "reads: " << reads.load(std::memory_order_acquire)
     << "; writes: " << writes.load(std::memory_order_acquire)
@@ -234,9 +238,3 @@ TEST(RWSpinLock, concurrent_holder_test) {
 }
 
 }
-
-int main(int argc, char** argv) {
-  testing::InitGoogleTest(&argc, argv);
-  google::ParseCommandLineFlags(&argc, &argv, true);
-  return RUN_ALL_TESTS();
-}