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.
|
||||
}
|
||||
{$INCLUDE wst_global.inc}
|
||||
{$INCLUDE wst_tests_defines.inc}
|
||||
unit test_json;
|
||||
|
||||
interface
|
||||
@ -39,6 +40,7 @@ type
|
||||
function Support_ComplextType_with_SimpleContent():Boolean;override;
|
||||
function Support_nil():Boolean;override;
|
||||
class function SupportInt64() : Boolean;override;
|
||||
class function SupportUInt64() : Boolean;override;
|
||||
published
|
||||
//procedure test_WriteBuffer();
|
||||
end;
|
||||
@ -82,6 +84,15 @@ begin
|
||||
end;
|
||||
|
||||
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
|
||||
Result := False;
|
||||
end;
|
||||
|
@ -429,6 +429,7 @@ type
|
||||
function Support_ComplextType_with_SimpleContent():Boolean;virtual;
|
||||
function Support_nil():Boolean;virtual;
|
||||
class function SupportInt64() : Boolean;virtual;
|
||||
class function SupportUInt64() : Boolean;virtual;
|
||||
published
|
||||
procedure Test_AnsiChar;
|
||||
procedure Test_AnsiChar_ScopeData;
|
||||
@ -814,6 +815,11 @@ begin
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
class function TTestFormatterSimpleType.SupportUInt64(): Boolean;
|
||||
begin
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
procedure TTestFormatterSimpleType.Test_AnsiChar;
|
||||
const VAL_1 : AnsiChar = 'O'; VAL_2 : AnsiChar = 'i';
|
||||
Var
|
||||
@ -1386,13 +1392,14 @@ Var
|
||||
begin
|
||||
s := Nil;
|
||||
Try
|
||||
if SupportInt64() then begin
|
||||
intVal_U := VAL_1;
|
||||
intVal_S := VAL_2;
|
||||
end else begin
|
||||
intVal_U := VAL_32_1;
|
||||
if SupportInt64() then
|
||||
intVal_S := VAL_2
|
||||
else
|
||||
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.BeginObject('Root',TypeInfo(TClass_Int));
|
||||
@ -1416,13 +1423,14 @@ begin
|
||||
f.Get(TypeInfo(Int64),x,intVal_S);
|
||||
f.EndScopeRead();
|
||||
|
||||
if SupportInt64() then begin
|
||||
CheckEquals(QWord(VAL_1),intVal_U);
|
||||
CheckEquals(VAL_2,intVal_S);
|
||||
end else begin
|
||||
CheckEquals(QWord(VAL_32_1),intVal_U);
|
||||
if SupportInt64() then
|
||||
CheckEquals(VAL_2,intVal_S)
|
||||
else
|
||||
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
|
||||
s.Free();
|
||||
End;
|
||||
@ -1440,7 +1448,7 @@ var
|
||||
begin
|
||||
s := Nil;
|
||||
Try
|
||||
if SupportInt64() then
|
||||
if SupportUInt64() then
|
||||
intVal_U := VAL_1
|
||||
else
|
||||
intVal_U := VAL_32_1;
|
||||
@ -1460,7 +1468,7 @@ begin
|
||||
f.BeginObjectRead(x,TypeInfo(TClass_Int));
|
||||
f.GetScopeInnerValue(TypeInfo(QWord),intVal_U);
|
||||
f.EndScopeRead();
|
||||
if SupportInt64() then
|
||||
if SupportUInt64() then
|
||||
CheckEquals(VAL_1,intVal_U)
|
||||
else
|
||||
CheckEquals(VAL_32_1,intVal_U);
|
||||
@ -2189,13 +2197,14 @@ begin
|
||||
a.Val_16S := CONST_Val_16S;
|
||||
a.Val_32U := CONST_Val_32U;
|
||||
a.Val_32S := CONST_Val_32S;
|
||||
if SupportInt64() then begin
|
||||
a.Val_64U := CONST_Val_64U;
|
||||
a.Val_64S := CONST_Val_64S;
|
||||
end else begin
|
||||
if SupportInt64() then
|
||||
a.Val_64S := CONST_Val_64S
|
||||
else
|
||||
a.Val_64S := CONST_Val_32S;
|
||||
if SupportUInt64() then
|
||||
a.Val_64U := CONST_Val_64U
|
||||
else
|
||||
a.Val_64U := CONST_Val_32U;
|
||||
a.Val_64S := CONST_Val_32S;
|
||||
end;
|
||||
|
||||
f := CreateFormatter(TypeInfo(TClass_Int));
|
||||
|
||||
@ -2223,13 +2232,14 @@ begin
|
||||
CheckEquals(CONST_Val_16S,a.Val_16S);
|
||||
CheckEquals(CONST_Val_32U,a.Val_32U);
|
||||
CheckEquals(CONST_Val_32S,a.Val_32S);
|
||||
if SupportInt64() then begin
|
||||
CheckEquals(QWord(CONST_Val_64U),a.Val_64U);
|
||||
CheckEquals(CONST_Val_64S,a.Val_64S);
|
||||
end else begin
|
||||
if SupportInt64() then
|
||||
CheckEquals(CONST_Val_64S,a.Val_64S)
|
||||
else
|
||||
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(CONST_Val_32S,a.Val_64S);
|
||||
end;
|
||||
Finally
|
||||
a.Free();
|
||||
s.Free();
|
||||
|
@ -37,7 +37,7 @@
|
||||
<PackageName Value="fpcunittestrunner"/>
|
||||
</Item3>
|
||||
</RequiredPackages>
|
||||
<Units Count="22">
|
||||
<Units Count="23">
|
||||
<Unit0>
|
||||
<Filename Value="wst_test_suite_gui.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
@ -148,6 +148,10 @@
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="wst_consts"/>
|
||||
</Unit21>
|
||||
<Unit22>
|
||||
<Filename Value="wst_tests_defines.inc"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit22>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<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