agpl_1.0.0_b5da3320/src/tests/t018_random.adb

 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
with Text_IO; use Text_IO;
with Ada.Exceptions; use Ada.Exceptions;

with Agpl.Random; use Agpl.Random;

procedure T018_Random is
   subtype Test_Range is Integer range 1 .. 2;
   Counter : array (Test_Range) of Natural := (others => 0);
begin
   for I in 1 .. 10000 loop
      declare
         Sample : constant Test_Range := Get_Integer (Test_Range'First,
                                                      Test_Range'Last);
      begin
         Counter (Sample) := Counter (Sample) + 1;
      end;
   end loop;

   for I in Counter'Range loop
      Put_Line (I'Img & ":" & Counter (I)'Img);
   end loop;
exception
   when E : others =>
      Put_Line ("Exception: " & Exception_Information (E));
end T018_Random;