tastrcmp1.pp 643 B

123456789101112131415161718192021222324252627282930
  1. program comp;
  2. uses
  3. SysUtils;
  4. var
  5. error : boolean;
  6. procedure check(ok : boolean; func : string; value : longint);
  7. begin
  8. if not ok then
  9. begin
  10. error:=true;
  11. writeln(func,' failed, result = ',value);
  12. end;
  13. end;
  14. var
  15. a, b: array[0..1] of char;
  16. tmp : longint;
  17. begin
  18. error:=false;
  19. a[0] := #0; a[1] := #1; //Empty string
  20. b[0] := #0; b[1] := #0; //Empty string with different char after end
  21. tmp:=AnsiStrComp(a, b); //should be zero because a=b
  22. check(tmp=0,'AnsiStrComp',tmp);
  23. tmp:=AnsiStrIComp(a, b); //should be zero because a=b
  24. check(tmp=0,'AnsiStrIComp',tmp);
  25. if error then
  26. halt(1);
  27. end.