fpc/tests/test/tcpstrconcat4.pp
Jonas Maebe 1a560e9875 * when concatenating ansistrings, do not map CP_NONE (rawbytestring) to
CP_ACP (defaultsystemcodepage), because if all input strings have the
    same code page then the result should also have that code page if it's
    assigned to a rawbytestring rather than getting defaultsystemcodepage
  * do not consider empty strings to determine the code page of the result
    in fpc_AnsiStr_Concat_multi(), because that will cause a different
    result than when using a sequence of fpc_AnsiStr_Concat() calls (it
    ignores empty strings to determine the result code page) and it's also
    slower
  * do not consider the run time code page of the destination string in
    fpc_AnsiStr_Concat(_multi)() because Delphi does not do so either. This
    was introduced in r19118, probably to hide another bug
  + test

git-svn-id: branches/cpstrrtl@25143 -
2013-07-19 16:33:14 +00:00

50 lines
976 B
ObjectPascal

{$mode delphiunicode}
type
tstr850 = type ansistring(850);
tstr866 = type ansistring(866);
tstr65001 = type ansistring(65001);
procedure test;
var
s1: tstr850;
s2: tstr866;
s3: tstr65001;
r: rawbytestring;
begin
s1:='a';
s2:='b';
s3:='c';
r:='d';
r:=s1+s2;
writeln(stringcodepage(r));
if (stringcodepage(r)<>0) and
(stringcodepage(r)<>defaultsystemcodepage) then
halt(1);
setcodepage(r,850);
r:=s1+s2;
writeln(stringcodepage(r));
if (stringcodepage(r)<>0) and
(stringcodepage(r)<>defaultsystemcodepage) then
halt(2);
setcodepage(r,CP_ASCII);
r:=s1+s2;
writeln(stringcodepage(r));
if (stringcodepage(r)<>0) and
(stringcodepage(r)<>defaultsystemcodepage) then
halt(3);
r:=s1+s1;
writeln(stringcodepage(r));
if (stringcodepage(r)<>stringcodepage(s1)) then
halt(4);
r:=s2+s2;
writeln(stringcodepage(r));
if (stringcodepage(r)<>stringcodepage(s2)) then
halt(5);
end;
begin
test;
end.