exceptionstruct testcase
diff --git a/lib/delphi/test/serializer/SerializerData.dpr b/lib/delphi/test/serializer/SerializerData.dpr
index 92ed00b..cb8ca3e 100644
--- a/lib/delphi/test/serializer/SerializerData.dpr
+++ b/lib/delphi/test/serializer/SerializerData.dpr
@@ -69,11 +69,18 @@
end;
+function CreateBatchGetResponse : IBatchGetResponse; stdcall;
+begin
+ result := Fixtures.CreateBatchGetResponse;
+end;
+
+
exports
CreateOneOfEach,
CreateNesting,
CreateHolyMoley,
- CreateCompactProtoTestStruct;
+ CreateCompactProtoTestStruct,
+ CreateBatchGetResponse;
begin
IsMultiThread := TRUE;
diff --git a/lib/delphi/test/serializer/SerializerData.dproj b/lib/delphi/test/serializer/SerializerData.dproj
index cfc27f8..822030f 100644
--- a/lib/delphi/test/serializer/SerializerData.dproj
+++ b/lib/delphi/test/serializer/SerializerData.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>{B523D1D7-2C9A-4B39-A6CF-69EF536D5079}</ProjectGuid>
<MainSource>SerializerData.dpr</MainSource>
@@ -100,7 +82,7 @@
</BuildConfiguration>
</ItemGroup>
<Import Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')" Project="$(BDS)\Bin\CodeGear.Delphi.Targets"/>
- <Import Condition="Exists('$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj')" Project="$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj"/>
+ <Import Condition="Exists('$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\8.0\UserTools.proj')" Project="$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\8.0\UserTools.proj"/>
<PropertyGroup>
<PreBuildEvent><![CDATA[thrift.exe -r -gen delphi:com_types ..\keywords\ReservedKeywords.thrift
thrift.exe -r -gen delphi:com_types ..\..\..\..\test\DebugProtoTest.thrift]]></PreBuildEvent>
diff --git a/lib/delphi/test/serializer/TestSerializer.Data.pas b/lib/delphi/test/serializer/TestSerializer.Data.pas
index 24f850d..fe09f67 100644
--- a/lib/delphi/test/serializer/TestSerializer.Data.pas
+++ b/lib/delphi/test/serializer/TestSerializer.Data.pas
@@ -27,6 +27,7 @@
ComObj,
Thrift.Protocol,
Thrift.Collections,
+ test.TestSerializer,
DebugProtoTest;
@@ -37,6 +38,7 @@
class function CreateNesting : INesting;
class function CreateHolyMoley : IHolyMoley;
class function CreateCompactProtoTestStruct : ICompactProtoTestStruct;
+ class function CreateBatchGetResponse : IBatchGetResponse;
// These byte arrays are serialized versions of the above structs.
// They were serialized in binary protocol using thrift 0.6.x and are used to
@@ -359,6 +361,11 @@
end;
+class function Fixtures.CreateBatchGetResponse : IBatchGetResponse;
+begin
+ result := TBatchGetResponseImpl.Create;
+ x
+end;
end.
diff --git a/lib/delphi/test/serializer/TestSerializer.Tests.pas b/lib/delphi/test/serializer/TestSerializer.Tests.pas
index e6a309e..7829d97 100644
--- a/lib/delphi/test/serializer/TestSerializer.Tests.pas
+++ b/lib/delphi/test/serializer/TestSerializer.Tests.pas
@@ -41,6 +41,7 @@
Thrift.WinHTTP,
Thrift.TypeRegistry,
System_,
+ test.ExceptionStruct,
DebugProtoTest;
{$TYPEINFO ON}
@@ -82,8 +83,10 @@
procedure Test_Serializer_Deserializer;
procedure Test_COM_Types;
procedure Test_ThriftBytesCTORs;
- procedure Test_OneOfEach( const method : TMethod; const factory : TFactoryPair; const stream : TFileStream);
- procedure Test_CompactStruct( const method : TMethod; const factory : TFactoryPair; const stream : TFileStream);
+
+ procedure Test_OneOfEach( const method : TMethod; const factory : TFactoryPair; const stream : TFileStream);
+ procedure Test_CompactStruct( const method : TMethod; const factory : TFactoryPair; const stream : TFileStream);
+ procedure Test_ExceptionStruct( const method : TMethod; const factory : TFactoryPair; const stream : TFileStream);
public
constructor Create;
@@ -100,6 +103,7 @@
function CreateNesting : INesting; stdcall; external SERIALIZERDATA_DLL;
function CreateHolyMoley : IHolyMoley; stdcall; external SERIALIZERDATA_DLL;
function CreateCompactProtoTestStruct : ICompactProtoTestStruct; stdcall; external SERIALIZERDATA_DLL;
+function CreateBatchGetResponse : IBatchGetResponse; stdcall; external SERIALIZERDATA_DLL;
{ TTestSerializer }
@@ -266,6 +270,42 @@
end;
+procedure TTestSerializer.Test_ExceptionStruct( const method : TMethod; const factory : TFactoryPair; const stream : TFileStream);
+var tested, correct : IBatchGetResponse;
+ bytes : TBytes;
+begin
+ // write
+ tested := CreateBatchGetResponse;
+ case method of
+ mt_Bytes: bytes := Serialize( tested, factory);
+ mt_Stream: begin
+ stream.Size := 0;
+ Serialize( tested, factory, stream);
+ end
+ else
+ ASSERT( FALSE);
+ end;
+
+ // init + read
+ correct := TBatchGetResponseImpl.Create;
+ case method of
+ mt_Bytes: Deserialize( bytes, tested, factory);
+ mt_Stream: begin
+ stream.Position := 0;
+ Deserialize( stream, tested, factory);
+ end
+ else
+ ASSERT( FALSE);
+ end;
+
+ // check
+ correct := CreateCompactProtoTestStruct;
+ ASSERT( correct.Field500 = tested.Field500);
+ ASSERT( correct.Field5000 = tested.Field5000);
+ ASSERT( correct.Field20000 = tested.Field20000);
+end;
+
+
procedure TTestSerializer.Test_Serializer_Deserializer;
var factory : TFactoryPair;
stream : TFileStream;
@@ -279,8 +319,9 @@
for factory in FProtocols do begin
Writeln('- '+UserFriendlyName(factory));
- Test_OneOfEach( method, factory, stream);
- Test_CompactStruct( method, factory, stream);
+ Test_OneOfEach( method, factory, stream);
+ Test_CompactStruct( method, factory, stream);
+ Test_ExceptionStruct( method, factory, stream);
end;
Writeln;
@@ -348,6 +389,7 @@
Test_Serializer_Deserializer;
Test_COM_Types;
Test_ThriftBytesCTORs;
+ Test_ExceptionStructs;
except
on e:Exception do begin
Writeln( e.ClassName+': '+ e.Message);
diff --git a/lib/delphi/test/serializer/TestSerializer.dpr b/lib/delphi/test/serializer/TestSerializer.dpr
index b78c0db..00d620a 100644
--- a/lib/delphi/test/serializer/TestSerializer.dpr
+++ b/lib/delphi/test/serializer/TestSerializer.dpr
@@ -44,6 +44,7 @@
System_ in 'gen-delphi\System_.pas',
SysUtils_ in 'gen-delphi\SysUtils_.pas',
DebugProtoTest in 'gen-delphi\DebugProtoTest.pas',
+ test.ExceptionStruct in 'gen-delphi\test.ExceptionStruct.pas',
TestSerializer.Tests in 'TestSerializer.Tests.pas';
diff --git a/lib/delphi/test/serializer/TestSerializer.dproj b/lib/delphi/test/serializer/TestSerializer.dproj
index 383e04a..572e6e5 100644
--- a/lib/delphi/test/serializer/TestSerializer.dproj
+++ b/lib/delphi/test/serializer/TestSerializer.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>{9282EDD8-7C12-41B0-8172-61C6BFA6E238}</ProjectGuid>
<MainSource>TestSerializer.dpr</MainSource>
@@ -85,6 +67,7 @@
<DCCReference Include="gen-delphi\System_.pas"/>
<DCCReference Include="gen-delphi\SysUtils_.pas"/>
<DCCReference Include="gen-delphi\DebugProtoTest.pas"/>
+ <DCCReference Include="gen-delphi\test.ExceptionStruct.pas"/>
<DCCReference Include="TestSerializer.Tests.pas"/>
<BuildConfiguration Include="Debug">
<Key>Cfg_2</Key>
@@ -99,10 +82,11 @@
</BuildConfiguration>
</ItemGroup>
<Import Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')" Project="$(BDS)\Bin\CodeGear.Delphi.Targets"/>
- <Import Condition="Exists('$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj')" Project="$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj"/>
+ <Import Condition="Exists('$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\8.0\UserTools.proj')" Project="$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\8.0\UserTools.proj"/>
<PropertyGroup>
<PreBuildEvent><![CDATA[thrift.exe -r -gen delphi:com_types,rtti ..\keywords\ReservedKeywords.thrift
-thrift.exe -r -gen delphi:com_types ..\..\..\..\test\DebugProtoTest.thrift]]></PreBuildEvent>
+thrift.exe -r -gen delphi:com_types ..\..\..\..\test\DebugProtoTest.thrift
+thrift.exe -r -gen delphi:com_types ..\..\..\..\test\ExceptionStruct.thrift]]></PreBuildEvent>
</PropertyGroup>
<ProjectExtensions>
<Borland.Personality>Delphi.Personality.12</Borland.Personality>
diff --git a/test/ExceptionStruct.thrift b/test/ExceptionStruct.thrift
index 3d1d549..b962209 100644
--- a/test/ExceptionStruct.thrift
+++ b/test/ExceptionStruct.thrift
@@ -17,7 +17,7 @@
* under the License.
*/
-namespace test.ExceptionStruct
+namespace * test.ExceptionStruct
enum ErrorCode {
GenericError,
@@ -26,13 +26,13 @@
}
struct GetRequest {
- 1: string id;
- 2: binary data # some arbitrary data
+ 1: string id
+ 2: binary data // some arbitrary data
}
struct GetResponse {
1: i32 job_nr
- 2: binary data # some arbitrary data
+ 2: binary data // some arbitrary data
}
struct BatchGetRequest {