THRIFT-5591 Add uuid type to IDL and implement reference code (+ improved self-tests)
Client: compiler general, netstd, Delphi
Patch: Jens Geyer
diff --git a/lib/delphi/test/TestClient.pas b/lib/delphi/test/TestClient.pas
index 040f815..86235eb 100644
--- a/lib/delphi/test/TestClient.pas
+++ b/lib/delphi/test/TestClient.pas
@@ -34,7 +34,7 @@
 interface
 
 uses
-  Windows, SysUtils, Classes, Math, ComObj, ActiveX,
+  Classes, Windows, SysUtils, Math, ActiveX, ComObj,
   {$IFDEF SupportsAsync} System.Threading, {$ENDIF}
   DateUtils,
   Generics.Collections,
@@ -393,6 +393,7 @@
   i32 : Integer;
   i64 : Int64;
   binOut,binIn : TBytes;
+  guidIn, guidOut : TGuid;
   dub : Double;
   o : IXtruct;
   o2 : IXtruct2;
@@ -543,6 +544,16 @@
   i64 := client.testI64(-34359738368);
   Expect( i64 = -34359738368, 'testI64(-34359738368) = ' + IntToStr( i64));
 
+  guidOut := StringToGUID('{00112233-4455-6677-8899-AABBCCDDEEFF}');
+  Console.WriteLine('testUuid('+GUIDToString(guidOut)+')');
+  try
+    guidIn := client.testUuid(guidOut);
+    Expect( IsEqualGUID(guidIn, guidOut), 'testUuid('+GUIDToString(guidOut)+') = '+GUIDToString(guidIn));
+  except
+    on e:TApplicationException do Console.WriteLine('testUuid(): '+e.Message);
+    on e:Exception do Expect( FALSE, 'testUuid(): Unexpected exception "'+e.ClassName+'": '+e.Message);
+  end;
+
   // random binary small
   for testsize := Low(TTestSize) to High(TTestSize) do begin
     binOut := PrepareBinaryData( TRUE, testsize);
diff --git a/lib/delphi/test/TestServer.pas b/lib/delphi/test/TestServer.pas
index d7cc026..3ae82a1 100644
--- a/lib/delphi/test/TestServer.pas
+++ b/lib/delphi/test/TestServer.pas
@@ -67,6 +67,7 @@
         function testI64(const thing: Int64): Int64;
         function testDouble(const thing: Double): Double;
         function testBinary(const thing: TBytes): TBytes;
+        function testUuid(const thing: System.TGuid): System.TGuid;
         function testStruct(const thing: IXtruct): IXtruct;
         function testNest(const thing: IXtruct2): IXtruct2;
         function testMap(const thing: IThriftDictionary<Integer, Integer>): IThriftDictionary<Integer, Integer>;
@@ -150,6 +151,12 @@
   Result := thing;
 end;
 
+function TTestServer.TTestHandlerImpl.testUuid(const thing: System.TGuid): System.TGuid;
+begin
+  Console.WriteLine('testUuid('+GUIDToString(thing)+')');
+  Result := thing;
+end;
+
 function TTestServer.TTestHandlerImpl.testEnum(thing: TNumberz): TNumberz;
 begin
   Console.WriteLine('testEnum(' + EnumUtils<TNumberz>.ToString(Ord(thing)) + ')');
diff --git a/lib/delphi/test/client.dproj b/lib/delphi/test/client.dproj
index c57424d..ae6683d 100644
--- a/lib/delphi/test/client.dproj
+++ b/lib/delphi/test/client.dproj
@@ -1,22 +1,4 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
-   http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-	<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+	<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 		<PropertyGroup>
 			<ProjectGuid>{F262F488-F81C-4B6E-8694-518C54CBB8F3}</ProjectGuid>
 			<MainSource>client.dpr</MainSource>
@@ -142,7 +124,9 @@
 						<VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
 						<VersionInfoKeys Name="Comments"/>
 					</VersionInfoKeys>
-					<Parameters/>
+					<Parameters>
+						<Parameters Name="RunParams">--protocol=compact  </Parameters>
+					</Parameters>
 				</Delphi.Personality>
 				<Platforms>
 					<Platform value="Win32">True</Platform>
diff --git a/lib/delphi/test/serializer/TestSerializer.Data.pas b/lib/delphi/test/serializer/TestSerializer.Data.pas
index 4b8cc66..269e307 100644
--- a/lib/delphi/test/serializer/TestSerializer.Data.pas
+++ b/lib/delphi/test/serializer/TestSerializer.Data.pas
@@ -23,6 +23,8 @@
 
 uses
   SysUtils,
+  ActiveX,
+  ComObj,
   Thrift.Protocol,
   Thrift.Collections,
   DebugProtoTest;
@@ -193,6 +195,8 @@
   // !!
   result.setZomg_unicode( UnicodeString( us));
 
+  result.Rfc4122_uuid := TGuid.Create('{00112233-4455-6677-8899-aabbccddeeff}');
+
   {$IF cDebugProtoTest_Option_AnsiStr_Binary}
   result.SetBase64('base64');
   {$ELSEIF cDebugProtoTest_Option_COM_Types}
diff --git a/lib/delphi/test/serializer/TestSerializer.Tests.pas b/lib/delphi/test/serializer/TestSerializer.Tests.pas
index 443a22d..6ed1a48 100644
--- a/lib/delphi/test/serializer/TestSerializer.Tests.pas
+++ b/lib/delphi/test/serializer/TestSerializer.Tests.pas
@@ -43,6 +43,7 @@
   System_,
   DebugProtoTest;
 
+{$TYPEINFO ON}
 
 type
   TFactoryPair = record
@@ -208,6 +209,7 @@
   ASSERT( Abs( tested.Double_precision - correct.Double_precision) < 1E-12);
   ASSERT( tested.Some_characters = correct.Some_characters);
   ASSERT( tested.Zomg_unicode = correct.Zomg_unicode);
+  ASSERT( tested.Rfc4122_uuid = correct.Rfc4122_uuid);
   ASSERT( tested.What_who = correct.What_who);
 
   ASSERT( LengthOf(tested.Base64) = LengthOf(correct.Base64));
@@ -303,9 +305,9 @@
 
 
 class function TTestSerializer.UserFriendlyName( const method : TMethod) : string;
+const NAMES : array[TMethod] of string = ('TBytes','Stream');
 begin
-  result := EnumUtils<TMethod>.ToString(Ord(method));
-  result := StringReplace( result, 'mt_', '', [rfReplaceAll]);
+  result := NAMES[method];
 end;
 
 
@@ -342,7 +344,7 @@
     config : IThriftConfiguration;
 begin
   config := TThriftConfigurationImpl.Create;
-  config.MaxMessageSize := 0;   // we don't read anything here
+  //config.MaxMessageSize := 0;   // we don't read anything here
 
   serial := TSerializer.Create( factory.prot, factory.trans, config);
   try
@@ -358,7 +360,7 @@
     config : IThriftConfiguration;
 begin
   config := TThriftConfigurationImpl.Create;
-  config.MaxMessageSize := 0;   // we don't read anything here
+  //config.MaxMessageSize := 0;   // we don't read anything here
 
   serial := TSerializer.Create( factory.prot, factory.trans, config);
   try
diff --git a/lib/delphi/test/server.dproj b/lib/delphi/test/server.dproj
index 9f7e5c6..151f7ee 100644
--- a/lib/delphi/test/server.dproj
+++ b/lib/delphi/test/server.dproj
@@ -1,22 +1,4 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
-   http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-	<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+	<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 		<PropertyGroup>
 			<ProjectGuid>{07CEDA3D-0963-40FE-B3C2-0ED4E24DE067}</ProjectGuid>
 			<MainSource>server.dpr</MainSource>
@@ -140,6 +122,9 @@
 						<VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
 						<VersionInfoKeys Name="Comments"/>
 					</VersionInfoKeys>
+					<Parameters>
+						<Parameters Name="RunParams">--protocol=compact  </Parameters>
+					</Parameters>
 				</Delphi.Personality>
 				<Platforms>
 					<Platform value="Win32">True</Platform>