ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/fbintf/testsuite/Test21.pas
(Generate patch)

Comparing ibx/trunk/fbintf/testsuite/Test21.pas (file contents):
Revision 355 by tony, Sat Oct 23 14:11:37 2021 UTC vs.
Revision 356 by tony, Sun Oct 24 14:00:52 2021 UTC

# Line 52 | Line 52 | type
52    private
53      procedure UpdateDatabase(Attachment: IAttachment);
54      procedure QueryDatabase(Attachment: IAttachment);
55 +    procedure ValidateStrToNumeric;
56    public
57      function TestTitle: AnsiString; override;
58      procedure RunTest(CharSet: AnsiString; SQLDialect: integer); override;
# Line 61 | Line 62 | type
62  
63   implementation
64  
65 + uses IBUtils;
66 +
67   const
68    sqlCreateTable =
69      'Create Table TestData ('+
# Line 154 | Line 157 | begin
157    ReportResults(Statement);
158   end;
159  
160 + procedure TTest21.ValidateStrToNumeric;
161 + const
162 +  TestValues: array of string = ['1234.567','-765.4321','0.1','0.01','+123',
163 +                                 '1.23456E308','-1.2e-02','10.','.12', '0.12',
164 +                                 '1.2E1.2', '1,000', '1e1e1', '1.2+3']; {bad syntax}
165 + var
166 +  i: integer;
167 +  aValue: Int64;
168 +  aScale: integer;
169 + begin
170 +  for i := 0 to Length(TestValues) - 1 do
171 +  begin
172 +    if TryStrToNumeric(TestValues[i],aValue,aScale) then
173 +    begin
174 +      writeln(Outfile,TestValues[i],' parsed to ',aValue,' scale = ',aScale);
175 +      writeln(Outfile,'As Float = ',NumericToDouble(aValue,aScale));
176 +    end
177 +    else
178 +      writeln(Outfile,'Parsing of ',TestValues[i],' failed');
179 +  end;
180 + end;
181 +
182   function TTest21.TestTitle: AnsiString;
183   begin
184    Result := 'Test 21: Exercise setting and getting of numeric data types';
# Line 171 | Line 196 | begin
196    Attachment := FirebirdAPI.CreateDatabase(Owner.GetNewDatabaseName,DPB);
197    try
198      Attachment.ExecImmediate([isc_tpb_write,isc_tpb_wait,isc_tpb_consistency],sqlCreateTable);
199 +    ValidateStrToNumeric;
200      SetFloatTemplate('#,###.00000000');
201      UpdateDatabase(Attachment);
202      QueryDatabase(Attachment);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines