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 351 by tony, Wed Oct 20 15:04:35 2021 UTC vs.
Revision 380 by tony, Mon Jan 10 10:13:17 2022 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 121 | Line 124 | begin
124      Params[1].AsString := '1.0';
125      Params[2].AsString := '10.';
126      Params[3].AsString := '2.3E-2';
127 <    Params[4].AsString := '0';
127 >    Params[4].AsString := '11e-4';
128      Params[5].AsString := '2.33456E2';
129    end;
130    Statement.Execute;
# 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);

Comparing ibx/trunk/fbintf/testsuite/Test21.pas (property svn:eol-style):
Revision 351 by tony, Wed Oct 20 15:04:35 2021 UTC vs.
Revision 380 by tony, Mon Jan 10 10:13:17 2022 UTC

# Line 0 | Line 1
1 + native

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines