fpc/tests/test/units/sysutils/tastrcmp1.pp
giulio cc08543f57 Patch from Petr Kristan for AnsiStrComp/AnsiStrIComp to fix comparison
when both strings are empty and differ after the null character + test.

git-svn-id: trunk@11277 -
2008-06-25 07:07:54 +00:00

30 lines
643 B
ObjectPascal

program comp;
uses
SysUtils;
var
error : boolean;
procedure check(ok : boolean; func : string; value : longint);
begin
if not ok then
begin
error:=true;
writeln(func,' failed, result = ',value);
end;
end;
var
a, b: array[0..1] of char;
tmp : longint;
begin
error:=false;
a[0] := #0; a[1] := #1; //Empty string
b[0] := #0; b[1] := #0; //Empty string with different char after end
tmp:=AnsiStrComp(a, b); //should be zero because a=b
check(tmp=0,'AnsiStrComp',tmp);
tmp:=AnsiStrIComp(a, b); //should be zero because a=b
check(tmp=0,'AnsiStrIComp',tmp);
if error then
halt(1);
end.