mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-24 11:09:15 +02:00
fcl-json: fixed StringToJSONString
This commit is contained in:
parent
e03b920520
commit
5700cb56ac
packages/fcl-json
@ -804,7 +804,7 @@ implementation
|
||||
Uses typinfo;
|
||||
|
||||
const
|
||||
HexDigits = '01234567890ABCDEF';
|
||||
HexDigits: array[0..15] of char = '0123456789ABCDEF';
|
||||
|
||||
Resourcestring
|
||||
SErrCannotConvertFromNull = 'Cannot convert data from Null value';
|
||||
|
@ -310,6 +310,9 @@ begin
|
||||
C.SetValue('a','abc');
|
||||
C.GetValue('a',L,'');
|
||||
AssertStrings('String',L,['abc']);
|
||||
C.SetValue('a','a'#1#2);
|
||||
C.GetValue('a',L,'');
|
||||
AssertStrings('String',L,['a'#1#2]);
|
||||
C.SetValue('a',Integer(1));
|
||||
C.GetValue('a',L,'');
|
||||
AssertStrings('integer',L,['1']);
|
||||
|
@ -177,6 +177,7 @@ type
|
||||
procedure TestCreateBoolean;
|
||||
procedure TestCreateObject;
|
||||
procedure TestCreateJSONString;
|
||||
procedure TestCreateJSONStringSpecialChars;
|
||||
procedure TestCreateJSONObject;
|
||||
procedure TestCreateNilPointer;
|
||||
procedure TestCreatePointer;
|
||||
@ -2394,6 +2395,37 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TTestArray.TestCreateJSONStringSpecialChars;
|
||||
const
|
||||
S: array[0..7] of string = (
|
||||
'A'#1,
|
||||
'B'#9,
|
||||
'C'#10,
|
||||
'D'#12,
|
||||
'E'#13,
|
||||
'F'#10#13,
|
||||
'G"Foo"',
|
||||
'H\J');
|
||||
Var
|
||||
J : TJSONArray;
|
||||
i: Integer;
|
||||
|
||||
begin
|
||||
J:=TJSonArray.Create;
|
||||
try
|
||||
for i:=0 to high(S) do
|
||||
J.Add(S[i]);
|
||||
TestItemCount(J,length(S));
|
||||
for i:=0 to high(S) do
|
||||
begin
|
||||
TestJSONType(J[i],jtString);
|
||||
end;
|
||||
TestJSON(J,'["A\u0001", "B\t", "C\n", "D\f", "E\r", "F\n\r", "G\"Foo\"", "H\\J"]');
|
||||
finally
|
||||
FreeAndNil(J);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TTestArray.TestCreateObject;
|
||||
|
||||
Var
|
||||
|
Loading…
Reference in New Issue
Block a user