You've already forked lazarus-ccr
JSON : native Int64 support through fcl-json ( only on fpc trunck )
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@894 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -11,6 +11,7 @@
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
}
|
}
|
||||||
{$INCLUDE wst_global.inc}
|
{$INCLUDE wst_global.inc}
|
||||||
|
{$INCLUDE wst_tests_defines.inc}
|
||||||
unit test_json;
|
unit test_json;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
@ -39,6 +40,7 @@ type
|
|||||||
function Support_ComplextType_with_SimpleContent():Boolean;override;
|
function Support_ComplextType_with_SimpleContent():Boolean;override;
|
||||||
function Support_nil():Boolean;override;
|
function Support_nil():Boolean;override;
|
||||||
class function SupportInt64() : Boolean;override;
|
class function SupportInt64() : Boolean;override;
|
||||||
|
class function SupportUInt64() : Boolean;override;
|
||||||
published
|
published
|
||||||
//procedure test_WriteBuffer();
|
//procedure test_WriteBuffer();
|
||||||
end;
|
end;
|
||||||
@ -82,6 +84,15 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
class function TTestJsonRpcFormatter.SupportInt64(): Boolean;
|
class function TTestJsonRpcFormatter.SupportInt64(): Boolean;
|
||||||
|
begin
|
||||||
|
{$IFDEF WST_HAS_JSON_INT64}
|
||||||
|
Result := True;
|
||||||
|
{$ELSE WST_HAS_JSON_INT64}
|
||||||
|
Result := False;
|
||||||
|
{$ENDIF WST_HAS_JSON_INT64}
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TTestJsonRpcFormatter.SupportUInt64(): Boolean;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
end;
|
end;
|
||||||
|
@ -429,6 +429,7 @@ type
|
|||||||
function Support_ComplextType_with_SimpleContent():Boolean;virtual;
|
function Support_ComplextType_with_SimpleContent():Boolean;virtual;
|
||||||
function Support_nil():Boolean;virtual;
|
function Support_nil():Boolean;virtual;
|
||||||
class function SupportInt64() : Boolean;virtual;
|
class function SupportInt64() : Boolean;virtual;
|
||||||
|
class function SupportUInt64() : Boolean;virtual;
|
||||||
published
|
published
|
||||||
procedure Test_AnsiChar;
|
procedure Test_AnsiChar;
|
||||||
procedure Test_AnsiChar_ScopeData;
|
procedure Test_AnsiChar_ScopeData;
|
||||||
@ -814,6 +815,11 @@ begin
|
|||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class function TTestFormatterSimpleType.SupportUInt64(): Boolean;
|
||||||
|
begin
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TTestFormatterSimpleType.Test_AnsiChar;
|
procedure TTestFormatterSimpleType.Test_AnsiChar;
|
||||||
const VAL_1 : AnsiChar = 'O'; VAL_2 : AnsiChar = 'i';
|
const VAL_1 : AnsiChar = 'O'; VAL_2 : AnsiChar = 'i';
|
||||||
Var
|
Var
|
||||||
@ -1386,13 +1392,14 @@ Var
|
|||||||
begin
|
begin
|
||||||
s := Nil;
|
s := Nil;
|
||||||
Try
|
Try
|
||||||
if SupportInt64() then begin
|
if SupportInt64() then
|
||||||
intVal_U := VAL_1;
|
intVal_S := VAL_2
|
||||||
intVal_S := VAL_2;
|
else
|
||||||
end else begin
|
|
||||||
intVal_U := VAL_32_1;
|
|
||||||
intVal_S := VAL_32_2;
|
intVal_S := VAL_32_2;
|
||||||
end;
|
if SupportUInt64() then
|
||||||
|
intVal_U := VAL_1
|
||||||
|
else
|
||||||
|
intVal_U := VAL_32_1;
|
||||||
f := CreateFormatter(TypeInfo(TClass_Int));
|
f := CreateFormatter(TypeInfo(TClass_Int));
|
||||||
|
|
||||||
f.BeginObject('Root',TypeInfo(TClass_Int));
|
f.BeginObject('Root',TypeInfo(TClass_Int));
|
||||||
@ -1416,13 +1423,14 @@ begin
|
|||||||
f.Get(TypeInfo(Int64),x,intVal_S);
|
f.Get(TypeInfo(Int64),x,intVal_S);
|
||||||
f.EndScopeRead();
|
f.EndScopeRead();
|
||||||
|
|
||||||
if SupportInt64() then begin
|
if SupportInt64() then
|
||||||
CheckEquals(QWord(VAL_1),intVal_U);
|
CheckEquals(VAL_2,intVal_S)
|
||||||
CheckEquals(VAL_2,intVal_S);
|
else
|
||||||
end else begin
|
|
||||||
CheckEquals(QWord(VAL_32_1),intVal_U);
|
|
||||||
CheckEquals(VAL_32_2,intVal_S);
|
CheckEquals(VAL_32_2,intVal_S);
|
||||||
end;
|
if SupportUInt64() then
|
||||||
|
CheckEquals(QWord(VAL_1),intVal_U)
|
||||||
|
else
|
||||||
|
CheckEquals(QWord(VAL_32_1),intVal_U);
|
||||||
Finally
|
Finally
|
||||||
s.Free();
|
s.Free();
|
||||||
End;
|
End;
|
||||||
@ -1440,7 +1448,7 @@ var
|
|||||||
begin
|
begin
|
||||||
s := Nil;
|
s := Nil;
|
||||||
Try
|
Try
|
||||||
if SupportInt64() then
|
if SupportUInt64() then
|
||||||
intVal_U := VAL_1
|
intVal_U := VAL_1
|
||||||
else
|
else
|
||||||
intVal_U := VAL_32_1;
|
intVal_U := VAL_32_1;
|
||||||
@ -1460,7 +1468,7 @@ begin
|
|||||||
f.BeginObjectRead(x,TypeInfo(TClass_Int));
|
f.BeginObjectRead(x,TypeInfo(TClass_Int));
|
||||||
f.GetScopeInnerValue(TypeInfo(QWord),intVal_U);
|
f.GetScopeInnerValue(TypeInfo(QWord),intVal_U);
|
||||||
f.EndScopeRead();
|
f.EndScopeRead();
|
||||||
if SupportInt64() then
|
if SupportUInt64() then
|
||||||
CheckEquals(VAL_1,intVal_U)
|
CheckEquals(VAL_1,intVal_U)
|
||||||
else
|
else
|
||||||
CheckEquals(VAL_32_1,intVal_U);
|
CheckEquals(VAL_32_1,intVal_U);
|
||||||
@ -2189,13 +2197,14 @@ begin
|
|||||||
a.Val_16S := CONST_Val_16S;
|
a.Val_16S := CONST_Val_16S;
|
||||||
a.Val_32U := CONST_Val_32U;
|
a.Val_32U := CONST_Val_32U;
|
||||||
a.Val_32S := CONST_Val_32S;
|
a.Val_32S := CONST_Val_32S;
|
||||||
if SupportInt64() then begin
|
if SupportInt64() then
|
||||||
a.Val_64U := CONST_Val_64U;
|
a.Val_64S := CONST_Val_64S
|
||||||
a.Val_64S := CONST_Val_64S;
|
else
|
||||||
end else begin
|
a.Val_64S := CONST_Val_32S;
|
||||||
|
if SupportUInt64() then
|
||||||
|
a.Val_64U := CONST_Val_64U
|
||||||
|
else
|
||||||
a.Val_64U := CONST_Val_32U;
|
a.Val_64U := CONST_Val_32U;
|
||||||
a.Val_64S := CONST_Val_32S;
|
|
||||||
end;
|
|
||||||
|
|
||||||
f := CreateFormatter(TypeInfo(TClass_Int));
|
f := CreateFormatter(TypeInfo(TClass_Int));
|
||||||
|
|
||||||
@ -2223,13 +2232,14 @@ begin
|
|||||||
CheckEquals(CONST_Val_16S,a.Val_16S);
|
CheckEquals(CONST_Val_16S,a.Val_16S);
|
||||||
CheckEquals(CONST_Val_32U,a.Val_32U);
|
CheckEquals(CONST_Val_32U,a.Val_32U);
|
||||||
CheckEquals(CONST_Val_32S,a.Val_32S);
|
CheckEquals(CONST_Val_32S,a.Val_32S);
|
||||||
if SupportInt64() then begin
|
if SupportInt64() then
|
||||||
CheckEquals(QWord(CONST_Val_64U),a.Val_64U);
|
CheckEquals(CONST_Val_64S,a.Val_64S)
|
||||||
CheckEquals(CONST_Val_64S,a.Val_64S);
|
else
|
||||||
end else begin
|
CheckEquals(CONST_Val_32S,a.Val_64S);
|
||||||
|
if SupportUInt64() then
|
||||||
|
CheckEquals(QWord(CONST_Val_64U),a.Val_64U)
|
||||||
|
else
|
||||||
CheckEquals(QWord(CONST_Val_32U),a.Val_64U);
|
CheckEquals(QWord(CONST_Val_32U),a.Val_64U);
|
||||||
CheckEquals(CONST_Val_32S,a.Val_64S);
|
|
||||||
end;
|
|
||||||
Finally
|
Finally
|
||||||
a.Free();
|
a.Free();
|
||||||
s.Free();
|
s.Free();
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
<PackageName Value="fpcunittestrunner"/>
|
<PackageName Value="fpcunittestrunner"/>
|
||||||
</Item3>
|
</Item3>
|
||||||
</RequiredPackages>
|
</RequiredPackages>
|
||||||
<Units Count="22">
|
<Units Count="23">
|
||||||
<Unit0>
|
<Unit0>
|
||||||
<Filename Value="wst_test_suite_gui.lpr"/>
|
<Filename Value="wst_test_suite_gui.lpr"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
@ -148,6 +148,10 @@
|
|||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="wst_consts"/>
|
<UnitName Value="wst_consts"/>
|
||||||
</Unit21>
|
</Unit21>
|
||||||
|
<Unit22>
|
||||||
|
<Filename Value="wst_tests_defines.inc"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
</Unit22>
|
||||||
</Units>
|
</Units>
|
||||||
</ProjectOptions>
|
</ProjectOptions>
|
||||||
<CompilerOptions>
|
<CompilerOptions>
|
||||||
|
7
wst/trunk/tests/test_suite/wst_tests_defines.inc
Normal file
7
wst/trunk/tests/test_suite/wst_tests_defines.inc
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{$UNDEF WST_HAS_JSON_INT64}
|
||||||
|
|
||||||
|
{$IFDEF FPC}
|
||||||
|
{$IF (FPC_VERSION > 2) OR ( (FPC_VERSION = 2) AND (FPC_RELEASE > 2) ) }
|
||||||
|
{$DEFINE WST_HAS_JSON_INT64}
|
||||||
|
{$IFEND}
|
||||||
|
{$IFEND}
|
Reference in New Issue
Block a user