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

Comparing ibx/branches/udr/testsuite/Test21.pas (file contents):
Revision 370 by tony, Wed Jan 5 14:59:15 2022 UTC vs.
Revision 371 by tony, Wed Jan 5 15:21:22 2022 UTC

# Line 53 | Line 53 | type
53      procedure UpdateDatabase(Attachment: IAttachment);
54      procedure QueryDatabase(Attachment: IAttachment);
55      procedure ValidateStrToNumeric;
56 +    procedure ValidateNumericInterface;
57    public
58      function TestTitle: AnsiString; override;
59      procedure RunTest(CharSet: AnsiString; SQLDialect: integer); override;
# Line 62 | Line 63 | type
63  
64   implementation
65  
66 < uses IBUtils;
66 > uses FBNumeric, FmtBCD;
67  
68   const
69    sqlCreateTable =
# Line 145 | Line 146 | begin
146    except on E: Exception do
147      writeln(Outfile,'Expected Error - ',E.Message);
148    end;
149 <
149 >  writeln(OutFile,'Test Numeric Type');
150 >  with Statement.GetSQLParams do
151 >  begin
152 >    Clear;
153 >    Params[0].AsInteger := 7;
154 >    Params[1].AsNumeric := NewNumeric(1.0);
155 >    Params[2].AsVariant := 1234567;
156 >    Params[3].AsNumeric := NewNumeric(StrToFloat('2.3E-2'),-4);
157 >    Params[4].AsNumeric := NewNumeric('11e-4');
158 >    Params[5].AsVariant := 1234.25;
159 >  end;
160 >  Statement.Execute;
161   end;
162  
163   procedure TTest21.QueryDatabase(Attachment: IAttachment);
# Line 179 | Line 191 | begin
191    end;
192   end;
193  
194 + procedure TTest21.ValidateNumericInterface;
195 + var numeric: IFBNumeric;
196 + begin
197 +  writeln(Outfile,'Validating Numeric Interface - IFBNumeric');
198 +  numeric := NewNumeric(StrToCurr('9999.123456780'));
199 +  writeln(Outfile,'Value from Currency = ',numeric.getAsString);
200 +  writeln(Outfile,'Raw Value = ',numeric.getRawValue,' Scale = ',numeric.getScale);
201 +  numeric := NewNumeric(StrToCurr('9999.123456780')).clone(-2);
202 +  writeln(Outfile,'Value from Currency(rescaled) = ',numeric.getAsString);
203 +  writeln(Outfile,'Raw Value = ',numeric.getRawValue,' Scale = ',numeric.getScale);
204 +  numeric := NewNumeric(StrToFloat('9999.123456780'),-8);
205 +  writeln(Outfile,'Value from Double = ',numeric.getAsString);
206 +  writeln(Outfile,'Raw Value = ',numeric.getRawValue,' Scale = ',numeric.getScale);
207 +  numeric := NewNumeric(StrToInt64('9223372036854775807'));
208 +  writeln(Outfile,'Value from Integer = ',numeric.getAsString);
209 +  writeln(Outfile,'Raw Value = ',numeric.getRawValue,' Scale = ',numeric.getScale);
210 +  numeric := NewNumeric('9223372036854775807');
211 +  writeln(Outfile,'Value from string = ',numeric.getAsString);
212 +  writeln(Outfile,'Raw Value = ',numeric.getRawValue,' Scale = ',numeric.getScale);
213 +  numeric := NewNumeric('9999.123456780');
214 +  writeln(Outfile,'Value from string = ',numeric.getAsString);
215 +  writeln(Outfile,'Raw Value = ',numeric.getRawValue,' Scale = ',numeric.getScale);
216 +  numeric := NewNumeric('-1.2e-02');
217 +  writeln(Outfile,'Value from string = ',numeric.getAsString);
218 +  writeln(Outfile,'Raw Value = ',numeric.getRawValue,' Scale = ',numeric.getScale);
219 +  numeric := NewNumeric(StrToBCD('9999.123456780'));
220 +  writeln(Outfile,'Value from BCD = ',numeric.getAsString);
221 +  writeln(Outfile,'Raw Value = ',numeric.getRawValue,' Scale = ',numeric.getScale);
222 +  numeric := NumericFromRawValues(9999123456780,-6);
223 +  writeln(Outfile,'Value from Raw Data = ',numeric.getAsString);
224 +  writeln(Outfile,'Raw Value = ',numeric.getRawValue,' Scale = ',numeric.getScale);
225 + end;
226 +
227   function TTest21.TestTitle: AnsiString;
228   begin
229    Result := 'Test 21: Exercise setting and getting of numeric data types';
# Line 197 | Line 242 | begin
242    try
243      Attachment.ExecImmediate([isc_tpb_write,isc_tpb_wait,isc_tpb_consistency],sqlCreateTable);
244      ValidateStrToNumeric;
245 +    ValidateNumericInterface;
246      SetFloatTemplate('#,###.00000000');
247      UpdateDatabase(Attachment);
248      QueryDatabase(Attachment);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines