summaryrefslogtreecommitdiff
path: root/tests/webtbs/tw10013.pp
blob: 85386baa23af9118353149b39df152890ee99670 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
program rcerror;

{$MODE DELPHI} {$H+} {$R+}

uses SysUtils;

var
  ws: WideString;
  //wc: WideChar;
  i: Integer;

begin
  ws := UTF8Decode('something');

  WriteLn;
  WriteLn('str: "', UTF8Encode(ws), '"');
  WriteLn('len (must be 9) : ', Length(ws));
  WriteLn;

  for i := 1 to Length(ws) * 2 + 1 do
  begin

    Write('Try to access ws[', i, ']');

    try

      ws[i] := ws[i];
      //wc := ws[i];
      //ws[i] := wc;

      if i > Length(ws) then
        begin
          writeln(' FAULT');
          halt(1);
        end
      else
        WriteLn(' OK');

    except

      on e : Exception do
      begin
        if (e is ERangeError) and (i > Length(ws)) then
          WriteLn(' OK (got a range-check error as expected)');
      end;

    end;

  end;
end.