mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-16 10:19:30 +02:00
Always accept empty string as meaning zero is TryRomanToInt, fixes intermittent errors in tromantoint test
git-svn-id: trunk@40537 -
This commit is contained in:
parent
f7efca92ec
commit
f8563772c5
@ -2427,7 +2427,12 @@ begin
|
||||
Result := True;
|
||||
Exit;
|
||||
end;
|
||||
if (Len = 0) then Exit;
|
||||
if (Len = 0) then
|
||||
begin
|
||||
Result:=true;
|
||||
N:=0;
|
||||
Exit;
|
||||
end;
|
||||
i := 1;
|
||||
N := 0;
|
||||
Terminated := False;
|
||||
|
@ -14,10 +14,16 @@ procedure RomanToIntTest(const testRoman: string;
|
||||
var
|
||||
test: integer;
|
||||
begin
|
||||
test := RomanToInt(testRoman);
|
||||
try
|
||||
test := RomanToInt(testRoman);
|
||||
except
|
||||
{ make sure that if an exception is generated,
|
||||
the error is raised }
|
||||
test:=expectation-1;
|
||||
end;
|
||||
if test <> expectation then
|
||||
begin
|
||||
writeln('Testing strUtils/RomanToInt: Test with ', testRoman, ' failed.');
|
||||
writeln('Testing strUtils/RomanToInt: Test with "', testRoman, '" failed.');
|
||||
writeln('Returned number: ', test);
|
||||
writeln('Expected number: ', expectation);
|
||||
exitCode := 1;
|
||||
@ -30,6 +36,9 @@ var
|
||||
testInteger: integer;
|
||||
|
||||
begin
|
||||
{ Check that empty string is accepted as zero vvalue }
|
||||
RomanToIntTest('',0);
|
||||
|
||||
for i := 1 to 2000 do
|
||||
begin
|
||||
testInteger := i;
|
||||
|
Loading…
Reference in New Issue
Block a user