summaryrefslogtreecommitdiff
path: root/tests/test/tparray16.pp
blob: 1c2498f28a5d171494f07843acc9e6a82f066acf (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
{ from gpc tests, original name pack4.pas }

{$ifdef fpc}
{$bitpacking on}
{$endif fpc}

Program PackUnpack;

Var
  foo: array [ 1..7 ] of Boolean;
  bar: packed array [ 1..3 ] of Boolean;
  i: Integer;
  temp: Boolean;

begin
  for i:= 1 to 3 do
    bar [ i ]:= true;
  for i:= 1 to 7 do
    foo [ i ]:= false;
  foo [ 4 ]:= true;
  foo [ 5 ]:= true;
  pack ( foo, 3, bar );
  if bar [ 3 ] and bar [ 2 ] and not bar [ 1 ] then
    begin
      for i:= 1 to 3 do
        begin
          temp:= not bar [ i ];
          bar [ i ]:= temp;
        end { for };
      unpack ( bar, foo, 5 );
      if not foo [ 1 ] and not foo [ 2 ] and not foo [ 3 ] and foo [ 4 ]
         and foo [ 5 ] and not foo [ 6 ] and not foo [ 7 ] then
        writeln ( 'OK' )
      else
        begin
          write ( 'failed: foo =' );
          for i:= 1 to 7 do
            write ( ' ', foo [ i ] );
          writeln;
          halt(1);
        end { else };
    end { if }
  else
    begin
      write ( 'failed: bar =' );
      for i:= 1 to 3 do
        write ( ' ', bar [ i ] );
      writeln;
      halt(1);
    end { else };
end.