fpc/tests/test/tcpstr19.pp
paul 3b153c223a compiler:
- treat the defs equal when convert from rawbytstring to any ansistring type (delphi compatible)
  - set result of ansistring copy() function to the type of first argument for ansistring arguments and to ansistring for pchar and char array arguments (delphi compatible)
  + test

git-svn-id: trunk@20285 -
2012-02-09 08:22:38 +00:00

29 lines
595 B
ObjectPascal

program tcpstr19;
// test conversions from and to rawbytestring
// test that copy function returns the same def as argument
{$APPTYPE CONSOLE}
{$ifdef fpc}
{$MODE DELPHIUNICODE}
{$endif}
uses
SysUtils;
var
S: AnsiString;
R: RawByteString;
begin
S := UTF8Encode('Test');
if StringCodePage(S) <> CP_UTF8 then
halt(1);
S := Copy('Test', 1, 2);
if StringCodePage(S) <> DefaultSystemCodePage then
halt(2);
if StringCodePage(Copy(UTF8Encode('Test'), 1, 2)) <> CP_UTF8 then
halt(3);
R := 'Test';
if StringCodePage(R) <> DefaultSystemCodePage then
halt(4);
end.