1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
program tcpstr20;
{$APPTYPE CONSOLE}
{$MODE Delphi}
// Test checks that preferred string type arguments
// for AnsiChar are: ShortString, AnsiString, UnicodeString, WideString
// for WideChar are: UnicodeString, WideString, AnsiString, ShortString
const
AC = AnsiChar(13);
WC = WideChar(13);
procedure Test(const I, Compare, ExitCode: Integer);
begin
if I <> Compare then
begin
WriteLn(I, ' <> ', Compare);
halt(ExitCode);
end;
end;
{$ifndef FPC_WIDESTRING_EQUAL_UNICODESTRING}
function OverAll(const S: WideString): Integer; overload;
begin
Result := 1;
end;
{$endif}
function OverAll(const S: UnicodeString): Integer; overload;
begin
Result := 2;
end;
function OverAll(const S: RawByteString): Integer; overload;
begin
Result := 3;
end;
function OverAll(const S: ShortString): Integer; overload;
begin
Result := 4;
end;
{$ifndef FPC_WIDESTRING_EQUAL_UNICODESTRING}
function OverWide(const S: WideString): Integer; overload;
begin
Result := 1;
end;
{$endif}
function OverWide(const S: UnicodeString): Integer; overload;
begin
Result := 2;
end;
function OverNonWide(const S: RawByteString): Integer; overload;
begin
Result := 3;
end;
function OverNonWide(const S: ShortString): Integer; overload;
begin
Result := 4;
end;
{$ifndef FPC_WIDESTRING_EQUAL_UNICODESTRING}
function OverAllNoUni(const S: WideString): Integer; overload;
begin
Result := 1;
end;
function OverAllNoUni(const S: RawByteString): Integer; overload;
begin
Result := 3;
end;
function OverAllNoUni(const S: ShortString): Integer; overload;
begin
Result := 4;
end;
{$endif}
{$ifndef FPC_WIDESTRING_EQUAL_UNICODESTRING}
function OverAllNoShort(const S: WideString): Integer; overload;
begin
Result := 1;
end;
{$endif}
function OverAllNoShort(const S: UnicodeString): Integer; overload;
begin
Result := 2;
end;
function OverAllNoShort(const S: RawByteString): Integer; overload;
begin
Result := 3;
end;
begin
Test(OverAll(AC), 4, 1);
Test(OverAll(WC), 2, 2);
Test(OverWide(AC), 2, 3);
Test(OverNonWide(WC), 3, 4);
{$ifndef FPC_WIDESTRING_EQUAL_UNICODESTRING}
Test(OverAllNoUni(WC), 1, 5);
{$endif}
Test(OverAllNoShort(AC), 3, 6);
end.
|