You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by hc...@apache.org on 2014/11/18 10:02:31 UTC

[03/37] thrift git commit: THRIFT-2729: C++ - .clang-format created and applied

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/TransportTest.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/TransportTest.cpp b/lib/cpp/test/TransportTest.cpp
old mode 100755
new mode 100644
index c1cb976..0305732
--- a/lib/cpp/test/TransportTest.cpp
+++ b/lib/cpp/test/TransportTest.cpp
@@ -36,10 +36,9 @@
 
 #include <thrift/concurrency/FunctionRunner.h>
 #if _WIN32
-  #include <thrift/windows/TWinsockSingleton.h>
+#include <thrift/windows/TWinsockSingleton.h>
 #endif
 
-
 using namespace apache::thrift::transport;
 
 static boost::mt19937 rng;
@@ -49,14 +48,14 @@ void initrand(unsigned int seed) {
 }
 
 class SizeGenerator {
- public:
+public:
   virtual ~SizeGenerator() {}
   virtual uint32_t nextSize() = 0;
   virtual std::string describe() const = 0;
 };
 
 class ConstantSizeGenerator : public SizeGenerator {
- public:
+public:
   ConstantSizeGenerator(uint32_t value) : value_(value) {}
   uint32_t nextSize() { return value_; }
   std::string describe() const {
@@ -65,14 +64,14 @@ class ConstantSizeGenerator : public SizeGenerator {
     return desc.str();
   }
 
- private:
+private:
   uint32_t value_;
 };
 
 class RandomSizeGenerator : public SizeGenerator {
- public:
-  RandomSizeGenerator(uint32_t min, uint32_t max) :
-    generator_(rng, boost::uniform_int<int>(min, max)) {}
+public:
+  RandomSizeGenerator(uint32_t min, uint32_t max)
+    : generator_(rng, boost::uniform_int<int>(min, max)) {}
 
   uint32_t nextSize() { return generator_(); }
 
@@ -85,9 +84,8 @@ class RandomSizeGenerator : public SizeGenerator {
   uint32_t getMin() const { return (generator_.distribution().min)(); }
   uint32_t getMax() const { return (generator_.distribution().max)(); }
 
- private:
-  boost::variate_generator< boost::mt19937&, boost::uniform_int<int> >
-    generator_;
+private:
+  boost::variate_generator<boost::mt19937&, boost::uniform_int<int> > generator_;
 };
 
 /**
@@ -98,16 +96,15 @@ class RandomSizeGenerator : public SizeGenerator {
  *   to make a copy of the generator to bind it to the test function.)
  */
 class GenericSizeGenerator : public SizeGenerator {
- public:
-  GenericSizeGenerator(uint32_t value) :
-    generator_(new ConstantSizeGenerator(value)) {}
-  GenericSizeGenerator(uint32_t min, uint32_t max) :
-    generator_(new RandomSizeGenerator(min, max)) {}
+public:
+  GenericSizeGenerator(uint32_t value) : generator_(new ConstantSizeGenerator(value)) {}
+  GenericSizeGenerator(uint32_t min, uint32_t max)
+    : generator_(new RandomSizeGenerator(min, max)) {}
 
   uint32_t nextSize() { return generator_->nextSize(); }
   std::string describe() const { return generator_->describe(); }
 
- private:
+private:
   boost::shared_ptr<SizeGenerator> generator_;
 };
 
@@ -125,7 +122,7 @@ class GenericSizeGenerator : public SizeGenerator {
  */
 template <class Transport_>
 class CoupledTransports {
- public:
+public:
   virtual ~CoupledTransports() {}
   typedef Transport_ TransportType;
 
@@ -134,18 +131,17 @@ class CoupledTransports {
   boost::shared_ptr<Transport_> in;
   boost::shared_ptr<Transport_> out;
 
- private:
+private:
   CoupledTransports(const CoupledTransports&);
-  CoupledTransports &operator=(const CoupledTransports&);
+  CoupledTransports& operator=(const CoupledTransports&);
 };
 
 /**
  * Coupled TMemoryBuffers
  */
 class CoupledMemoryBuffers : public CoupledTransports<TMemoryBuffer> {
- public:
-  CoupledMemoryBuffers() :
-    buf(new TMemoryBuffer) {
+public:
+  CoupledMemoryBuffers() : buf(new TMemoryBuffer) {
     in = buf;
     out = buf;
   }
@@ -159,7 +155,7 @@ class CoupledMemoryBuffers : public CoupledTransports<TMemoryBuffer> {
  */
 template <class WrapperTransport_, class InnerCoupledTransports_>
 class CoupledWrapperTransportsT : public CoupledTransports<WrapperTransport_> {
- public:
+public:
   CoupledWrapperTransportsT() {
     if (inner_.in) {
       this->in.reset(new WrapperTransport_(inner_.in));
@@ -176,34 +172,27 @@ class CoupledWrapperTransportsT : public CoupledTransports<WrapperTransport_> {
  * Coupled TBufferedTransports.
  */
 template <class InnerTransport_>
-class CoupledBufferedTransportsT :
-  public CoupledWrapperTransportsT<TBufferedTransport, InnerTransport_> {
-};
+class CoupledBufferedTransportsT
+    : public CoupledWrapperTransportsT<TBufferedTransport, InnerTransport_> {};
 
-typedef CoupledBufferedTransportsT<CoupledMemoryBuffers>
-  CoupledBufferedTransports;
+typedef CoupledBufferedTransportsT<CoupledMemoryBuffers> CoupledBufferedTransports;
 
 /**
  * Coupled TFramedTransports.
  */
 template <class InnerTransport_>
-class CoupledFramedTransportsT :
-  public CoupledWrapperTransportsT<TFramedTransport, InnerTransport_> {
-};
+class CoupledFramedTransportsT
+    : public CoupledWrapperTransportsT<TFramedTransport, InnerTransport_> {};
 
-typedef CoupledFramedTransportsT<CoupledMemoryBuffers>
-  CoupledFramedTransports;
+typedef CoupledFramedTransportsT<CoupledMemoryBuffers> CoupledFramedTransports;
 
 /**
  * Coupled TZlibTransports.
  */
 template <class InnerTransport_>
-class CoupledZlibTransportsT :
-  public CoupledWrapperTransportsT<TZlibTransport, InnerTransport_> {
-};
+class CoupledZlibTransportsT : public CoupledWrapperTransportsT<TZlibTransport, InnerTransport_> {};
 
-typedef CoupledZlibTransportsT<CoupledMemoryBuffers>
-  CoupledZlibTransports;
+typedef CoupledZlibTransportsT<CoupledMemoryBuffers> CoupledZlibTransports;
 
 #ifndef _WIN32
 // FD transport doesn't make much sense on Windows.
@@ -211,7 +200,7 @@ typedef CoupledZlibTransportsT<CoupledMemoryBuffers>
  * Coupled TFDTransports.
  */
 class CoupledFDTransports : public CoupledTransports<TFDTransport> {
- public:
+public:
   CoupledFDTransports() {
     int pipes[2];
 
@@ -229,7 +218,7 @@ class CoupledFDTransports : public CoupledTransports<TFDTransport> {
  * Coupled TSockets
  */
 class CoupledSocketTransports : public CoupledTransports<TSocket> {
- public:
+public:
   CoupledSocketTransports() {
     THRIFT_SOCKET sockets[2] = {0};
     if (THRIFT_SOCKETPAIR(PF_UNIX, SOCK_STREAM, 0, sockets) != 0) {
@@ -242,39 +231,34 @@ class CoupledSocketTransports : public CoupledTransports<TSocket> {
   }
 };
 
-//These could be made to work on Windows, but I don't care enough to make it happen
+// These could be made to work on Windows, but I don't care enough to make it happen
 #ifndef _WIN32
 /**
  * Coupled TFileTransports
  */
 class CoupledFileTransports : public CoupledTransports<TFileTransport> {
- public:
+public:
   CoupledFileTransports() {
 #ifndef _WIN32
     const char* tmp_dir = "/tmp";
-    #define FILENAME_SUFFIX "/thrift.transport_test"
+#define FILENAME_SUFFIX "/thrift.transport_test"
 #else
     const char* tmp_dir = getenv("TMP");
-    #define FILENAME_SUFFIX "\\thrift.transport_test"
+#define FILENAME_SUFFIX "\\thrift.transport_test"
 #endif
 
     // Create a temporary file to use
     filename.resize(strlen(tmp_dir) + strlen(FILENAME_SUFFIX));
-    THRIFT_SNPRINTF(&filename[0], filename.size(),
-             "%s" FILENAME_SUFFIX, tmp_dir);
-    #undef FILENAME_SUFFIX
+    THRIFT_SNPRINTF(&filename[0], filename.size(), "%s" FILENAME_SUFFIX, tmp_dir);
+#undef FILENAME_SUFFIX
 
-    {
-      std::ofstream dummy_creation(filename.c_str(), std::ofstream::trunc);
-    }
+    { std::ofstream dummy_creation(filename.c_str(), std::ofstream::trunc); }
 
     in.reset(new TFileTransport(filename, true));
     out.reset(new TFileTransport(filename));
   }
 
-  ~CoupledFileTransports() {
-    remove(filename.c_str());
-  }
+  ~CoupledFileTransports() { remove(filename.c_str()); }
 
   std::string filename;
 };
@@ -290,7 +274,7 @@ class CoupledFileTransports : public CoupledTransports<TFileTransport> {
  */
 template <class CoupledTransports_>
 class CoupledTTransports : public CoupledTransports<TTransport> {
- public:
+public:
   CoupledTTransports() : transports() {
     in = transports.in;
     out = transports.out;
@@ -308,7 +292,7 @@ class CoupledTTransports : public CoupledTransports<TTransport> {
  */
 template <class CoupledTransports_>
 class CoupledBufferBases : public CoupledTransports<TBufferBase> {
- public:
+public:
   CoupledBufferBases() : transports() {
     in = transports.in;
     out = transports.out;
@@ -332,12 +316,8 @@ class CoupledBufferBases : public CoupledTransports<TBufferBase> {
  **************************************************************************/
 
 struct TriggerInfo {
-  TriggerInfo(int seconds, const boost::shared_ptr<TTransport>& transport,
-              uint32_t writeLength) :
-    timeoutSeconds(seconds),
-    transport(transport),
-    writeLength(writeLength),
-    next(NULL) {}
+  TriggerInfo(int seconds, const boost::shared_ptr<TTransport>& transport, uint32_t writeLength)
+    : timeoutSeconds(seconds), transport(transport), writeLength(writeLength), next(NULL) {}
 
   int timeoutSeconds;
   boost::shared_ptr<TTransport> transport;
@@ -351,7 +331,7 @@ unsigned int g_numTriggersFired;
 bool g_teardown = false;
 
 void alarm_handler() {
-  TriggerInfo *info = NULL;
+  TriggerInfo* info = NULL;
   {
     apache::thrift::concurrency::Synchronized s(g_alarm_monitor);
     // The alarm timed out, which almost certainly means we're stuck
@@ -383,26 +363,26 @@ void alarm_handler() {
 }
 
 void alarm_handler_wrapper() {
-  int64_t timeout = 0;  //timeout of 0 means wait forever
-  while(true) {
+  int64_t timeout = 0; // timeout of 0 means wait forever
+  while (true) {
     bool fireHandler = false;
     {
       apache::thrift::concurrency::Synchronized s(g_alarm_monitor);
-      if(g_teardown)
-         return;
-      //calculate timeout
+      if (g_teardown)
+        return;
+      // calculate timeout
       if (g_triggerInfo == NULL) {
         timeout = 0;
       } else {
-         timeout = g_triggerInfo->timeoutSeconds * 1000;
+        timeout = g_triggerInfo->timeoutSeconds * 1000;
       }
 
       int waitResult = g_alarm_monitor.waitForTimeRelative(timeout);
-      if(waitResult == THRIFT_ETIMEDOUT)
+      if (waitResult == THRIFT_ETIMEDOUT)
         fireHandler = true;
     }
-    if(fireHandler)
-      alarm_handler(); //calling outside the lock
+    if (fireHandler)
+      alarm_handler(); // calling outside the lock
   }
 }
 
@@ -415,7 +395,7 @@ void alarm_handler_wrapper() {
  * to the end.)
  */
 void add_trigger(unsigned int seconds,
-                 const boost::shared_ptr<TTransport> &transport,
+                 const boost::shared_ptr<TTransport>& transport,
                  uint32_t write_len) {
   TriggerInfo* info = new TriggerInfo(seconds, transport, write_len);
   {
@@ -437,7 +417,7 @@ void add_trigger(unsigned int seconds,
 }
 
 void clear_triggers() {
-  TriggerInfo *info = NULL;
+  TriggerInfo* info = NULL;
 
   {
     apache::thrift::concurrency::Synchronized s(g_alarm_monitor);
@@ -455,7 +435,7 @@ void clear_triggers() {
 }
 
 void set_trigger(unsigned int seconds,
-                 const boost::shared_ptr<TTransport> &transport,
+                 const boost::shared_ptr<TTransport>& transport,
                  uint32_t write_len) {
   clear_triggers();
   add_trigger(seconds, transport, write_len);
@@ -499,10 +479,8 @@ void test_rw(uint32_t totalSize,
   BOOST_REQUIRE(transports.in != NULL);
   BOOST_REQUIRE(transports.out != NULL);
 
-  boost::shared_array<uint8_t> wbuf =
-    boost::shared_array<uint8_t>(new uint8_t[totalSize]);
-  boost::shared_array<uint8_t> rbuf =
-    boost::shared_array<uint8_t>(new uint8_t[totalSize]);
+  boost::shared_array<uint8_t> wbuf = boost::shared_array<uint8_t>(new uint8_t[totalSize]);
+  boost::shared_array<uint8_t> rbuf = boost::shared_array<uint8_t>(new uint8_t[totalSize]);
 
   // store some data in wbuf
   for (uint32_t n = 0; n < totalSize; ++n) {
@@ -522,8 +500,7 @@ void test_rw(uint32_t totalSize,
 
     // Make sure (total_written - total_read) + wchunk_size
     // is less than maxOutstanding
-    if (maxOutstanding > 0 &&
-        wchunk_size > maxOutstanding - (total_written - total_read)) {
+    if (maxOutstanding > 0 && wchunk_size > maxOutstanding - (total_written - total_read)) {
       wchunk_size = maxOutstanding - (total_written - total_read);
     }
 
@@ -537,8 +514,7 @@ void test_rw(uint32_t totalSize,
 
       try {
         transports.out->write(wbuf.get() + total_written, write_size);
-      }
-      catch (TTransportException & te) {
+      } catch (TTransportException& te) {
         if (te.getType() == TTransportException::TIMED_OUT)
           break;
         throw te;
@@ -572,17 +548,15 @@ void test_rw(uint32_t totalSize,
       try {
         bytes_read = transports.in->read(rbuf.get() + total_read, read_size);
       } catch (TTransportException& e) {
-        BOOST_FAIL("read(pos=" << total_read << ", size=" << read_size <<
-                   ") threw exception \"" << e.what() <<
-                   "\"; written so far: " << total_written << " / " <<
-                   totalSize << " bytes");
+        BOOST_FAIL("read(pos=" << total_read << ", size=" << read_size << ") threw exception \""
+                               << e.what() << "\"; written so far: " << total_written << " / "
+                               << totalSize << " bytes");
       }
 
       BOOST_REQUIRE_MESSAGE(bytes_read > 0,
-                            "read(pos=" << total_read << ", size=" <<
-                            read_size << ") returned " << bytes_read <<
-                            "; written so far: " << total_written << " / " <<
-                            totalSize << " bytes");
+                            "read(pos=" << total_read << ", size=" << read_size << ") returned "
+                                        << bytes_read << "; written so far: " << total_written
+                                        << " / " << totalSize << " bytes");
       chunk_read += bytes_read;
       total_read += bytes_read;
     }
@@ -592,7 +566,6 @@ void test_rw(uint32_t totalSize,
   BOOST_CHECK_EQUAL(memcmp(rbuf.get(), wbuf.get(), totalSize), 0);
 }
 
-
 template <class CoupledTransports>
 void test_read_part_available() {
   CoupledTransports transports;
@@ -609,8 +582,8 @@ void test_read_part_available() {
   transports.out->flush();
   set_trigger(3, transports.out, 1);
   uint32_t bytes_read = transports.in->read(read_buf, 10);
-  BOOST_CHECK_EQUAL(g_numTriggersFired, (unsigned int) 0);
-  BOOST_CHECK_EQUAL(bytes_read, (uint32_t) 9);
+  BOOST_CHECK_EQUAL(g_numTriggersFired, (unsigned int)0);
+  BOOST_CHECK_EQUAL(bytes_read, (uint32_t)9);
 
   clear_triggers();
 }
@@ -676,7 +649,7 @@ void test_read_partial_midframe() {
 
   // Now read 4 bytes, so that we are partway through the written data.
   uint32_t bytes_read = transports.in->read(read_buf, 4);
-  BOOST_CHECK_EQUAL(bytes_read, (uint32_t) 4);
+  BOOST_CHECK_EQUAL(bytes_read, (uint32_t)4);
 
   // Now attempt to read 10 bytes.  Only 9 more are available.
   //
@@ -689,13 +662,13 @@ void test_read_partial_midframe() {
   while (total_read < 9) {
     set_trigger(3, transports.out, 1);
     bytes_read = transports.in->read(read_buf, 10);
-    BOOST_REQUIRE_EQUAL(g_numTriggersFired, (unsigned int) 0);
-    BOOST_REQUIRE_GT(bytes_read, (uint32_t) 0);
+    BOOST_REQUIRE_EQUAL(g_numTriggersFired, (unsigned int)0);
+    BOOST_REQUIRE_GT(bytes_read, (uint32_t)0);
     total_read += bytes_read;
-    BOOST_REQUIRE_LE(total_read, (uint32_t) 9);
+    BOOST_REQUIRE_LE(total_read, (uint32_t)9);
   }
 
-  BOOST_CHECK_EQUAL(total_read, (uint32_t) 9);
+  BOOST_CHECK_EQUAL(total_read, (uint32_t)9);
 
   clear_triggers();
 }
@@ -717,7 +690,7 @@ void test_borrow_part_available() {
   set_trigger(3, transports.out, 1);
   uint32_t borrow_len = 10;
   const uint8_t* borrowed_buf = transports.in->borrow(read_buf, &borrow_len);
-  BOOST_CHECK_EQUAL(g_numTriggersFired, (unsigned int) 0);
+  BOOST_CHECK_EQUAL(g_numTriggersFired, (unsigned int)0);
   BOOST_CHECK(borrowed_buf == NULL);
 
   clear_triggers();
@@ -743,11 +716,11 @@ void test_read_none_available() {
   add_trigger(1, transports.out, 8);
   uint32_t bytes_read = transports.in->read(read_buf, 10);
   if (bytes_read == 0) {
-    BOOST_CHECK_EQUAL(g_numTriggersFired, (unsigned int) 0);
+    BOOST_CHECK_EQUAL(g_numTriggersFired, (unsigned int)0);
     clear_triggers();
   } else {
-    BOOST_CHECK_EQUAL(g_numTriggersFired, (unsigned int) 1);
-    BOOST_CHECK_EQUAL(bytes_read, (uint32_t) 2);
+    BOOST_CHECK_EQUAL(g_numTriggersFired, (unsigned int)1);
+    BOOST_CHECK_EQUAL(bytes_read, (uint32_t)2);
   }
 
   clear_triggers();
@@ -767,7 +740,7 @@ void test_borrow_none_available() {
   uint32_t borrow_len = 10;
   const uint8_t* borrowed_buf = transports.in->borrow(NULL, &borrow_len);
   BOOST_CHECK(borrowed_buf == NULL);
-  BOOST_CHECK_EQUAL(g_numTriggersFired, (unsigned int) 0);
+  BOOST_CHECK_EQUAL(g_numTriggersFired, (unsigned int)0);
 
   clear_triggers();
 }
@@ -788,47 +761,40 @@ void test_borrow_none_available() {
  *   is compiler-dependent.  gcc returns mangled names.)
  **************************************************************************/
 
-#define ADD_TEST_RW(CoupledTransports, totalSize, ...) \
-    addTestRW< CoupledTransports >(BOOST_STRINGIZE(CoupledTransports), \
-                                   totalSize, ## __VA_ARGS__);
-
-#define TEST_RW(CoupledTransports, totalSize, ...) \
-  do { \
-    /* Add the test as specified, to test the non-virtual function calls */ \
-    ADD_TEST_RW(CoupledTransports, totalSize, ## __VA_ARGS__); \
-    /* \
-     * Also test using the transport as a TTransport*, to test \
-     * the read_virt()/write_virt() calls \
-     */ \
-    ADD_TEST_RW(CoupledTTransports<CoupledTransports>, \
-                totalSize, ## __VA_ARGS__); \
-    /* Test wrapping the transport with TBufferedTransport */ \
-    ADD_TEST_RW(CoupledBufferedTransportsT<CoupledTransports>, \
-                totalSize, ## __VA_ARGS__); \
-    /* Test wrapping the transport with TFramedTransports */ \
-    ADD_TEST_RW(CoupledFramedTransportsT<CoupledTransports>, \
-                totalSize, ## __VA_ARGS__); \
-    /* Test wrapping the transport with TZlibTransport */ \
-    ADD_TEST_RW(CoupledZlibTransportsT<CoupledTransports>, \
-                totalSize, ## __VA_ARGS__); \
+#define ADD_TEST_RW(CoupledTransports, totalSize, ...)                                             \
+  addTestRW<CoupledTransports>(BOOST_STRINGIZE(CoupledTransports), totalSize, ##__VA_ARGS__);
+
+#define TEST_RW(CoupledTransports, totalSize, ...)                                                 \
+  do {                                                                                             \
+    /* Add the test as specified, to test the non-virtual function calls */                        \
+    ADD_TEST_RW(CoupledTransports, totalSize, ##__VA_ARGS__);                                      \
+    /*                                                                                             \
+     * Also test using the transport as a TTransport*, to test                                     \
+     * the read_virt()/write_virt() calls                                                          \
+     */                                                                                            \
+    ADD_TEST_RW(CoupledTTransports<CoupledTransports>, totalSize, ##__VA_ARGS__);                  \
+    /* Test wrapping the transport with TBufferedTransport */                                      \
+    ADD_TEST_RW(CoupledBufferedTransportsT<CoupledTransports>, totalSize, ##__VA_ARGS__);          \
+    /* Test wrapping the transport with TFramedTransports */                                       \
+    ADD_TEST_RW(CoupledFramedTransportsT<CoupledTransports>, totalSize, ##__VA_ARGS__);            \
+    /* Test wrapping the transport with TZlibTransport */                                          \
+    ADD_TEST_RW(CoupledZlibTransportsT<CoupledTransports>, totalSize, ##__VA_ARGS__);              \
   } while (0)
 
-#define ADD_TEST_BLOCKING(CoupledTransports) \
-    addTestBlocking< CoupledTransports >(BOOST_STRINGIZE(CoupledTransports));
+#define ADD_TEST_BLOCKING(CoupledTransports)                                                       \
+  addTestBlocking<CoupledTransports>(BOOST_STRINGIZE(CoupledTransports));
 
-#define TEST_BLOCKING_BEHAVIOR(CoupledTransports) \
-  ADD_TEST_BLOCKING(CoupledTransports); \
-  ADD_TEST_BLOCKING(CoupledTTransports<CoupledTransports>); \
-  ADD_TEST_BLOCKING(CoupledBufferedTransportsT<CoupledTransports>); \
-  ADD_TEST_BLOCKING(CoupledFramedTransportsT<CoupledTransports>); \
+#define TEST_BLOCKING_BEHAVIOR(CoupledTransports)                                                  \
+  ADD_TEST_BLOCKING(CoupledTransports);                                                            \
+  ADD_TEST_BLOCKING(CoupledTTransports<CoupledTransports>);                                        \
+  ADD_TEST_BLOCKING(CoupledBufferedTransportsT<CoupledTransports>);                                \
+  ADD_TEST_BLOCKING(CoupledFramedTransportsT<CoupledTransports>);                                  \
   ADD_TEST_BLOCKING(CoupledZlibTransportsT<CoupledTransports>);
 
 class TransportTestGen {
- public:
-  TransportTestGen(boost::unit_test::test_suite* suite,
-                   float sizeMultiplier) :
-      suite_(suite),
-      sizeMultiplier_(sizeMultiplier) {}
+public:
+  TransportTestGen(boost::unit_test::test_suite* suite, float sizeMultiplier)
+    : suite_(suite), sizeMultiplier_(sizeMultiplier) {}
 
   void generate() {
     GenericSizeGenerator rand4k(1, 4096);
@@ -839,15 +805,15 @@ class TransportTestGen {
      */
 
     // TMemoryBuffer tests
-    TEST_RW(CoupledMemoryBuffers, 1024*1024, 0, 0);
-    TEST_RW(CoupledMemoryBuffers, 1024*256, rand4k, rand4k);
-    TEST_RW(CoupledMemoryBuffers, 1024*256, 167, 163);
-    TEST_RW(CoupledMemoryBuffers, 1024*16, 1, 1);
+    TEST_RW(CoupledMemoryBuffers, 1024 * 1024, 0, 0);
+    TEST_RW(CoupledMemoryBuffers, 1024 * 256, rand4k, rand4k);
+    TEST_RW(CoupledMemoryBuffers, 1024 * 256, 167, 163);
+    TEST_RW(CoupledMemoryBuffers, 1024 * 16, 1, 1);
 
-    TEST_RW(CoupledMemoryBuffers, 1024*256, 0, 0, rand4k, rand4k);
-    TEST_RW(CoupledMemoryBuffers, 1024*256, rand4k, rand4k, rand4k, rand4k);
-    TEST_RW(CoupledMemoryBuffers, 1024*256, 167, 163, rand4k, rand4k);
-    TEST_RW(CoupledMemoryBuffers, 1024*16, 1, 1, rand4k, rand4k);
+    TEST_RW(CoupledMemoryBuffers, 1024 * 256, 0, 0, rand4k, rand4k);
+    TEST_RW(CoupledMemoryBuffers, 1024 * 256, rand4k, rand4k, rand4k, rand4k);
+    TEST_RW(CoupledMemoryBuffers, 1024 * 256, 167, 163, rand4k, rand4k);
+    TEST_RW(CoupledMemoryBuffers, 1024 * 16, 1, 1, rand4k, rand4k);
 
     TEST_BLOCKING_BEHAVIOR(CoupledMemoryBuffers);
 
@@ -856,68 +822,57 @@ class TransportTestGen {
     // Since CoupledFDTransports tests with a pipe, writes will block
     // if there is too much outstanding unread data in the pipe.
     uint32_t fd_max_outstanding = 4096;
-    TEST_RW(CoupledFDTransports, 1024*1024, 0, 0,
-            0, 0, fd_max_outstanding);
-    TEST_RW(CoupledFDTransports, 1024*256, rand4k, rand4k,
-            0, 0, fd_max_outstanding);
-    TEST_RW(CoupledFDTransports, 1024*256, 167, 163,
-            0, 0, fd_max_outstanding);
-    TEST_RW(CoupledFDTransports, 1024*16, 1, 1,
-            0, 0, fd_max_outstanding);
-
-    TEST_RW(CoupledFDTransports, 1024*256, 0, 0,
-            rand4k, rand4k, fd_max_outstanding);
-    TEST_RW(CoupledFDTransports, 1024*256, rand4k, rand4k,
-            rand4k, rand4k, fd_max_outstanding);
-    TEST_RW(CoupledFDTransports, 1024*256, 167, 163,
-            rand4k, rand4k, fd_max_outstanding);
-    TEST_RW(CoupledFDTransports, 1024*16, 1, 1,
-            rand4k, rand4k, fd_max_outstanding);
+    TEST_RW(CoupledFDTransports, 1024 * 1024, 0, 0, 0, 0, fd_max_outstanding);
+    TEST_RW(CoupledFDTransports, 1024 * 256, rand4k, rand4k, 0, 0, fd_max_outstanding);
+    TEST_RW(CoupledFDTransports, 1024 * 256, 167, 163, 0, 0, fd_max_outstanding);
+    TEST_RW(CoupledFDTransports, 1024 * 16, 1, 1, 0, 0, fd_max_outstanding);
+
+    TEST_RW(CoupledFDTransports, 1024 * 256, 0, 0, rand4k, rand4k, fd_max_outstanding);
+    TEST_RW(CoupledFDTransports, 1024 * 256, rand4k, rand4k, rand4k, rand4k, fd_max_outstanding);
+    TEST_RW(CoupledFDTransports, 1024 * 256, 167, 163, rand4k, rand4k, fd_max_outstanding);
+    TEST_RW(CoupledFDTransports, 1024 * 16, 1, 1, rand4k, rand4k, fd_max_outstanding);
 
     TEST_BLOCKING_BEHAVIOR(CoupledFDTransports);
 #endif //_WIN32
 
     // TSocket tests
     uint32_t socket_max_outstanding = 4096;
-    TEST_RW(CoupledSocketTransports, 1024*1024, 0, 0,
-            0, 0, socket_max_outstanding);
-    TEST_RW(CoupledSocketTransports, 1024*256, rand4k, rand4k,
-            0, 0, socket_max_outstanding);
-    TEST_RW(CoupledSocketTransports, 1024*256, 167, 163,
-            0, 0, socket_max_outstanding);
+    TEST_RW(CoupledSocketTransports, 1024 * 1024, 0, 0, 0, 0, socket_max_outstanding);
+    TEST_RW(CoupledSocketTransports, 1024 * 256, rand4k, rand4k, 0, 0, socket_max_outstanding);
+    TEST_RW(CoupledSocketTransports, 1024 * 256, 167, 163, 0, 0, socket_max_outstanding);
     // Doh.  Apparently writing to a socket has some additional overhead for
     // each send() call.  If we have more than ~400 outstanding 1-byte write
     // requests, additional send() calls start blocking.
-    TEST_RW(CoupledSocketTransports, 1024*16, 1, 1,
-            0, 0, socket_max_outstanding);
-    TEST_RW(CoupledSocketTransports, 1024*256, 0, 0,
-            rand4k, rand4k, socket_max_outstanding);
-    TEST_RW(CoupledSocketTransports, 1024*256, rand4k, rand4k,
-            rand4k, rand4k, socket_max_outstanding);
-    TEST_RW(CoupledSocketTransports, 1024*256, 167, 163,
-            rand4k, rand4k, socket_max_outstanding);
-    TEST_RW(CoupledSocketTransports, 1024*16, 1, 1,
-            rand4k, rand4k, socket_max_outstanding);
+    TEST_RW(CoupledSocketTransports, 1024 * 16, 1, 1, 0, 0, socket_max_outstanding);
+    TEST_RW(CoupledSocketTransports, 1024 * 256, 0, 0, rand4k, rand4k, socket_max_outstanding);
+    TEST_RW(CoupledSocketTransports,
+            1024 * 256,
+            rand4k,
+            rand4k,
+            rand4k,
+            rand4k,
+            socket_max_outstanding);
+    TEST_RW(CoupledSocketTransports, 1024 * 256, 167, 163, rand4k, rand4k, socket_max_outstanding);
+    TEST_RW(CoupledSocketTransports, 1024 * 16, 1, 1, rand4k, rand4k, socket_max_outstanding);
 
     TEST_BLOCKING_BEHAVIOR(CoupledSocketTransports);
 
-//These could be made to work on Windows, but I don't care enough to make it happen
+// These could be made to work on Windows, but I don't care enough to make it happen
 #ifndef _WIN32
     // TFileTransport tests
     // We use smaller buffer sizes here, since TFileTransport is fairly slow.
     //
     // TFileTransport can't write more than 16MB at once
-    uint32_t max_write_at_once = 1024*1024*16 - 4;
-    TEST_RW(CoupledFileTransports, 1024*1024, max_write_at_once, 0);
-    TEST_RW(CoupledFileTransports, 1024*128, rand4k, rand4k);
-    TEST_RW(CoupledFileTransports, 1024*128, 167, 163);
-    TEST_RW(CoupledFileTransports, 1024*2, 1, 1);
-
-    TEST_RW(CoupledFileTransports, 1024*64, 0, 0, rand4k, rand4k);
-    TEST_RW(CoupledFileTransports, 1024*64,
-            rand4k, rand4k, rand4k, rand4k);
-    TEST_RW(CoupledFileTransports, 1024*64, 167, 163, rand4k, rand4k);
-    TEST_RW(CoupledFileTransports, 1024*2, 1, 1, rand4k, rand4k);
+    uint32_t max_write_at_once = 1024 * 1024 * 16 - 4;
+    TEST_RW(CoupledFileTransports, 1024 * 1024, max_write_at_once, 0);
+    TEST_RW(CoupledFileTransports, 1024 * 128, rand4k, rand4k);
+    TEST_RW(CoupledFileTransports, 1024 * 128, 167, 163);
+    TEST_RW(CoupledFileTransports, 1024 * 2, 1, 1);
+
+    TEST_RW(CoupledFileTransports, 1024 * 64, 0, 0, rand4k, rand4k);
+    TEST_RW(CoupledFileTransports, 1024 * 64, rand4k, rand4k, rand4k, rand4k);
+    TEST_RW(CoupledFileTransports, 1024 * 64, 167, 163, rand4k, rand4k);
+    TEST_RW(CoupledFileTransports, 1024 * 2, 1, 1, rand4k, rand4k);
 
     TEST_BLOCKING_BEHAVIOR(CoupledFileTransports);
 #endif
@@ -925,23 +880,45 @@ class TransportTestGen {
     // Add some tests that access TBufferedTransport and TFramedTransport
     // via TTransport pointers and TBufferBase pointers.
     ADD_TEST_RW(CoupledTTransports<CoupledBufferedTransports>,
-                1024*1024, rand4k, rand4k, rand4k, rand4k);
+                1024 * 1024,
+                rand4k,
+                rand4k,
+                rand4k,
+                rand4k);
     ADD_TEST_RW(CoupledBufferBases<CoupledBufferedTransports>,
-                1024*1024, rand4k, rand4k, rand4k, rand4k);
+                1024 * 1024,
+                rand4k,
+                rand4k,
+                rand4k,
+                rand4k);
     ADD_TEST_RW(CoupledTTransports<CoupledFramedTransports>,
-                1024*1024, rand4k, rand4k, rand4k, rand4k);
+                1024 * 1024,
+                rand4k,
+                rand4k,
+                rand4k,
+                rand4k);
     ADD_TEST_RW(CoupledBufferBases<CoupledFramedTransports>,
-                1024*1024, rand4k, rand4k, rand4k, rand4k);
+                1024 * 1024,
+                rand4k,
+                rand4k,
+                rand4k,
+                rand4k);
 
     // Test using TZlibTransport via a TTransport pointer
     ADD_TEST_RW(CoupledTTransports<CoupledZlibTransports>,
-                1024*1024, rand4k, rand4k, rand4k, rand4k);
+                1024 * 1024,
+                rand4k,
+                rand4k,
+                rand4k,
+                rand4k);
   }
 
- private:
+private:
   template <class CoupledTransports>
-  void addTestRW(const char* transport_name, uint32_t totalSize,
-                 GenericSizeGenerator wSizeGen, GenericSizeGenerator rSizeGen,
+  void addTestRW(const char* transport_name,
+                 uint32_t totalSize,
+                 GenericSizeGenerator wSizeGen,
+                 GenericSizeGenerator rSizeGen,
                  GenericSizeGenerator wChunkSizeGen = 0,
                  GenericSizeGenerator rChunkSizeGen = 0,
                  uint32_t maxOutstanding = 0,
@@ -950,60 +927,50 @@ class TransportTestGen {
     totalSize = static_cast<uint32_t>(totalSize * sizeMultiplier_);
 
     std::ostringstream name;
-    name << transport_name << "::test_rw(" << totalSize << ", " <<
-      wSizeGen.describe() << ", " << rSizeGen.describe() << ", " <<
-      wChunkSizeGen.describe() << ", " << rChunkSizeGen.describe() << ", " <<
-      maxOutstanding << ")";
-
-    boost::unit_test::callback0<> test_func =
-      apache::thrift::stdcxx::bind(test_rw<CoupledTransports>, totalSize,
-                     wSizeGen, rSizeGen, wChunkSizeGen, rChunkSizeGen,
-                     maxOutstanding);
-    boost::unit_test::test_case* tc =
-      boost::unit_test::make_test_case(test_func, name.str());
+    name << transport_name << "::test_rw(" << totalSize << ", " << wSizeGen.describe() << ", "
+         << rSizeGen.describe() << ", " << wChunkSizeGen.describe() << ", "
+         << rChunkSizeGen.describe() << ", " << maxOutstanding << ")";
+
+    boost::unit_test::callback0<> test_func
+        = apache::thrift::stdcxx::bind(test_rw<CoupledTransports>,
+                                       totalSize,
+                                       wSizeGen,
+                                       rSizeGen,
+                                       wChunkSizeGen,
+                                       rChunkSizeGen,
+                                       maxOutstanding);
+    boost::unit_test::test_case* tc = boost::unit_test::make_test_case(test_func, name.str());
     suite_->add(tc, expectedFailures);
   }
 
   template <class CoupledTransports>
-  void addTestBlocking(const char* transportName,
-                       uint32_t expectedFailures = 0) {
+  void addTestBlocking(const char* transportName, uint32_t expectedFailures = 0) {
     char name[1024];
     boost::unit_test::test_case* tc;
 
-    THRIFT_SNPRINTF(name, sizeof(name), "%s::test_read_part_available()",
-             transportName);
-    tc = boost::unit_test::make_test_case(
-          test_read_part_available<CoupledTransports>, name);
+    THRIFT_SNPRINTF(name, sizeof(name), "%s::test_read_part_available()", transportName);
+    tc = boost::unit_test::make_test_case(test_read_part_available<CoupledTransports>, name);
     suite_->add(tc, expectedFailures);
 
-    THRIFT_SNPRINTF(name, sizeof(name), "%s::test_read_part_available_in_chunks()",
-             transportName);
-    tc = boost::unit_test::make_test_case(
-          test_read_part_available_in_chunks<CoupledTransports>, name);
+    THRIFT_SNPRINTF(name, sizeof(name), "%s::test_read_part_available_in_chunks()", transportName);
+    tc = boost::unit_test::make_test_case(test_read_part_available_in_chunks<CoupledTransports>,
+                                          name);
     suite_->add(tc, expectedFailures);
 
-    THRIFT_SNPRINTF(name, sizeof(name), "%s::test_read_partial_midframe()",
-             transportName);
-    tc = boost::unit_test::make_test_case(
-          test_read_partial_midframe<CoupledTransports>, name);
+    THRIFT_SNPRINTF(name, sizeof(name), "%s::test_read_partial_midframe()", transportName);
+    tc = boost::unit_test::make_test_case(test_read_partial_midframe<CoupledTransports>, name);
     suite_->add(tc, expectedFailures);
 
-    THRIFT_SNPRINTF(name, sizeof(name), "%s::test_read_none_available()",
-             transportName);
-    tc = boost::unit_test::make_test_case(
-          test_read_none_available<CoupledTransports>, name);
+    THRIFT_SNPRINTF(name, sizeof(name), "%s::test_read_none_available()", transportName);
+    tc = boost::unit_test::make_test_case(test_read_none_available<CoupledTransports>, name);
     suite_->add(tc, expectedFailures);
 
-    THRIFT_SNPRINTF(name, sizeof(name), "%s::test_borrow_part_available()",
-             transportName);
-    tc = boost::unit_test::make_test_case(
-          test_borrow_part_available<CoupledTransports>, name);
+    THRIFT_SNPRINTF(name, sizeof(name), "%s::test_borrow_part_available()", transportName);
+    tc = boost::unit_test::make_test_case(test_borrow_part_available<CoupledTransports>, name);
     suite_->add(tc, expectedFailures);
 
-    THRIFT_SNPRINTF(name, sizeof(name), "%s::test_borrow_none_available()",
-             transportName);
-    tc = boost::unit_test::make_test_case(
-          test_borrow_none_available<CoupledTransports>, name);
+    THRIFT_SNPRINTF(name, sizeof(name), "%s::test_borrow_none_available()", transportName);
+    tc = boost::unit_test::make_test_case(test_borrow_none_available<CoupledTransports>, name);
     suite_->add(tc, expectedFailures);
   }
 
@@ -1022,15 +989,15 @@ class TransportTestGen {
 struct global_fixture {
   boost::shared_ptr<apache::thrift::concurrency::Thread> alarmThread_;
   global_fixture() {
-  #if _WIN32
+#if _WIN32
     apache::thrift::transport::TWinsockSingleton::create();
-  #endif
+#endif
 
     apache::thrift::concurrency::PlatformThreadFactory factory;
     factory.setDetached(false);
 
     alarmThread_ = factory.newThread(
-      apache::thrift::concurrency::FunctionRunner::create(alarm_handler_wrapper));
+        apache::thrift::concurrency::FunctionRunner::create(alarm_handler_wrapper));
     alarmThread_->start();
   }
   ~global_fixture() {
@@ -1054,8 +1021,7 @@ boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) {
 
   initrand(seed);
 
-  boost::unit_test::test_suite* suite =
-    &boost::unit_test::framework::master_test_suite();
+  boost::unit_test::test_suite* suite = &boost::unit_test::framework::master_test_suite();
   suite->p_name.value = "TransportTest";
   TransportTestGen transport_test_generator(suite, 1);
   transport_test_generator.generate();

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/ZlibTest.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/ZlibTest.cpp b/lib/cpp/test/ZlibTest.cpp
index 49c5514..14b1a37 100644
--- a/lib/cpp/test/ZlibTest.cpp
+++ b/lib/cpp/test/ZlibTest.cpp
@@ -48,26 +48,24 @@ boost::mt19937 rng;
  */
 
 class SizeGenerator {
- public:
+public:
   virtual ~SizeGenerator() {}
   virtual unsigned int getSize() = 0;
 };
 
 class ConstantSizeGenerator : public SizeGenerator {
- public:
+public:
   ConstantSizeGenerator(unsigned int value) : value_(value) {}
-  virtual unsigned int getSize() {
-    return value_;
-  }
+  virtual unsigned int getSize() { return value_; }
 
- private:
+private:
   unsigned int value_;
 };
 
 class LogNormalSizeGenerator : public SizeGenerator {
- public:
-  LogNormalSizeGenerator(double mean, double std_dev) :
-      gen_(rng, boost::lognormal_distribution<double>(mean, std_dev)) {}
+public:
+  LogNormalSizeGenerator(double mean, double std_dev)
+    : gen_(rng, boost::lognormal_distribution<double>(mean, std_dev)) {}
 
   virtual unsigned int getSize() {
     // Loop until we get a size of 1 or more
@@ -79,8 +77,8 @@ class LogNormalSizeGenerator : public SizeGenerator {
     }
   }
 
- private:
-  boost::variate_generator< boost::mt19937, boost::lognormal_distribution<double> > gen_;
+private:
+  boost::variate_generator<boost::mt19937, boost::lognormal_distribution<double> > gen_;
 };
 
 uint8_t* gen_uniform_buffer(uint32_t buf_len, uint8_t c) {
@@ -95,10 +93,10 @@ uint8_t* gen_compressible_buffer(uint32_t buf_len) {
   // Generate small runs of alternately increasing and decreasing bytes
   boost::uniform_smallint<uint32_t> run_length_distribution(1, 64);
   boost::uniform_smallint<uint8_t> byte_distribution(0, UINT8_MAX);
-  boost::variate_generator< boost::mt19937, boost::uniform_smallint<uint8_t> >
-    byte_generator(rng, byte_distribution);
-  boost::variate_generator< boost::mt19937, boost::uniform_smallint<uint32_t> >
-    run_len_generator(rng, run_length_distribution);
+  boost::variate_generator<boost::mt19937, boost::uniform_smallint<uint8_t> >
+      byte_generator(rng, byte_distribution);
+  boost::variate_generator<boost::mt19937, boost::uniform_smallint<uint32_t> >
+      run_len_generator(rng, run_length_distribution);
 
   uint32_t idx = 0;
   int8_t step = 1;
@@ -125,8 +123,8 @@ uint8_t* gen_random_buffer(uint32_t buf_len) {
   uint8_t* buf = new uint8_t[buf_len];
 
   boost::uniform_smallint<uint8_t> distribution(0, UINT8_MAX);
-  boost::variate_generator< boost::mt19937, boost::uniform_smallint<uint8_t> >
-    generator(rng, distribution);
+  boost::variate_generator<boost::mt19937, boost::uniform_smallint<uint8_t> >
+      generator(rng, distribution);
 
   for (uint32_t n = 0; n < buf_len; ++n) {
     buf[n] = generator();
@@ -167,7 +165,7 @@ void test_separate_checksum(const uint8_t* buf, uint32_t buf_len) {
   membuf->appendBufferToString(tmp_buf);
   zlib_trans.reset(new TZlibTransport(membuf,
                                       TZlibTransport::DEFAULT_URBUF_SIZE,
-                                      static_cast<uint32_t>(tmp_buf.length()-1)));
+                                      static_cast<uint32_t>(tmp_buf.length() - 1)));
 
   boost::shared_array<uint8_t> mirror(new uint8_t[buf_len]);
   uint32_t got = zlib_trans->readAll(mirror.get(), buf_len);
@@ -186,8 +184,7 @@ void test_incomplete_checksum(const uint8_t* buf, uint32_t buf_len) {
   string tmp_buf;
   membuf->appendBufferToString(tmp_buf);
   tmp_buf.erase(tmp_buf.length() - 1);
-  membuf->resetBuffer(const_cast<uint8_t*>(
-                        reinterpret_cast<const uint8_t*>(tmp_buf.data())),
+  membuf->resetBuffer(const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(tmp_buf.data())),
                       static_cast<uint32_t>(tmp_buf.length()));
 
   boost::shared_array<uint8_t> mirror(new uint8_t[buf_len]);
@@ -202,7 +199,8 @@ void test_incomplete_checksum(const uint8_t* buf, uint32_t buf_len) {
   }
 }
 
-void test_read_write_mix(const uint8_t* buf, uint32_t buf_len,
+void test_read_write_mix(const uint8_t* buf,
+                         uint32_t buf_len,
                          const boost::shared_ptr<SizeGenerator>& write_gen,
                          const boost::shared_ptr<SizeGenerator>& read_gen) {
   // Try it with a mix of read/write sizes.
@@ -232,7 +230,7 @@ void test_read_write_mix(const uint8_t* buf, uint32_t buf_len,
     }
     uint32_t got = zlib_trans->read(mirror.get() + tot, read_len);
     BOOST_REQUIRE_LE(got, expected_read_len);
-    BOOST_REQUIRE_NE(got, (uint32_t) 0);
+    BOOST_REQUIRE_NE(got, (uint32_t)0);
     tot += got;
   }
 
@@ -264,8 +262,7 @@ void test_invalid_checksum(const uint8_t* buf, uint32_t buf_len) {
   // error when only modifying checksum bytes.
   int index = static_cast<int>(tmp_buf.size() - 1);
   tmp_buf[index]++;
-  membuf->resetBuffer(const_cast<uint8_t*>(
-                        reinterpret_cast<const uint8_t*>(tmp_buf.data())),
+  membuf->resetBuffer(const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(tmp_buf.data())),
                       static_cast<uint32_t>(tmp_buf.length()));
 
   boost::shared_array<uint8_t> mirror(new uint8_t[buf_len]);
@@ -323,21 +320,22 @@ void test_no_write() {
     TZlibTransport w_zlib_trans(membuf);
   }
 
-  BOOST_CHECK_EQUAL(membuf->available_read(), (uint32_t) 0);
+  BOOST_CHECK_EQUAL(membuf->available_read(), (uint32_t)0);
 }
 
 /*
  * Initialization
  */
 
-#define ADD_TEST_CASE(suite, name, function, ...) \
-  do { \
-    ::std::ostringstream name_ss; \
-    name_ss << name << "-" << BOOST_STRINGIZE(function); \
-    ::boost::unit_test::test_case* tc = ::boost::unit_test::make_test_case( \
-        ::apache::thrift::stdcxx::bind(function, ## __VA_ARGS__), \
-        name_ss.str()); \
-    (suite)->add(tc); \
+#define ADD_TEST_CASE(suite, name, function, ...)                                                  \
+  do {                                                                                             \
+    ::std::ostringstream name_ss;                                                                  \
+    name_ss << name << "-" << BOOST_STRINGIZE(function);                                           \
+    ::boost::unit_test::test_case* tc                                                              \
+        = ::boost::unit_test::make_test_case(::apache::thrift::stdcxx::bind(function,              \
+                                                                            ##__VA_ARGS__),        \
+                                             name_ss.str());                                       \
+    (suite)->add(tc);                                                                              \
   } while (0)
 
 void add_tests(boost::unit_test::test_suite* suite,
@@ -350,20 +348,30 @@ void add_tests(boost::unit_test::test_suite* suite,
   ADD_TEST_CASE(suite, name, test_invalid_checksum, buf, buf_len);
   ADD_TEST_CASE(suite, name, test_write_after_flush, buf, buf_len);
 
-  boost::shared_ptr<SizeGenerator> size_32k(new ConstantSizeGenerator(1<<15));
+  boost::shared_ptr<SizeGenerator> size_32k(new ConstantSizeGenerator(1 << 15));
   boost::shared_ptr<SizeGenerator> size_lognormal(new LogNormalSizeGenerator(20, 30));
-  ADD_TEST_CASE(suite, name << "-constant",
-                test_read_write_mix, buf, buf_len,
-                size_32k, size_32k);
-  ADD_TEST_CASE(suite, name << "-lognormal-write",
-                test_read_write_mix, buf, buf_len,
-                size_lognormal, size_32k);
-  ADD_TEST_CASE(suite, name << "-lognormal-read",
-                test_read_write_mix, buf, buf_len,
-                size_32k, size_lognormal);
-  ADD_TEST_CASE(suite, name << "-lognormal-both",
-                test_read_write_mix, buf, buf_len,
-                size_lognormal, size_lognormal);
+  ADD_TEST_CASE(suite, name << "-constant", test_read_write_mix, buf, buf_len, size_32k, size_32k);
+  ADD_TEST_CASE(suite,
+                name << "-lognormal-write",
+                test_read_write_mix,
+                buf,
+                buf_len,
+                size_lognormal,
+                size_32k);
+  ADD_TEST_CASE(suite,
+                name << "-lognormal-read",
+                test_read_write_mix,
+                buf,
+                buf_len,
+                size_32k,
+                size_lognormal);
+  ADD_TEST_CASE(suite,
+                name << "-lognormal-both",
+                test_read_write_mix,
+                buf,
+                buf_len,
+                size_lognormal,
+                size_lognormal);
 
   // Test with a random size distribution,
   // but use the exact same distribution for reading as for writing.
@@ -373,9 +381,13 @@ void add_tests(boost::unit_test::test_suite* suite,
   // both start with random number generators in the same state.
   boost::shared_ptr<SizeGenerator> write_size_gen(new LogNormalSizeGenerator(20, 30));
   boost::shared_ptr<SizeGenerator> read_size_gen(new LogNormalSizeGenerator(20, 30));
-  ADD_TEST_CASE(suite, name << "-lognormal-same-distribution",
-                test_read_write_mix, buf, buf_len,
-                write_size_gen, read_size_gen);
+  ADD_TEST_CASE(suite,
+                name << "-lognormal-same-distribution",
+                test_read_write_mix,
+                buf,
+                buf_len,
+                write_size_gen,
+                read_size_gen);
 }
 
 void print_usage(FILE* f, const char* argv0) {
@@ -392,11 +404,10 @@ boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) {
   printf("seed: %" PRIu32 "\n", seed);
   rng.seed(seed);
 
-  boost::unit_test::test_suite* suite =
-    &boost::unit_test::framework::master_test_suite();
+  boost::unit_test::test_suite* suite = &boost::unit_test::framework::master_test_suite();
   suite->p_name.value = "ZlibTest";
 
-  uint32_t buf_len = 1024*32;
+  uint32_t buf_len = 1024 * 32;
   add_tests(suite, gen_uniform_buffer(buf_len, 'a'), buf_len, "uniform");
   add_tests(suite, gen_compressible_buffer(buf_len), buf_len, "compressible");
   add_tests(suite, gen_random_buffer(buf_len), buf_len, "random");

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/concurrency/Tests.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/concurrency/Tests.cpp b/lib/cpp/test/concurrency/Tests.cpp
index c80bb88..0d81d7e 100644
--- a/lib/cpp/test/concurrency/Tests.cpp
+++ b/lib/cpp/test/concurrency/Tests.cpp
@@ -29,7 +29,7 @@ int main(int argc, char** argv) {
 
   std::string arg;
 
-  std::vector<std::string>  args(argc - 1 > 1 ? argc - 1 : 1);
+  std::vector<std::string> args(argc - 1 > 1 ? argc - 1 : 1);
 
   args[0] = "all";
 
@@ -45,9 +45,9 @@ int main(int argc, char** argv) {
 
     std::cout << "ThreadFactory tests..." << std::endl;
 
-    size_t count =  1000;
-    size_t floodLoops =  1;
-    size_t floodCount =  100000;
+    size_t count = 1000;
+    size_t floodLoops = 1;
+    size_t floodCount = 100000;
 
     std::cout << "\t\tThreadFactory reap N threads test: N = " << count << std::endl;
 
@@ -89,7 +89,6 @@ int main(int argc, char** argv) {
     std::cout << "\t\t\tscall per ms: " << count / (time01 - time00) << std::endl;
   }
 
-
   if (runAll || args[0].compare("timer-manager") == 0) {
 
     std::cout << "TimerManager tests..." << std::endl;
@@ -113,16 +112,17 @@ int main(int argc, char** argv) {
 
       int64_t delay = 10LL;
 
-      std::cout << "\t\tThreadManager load test: worker count: " << workerCount << " task count: " << taskCount << " delay: " << delay << std::endl;
+      std::cout << "\t\tThreadManager load test: worker count: " << workerCount
+                << " task count: " << taskCount << " delay: " << delay << std::endl;
 
       ThreadManagerTests threadManagerTests;
 
       assert(threadManagerTests.loadTest(taskCount, delay, workerCount));
 
-      std::cout << "\t\tThreadManager block test: worker count: " << workerCount << " delay: " << delay << std::endl;
+      std::cout << "\t\tThreadManager block test: worker count: " << workerCount
+                << " delay: " << delay << std::endl;
 
       assert(threadManagerTests.blockTest(delay, workerCount));
-
     }
   }
 
@@ -140,11 +140,12 @@ int main(int argc, char** argv) {
 
       int64_t delay = 10LL;
 
-      for (size_t workerCount = minWorkerCount; workerCount < maxWorkerCount; workerCount*= 2) {
+      for (size_t workerCount = minWorkerCount; workerCount < maxWorkerCount; workerCount *= 2) {
 
         size_t taskCount = workerCount * tasksPerWorker;
 
-        std::cout << "\t\tThreadManager load test: worker count: " << workerCount << " task count: " << taskCount << " delay: " << delay << std::endl;
+        std::cout << "\t\tThreadManager load test: worker count: " << workerCount
+                  << " task count: " << taskCount << " delay: " << delay << std::endl;
 
         ThreadManagerTests threadManagerTests;
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/concurrency/ThreadFactoryTests.h
----------------------------------------------------------------------
diff --git a/lib/cpp/test/concurrency/ThreadFactoryTests.h b/lib/cpp/test/concurrency/ThreadFactoryTests.h
old mode 100755
new mode 100644
index 2d97337..d7431a8
--- a/lib/cpp/test/concurrency/ThreadFactoryTests.h
+++ b/lib/cpp/test/concurrency/ThreadFactoryTests.h
@@ -27,7 +27,10 @@
 #include <iostream>
 #include <set>
 
-namespace apache { namespace thrift { namespace concurrency { namespace test {
+namespace apache {
+namespace thrift {
+namespace concurrency {
+namespace test {
 
 using boost::shared_ptr;
 using namespace apache::thrift::concurrency;
@@ -40,18 +43,14 @@ using namespace apache::thrift::concurrency;
 class ThreadFactoryTests {
 
 public:
-
   static const double TEST_TOLERANCE;
 
-  class Task: public Runnable {
+  class Task : public Runnable {
 
   public:
-
     Task() {}
 
-    void run() {
-      std::cout << "\t\t\tHello World" << std::endl;
-    }
+    void run() { std::cout << "\t\t\tHello World" << std::endl; }
   };
 
   /**
@@ -77,20 +76,17 @@ public:
   /**
    * Reap N threads
    */
-  class ReapNTask: public Runnable {
-
-   public:
+  class ReapNTask : public Runnable {
 
-    ReapNTask(Monitor& monitor, int& activeCount) :
-      _monitor(monitor),
-      _count(activeCount) {}
+  public:
+    ReapNTask(Monitor& monitor, int& activeCount) : _monitor(monitor), _count(activeCount) {}
 
     void run() {
       Synchronized s(_monitor);
 
       _count--;
 
-      //std::cout << "\t\t\tthread count: " << _count << std::endl;
+      // std::cout << "\t\t\tthread count: " << _count << std::endl;
 
       if (_count == 0) {
         _monitor.notify();
@@ -102,15 +98,15 @@ public:
     int& _count;
   };
 
-  bool reapNThreads(int loop=1, int count=10) {
+  bool reapNThreads(int loop = 1, int count = 10) {
 
-    PlatformThreadFactory threadFactory =  PlatformThreadFactory();
+    PlatformThreadFactory threadFactory = PlatformThreadFactory();
 
     Monitor* monitor = new Monitor();
 
-    for(int lix = 0; lix < loop; lix++) {
+    for (int lix = 0; lix < loop; lix++) {
 
-      int* activeCount  = new int(count);
+      int* activeCount = new int(count);
 
       std::set<shared_ptr<Thread> > threads;
 
@@ -118,20 +114,25 @@ public:
 
       for (tix = 0; tix < count; tix++) {
         try {
-          threads.insert(threadFactory.newThread(shared_ptr<Runnable>(new ReapNTask(*monitor, *activeCount))));
-        } catch(SystemResourceException& e) {
-          std::cout << "\t\t\tfailed to create " << lix * count + tix << " thread " << e.what() << std::endl;
+          threads.insert(
+              threadFactory.newThread(shared_ptr<Runnable>(new ReapNTask(*monitor, *activeCount))));
+        } catch (SystemResourceException& e) {
+          std::cout << "\t\t\tfailed to create " << lix* count + tix << " thread " << e.what()
+                    << std::endl;
           throw e;
         }
       }
 
       tix = 0;
-      for (std::set<shared_ptr<Thread> >::const_iterator thread = threads.begin(); thread != threads.end(); tix++, ++thread) {
+      for (std::set<shared_ptr<Thread> >::const_iterator thread = threads.begin();
+           thread != threads.end();
+           tix++, ++thread) {
 
         try {
           (*thread)->start();
-        } catch(SystemResourceException& e) {
-          std::cout << "\t\t\tfailed to start  " << lix * count + tix << " thread " << e.what() << std::endl;
+        } catch (SystemResourceException& e) {
+          std::cout << "\t\t\tfailed to start  " << lix* count + tix << " thread " << e.what()
+                    << std::endl;
           throw e;
         }
       }
@@ -143,7 +144,7 @@ public:
         }
       }
       delete activeCount;
-      std::cout << "\t\t\treaped " << lix * count << " threads" << std::endl;
+      std::cout << "\t\t\treaped " << lix* count << " threads" << std::endl;
     }
 
     std::cout << "\t\t\tSuccess!" << std::endl;
@@ -151,21 +152,12 @@ public:
     return true;
   }
 
-  class SynchStartTask: public Runnable {
+  class SynchStartTask : public Runnable {
 
-   public:
-
-    enum STATE {
-      UNINITIALIZED,
-      STARTING,
-      STARTED,
-      STOPPING,
-      STOPPED
-    };
+  public:
+    enum STATE { UNINITIALIZED, STARTING, STARTED, STOPPING, STOPPED };
 
-    SynchStartTask(Monitor& monitor, volatile  STATE& state) :
-      _monitor(monitor),
-      _state(state) {}
+    SynchStartTask(Monitor& monitor, volatile STATE& state) : _monitor(monitor), _state(state) {}
 
     void run() {
       {
@@ -189,9 +181,9 @@ public:
       }
     }
 
-   private:
+  private:
     Monitor& _monitor;
-    volatile  STATE& _state;
+    volatile STATE& _state;
   };
 
   bool synchStartTest() {
@@ -200,9 +192,10 @@ public:
 
     SynchStartTask::STATE state = SynchStartTask::UNINITIALIZED;
 
-    shared_ptr<SynchStartTask> task = shared_ptr<SynchStartTask>(new SynchStartTask(monitor, state));
+    shared_ptr<SynchStartTask> task
+        = shared_ptr<SynchStartTask>(new SynchStartTask(monitor, state));
 
-    PlatformThreadFactory threadFactory =  PlatformThreadFactory();
+    PlatformThreadFactory threadFactory = PlatformThreadFactory();
 
     shared_ptr<Thread> thread = threadFactory.newThread(task);
 
@@ -226,8 +219,8 @@ public:
       Synchronized s(monitor);
 
       try {
-          monitor.wait(100);
-      } catch(TimedOutException& e) {
+        monitor.wait(100);
+      } catch (TimedOutException& e) {
       }
 
       if (state == SynchStartTask::STARTED) {
@@ -253,7 +246,7 @@ public:
 
   /** See how accurate monitor timeout is. */
 
-  bool monitorTimeoutTest(size_t count=1000, int64_t timeout=10) {
+  bool monitorTimeoutTest(size_t count = 1000, int64_t timeout = 10) {
 
     Monitor monitor;
 
@@ -263,8 +256,8 @@ public:
       {
         Synchronized s(monitor);
         try {
-            monitor.wait(timeout);
-        } catch(TimedOutException& e) {
+          monitor.wait(timeout);
+        } catch (TimedOutException& e) {
         }
       }
     }
@@ -273,31 +266,32 @@ public:
 
     double error = ((endTime - startTime) - (count * timeout)) / (double)(count * timeout);
 
-    if (error < 0.0)  {
+    if (error < 0.0) {
 
       error *= 1.0;
     }
 
     bool success = error < ThreadFactoryTests::TEST_TOLERANCE;
 
-    std::cout << "\t\t\t" << (success ? "Success" : "Failure") << "! expected time: " << count * timeout << "ms elapsed time: "<< endTime - startTime << "ms error%: " << error * 100.0 << std::endl;
+    std::cout << "\t\t\t" << (success ? "Success" : "Failure")
+              << "! expected time: " << count * timeout
+              << "ms elapsed time: " << endTime - startTime << "ms error%: " << error * 100.0
+              << std::endl;
 
     return success;
   }
 
-
   class FloodTask : public Runnable {
   public:
-
-    FloodTask(const size_t id) :_id(id) {}
-    ~FloodTask(){
-      if(_id % 1000 == 0) {
+    FloodTask(const size_t id) : _id(id) {}
+    ~FloodTask() {
+      if (_id % 1000 == 0) {
         std::cout << "\t\tthread " << _id << " done" << std::endl;
       }
     }
 
-    void run(){
-      if(_id % 1000 == 0) {
+    void run() {
+      if (_id % 1000 == 0) {
         std::cout << "\t\tthread " << _id << " started" << std::endl;
       }
 
@@ -306,42 +300,41 @@ public:
     const size_t _id;
   };
 
-  void foo(PlatformThreadFactory *tf) {
-    (void) tf;
-  }
+  void foo(PlatformThreadFactory* tf) { (void)tf; }
 
-  bool floodNTest(size_t loop=1, size_t count=100000) {
+  bool floodNTest(size_t loop = 1, size_t count = 100000) {
 
     bool success = false;
 
-    for(size_t lix = 0; lix < loop; lix++) {
+    for (size_t lix = 0; lix < loop; lix++) {
 
       PlatformThreadFactory threadFactory = PlatformThreadFactory();
       threadFactory.setDetached(true);
 
-        for(size_t tix = 0; tix < count; tix++) {
+      for (size_t tix = 0; tix < count; tix++) {
 
-          try {
+        try {
 
-            shared_ptr<FloodTask> task(new FloodTask(lix * count + tix ));
+          shared_ptr<FloodTask> task(new FloodTask(lix * count + tix));
 
-            shared_ptr<Thread> thread = threadFactory.newThread(task);
+          shared_ptr<Thread> thread = threadFactory.newThread(task);
 
-            thread->start();
+          thread->start();
 
-            THRIFT_SLEEP_USEC(1);
+          THRIFT_SLEEP_USEC(1);
 
-          } catch (TException& e) {
+        } catch (TException& e) {
 
-            std::cout << "\t\t\tfailed to start  " << lix * count + tix << " thread " << e.what() << std::endl;
+          std::cout << "\t\t\tfailed to start  " << lix* count + tix << " thread " << e.what()
+                    << std::endl;
 
-            return success;
-          }
+          return success;
         }
+      }
 
-        std::cout << "\t\t\tflooded " << (lix + 1) * count << " threads" << std::endl;
+      std::cout << "\t\t\tflooded " << (lix + 1) * count << " threads" << std::endl;
 
-        success = true;
+      success = true;
     }
 
     return success;
@@ -349,5 +342,7 @@ public:
 };
 
 const double ThreadFactoryTests::TEST_TOLERANCE = .20;
-
-}}}} // apache::thrift::concurrency::test
+}
+}
+}
+} // apache::thrift::concurrency::test

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/concurrency/ThreadManagerTests.h
----------------------------------------------------------------------
diff --git a/lib/cpp/test/concurrency/ThreadManagerTests.h b/lib/cpp/test/concurrency/ThreadManagerTests.h
old mode 100755
new mode 100644
index c08448b..27bf6c5
--- a/lib/cpp/test/concurrency/ThreadManagerTests.h
+++ b/lib/cpp/test/concurrency/ThreadManagerTests.h
@@ -29,7 +29,10 @@
 #include <set>
 #include <stdint.h>
 
-namespace apache { namespace thrift { namespace concurrency { namespace test {
+namespace apache {
+namespace thrift {
+namespace concurrency {
+namespace test {
 
 using namespace apache::thrift::concurrency;
 
@@ -38,15 +41,11 @@ class ThreadManagerTests {
   static const double TEST_TOLERANCE;
 
 public:
-  class Task: public Runnable {
+  class Task : public Runnable {
 
   public:
-
-    Task(Monitor& monitor, size_t& count, int64_t timeout) :
-      _monitor(monitor),
-      _count(count),
-      _timeout(timeout),
-      _done(false) {}
+    Task(Monitor& monitor, size_t& count, int64_t timeout)
+      : _monitor(monitor), _count(count), _timeout(timeout), _done(false) {}
 
     void run() {
 
@@ -57,9 +56,9 @@ public:
 
         try {
           _sleep.wait(_timeout);
-        } catch(TimedOutException& e) {
+        } catch (TimedOutException& e) {
           ;
-        }catch(...) {
+        } catch (...) {
           assert(0);
         }
       }
@@ -96,7 +95,7 @@ public:
    * completes. Verify that all tasks completed and that thread manager cleans
    * up properly on delete.
    */
-  bool loadTest(size_t count=100, int64_t timeout=100LL, size_t workerCount=4) {
+  bool loadTest(size_t count = 100, int64_t timeout = 100LL, size_t workerCount = 4) {
 
     Monitor monitor;
 
@@ -104,7 +103,8 @@ public:
 
     shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workerCount);
 
-    shared_ptr<PlatformThreadFactory> threadFactory = shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
+    shared_ptr<PlatformThreadFactory> threadFactory
+        = shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
 
 #ifndef USE_BOOST_THREAD
     threadFactory->setPriority(PosixThreadFactory::HIGHEST);
@@ -117,20 +117,23 @@ public:
 
     for (size_t ix = 0; ix < count; ix++) {
 
-      tasks.insert(shared_ptr<ThreadManagerTests::Task>(new ThreadManagerTests::Task(monitor, activeCount, timeout)));
+      tasks.insert(shared_ptr<ThreadManagerTests::Task>(
+          new ThreadManagerTests::Task(monitor, activeCount, timeout)));
     }
 
     int64_t time00 = Util::currentTime();
 
-    for (std::set<shared_ptr<ThreadManagerTests::Task> >::iterator ix = tasks.begin(); ix != tasks.end(); ix++) {
+    for (std::set<shared_ptr<ThreadManagerTests::Task> >::iterator ix = tasks.begin();
+         ix != tasks.end();
+         ix++) {
 
-        threadManager->add(*ix);
+      threadManager->add(*ix);
     }
 
     {
       Synchronized s(monitor);
 
-      while(activeCount > 0) {
+      while (activeCount > 0) {
 
         monitor.wait();
       }
@@ -145,7 +148,9 @@ public:
     int64_t minTime = 9223372036854775807LL;
     int64_t maxTime = 0;
 
-    for (std::set<shared_ptr<ThreadManagerTests::Task> >::iterator ix = tasks.begin(); ix != tasks.end(); ix++) {
+    for (std::set<shared_ptr<ThreadManagerTests::Task> >::iterator ix = tasks.begin();
+         ix != tasks.end();
+         ix++) {
 
       shared_ptr<ThreadManagerTests::Task> task = *ix;
 
@@ -169,43 +174,43 @@ public:
         maxTime = delta;
       }
 
-      averageTime+= delta;
+      averageTime += delta;
     }
 
     averageTime /= count;
 
-    std::cout << "\t\t\tfirst start: " << firstTime << "ms Last end: " << lastTime << "ms min: " << minTime << "ms max: " << maxTime << "ms average: " << averageTime << "ms" << std::endl;
+    std::cout << "\t\t\tfirst start: " << firstTime << "ms Last end: " << lastTime
+              << "ms min: " << minTime << "ms max: " << maxTime << "ms average: " << averageTime
+              << "ms" << std::endl;
 
     double expectedTime = ((count + (workerCount - 1)) / workerCount) * timeout;
 
     double error = ((time01 - time00) - expectedTime) / expectedTime;
 
     if (error < 0) {
-      error*= -1.0;
+      error *= -1.0;
     }
 
     bool success = error < TEST_TOLERANCE;
 
-    std::cout << "\t\t\t" << (success ? "Success" : "Failure") << "! expected time: " << expectedTime << "ms elapsed time: "<< time01 - time00 << "ms error%: " << error * 100.0 << std::endl;
+    std::cout << "\t\t\t" << (success ? "Success" : "Failure")
+              << "! expected time: " << expectedTime << "ms elapsed time: " << time01 - time00
+              << "ms error%: " << error * 100.0 << std::endl;
 
     return success;
   }
 
-  class BlockTask: public Runnable {
+  class BlockTask : public Runnable {
 
   public:
-
-    BlockTask(Monitor& monitor, Monitor& bmonitor, size_t& count) :
-      _monitor(monitor),
-      _bmonitor(bmonitor),
-      _count(count) {}
+    BlockTask(Monitor& monitor, Monitor& bmonitor, size_t& count)
+      : _monitor(monitor), _bmonitor(bmonitor), _count(count) {}
 
     void run() {
       {
         Synchronized s(_bmonitor);
 
         _bmonitor.wait();
-
       }
 
       {
@@ -229,8 +234,8 @@ public:
    * Block test.  Create pendingTaskCountMax tasks.  Verify that we block adding the
    * pendingTaskCountMax + 1th task.  Verify that we unblock when a task completes */
 
-  bool blockTest(int64_t timeout=100LL, size_t workerCount=2) {
-    (void) timeout;
+  bool blockTest(int64_t timeout = 100LL, size_t workerCount = 2) {
+    (void)timeout;
     bool success = false;
 
     try {
@@ -242,9 +247,11 @@ public:
 
       size_t activeCounts[] = {workerCount, pendingTaskMaxCount, 1};
 
-      shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workerCount, pendingTaskMaxCount);
+      shared_ptr<ThreadManager> threadManager
+          = ThreadManager::newSimpleThreadManager(workerCount, pendingTaskMaxCount);
 
-      shared_ptr<PlatformThreadFactory> threadFactory = shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
+      shared_ptr<PlatformThreadFactory> threadFactory
+          = shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
 
 #ifndef USE_BOOST_THREAD
       threadFactory->setPriority(PosixThreadFactory::HIGHEST);
@@ -257,43 +264,49 @@ public:
 
       for (size_t ix = 0; ix < workerCount; ix++) {
 
-        tasks.insert(shared_ptr<ThreadManagerTests::BlockTask>(new ThreadManagerTests::BlockTask(monitor, bmonitor,activeCounts[0])));
+        tasks.insert(shared_ptr<ThreadManagerTests::BlockTask>(
+            new ThreadManagerTests::BlockTask(monitor, bmonitor, activeCounts[0])));
       }
 
       for (size_t ix = 0; ix < pendingTaskMaxCount; ix++) {
 
-        tasks.insert(shared_ptr<ThreadManagerTests::BlockTask>(new ThreadManagerTests::BlockTask(monitor, bmonitor,activeCounts[1])));
+        tasks.insert(shared_ptr<ThreadManagerTests::BlockTask>(
+            new ThreadManagerTests::BlockTask(monitor, bmonitor, activeCounts[1])));
       }
 
-      for (std::set<shared_ptr<ThreadManagerTests::BlockTask> >::iterator ix = tasks.begin(); ix != tasks.end(); ix++) {
+      for (std::set<shared_ptr<ThreadManagerTests::BlockTask> >::iterator ix = tasks.begin();
+           ix != tasks.end();
+           ix++) {
         threadManager->add(*ix);
       }
 
-      if(!(success = (threadManager->totalTaskCount() == pendingTaskMaxCount + workerCount))) {
+      if (!(success = (threadManager->totalTaskCount() == pendingTaskMaxCount + workerCount))) {
         throw TException("Unexpected pending task count");
       }
 
-      shared_ptr<ThreadManagerTests::BlockTask> extraTask(new ThreadManagerTests::BlockTask(monitor, bmonitor, activeCounts[2]));
+      shared_ptr<ThreadManagerTests::BlockTask> extraTask(
+          new ThreadManagerTests::BlockTask(monitor, bmonitor, activeCounts[2]));
 
       try {
         threadManager->add(extraTask, 1);
         throw TException("Unexpected success adding task in excess of pending task count");
-      } catch(TooManyPendingTasksException& e) {
+      } catch (TooManyPendingTasksException& e) {
         throw TException("Should have timed out adding task in excess of pending task count");
-      } catch(TimedOutException& e) {
+      } catch (TimedOutException& e) {
         // Expected result
       }
 
       try {
         threadManager->add(extraTask, -1);
         throw TException("Unexpected success adding task in excess of pending task count");
-      } catch(TimedOutException& e) {
+      } catch (TimedOutException& e) {
         throw TException("Unexpected timeout adding task in excess of pending task count");
-      } catch(TooManyPendingTasksException& e) {
+      } catch (TooManyPendingTasksException& e) {
         // Expected result
       }
 
-      std::cout << "\t\t\t" << "Pending tasks " << threadManager->pendingTaskCount()  << std::endl;
+      std::cout << "\t\t\t"
+                << "Pending tasks " << threadManager->pendingTaskCount() << std::endl;
 
       {
         Synchronized s(bmonitor);
@@ -304,21 +317,24 @@ public:
       {
         Synchronized s(monitor);
 
-        while(activeCounts[0] != 0) {
+        while (activeCounts[0] != 0) {
           monitor.wait();
         }
       }
 
-      std::cout << "\t\t\t" << "Pending tasks " << threadManager->pendingTaskCount() << std::endl;
+      std::cout << "\t\t\t"
+                << "Pending tasks " << threadManager->pendingTaskCount() << std::endl;
 
       try {
         threadManager->add(extraTask, 1);
-      } catch(TimedOutException& e) {
-        std::cout << "\t\t\t" << "add timed out unexpectedly"  << std::endl;
+      } catch (TimedOutException& e) {
+        std::cout << "\t\t\t"
+                  << "add timed out unexpectedly" << std::endl;
         throw TException("Unexpected timeout adding task");
 
-      } catch(TooManyPendingTasksException& e) {
-        std::cout << "\t\t\t" << "add encountered too many pending exepctions" << std::endl;
+      } catch (TooManyPendingTasksException& e) {
+        std::cout << "\t\t\t"
+                  << "add encountered too many pending exepctions" << std::endl;
         throw TException("Unexpected timeout adding task");
       }
 
@@ -333,7 +349,7 @@ public:
       {
         Synchronized s(monitor);
 
-        while(activeCounts[1] != 0) {
+        while (activeCounts[1] != 0) {
           monitor.wait();
         }
       }
@@ -349,26 +365,28 @@ public:
       {
         Synchronized s(monitor);
 
-        while(activeCounts[2] != 0) {
+        while (activeCounts[2] != 0) {
           monitor.wait();
         }
       }
 
-      if(!(success = (threadManager->totalTaskCount() == 0))) {
+      if (!(success = (threadManager->totalTaskCount() == 0))) {
         throw TException("Unexpected pending task count");
       }
 
-    } catch(TException& e) {
+    } catch (TException& e) {
       std::cout << "ERROR: " << e.what() << std::endl;
     }
 
     std::cout << "\t\t\t" << (success ? "Success" : "Failure") << std::endl;
     return success;
- }
+  }
 };
 
 const double ThreadManagerTests::TEST_TOLERANCE = .20;
-
-}}}} // apache::thrift::concurrency
+}
+}
+}
+} // apache::thrift::concurrency
 
 using namespace apache::thrift::concurrency::test;

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/concurrency/TimerManagerTests.h
----------------------------------------------------------------------
diff --git a/lib/cpp/test/concurrency/TimerManagerTests.h b/lib/cpp/test/concurrency/TimerManagerTests.h
index 62eb4f4..dda16ed 100644
--- a/lib/cpp/test/concurrency/TimerManagerTests.h
+++ b/lib/cpp/test/concurrency/TimerManagerTests.h
@@ -25,7 +25,10 @@
 #include <assert.h>
 #include <iostream>
 
-namespace apache { namespace thrift { namespace concurrency { namespace test {
+namespace apache {
+namespace thrift {
+namespace concurrency {
+namespace test {
 
 using namespace apache::thrift::concurrency;
 
@@ -33,16 +36,15 @@ class TimerManagerTests {
 
   static const double TEST_TOLERANCE;
 
- public:
-  class Task: public Runnable {
-   public:
-
-    Task(Monitor& monitor, int64_t timeout) :
-      _timeout(timeout),
-      _startTime(Util::currentTime()),
-      _monitor(monitor),
-      _success(false),
-      _done(false) {}
+public:
+  class Task : public Runnable {
+  public:
+    Task(Monitor& monitor, int64_t timeout)
+      : _timeout(timeout),
+        _startTime(Util::currentTime()),
+        _monitor(monitor),
+        _success(false),
+        _done(false) {}
 
     ~Task() { std::cerr << this << std::endl; }
 
@@ -54,20 +56,20 @@ class TimerManagerTests {
 
       int64_t delta = _endTime - _startTime;
 
-
-      delta = delta > _timeout ?  delta - _timeout : _timeout - delta;
+      delta = delta > _timeout ? delta - _timeout : _timeout - delta;
 
       float error = delta / _timeout;
 
-      if(error < TEST_TOLERANCE) {
+      if (error < TEST_TOLERANCE) {
         _success = true;
       }
 
       _done = true;
 
-      std::cout << "\t\t\tTimerManagerTests::Task[" << this << "] done" << std::endl; //debug
+      std::cout << "\t\t\tTimerManagerTests::Task[" << this << "] done" << std::endl; // debug
 
-      {Synchronized s(_monitor);
+      {
+        Synchronized s(_monitor);
         _monitor.notifyAll();
       }
     }
@@ -86,9 +88,10 @@ class TimerManagerTests {
    * properly clean up itself and the remaining orphaned timeout task when the
    * manager goes out of scope and its destructor is called.
    */
-  bool test00(int64_t timeout=1000LL) {
+  bool test00(int64_t timeout = 1000LL) {
 
-    shared_ptr<TimerManagerTests::Task> orphanTask = shared_ptr<TimerManagerTests::Task>(new TimerManagerTests::Task(_monitor, 10 * timeout));
+    shared_ptr<TimerManagerTests::Task> orphanTask
+        = shared_ptr<TimerManagerTests::Task>(new TimerManagerTests::Task(_monitor, 10 * timeout));
 
     {
 
@@ -113,12 +116,13 @@ class TimerManagerTests {
           // Wait for 1 second in order to give timerManager a chance to start sleeping in response
           // to adding orphanTask. We need to do this so we can verify that adding the second task
           // kicks the dispatcher out of the current wait and starts the new 1 second wait.
-          _monitor.wait (1000);
-          assert (0 == "ERROR: This wait should time out. TimerManager dispatcher may have a problem.");
-        } catch (TimedOutException &ex) {
+          _monitor.wait(1000);
+          assert(
+              0 == "ERROR: This wait should time out. TimerManager dispatcher may have a problem.");
+        } catch (TimedOutException& ex) {
         }
 
-        task.reset (new TimerManagerTests::Task(_monitor, timeout));
+        task.reset(new TimerManagerTests::Task(_monitor, timeout));
 
         timerManager.add(task, timeout);
 
@@ -127,7 +131,6 @@ class TimerManagerTests {
 
       assert(task->_done);
 
-
       std::cout << "\t\t\t" << (task->_success ? "Success" : "Failure") << "!" << std::endl;
     }
 
@@ -144,5 +147,7 @@ class TimerManagerTests {
 };
 
 const double TimerManagerTests::TEST_TOLERANCE = .20;
-
-}}}} // apache::thrift::concurrency
+}
+}
+}
+} // apache::thrift::concurrency

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/processor/EventLog.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/test/processor/EventLog.cpp b/lib/cpp/test/processor/EventLog.cpp
index 0ac3028..d4b8372 100644
--- a/lib/cpp/test/processor/EventLog.cpp
+++ b/lib/cpp/test/processor/EventLog.cpp
@@ -36,10 +36,11 @@ void debug(const char* fmt, ...) {
 
   fprintf(stderr, "\n");
 }
-
 }
 
-namespace apache { namespace thrift { namespace test {
+namespace apache {
+namespace thrift {
+namespace test {
 
 uint32_t EventLog::nextId_ = 0;
 
@@ -74,11 +75,12 @@ EventLog::EventLog() {
   debug("New log: %d", id_);
 }
 
-void EventLog::append(EventType type, uint32_t connectionId, uint32_t callId,
+void EventLog::append(EventType type,
+                      uint32_t connectionId,
+                      uint32_t callId,
                       const string& message) {
   Synchronized s(monitor_);
-  debug("%d <-- %u, %u, %s \"%s\"", id_, connectionId, callId, type,
-        message.c_str());
+  debug("%d <-- %u, %u, %s \"%s\"", id_, connectionId, callId, type, message.c_str());
 
   Event e(type, connectionId, callId, message);
   events_.push_back(e);
@@ -125,5 +127,6 @@ Event EventLog::waitForConnEvent(uint32_t connId, int64_t timeout) {
     }
   }
 }
-
-}}} // apache::thrift::test
+}
+}
+} // apache::thrift::test

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/processor/EventLog.h
----------------------------------------------------------------------
diff --git a/lib/cpp/test/processor/EventLog.h b/lib/cpp/test/processor/EventLog.h
index d731cec..4f8275d 100644
--- a/lib/cpp/test/processor/EventLog.h
+++ b/lib/cpp/test/processor/EventLog.h
@@ -21,7 +21,9 @@
 
 #include <thrift/concurrency/Monitor.h>
 
-namespace apache { namespace thrift { namespace test {
+namespace apache {
+namespace thrift {
+namespace test {
 
 // Initially I made EventType an enum, but using char* results
 // in much more readable error messages when there is a mismatch.
@@ -31,21 +33,17 @@ namespace apache { namespace thrift { namespace test {
 typedef const char* EventType;
 
 struct Event {
-  Event(EventType type, uint32_t connectionId, uint32_t callId,
-        const std::string& message) :
-      type(type),
-      connectionId(connectionId),
-      callId(callId),
-      message(message) {}
+  Event(EventType type, uint32_t connectionId, uint32_t callId, const std::string& message)
+    : type(type), connectionId(connectionId), callId(callId), message(message) {}
 
   EventType type;
-  uint32_t  connectionId;
-  uint32_t  callId;
-  std::string    message;
+  uint32_t connectionId;
+  uint32_t callId;
+  std::string message;
 };
 
 class EventLog {
- public:
+public:
   static EventType ET_LOG_END;
   static EventType ET_CONN_CREATED;
   static EventType ET_CONN_DESTROYED;
@@ -73,13 +71,15 @@ class EventLog {
 
   EventLog();
 
-  void append(EventType type, uint32_t connectionId, uint32_t callId,
+  void append(EventType type,
+              uint32_t connectionId,
+              uint32_t callId,
               const std::string& message = "");
 
   Event waitForEvent(int64_t timeout = 500);
   Event waitForConnEvent(uint32_t connId, int64_t timeout = 500);
 
- protected:
+protected:
   typedef std::list<Event> EventList;
 
   concurrency::Monitor monitor_;
@@ -88,7 +88,8 @@ class EventLog {
 
   static uint32_t nextId_;
 };
-
-}}} // apache::thrift::test
+}
+}
+} // apache::thrift::test
 
 #endif // _THRIFT_TEST_EVENTLOG_H_

http://git-wip-us.apache.org/repos/asf/thrift/blob/74260aa9/lib/cpp/test/processor/Handlers.h
----------------------------------------------------------------------
diff --git a/lib/cpp/test/processor/Handlers.h b/lib/cpp/test/processor/Handlers.h
index 75f4349..d894107 100644
--- a/lib/cpp/test/processor/Handlers.h
+++ b/lib/cpp/test/processor/Handlers.h
@@ -23,15 +23,14 @@
 #include "gen-cpp/ParentService.h"
 #include "gen-cpp/ChildService.h"
 
-namespace apache { namespace thrift { namespace test {
+namespace apache {
+namespace thrift {
+namespace test {
 
 class ParentHandler : virtual public ParentServiceIf {
- public:
-  ParentHandler(const boost::shared_ptr<EventLog>& log) :
-      triggerMonitor(&mutex_),
-      generation_(0),
-      wait_(false),
-      log_(log) { }
+public:
+  ParentHandler(const boost::shared_ptr<EventLog>& log)
+    : triggerMonitor(&mutex_), generation_(0), wait_(false), log_(log) {}
 
   int32_t incrementGeneration() {
     concurrency::Guard g(mutex_);
@@ -116,7 +115,7 @@ class ParentHandler : virtual public ParentServiceIf {
     triggerMonitor.notifyAll();
   }
 
- protected:
+protected:
   /**
    * blockUntilTriggered() won't return until triggerPendingCalls() is invoked
    * in another thread.
@@ -141,10 +140,8 @@ class ParentHandler : virtual public ParentServiceIf {
 };
 
 class ChildHandler : public ParentHandler, virtual public ChildServiceIf {
- public:
-  ChildHandler(const boost::shared_ptr<EventLog>& log) :
-      ParentHandler(log),
-      value_(0) {}
+public:
+  ChildHandler(const boost::shared_ptr<EventLog>& log) : ParentHandler(log), value_(0) {}
 
   int32_t setValue(int32_t value) {
     concurrency::Guard g(mutex_);
@@ -162,18 +159,16 @@ class ChildHandler : public ParentHandler, virtual public ChildServiceIf {
     return value_;
   }
 
- protected:
+protected:
   int32_t value_;
 };
 
 struct ConnContext {
- public:
+public:
   ConnContext(boost::shared_ptr<protocol::TProtocol> in,
               boost::shared_ptr<protocol::TProtocol> out,
-              uint32_t id) :
-      input(in),
-      output(out),
-      id(id) {}
+              uint32_t id)
+    : input(in), output(out), id(id) {}
 
   boost::shared_ptr<protocol::TProtocol> input;
   boost::shared_ptr<protocol::TProtocol> output;
@@ -181,22 +176,18 @@ struct ConnContext {
 };
 
 struct CallContext {
- public:
-  CallContext(ConnContext *context, uint32_t id, const std::string& name) :
-      connContext(context),
-      name(name),
-      id(id) {}
+public:
+  CallContext(ConnContext* context, uint32_t id, const std::string& name)
+    : connContext(context), name(name), id(id) {}
 
-  ConnContext *connContext;
+  ConnContext* connContext;
   std::string name;
   uint32_t id;
 };
 
 class ServerEventHandler : public server::TServerEventHandler {
- public:
-  ServerEventHandler(const boost::shared_ptr<EventLog>& log) :
-      nextId_(1),
-      log_(log) {}
+public:
+  ServerEventHandler(const boost::shared_ptr<EventLog>& log) : nextId_(1), log_(log) {}
 
   virtual void preServe() {}
 
@@ -209,8 +200,8 @@ class ServerEventHandler : public server::TServerEventHandler {
   }
 
   virtual void deleteContext(void* serverContext,
-                             boost::shared_ptr<protocol::TProtocol>input,
-                             boost::shared_ptr<protocol::TProtocol>output) {
+                             boost::shared_ptr<protocol::TProtocol> input,
+                             boost::shared_ptr<protocol::TProtocol> output) {
     ConnContext* context = reinterpret_cast<ConnContext*>(serverContext);
 
     if (input != context->input) {
@@ -225,22 +216,21 @@ class ServerEventHandler : public server::TServerEventHandler {
     delete context;
   }
 
-  virtual void processContext(
-      void* serverContext,
-      boost::shared_ptr<transport::TTransport> transport) {
-    // TODO: We currently don't test the behavior of the processContext()
-    // calls.  The various server implementations call processContext() at
-    // slightly different times, and it is too annoying to try and account for
-    // their various differences.
-    //
-    // TThreadedServer, TThreadPoolServer, and TSimpleServer usually wait until
-    // they see the first byte of a request before calling processContext().
-    // However, they don't wait for the first byte of the very first request,
-    // and instead immediately call processContext() before any data is
-    // received.
-    //
-    // TNonblockingServer always waits until receiving the full request before
-    // calling processContext().
+  virtual void processContext(void* serverContext,
+                              boost::shared_ptr<transport::TTransport> transport) {
+// TODO: We currently don't test the behavior of the processContext()
+// calls.  The various server implementations call processContext() at
+// slightly different times, and it is too annoying to try and account for
+// their various differences.
+//
+// TThreadedServer, TThreadPoolServer, and TSimpleServer usually wait until
+// they see the first byte of a request before calling processContext().
+// However, they don't wait for the first byte of the very first request,
+// and instead immediately call processContext() before any data is
+// received.
+//
+// TNonblockingServer always waits until receiving the full request before
+// calling processContext().
 #if 0
     ConnContext* context = reinterpret_cast<ConnContext*>(serverContext);
     log_->append(EventLog::ET_PROCESS, context->id, 0);
@@ -250,16 +240,14 @@ class ServerEventHandler : public server::TServerEventHandler {
 #endif
   }
 
- protected:
+protected:
   uint32_t nextId_;
   boost::shared_ptr<EventLog> log_;
 };
 
 class ProcessorEventHandler : public TProcessorEventHandler {
- public:
-  ProcessorEventHandler(const boost::shared_ptr<EventLog>& log) :
-      nextId_(1),
-      log_(log) {}
+public:
+  ProcessorEventHandler(const boost::shared_ptr<EventLog>& log) : nextId_(1), log_(log) {}
 
   void* getContext(const char* fnName, void* serverContext) {
     ConnContext* connContext = reinterpret_cast<ConnContext*>(serverContext);
@@ -267,71 +255,65 @@ class ProcessorEventHandler : public TProcessorEventHandler {
     CallContext* context = new CallContext(connContext, nextId_, fnName);
     ++nextId_;
 
-    log_->append(EventLog::ET_CALL_STARTED, connContext->id, context->id,
-                 fnName);
+    log_->append(EventLog::ET_CALL_STARTED, connContext->id, context->id, fnName);
     return context;
   }
 
   void freeContext(void* ctx, const char* fnName) {
     CallContext* context = reinterpret_cast<CallContext*>(ctx);
     checkName(context, fnName);
-    log_->append(EventLog::ET_CALL_FINISHED, context->connContext->id,
-                 context->id, fnName);
+    log_->append(EventLog::ET_CALL_FINISHED, context->connContext->id, context->id, fnName);
     delete context;
   }
 
   void preRead(void* ctx, const char* fnName) {
     CallContext* context = reinterpret_cast<CallContext*>(ctx);
     checkName(context, fnName);
-    log_->append(EventLog::ET_PRE_READ, context->connContext->id, context->id,
-                 fnName);
+    log_->append(EventLog::ET_PRE_READ, context->connContext->id, context->id, fnName);
   }
 
   void postRead(void* ctx, const char* fnName, uint32_t bytes) {
     THRIFT_UNUSED_VARIABLE(bytes);
     CallContext* context = reinterpret_cast<CallContext*>(ctx);
     checkName(context, fnName);
-    log_->append(EventLog::ET_POST_READ, context->connContext->id, context->id,
-                 fnName);
+    log_->append(EventLog::ET_POST_READ, context->connContext->id, context->id, fnName);
   }
 
   void preWrite(void* ctx, const char* fnName) {
     CallContext* context = reinterpret_cast<CallContext*>(ctx);
     checkName(context, fnName);
-    log_->append(EventLog::ET_PRE_WRITE, context->connContext->id, context->id,
-                 fnName);
+    log_->append(EventLog::ET_PRE_WRITE, context->connContext->id, context->id, fnName);
   }
 
   void postWrite(void* ctx, const char* fnName, uint32_t bytes) {
     THRIFT_UNUSED_VARIABLE(bytes);
     CallContext* context = reinterpret_cast<CallContext*>(ctx);
     checkName(context, fnName);
-    log_->append(EventLog::ET_POST_WRITE, context->connContext->id,
-                 context->id, fnName);
+    log_->append(EventLog::ET_POST_WRITE, context->connContext->id, context->id, fnName);
   }
 
   void asyncComplete(void* ctx, const char* fnName) {
     CallContext* context = reinterpret_cast<CallContext*>(ctx);
     checkName(context, fnName);
-    log_->append(EventLog::ET_ASYNC_COMPLETE, context->connContext->id,
-                 context->id, fnName);
+    log_->append(EventLog::ET_ASYNC_COMPLETE, context->connContext->id, context->id, fnName);
   }
 
   void handlerError(void* ctx, const char* fnName) {
     CallContext* context = reinterpret_cast<CallContext*>(ctx);
     checkName(context, fnName);
-    log_->append(EventLog::ET_HANDLER_ERROR, context->connContext->id,
-                 context->id, fnName);
+    log_->append(EventLog::ET_HANDLER_ERROR, context->connContext->id, context->id, fnName);
   }
 
- protected:
+protected:
   void checkName(const CallContext* context, const char* fnName) {
     // Note: we can't use BOOST_CHECK_EQUAL here, since the handler runs in a
     // different thread from the test functions.  Just abort if the names are
     // different
     if (context->name != fnName) {
-      fprintf(stderr, "call context name mismatch: \"%s\" != \"%s\"\n",
-              context->name.c_str(), fnName);
+      fprintf(stderr,
+              "call context name mismatch: \"%s\" != \"%s\"\n",
+              context->name.c_str(),
+              fnName);
       fflush(stderr);
       abort();
     }
@@ -340,7 +322,8 @@ class ProcessorEventHandler : public TProcessorEventHandler {
   uint32_t nextId_;
   boost::shared_ptr<EventLog> log_;
 };
-
-}}} // apache::thrift::test
+}
+}
+} // apache::thrift::test
 
 #endif // _THRIFT_PROCESSOR_TEST_HANDLERS_H_