THRIFT-5772: UUID support for c++ #2952
Client: cpp
Patch: CJCombrink

This closes #2952
diff --git a/test/cpp/CMakeLists.txt b/test/cpp/CMakeLists.txt
index f693a27..a6c1fd5 100644
--- a/test/cpp/CMakeLists.txt
+++ b/test/cpp/CMakeLists.txt
@@ -100,7 +100,7 @@
 #
 
 add_custom_command(OUTPUT gen-cpp/SecondService.cpp gen-cpp/SecondService.h gen-cpp/ThriftTest.cpp gen-cpp/ThriftTest.h gen-cpp/ThriftTest_types.cpp gen-cpp/ThriftTest_constants.cpp
-    COMMAND ${THRIFT_COMPILER} --gen cpp:templates,cob_style -r ${PROJECT_SOURCE_DIR}/test/v0.16/ThriftTest.thrift
+    COMMAND ${THRIFT_COMPILER} --gen cpp:templates,cob_style -r ${PROJECT_SOURCE_DIR}/test/ThriftTest.thrift
 )
 
 add_custom_command(OUTPUT gen-cpp/Service.cpp
diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp
index c4146cc..fd04ed8 100644
--- a/test/cpp/src/TestClient.cpp
+++ b/test/cpp/src/TestClient.cpp
@@ -70,7 +70,7 @@
 //
 
 template<typename Proto>
-class TPedanticProtocol : public Proto 
+class TPedanticProtocol : public Proto
 {
     public:
         TPedanticProtocol(std::shared_ptr<TTransport>& transport)
@@ -178,6 +178,18 @@
     return_code |= ERR_BASETYPES;                                                                  \
   }
 
+#define UUID_TEST(func, value, expected)                                                           \
+  cout << #func "(" << value << ") = ";                                                            \
+  try {                                                                                            \
+    if (!print_eq(expected, testClient.func(value)))                                               \
+      return_code |= ERR_BASETYPES;                                                                \
+  } catch (TTransportException&) {                                                                 \
+    throw;                                                                                         \
+  } catch (exception & ex) {                                                                       \
+    cout << "*** FAILED ***" << endl << ex.what() << endl;                                         \
+    return_code |= ERR_BASETYPES;                                                                  \
+  }
+
 int binary_test(ThriftTestClient& testClient, string::size_type siz);
 
 BOOST_CONSTEXPR_OR_CONST int ERR_BASETYPES = 1;
@@ -638,6 +650,15 @@
       if (i > 0) { i *= 2; } else { ++i; }
     }
 
+    /**
+     * UUID TEST
+     */
+    const std::string expected_uuid{"5e2ab188-1726-4e75-a04f-1ed9a6a89c4c"};
+    UUID_TEST(testUuid, std::string{"{5e2ab188-1726-4e75-a04f-1ed9a6a89c4c}"}, expected_uuid);
+    UUID_TEST(testUuid, std::string{"5e2ab188-1726-4e75-a04f-1ed9a6a89c4c"}, expected_uuid);
+    UUID_TEST(testUuid, std::string{"5e2ab18817264e75a04f1ed9a6a89c4c"}, expected_uuid);
+    UUID_TEST(testUuid, std::string{"{5e2ab18817264e75a04f1ed9a6a89c4c}"}, expected_uuid);
+    UUID_TEST(testUuid, std::string{}, std::string{"00000000-0000-0000-0000-000000000000"});
 
     /**
      * STRUCT TEST
diff --git a/test/cpp/src/TestServer.cpp b/test/cpp/src/TestServer.cpp
index 65317f8..6c61f40 100644
--- a/test/cpp/src/TestServer.cpp
+++ b/test/cpp/src/TestServer.cpp
@@ -132,6 +132,11 @@
     _return = thing;
   }
 
+  std::string testUuid(const std::string thing) override {
+    printf("testUuid(\"{%s}\")\n", thing.c_str());
+    return thing;
+  }
+
   void testStruct(Xtruct& out, const Xtruct& thing) override {
     printf("testStruct({\"%s\", %d, %d, %" PRId64 "})\n",
            thing.string_thing.c_str(),
@@ -442,6 +447,11 @@
     cob(res);
   }
 
+  void testUuid(::std::function<void(std::string const& _return)> cob, const std::string thing) override {
+    std::string res = _delegate->testUuid(thing);
+    cob(res);
+  }
+
   void testStruct(std::function<void(Xtruct const& _return)> cob, const Xtruct& thing) override {
     Xtruct res;
     _delegate->testStruct(res, thing);