mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 09:09:19 +02:00
* Add testcase for jdoIgnoreNulls
git-svn-id: trunk@46328 -
This commit is contained in:
parent
7be31033d7
commit
a5a4a32ff9
@ -396,9 +396,8 @@ begin
|
|||||||
If B then
|
If B then
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
if (PropData.JSONType=jtNull) then
|
if (PropData.JSONType<>jtNull) or not (jdoIgnoreNulls in Options) then
|
||||||
if Not (jdoIgnoreNulls in Options) then
|
DoRestoreProperty(AObject,PropInfo,PropData)
|
||||||
DoRestoreProperty(AObject,PropInfo,PropData);
|
|
||||||
except
|
except
|
||||||
On E : Exception do
|
On E : Exception do
|
||||||
If Assigned(FOnPropError) then
|
If Assigned(FOnPropError) then
|
||||||
|
@ -122,6 +122,7 @@ type
|
|||||||
procedure DeStream(JSON: TJSONStringType; AObject: TObject);
|
procedure DeStream(JSON: TJSONStringType; AObject: TObject);
|
||||||
procedure DeStream(JSON: TJSONObject; AObject: TObject);
|
procedure DeStream(JSON: TJSONObject; AObject: TObject);
|
||||||
procedure DoDateTimeFormat;
|
procedure DoDateTimeFormat;
|
||||||
|
Procedure DoNullError;
|
||||||
protected
|
protected
|
||||||
procedure SetUp; override;
|
procedure SetUp; override;
|
||||||
procedure TearDown; override;
|
procedure TearDown; override;
|
||||||
@ -138,6 +139,8 @@ type
|
|||||||
Procedure TestVariantString;
|
Procedure TestVariantString;
|
||||||
Procedure TestVariantArray;
|
Procedure TestVariantArray;
|
||||||
procedure TestEmpty;
|
procedure TestEmpty;
|
||||||
|
procedure TestNullError;
|
||||||
|
procedure TestNull;
|
||||||
procedure TestBoolean;
|
procedure TestBoolean;
|
||||||
procedure TestInteger;
|
procedure TestInteger;
|
||||||
procedure TestIntegerCaseInsensitive;
|
procedure TestIntegerCaseInsensitive;
|
||||||
@ -284,6 +287,23 @@ begin
|
|||||||
AssertEquals('Empty Tag',0,TComponent(FToFree).Tag);
|
AssertEquals('Empty Tag',0,TComponent(FToFree).Tag);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TTestJSONDeStreamer.TestNullError;
|
||||||
|
|
||||||
|
begin
|
||||||
|
AssertException('Null error',EJSON, @DoNullError);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TTestJSONDeStreamer.TestNull;
|
||||||
|
Var
|
||||||
|
B : TBooleanComponent;
|
||||||
|
|
||||||
|
begin
|
||||||
|
B:=TBooleanComponent.Create(Nil);
|
||||||
|
DS.Options:=DS.Options+[jdoIgnoreNulls];
|
||||||
|
DeStream('{ "BooleanProp" : null }',B);
|
||||||
|
AssertEquals('Correct boolean value',False,B.BooleanProp);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TTestJSONDeStreamer.DeStream(JSON : TJSONStringType; AObject : TObject);
|
procedure TTestJSONDeStreamer.DeStream(JSON : TJSONStringType; AObject : TObject);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -428,6 +448,15 @@ begin
|
|||||||
DeStream('{"DateTimeProp" : "'+DateTimeToStr(RecodeMillisecond(Now,0))+'"}',FToFree);
|
DeStream('{"DateTimeProp" : "'+DateTimeToStr(RecodeMillisecond(Now,0))+'"}',FToFree);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TTestJSONDeStreamer.DoNullError;
|
||||||
|
Var
|
||||||
|
B : TBooleanComponent;
|
||||||
|
|
||||||
|
begin
|
||||||
|
B:=TBooleanComponent.Create(Nil);
|
||||||
|
Destream('{ "BooleanProp" : null }',B);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TTestJSONDeStreamer.TestDateTimeFormat;
|
procedure TTestJSONDeStreamer.TestDateTimeFormat;
|
||||||
|
|
||||||
Const
|
Const
|
||||||
|
Loading…
Reference in New Issue
Block a user