> So wouldn't be better have less bigger test units for example
"tcurrency" which will do complex testing for for example all
math.operations with currency data type ?
> (as opposed to have lot of fragments in lot of anonymous files)
>
Feel free to write such a test.
See attached file. Is this way or not (may be that somewhat must be
IFDEFed for platforms where given data type does not exists?) ?
(as I do not know compiler internals, I do not know which makes sense to
test and which is redundant or irrelevant)
-Laco.
program tcurrency;
{ test basic mathematical operations using currency data type }
var
c1, c2: Currency;
d: Double;
i: Integer;
i64: int64;
begin
writeln('Currency and Double ...');
// addition double
d := 1;
c1 := 2;
c2 := 3;
if c1+d <> c2 then begin
writeln('Invalid currency+double=', c1+d, ', but expected ', c2);
halt(1);
end;
// multiplication double
d := 100;
c1 := 12.34;
c2 := 1234;
if d*c1 <> c2 then begin
writeln('Invalid currency*double=', d*c1, ', but expected ', c2);
halt(1);
end;
writeln('Currency and Integer ...');
// addition integer
i := 1;
c1 := 2;
c2 := 3;
if c1+i <> c2 then begin
writeln('Invalid currency+integer=', c1+i, ', but expected ', c2);
halt(2);
end;
// multiplication integer
i := 100;
c1 := 12.34;
c2 := 1234;
if i*c1 <> c2 then begin
writeln('Invalid currency*integer=', i*c1, ', but expected ', c2);
halt(2);
end;
writeln('Currency and Int64 ...');
// addition int64
i64 := 1;
c1 := 12.3456;
c2 := 13.3456;
if c1+i64 <> c2 then begin
writeln('Invalid currency+int64=', c1+i64, ', but expected ', c2);
halt(3);
end;
// multiplication int64
i64 := 10000;
c1 := 12.3456;
c2 := 123456;
if i64*c1 <> c2 then begin
writeln('Invalid currency*int64=', i64*c1, ', but expected ', c2);
halt(3);
end;
readln;
end.
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel