tcpstr21.pp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. program tcpstr21;
  2. {$APPTYPE CONSOLE}
  3. {$IFDEF FPC}
  4. {$MODE DELPHIUNICODE}
  5. {$ENDIF}
  6. // Test overload precedence for string constant when default string type is UnicodeString
  7. // ---- all string types ----
  8. procedure TestStrConst1(const S: UnicodeString); overload;
  9. begin
  10. end;
  11. {$ifndef FPC_WIDESTRING_EQUAL_UNICODESTRING}
  12. procedure TestStrConst1(const S: WideString); overload;
  13. begin
  14. halt(1);
  15. end;
  16. {$endif}
  17. procedure TestStrConst1(const S: PWideChar); overload;
  18. begin
  19. halt(1);
  20. end;
  21. procedure TestStrConst1(const S: PAnsiChar); overload;
  22. begin
  23. halt(1);
  24. end;
  25. procedure TestStrConst1(const S: AnsiString); overload;
  26. begin
  27. halt(1);
  28. end;
  29. procedure TestStrConst1(const S: ShortString); overload;
  30. begin
  31. halt(1);
  32. end;
  33. // ---- no UnicodeString ----
  34. procedure TestStrConst2(const S: WideString); overload;
  35. begin
  36. end;
  37. procedure TestStrConst2(const S: PWideChar); overload;
  38. begin
  39. halt(2);
  40. end;
  41. procedure TestStrConst2(const S: PAnsiChar); overload;
  42. begin
  43. halt(2);
  44. end;
  45. procedure TestStrConst2(const S: AnsiString); overload;
  46. begin
  47. halt(2);
  48. end;
  49. procedure TestStrConst2(const S: ShortString); overload;
  50. begin
  51. halt(2);
  52. end;
  53. // ---- no UnicodeString, WideString ----
  54. procedure TestStrConst3(const S: PWideChar); overload;
  55. begin
  56. end;
  57. procedure TestStrConst3(const S: PAnsiChar); overload;
  58. begin
  59. halt(3);
  60. end;
  61. procedure TestStrConst3(const S: AnsiString); overload;
  62. begin
  63. halt(3);
  64. end;
  65. procedure TestStrConst3(const S: ShortString); overload;
  66. begin
  67. halt(3);
  68. end;
  69. // ---- no UnicodeString, WideString, PWideChar ----
  70. procedure TestStrConst4(const S: PAnsiChar); overload;
  71. begin
  72. end;
  73. procedure TestStrConst4(const S: AnsiString); overload;
  74. begin
  75. halt(4);
  76. end;
  77. procedure TestStrConst4(const S: ShortString); overload;
  78. begin
  79. halt(4);
  80. end;
  81. // ---- no UnicodeString, WideString, PWideChar, PAnsiChar ----
  82. procedure TestStrConst5(const S: AnsiString); overload;
  83. begin
  84. end;
  85. procedure TestStrConst5(const S: ShortString); overload;
  86. begin
  87. halt(5);
  88. end;
  89. begin
  90. TestStrConst1('Test');
  91. TestStrConst2('Test');
  92. TestStrConst3('Test');
  93. TestStrConst4('Test');
  94. TestStrConst5('Test');
  95. end.