diff --git a/lib/cpp/test/OptionalRequiredTest.cpp b/lib/cpp/test/OptionalRequiredTest.cpp
index 3f60754..b0e5ef7 100644
--- a/lib/cpp/test/OptionalRequiredTest.cpp
+++ b/lib/cpp/test/OptionalRequiredTest.cpp
@@ -21,18 +21,15 @@
  * details.
  */
 
-#include <cassert>
 #include <map>
-#include <iostream>
 #include <thrift/protocol/TDebugProtocol.h>
 #include <thrift/protocol/TBinaryProtocol.h>
 #include <thrift/transport/TBufferTransports.h>
 #include "gen-cpp/OptionalRequiredTest_types.h"
 
-using std::cout;
-using std::endl;
-using std::map;
-using std::string;
+#define BOOST_TEST_MODULE OptionalRequiredTest
+#include <boost/test/unit_test.hpp>
+
 using namespace thrift::test;
 using namespace apache::thrift;
 using namespace apache::thrift::transport;
@@ -49,7 +46,7 @@
   } catch (TProtocolException & ex) {
     worked = false;
   }
-  assert(worked == should_work);
+  BOOST_CHECK(worked == should_work);
 }
 */
 
@@ -60,219 +57,330 @@
   r.read(&protocol);
 }
 
-int main() {
+BOOST_AUTO_TEST_CASE(test_optional_required_1) {
+  OldSchool o;
 
-  cout << "This old school struct should have three fields." << endl;
-  {
-    OldSchool o;
-    cout << ThriftDebugString(o) << endl;
-  }
-  cout << endl;
+  const std::string expected_result(
+    "OldSchool {\n"
+    "  01: im_int (i16) = 0,\n"
+    "  02: im_str (string) = \"\",\n"
+    "  03: im_big (list) = list<map>[0] {\n"
+    "  },\n"
+    "}");
+  const std::string result(apache::thrift::ThriftDebugString(o));
 
-  cout << "Setting a value before setting isset." << endl;
-  {
-    Simple s;
-    cout << ThriftDebugString(s) << endl;
-    s.im_optional = 10;
-    cout << ThriftDebugString(s) << endl;
-    s.__isset.im_optional = true;
-    cout << ThriftDebugString(s) << endl;
-  }
-  cout << endl;
+  BOOST_CHECK_MESSAGE(!expected_result.compare(result),
+    "Expected:\n" << expected_result << "\nGotten:\n" << result);
+}
 
-  cout << "Setting isset before setting a value." << endl;
-  {
-    Simple s;
-    cout << ThriftDebugString(s) << endl;
-    s.__isset.im_optional = true;
-    cout << ThriftDebugString(s) << endl;
-    s.im_optional = 10;
-    cout << ThriftDebugString(s) << endl;
-  }
-  cout << endl;
+BOOST_AUTO_TEST_CASE(test_optional_required_2_1) {
+  Simple s;
 
+  const std::string expected_result(
+    "Simple {\n"
+    "  01: im_default (i16) = 0,\n"
+    "  02: im_required (i16) = 0,\n"
+    "}");
+  const std::string result(apache::thrift::ThriftDebugString(s));
+
+  BOOST_CHECK_MESSAGE(!expected_result.compare(result),
+    "Expected:\n" << expected_result << "\nGotten:\n" << result);
+}
+
+BOOST_AUTO_TEST_CASE(test_optional_required_2_2) {
+  Simple s;
+  s.im_optional = 10;
+
+  const std::string expected_result(
+    "Simple {\n"
+    "  01: im_default (i16) = 0,\n"
+    "  02: im_required (i16) = 0,\n"
+    "}");
+  const std::string result(apache::thrift::ThriftDebugString(s));
+
+  BOOST_CHECK_MESSAGE(!expected_result.compare(result),
+    "Expected:\n" << expected_result << "\nGotten:\n" << result);
+}
+
+BOOST_AUTO_TEST_CASE(test_optional_required_2_3) {
+  Simple s;
+  s.im_optional = 10;
+  s.__isset.im_optional = true;
+
+  const std::string expected_result(
+    "Simple {\n"
+    "  01: im_default (i16) = 0,\n"
+    "  02: im_required (i16) = 0,\n"
+    "  03: im_optional (i16) = 10,\n"
+    "}");
+  const std::string result(apache::thrift::ThriftDebugString(s));
+
+  BOOST_CHECK_MESSAGE(!expected_result.compare(result),
+    "Expected:\n" << expected_result << "\nGotten:\n" << result);
+}
+
+BOOST_AUTO_TEST_CASE(test_optional_required_2_4) {
+  Simple s;
+  s.__isset.im_optional = true;
+
+  const std::string expected_result(
+    "Simple {\n"
+    "  01: im_default (i16) = 0,\n"
+    "  02: im_required (i16) = 0,\n"
+    "  03: im_optional (i16) = 0,\n"
+    "}");
+  const std::string result(apache::thrift::ThriftDebugString(s));
+
+  BOOST_CHECK_MESSAGE(!expected_result.compare(result),
+    "Expected:\n" << expected_result << "\nGotten:\n" << result);
+}
+
+BOOST_AUTO_TEST_CASE(test_optional_required_2_5) {
+  Simple s;
+  s.__isset.im_optional = true;
+  s.im_optional = 10;
+
+  const std::string expected_result(
+    "Simple {\n"
+    "  01: im_default (i16) = 0,\n"
+    "  02: im_required (i16) = 0,\n"
+    "  03: im_optional (i16) = 10,\n"
+    "}");
+  const std::string result(apache::thrift::ThriftDebugString(s));
+
+  BOOST_CHECK_MESSAGE(!expected_result.compare(result),
+    "Expected:\n" << expected_result << "\nGotten:\n" << result);
+}
+
+BOOST_AUTO_TEST_CASE(test_optional_required_3) {
   // assign/copy-construct with non-required fields
-  {
-    Simple s1, s2;
-    s1.__isset.im_default = true;
-    s1.__set_im_optional(10);
-    assert(s1.__isset.im_default);
-    assert(s1.__isset.im_optional);
 
-    s2 = s1;
+  Simple s1, s2;
+  s1.__isset.im_default = true;
+  s1.__set_im_optional(10);
+  BOOST_CHECK(s1.__isset.im_default);
+  BOOST_CHECK(s1.__isset.im_optional);
 
-    assert(s2.__isset.im_default);
-    assert(s2.__isset.im_optional);
+  s2 = s1;
 
-    Simple s3(s1);
+  BOOST_CHECK(s2.__isset.im_default);
+  BOOST_CHECK(s2.__isset.im_optional);
 
-    assert(s3.__isset.im_default);
-    assert(s3.__isset.im_optional);
-  }
+  Simple s3(s1);
 
+  BOOST_CHECK(s3.__isset.im_default);
+  BOOST_CHECK(s3.__isset.im_optional);
+}
+
+BOOST_AUTO_TEST_CASE(test_optional_required_4) {
   // Write-to-read with optional fields.
-  {
-    Simple s1, s2, s3;
-    s1.im_optional = 10;
-    assert(!s1.__isset.im_default);
-    // assert(!s1.__isset.im_required);  // Compile error.
-    assert(!s1.__isset.im_optional);
 
-    write_to_read(s1, s2);
+  Simple s1, s2, s3;
+  s1.im_optional = 10;
+  BOOST_CHECK(!s1.__isset.im_default);
+  // BOOST_CHECK(!s1.__isset.im_required);  // Compile error.
+  BOOST_CHECK(!s1.__isset.im_optional);
 
-    assert(s2.__isset.im_default);
-    // assert( s2.__isset.im_required);  // Compile error.
-    assert(!s2.__isset.im_optional);
-    assert(s3.im_optional == 0);
+  write_to_read(s1, s2);
 
-    s1.__isset.im_optional = true;
-    write_to_read(s1, s3);
+  BOOST_CHECK(s2.__isset.im_default);
+  // BOOST_CHECK( s2.__isset.im_required);  // Compile error.
+  BOOST_CHECK(!s2.__isset.im_optional);
+  BOOST_CHECK(s3.im_optional == 0);
 
-    assert(s3.__isset.im_default);
-    // assert( s3.__isset.im_required);  // Compile error.
-    assert(s3.__isset.im_optional);
-    assert(s3.im_optional == 10);
-  }
+  s1.__isset.im_optional = true;
+  write_to_read(s1, s3);
 
+  BOOST_CHECK(s3.__isset.im_default);
+  // BOOST_CHECK( s3.__isset.im_required);  // Compile error.
+  BOOST_CHECK(s3.__isset.im_optional);
+  BOOST_CHECK(s3.im_optional == 10);
+}
+
+BOOST_AUTO_TEST_CASE(test_optional_required_5) {
   // Writing between optional and default.
-  {
-    Tricky1 t1;
-    Tricky2 t2;
 
-    t2.im_optional = 10;
-    write_to_read(t2, t1);
-    write_to_read(t1, t2);
-    assert(!t1.__isset.im_default);
-    assert(t2.__isset.im_optional);
-    assert(t1.im_default == t2.im_optional);
-    assert(t1.im_default == 0);
-  }
+  Tricky1 t1;
+  Tricky2 t2;
 
+  t2.im_optional = 10;
+  write_to_read(t2, t1);
+  write_to_read(t1, t2);
+  BOOST_CHECK(!t1.__isset.im_default);
+  BOOST_CHECK(t2.__isset.im_optional);
+  BOOST_CHECK(t1.im_default == t2.im_optional);
+  BOOST_CHECK(t1.im_default == 0);
+}
+
+BOOST_AUTO_TEST_CASE(test_optional_required_6) {
   // Writing between default and required.
-  {
-    Tricky1 t1;
-    Tricky3 t3;
-    write_to_read(t1, t3);
-    write_to_read(t3, t1);
-    assert(t1.__isset.im_default);
-  }
 
+  Tricky1 t1;
+  Tricky3 t3;
+  write_to_read(t1, t3);
+  write_to_read(t3, t1);
+  BOOST_CHECK(t1.__isset.im_default);
+}
+
+BOOST_AUTO_TEST_CASE(test_optional_required_7) {
   // Writing between optional and required.
-  {
-    Tricky2 t2;
-    Tricky3 t3;
-    t2.__isset.im_optional = true;
-    write_to_read(t2, t3);
-    write_to_read(t3, t2);
-  }
 
+  Tricky2 t2;
+  Tricky3 t3;
+  t2.__isset.im_optional = true;
+  write_to_read(t2, t3);
+  write_to_read(t3, t2);
+}
+
+BOOST_AUTO_TEST_CASE(test_optional_required_8) {
   // Mu-hu-ha-ha-ha!
-  {
-    Tricky2 t2;
-    Tricky3 t3;
-    try {
-      write_to_read(t2, t3);
-      abort();
-    } catch (const TProtocolException&) {
-    }
 
-    write_to_read(t3, t2);
-    assert(t2.__isset.im_optional);
+  Tricky2 t2;
+  Tricky3 t3;
+  try {
+    write_to_read(t2, t3);
+    abort();
+  } catch (const TProtocolException&) {
   }
 
-  cout << "Complex struct, simple test." << endl;
-  {
-    Complex c;
-    cout << ThriftDebugString(c) << endl;
-  }
+  write_to_read(t3, t2);
+  BOOST_CHECK(t2.__isset.im_optional);
+}
 
-  {
-    Tricky1 t1;
-    Tricky2 t2;
-    // Compile error.
-    //(void)(t1 == t2);
-  }
+BOOST_AUTO_TEST_CASE(test_optional_required_9) {
+  Complex c;
 
-  {
-    OldSchool o1, o2, o3;
-    assert(o1 == o2);
-    o1.im_int = o2.im_int = 10;
-    assert(o1 == o2);
-    o1.__isset.im_int = true;
-    o2.__isset.im_int = false;
-    assert(o1 == o2);
-    o1.im_int = 20;
-    o1.__isset.im_int = false;
-    assert(o1 != o2);
-    o1.im_int = 10;
-    assert(o1 == o2);
-    o1.im_str = o2.im_str = "foo";
-    assert(o1 == o2);
-    o1.__isset.im_str = o2.__isset.im_str = true;
-    assert(o1 == o2);
-    map<int32_t, string> mymap;
-    mymap[1] = "bar";
-    mymap[2] = "baz";
-    o1.im_big.push_back(map<int32_t, string>());
-    assert(o1 != o2);
-    o2.im_big.push_back(map<int32_t, string>());
-    assert(o1 == o2);
-    o2.im_big.push_back(mymap);
-    assert(o1 != o2);
-    o1.im_big.push_back(mymap);
-    assert(o1 == o2);
+  const std::string expected_result(
+    "Complex {\n"
+    "  01: cp_default (i16) = 0,\n"
+    "  02: cp_required (i16) = 0,\n"
+    "  04: the_map (map) = map<i16,struct>[0] {\n"
+    "  },\n"
+    "  05: req_simp (struct) = Simple {\n"
+    "    01: im_default (i16) = 0,\n"
+    "    02: im_required (i16) = 0,\n"
+    "  },\n"
+    "}");
+  const std::string result(apache::thrift::ThriftDebugString(c));
 
-    TBinaryProtocol protocol(boost::shared_ptr<TTransport>(new TMemoryBuffer));
-    o1.write(&protocol);
+  BOOST_CHECK_MESSAGE(!expected_result.compare(result),
+    "Expected:\n" << expected_result << "\nGotten:\n" << result);
+}
 
-    o1.im_big.push_back(mymap);
-    mymap[3] = "qux";
-    o2.im_big.push_back(mymap);
-    assert(o1 != o2);
-    o1.im_big.back()[3] = "qux";
-    assert(o1 == o2);
+BOOST_AUTO_TEST_CASE(test_optional_required_10) {
+  Tricky1 t1;
+  Tricky2 t2;
+  // Compile error.
+  //(void)(t1 == t2);
+}
 
-    o3.read(&protocol);
-    o3.im_big.push_back(mymap);
-    assert(o1 == o3);
+BOOST_AUTO_TEST_CASE(test_optional_required_11) {
+  OldSchool o1, o2, o3;
+  BOOST_CHECK(o1 == o2);
+  o1.im_int = o2.im_int = 10;
+  BOOST_CHECK(o1 == o2);
+  o1.__isset.im_int = true;
+  o2.__isset.im_int = false;
+  BOOST_CHECK(o1 == o2);
+  o1.im_int = 20;
+  o1.__isset.im_int = false;
+  BOOST_CHECK(o1 != o2);
+  o1.im_int = 10;
+  BOOST_CHECK(o1 == o2);
+  o1.im_str = o2.im_str = "foo";
+  BOOST_CHECK(o1 == o2);
+  o1.__isset.im_str = o2.__isset.im_str = true;
+  BOOST_CHECK(o1 == o2);
+  std::map<int32_t, std::string> mymap;
+  mymap[1] = "bar";
+  mymap[2] = "baz";
+  o1.im_big.push_back(std::map<int32_t, std::string>());
+  BOOST_CHECK(o1 != o2);
+  o2.im_big.push_back(std::map<int32_t, std::string>());
+  BOOST_CHECK(o1 == o2);
+  o2.im_big.push_back(mymap);
+  BOOST_CHECK(o1 != o2);
+  o1.im_big.push_back(mymap);
+  BOOST_CHECK(o1 == o2);
 
-    // cout << ThriftDebugString(o3) << endl;
-  }
+  TBinaryProtocol protocol(boost::shared_ptr<TTransport>(new TMemoryBuffer));
+  o1.write(&protocol);
 
-  {
-    Tricky2 t1, t2;
-    assert(t1.__isset.im_optional == false);
-    assert(t2.__isset.im_optional == false);
-    assert(t1 == t2);
-    t1.im_optional = 5;
-    assert(t1 == t2);
-    t2.im_optional = 5;
-    assert(t1 == t2);
-    t1.__isset.im_optional = true;
-    assert(t1 != t2);
-    t2.__isset.im_optional = true;
-    assert(t1 == t2);
-    t1.im_optional = 10;
-    assert(t1 != t2);
-    t2.__isset.im_optional = false;
-    assert(t1 != t2);
-  }
+  o1.im_big.push_back(mymap);
+  mymap[3] = "qux";
+  o2.im_big.push_back(mymap);
+  BOOST_CHECK(o1 != o2);
+  o1.im_big.back()[3] = "qux";
+  BOOST_CHECK(o1 == o2);
+  
+  o3.read(&protocol);
+  o3.im_big.push_back(mymap);
+  BOOST_CHECK(o1 == o3);
 
-  {
-    OptionalDefault t1, t2;
-    cout << ThriftDebugString(t1) << endl;
-    assert(t1.__isset.opt_int == true);
-    assert(t1.__isset.opt_str == true);
-    assert(t1.opt_int == t2.opt_int);
-    assert(t1.opt_str == t2.opt_str);
+  const std::string expected_result(
+    "OldSchool {\n"
+    "  01: im_int (i16) = 10,\n"
+    "  02: im_str (string) = \"foo\",\n"
+    "  03: im_big (list) = list<map>[3] {\n"
+    "    [0] = map<i32,string>[0] {\n"
+    "    },\n"
+    "    [1] = map<i32,string>[2] {\n"
+    "      1 -> \"bar\",\n"
+    "      2 -> \"baz\",\n"
+    "    },\n"
+    "    [2] = map<i32,string>[3] {\n"
+    "      1 -> \"bar\",\n"
+    "      2 -> \"baz\",\n"
+    "      3 -> \"qux\",\n"
+    "    },\n"
+    "  },\n"
+    "}");
+  const std::string result(apache::thrift::ThriftDebugString(o3));
 
-    write_to_read(t1, t2);
-    cout << ThriftDebugString(t2) << endl;
-    assert(t2.__isset.opt_int == true);
-    assert(t2.__isset.opt_str == true);
-    assert(t1.opt_int == t2.opt_int);
-    assert(t1.opt_str == t2.opt_str);
-  }
+  BOOST_CHECK_MESSAGE(!expected_result.compare(result),
+    "Expected:\n" << expected_result << "\nGotten:\n" << result);
+}
 
-  return 0;
+BOOST_AUTO_TEST_CASE(test_optional_required_12) {
+  Tricky2 t1, t2;
+  BOOST_CHECK(t1.__isset.im_optional == false);
+  BOOST_CHECK(t2.__isset.im_optional == false);
+  BOOST_CHECK(t1 == t2);
+  t1.im_optional = 5;
+  BOOST_CHECK(t1 == t2);
+  t2.im_optional = 5;
+  BOOST_CHECK(t1 == t2);
+  t1.__isset.im_optional = true;
+  BOOST_CHECK(t1 != t2);
+  t2.__isset.im_optional = true;
+  BOOST_CHECK(t1 == t2);
+  t1.im_optional = 10;
+  BOOST_CHECK(t1 != t2);
+  t2.__isset.im_optional = false;
+  BOOST_CHECK(t1 != t2);
+}
+
+BOOST_AUTO_TEST_CASE(test_optional_required_13) {
+  OptionalDefault t1, t2;
+
+  BOOST_CHECK(t1.__isset.opt_int == true);
+  BOOST_CHECK(t1.__isset.opt_str == true);
+  BOOST_CHECK(t1.opt_int == t2.opt_int);
+  BOOST_CHECK(t1.opt_str == t2.opt_str);
+
+  write_to_read(t1, t2);
+  BOOST_CHECK(t2.__isset.opt_int == true);
+  BOOST_CHECK(t2.__isset.opt_str == true);
+  BOOST_CHECK(t1.opt_int == t2.opt_int);
+  BOOST_CHECK(t1.opt_str == t2.opt_str);
+
+  const std::string expected_result(
+    "OptionalDefault {\n"
+    "  01: opt_int (i16) = 1234,\n"
+    "  02: opt_str (string) = \"default\",\n"
+    "}");
+  const std::string result(apache::thrift::ThriftDebugString(t2));
+
+  BOOST_CHECK_MESSAGE(!expected_result.compare(result),
+    "Expected:\n" << expected_result << "\nGotten:\n" << result);
 }
