|
@@ -6,29 +6,27 @@ procedure test;
|
|
var
|
|
var
|
|
s: string;
|
|
s: string;
|
|
r: double;
|
|
r: double;
|
|
|
|
+ DS: Char;
|
|
begin
|
|
begin
|
|
- {$IFDEF FPC}
|
|
|
|
- CurrencyFormat := 1;
|
|
|
|
- NegCurrFormat := 0;
|
|
|
|
- {$ENDIF}
|
|
|
|
DecimalSeparator := '.';
|
|
DecimalSeparator := '.';
|
|
|
|
+ DS := DecimalSeparator;
|
|
r := 0.001;
|
|
r := 0.001;
|
|
s := FloatToStrF(r, ffGeneral, 12, 2);
|
|
s := FloatToStrF(r, ffGeneral, 12, 2);
|
|
{must print 0.001 }
|
|
{must print 0.001 }
|
|
writeln(s);
|
|
writeln(s);
|
|
- if (s <> '0.001') then
|
|
|
|
|
|
+ if (s <> '0'+DS+'001') then
|
|
halt(1);
|
|
halt(1);
|
|
|
|
|
|
s := FloatToStrF(r, ffFixed, 12, 2);
|
|
s := FloatToStrF(r, ffFixed, 12, 2);
|
|
{must print 0.00 }
|
|
{must print 0.00 }
|
|
writeln(s);
|
|
writeln(s);
|
|
- if (s <> '0.00') then
|
|
|
|
|
|
+ if (s <> '0'+DS+'00') then
|
|
halt(1);
|
|
halt(1);
|
|
|
|
|
|
s := FloatToStrF(r, ffNumber, 12, 2);
|
|
s := FloatToStrF(r, ffNumber, 12, 2);
|
|
{must print 0.00 }
|
|
{must print 0.00 }
|
|
writeln(s);
|
|
writeln(s);
|
|
- if (s <> '0.00') then
|
|
|
|
|
|
+ if (s <> '0'+DS+'00') then
|
|
halt(1);
|
|
halt(1);
|
|
|
|
|
|
r := -0.00001;
|
|
r := -0.00001;
|
|
@@ -37,7 +35,7 @@ begin
|
|
{must print -0.00001 }
|
|
{must print -0.00001 }
|
|
writeln(s);
|
|
writeln(s);
|
|
{$IFDEF FPC}
|
|
{$IFDEF FPC}
|
|
- if (s <> '-0.00001') then
|
|
|
|
|
|
+ if (s <> '-0'+DS+'00001') then
|
|
{$ELSE}
|
|
{$ELSE}
|
|
if (s <> '-1E-05') then // is this DCC bug ?
|
|
if (s <> '-1E-05') then // is this DCC bug ?
|
|
{$ENDIF}
|
|
{$ENDIF}
|
|
@@ -46,25 +44,26 @@ begin
|
|
s := FloatToStrF(r, ffExponent, 12, 2);
|
|
s := FloatToStrF(r, ffExponent, 12, 2);
|
|
{must print -1.00000000000E-05 }
|
|
{must print -1.00000000000E-05 }
|
|
writeln(s);
|
|
writeln(s);
|
|
- if (s <> '-1.00000000000E-05') then
|
|
|
|
|
|
+ if (s <> '-1'+DS+'00000000000E-05') then
|
|
halt(1);
|
|
halt(1);
|
|
|
|
|
|
s := FloatToStrF(r, ffFixed, 12, 2);
|
|
s := FloatToStrF(r, ffFixed, 12, 2);
|
|
{must print 0.00 }
|
|
{must print 0.00 }
|
|
writeln(s);
|
|
writeln(s);
|
|
- if (s <> '0.00') then
|
|
|
|
|
|
+ if (s <> '0'+DS+'00') then
|
|
halt(1);
|
|
halt(1);
|
|
|
|
|
|
s := FloatToStrF(r, ffNumber, 12, 2);
|
|
s := FloatToStrF(r, ffNumber, 12, 2);
|
|
{must print 0.00 }
|
|
{must print 0.00 }
|
|
writeln(s);
|
|
writeln(s);
|
|
- if (s <> '0.00') then
|
|
|
|
|
|
+ if (s <> '0'+DS+'00') then
|
|
halt(1);
|
|
halt(1);
|
|
|
|
|
|
s := FloatToStrF(r, ffCurrency, 12, 2);
|
|
s := FloatToStrF(r, ffCurrency, 12, 2);
|
|
{must print without leading zero }
|
|
{must print without leading zero }
|
|
writeln(s);
|
|
writeln(s);
|
|
- if (length(s) > 0) and (Pos('-', s) > 0) then
|
|
|
|
|
|
+ if (length(s) > 0) and
|
|
|
|
+ ((Pos('-', s) > 0) or ((Pos('(', s) > 0) and (Pos(')', s) > 0))) then
|
|
halt(1);
|
|
halt(1);
|
|
|
|
|
|
r := -0.00000;
|
|
r := -0.00000;
|
|
@@ -78,25 +77,26 @@ begin
|
|
s := FloatToStrF(r, ffExponent, 12, 2);
|
|
s := FloatToStrF(r, ffExponent, 12, 2);
|
|
{must print 0.00 }
|
|
{must print 0.00 }
|
|
writeln(s);
|
|
writeln(s);
|
|
- if (s <> '0.00000000000E+00') then
|
|
|
|
|
|
+ if (s <> '0'+DS+'00000000000E+00') then
|
|
halt(1);
|
|
halt(1);
|
|
|
|
|
|
s := FloatToStrF(r, ffFixed, 12, 2);
|
|
s := FloatToStrF(r, ffFixed, 12, 2);
|
|
{must print 0.00 }
|
|
{must print 0.00 }
|
|
writeln(s);
|
|
writeln(s);
|
|
- if (s <> '0.00') then
|
|
|
|
|
|
+ if (s <> '0'+DS+'00') then
|
|
halt(1);
|
|
halt(1);
|
|
|
|
|
|
s := FloatToStrF(r, ffNumber, 12, 2);
|
|
s := FloatToStrF(r, ffNumber, 12, 2);
|
|
{must print 0.00 }
|
|
{must print 0.00 }
|
|
writeln(s);
|
|
writeln(s);
|
|
- if (s <> '0.00') then
|
|
|
|
|
|
+ if (s <> '0'+DS+'00') then
|
|
halt(1);
|
|
halt(1);
|
|
|
|
|
|
s := FloatToStrF(r, ffCurrency, 12, 2);
|
|
s := FloatToStrF(r, ffCurrency, 12, 2);
|
|
{must print without leading zero }
|
|
{must print without leading zero }
|
|
writeln(s);
|
|
writeln(s);
|
|
- if (length(s) > 0) and (Pos('-', s) > 0) then
|
|
|
|
|
|
+ if (length(s) > 0) and
|
|
|
|
+ ((Pos('-', s) > 0) or ((Pos('(', s) > 0) and (Pos(')', s) > 0))) then
|
|
halt(1);
|
|
halt(1);
|
|
|
|
|
|
// Now check if we remove leading negative sign by mistake
|
|
// Now check if we remove leading negative sign by mistake
|
|
@@ -106,7 +106,7 @@ begin
|
|
{must print -0.00001 }
|
|
{must print -0.00001 }
|
|
writeln(s);
|
|
writeln(s);
|
|
{$IFDEF FPC}
|
|
{$IFDEF FPC}
|
|
- if (s <> '-0.00001') then
|
|
|
|
|
|
+ if (s <> '-0'+DS+'00001') then
|
|
{$ELSE}
|
|
{$ELSE}
|
|
if (s <> '-1E-5') then // is this DCC bug ?
|
|
if (s <> '-1E-5') then // is this DCC bug ?
|
|
{$ENDIF}
|
|
{$ENDIF}
|
|
@@ -116,7 +116,7 @@ begin
|
|
{must print -0.00001 }
|
|
{must print -0.00001 }
|
|
writeln(s);
|
|
writeln(s);
|
|
{$IFDEF FPC}
|
|
{$IFDEF FPC}
|
|
- if (s <> '-1.00000000000E-0005') then
|
|
|
|
|
|
+ if (s <> '-1'+DS+'00000000000E-0005') then
|
|
{$ELSE}
|
|
{$ELSE}
|
|
if (s <> '-1.00000000000E-5') then
|
|
if (s <> '-1.00000000000E-5') then
|
|
{$ENDIF}
|
|
{$ENDIF}
|
|
@@ -125,19 +125,26 @@ begin
|
|
s := FloatToStrF(r, ffFixed, 12, 5);
|
|
s := FloatToStrF(r, ffFixed, 12, 5);
|
|
{must print 0.00 }
|
|
{must print 0.00 }
|
|
writeln(s);
|
|
writeln(s);
|
|
- if (s <> '-0.00001') then
|
|
|
|
|
|
+ if (s <> '-0'+DS+'00001') then
|
|
halt(1);
|
|
halt(1);
|
|
|
|
|
|
s := FloatToStrF(r, ffNumber, 12, 5);
|
|
s := FloatToStrF(r, ffNumber, 12, 5);
|
|
{must print 0.00 }
|
|
{must print 0.00 }
|
|
writeln(s);
|
|
writeln(s);
|
|
- if (s <> '-0.00001') then
|
|
|
|
|
|
+ if (s <> '-0'+DS+'00001') then
|
|
halt(1);
|
|
halt(1);
|
|
|
|
|
|
s := FloatToStrF(r, ffCurrency, 12, 5);
|
|
s := FloatToStrF(r, ffCurrency, 12, 5);
|
|
- {must print without leading zero }
|
|
|
|
|
|
+
|
|
|
|
+ {here we check for various currency negative formats.
|
|
|
|
+ There's bug in rtl cause NegCurFormat can be > 10
|
|
|
|
+ and in that case it isn't handled by FloatToStrIntl().
|
|
|
|
+ So that's why we check NegCurFormat range here.}
|
|
|
|
+
|
|
writeln(s);
|
|
writeln(s);
|
|
- if (length(s) > 0) and (Pos('-', s) = 0) then
|
|
|
|
|
|
+
|
|
|
|
+ if (length(s) > 0) and (NegCurrFormat in [0..10]) and
|
|
|
|
+ (Pos('-', s) = 0) and (Pos('(', s) = 0) and (Pos(')', s) = 0) then
|
|
halt(1);
|
|
halt(1);
|
|
writeln('Tests for FloatToStrF(): SUCCESS');
|
|
writeln('Tests for FloatToStrF(): SUCCESS');
|
|
end;
|
|
end;
|