summaryrefslogtreecommitdiff
path: root/tests/test/tcpstr19.pp
blob: e655d0c6467763979667f95488b7ac1ade0baf42 (plain)
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
{ %skiptarget=android }
program tcpstr19;

// test conversions from and to rawbytestring
// test that copy function returns the same def as argument
// this test can be only run with the compiler built right now on the
// same system

{$APPTYPE CONSOLE}
{$ifdef fpc}
  {$MODE DELPHIUNICODE}
{$endif}

uses
  {$ifdef unix} cwstring, {$endif}
  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.