2
0

tover1.pp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. program tover1;
  2. const
  3. RESULT_PCHAR = 'pchar parameter call';
  4. RESULT_ANSI = 'ansistring parameter call';
  5. RESULT_SHORT = 'shortstring parameter call';
  6. RESULT_WIDE = 'widestring parameter call';
  7. { This tests method overloads, to verify
  8. if they conform to correct type conversion
  9. }
  10. function test_string(s: shortstring): shortstring;
  11. Begin
  12. test_string := RESULT_SHORT;
  13. end;
  14. {$ifndef ver1_0}
  15. function test_string(s: widestring): shortstring;
  16. Begin
  17. test_string := RESULT_WIDE;
  18. end;
  19. {$endif}
  20. function test_string(s: ansistring): shortstring;
  21. Begin
  22. test_string := RESULT_ANSI;
  23. end;
  24. function test_string(p:pchar): shortstring;
  25. begin
  26. test_string := RESULT_PCHAR;
  27. end;
  28. procedure fail;
  29. begin
  30. writeln('Failure!');
  31. Halt(1);
  32. end;
  33. var
  34. short_string : shortstring;
  35. ansi_string : ansistring;
  36. {$ifndef ver1_0}
  37. wide_string : widestring;
  38. {$endif}
  39. p_string : pchar;
  40. s: shortstring;
  41. Begin
  42. p_string:=nil;
  43. ansi_string:='';
  44. short_string:='';
  45. {$ifndef ver1_0}
  46. wide_string:='';
  47. {$endif}
  48. Write('Test of overloaded call to string routines...');
  49. { test parameter call }
  50. s:=test_string(short_string);
  51. if s <> RESULT_SHORT then
  52. fail;
  53. s:=test_string(ansi_string);
  54. if s <> RESULT_ANSI then
  55. fail;
  56. {$ifndef ver1_0}
  57. s:=test_string(wide_string);
  58. if s <> RESULT_WIDE then
  59. fail;
  60. {$endif}
  61. s:=test_string(p_string);
  62. if s <> RESULT_PCHAR then
  63. fail;
  64. WriteLn('Success!');
  65. end.