---------------------------------------------------------------- -- ZLib for Ada thick binding. -- -- -- -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- -- -- -- Open source license information is in the zlib.ads file. -- ----------------------------------------------------------------
-- Test/demo program for the generic read interface.
with Ada.Numerics.Discrete_Random; with Ada.Streams; with Ada.Text_IO;
with ZLib;
procedure Read is
use Ada.Streams;
------------------------------------ -- Test configuration parameters -- ------------------------------------
File_Size : Stream_Element_Offset := 100_000;
Continuous : constant Boolean := False; -- If this constant is True, the test would be repeated again and again, -- with increment File_Size for every iteration.
Header : constant ZLib.Header_Type := ZLib.Default; -- Do not use Header other than Default in ZLib versions 1.1.4 and older.
Init_Random : constant := 8; -- We are using the same random sequence, in case of we catch bug, -- so we would be able to reproduce it.
Gen : Random_Elements.Generator;
Period : constant Stream_Element_Offset := 200; -- Period constant variable for random generator not to be very random. -- Bigger period, harder random.
procedure Read
(Item : out Stream_Element_Array;
Last : out Stream_Element_Offset); -- this procedure is for generic instantiation of -- ZLib.Read -- reading data from the File_In.
procedure Read
(Item : out Stream_Element_Array;
Last : out Stream_Element_Offset) is begin
Last := Stream_Element_Offset'Min
(Item'Last,
Item'First + File_Size - Offset);
for J in Item'First .. Last loop if J < Item'First + Period then
Item (J) := Random_Elements.Random (Gen); else
Item (J) := Item (J - Period); endif;
Offset := Offset + 1; endloop; end Read;
----------- -- Reset -- -----------
procedure Reset is begin
Random_Elements.Reset (Gen, Init_Random);
Pack_Size := 0;
Offset := 1;
Read_First := Read_Buffer'Last + 1;
Read_Last := Read_Buffer'Last; end Reset;
begin
Ada.Text_IO.Put_Line ("ZLib " & ZLib.Version);
loop for Level in ZLib.Compression_Level'Range loop
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.