You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2015/03/03 21:36:02 UTC
[2/3] thrift git commit: THRIFT-3018 Compact protocol for Delphi,
one missing test case added Client: Delphi Patch: Jens Geyer
THRIFT-3018 Compact protocol for Delphi, one missing test case added
Client: Delphi
Patch: Jens Geyer
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/a6ea4442
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/a6ea4442
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/a6ea4442
Branch: refs/heads/master
Commit: a6ea4442dddfac1342835a30b1c8a81adb207a46
Parents: 3811e59
Author: Jens Geyer <je...@apache.org>
Authored: Mon Mar 2 23:06:57 2015 +0100
Committer: Jens Geyer <je...@apache.org>
Committed: Tue Mar 3 21:35:40 2015 +0100
----------------------------------------------------------------------
lib/delphi/src/Thrift.Protocol.Compact.pas | 27 +++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/a6ea4442/lib/delphi/src/Thrift.Protocol.Compact.pas
----------------------------------------------------------------------
diff --git a/lib/delphi/src/Thrift.Protocol.Compact.pas b/lib/delphi/src/Thrift.Protocol.Compact.pas
index 89bf9fb..818ef5d 100644
--- a/lib/delphi/src/Thrift.Protocol.Compact.pas
+++ b/lib/delphi/src/Thrift.Protocol.Compact.pas
@@ -522,7 +522,6 @@ end;
procedure TCompactProtocolImpl.WriteDouble( const dub: Double);
var data : TBytes;
begin
- SetLength( data, 8);
fixedLongToBytes( DoubleToInt64Bits(dub), data);
Transport.Write( data);
end;
@@ -629,7 +628,7 @@ end;
// Convert a Int64 into 8 little-endian bytes in buf
class procedure TCompactProtocolImpl.fixedLongToBytes( const n : Int64; var buf : TBytes);
begin
- ASSERT( Length(buf) >= 8);
+ SetLength( buf, 8);
buf[0] := Byte( n and $FF);
buf[1] := Byte((n shr 8) and $FF);
buf[2] := Byte((n shr 16) and $FF);
@@ -1064,10 +1063,34 @@ end;
{$ENDIF}
+{$IFDEF Debug}
+procedure TestLongBytes;
+
+ procedure Test( const test : Int64);
+ var buf : TBytes;
+ begin
+ TCompactProtocolImpl.fixedLongToBytes( test, buf);
+ ASSERT( TCompactProtocolImpl.bytesToLong( buf) = test, IntToStr(test));
+ end;
+
+var i : Integer;
+begin
+ Test( 0);
+ for i := 0 to 62 do begin
+ Test( +(Int64(1) shl i));
+ Test( -(Int64(1) shl i));
+ end;
+ Test( Int64($7FFFFFFFFFFFFFFF));
+ Test( Int64($8000000000000000));
+end;
+{$ENDIF}
+
+
initialization
{$IFDEF Debug}
TestDoubleToInt64Bits;
TestZigZag;
+ TestLongBytes;
{$ENDIF}
end.