Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: /charles/src/testdir/

charles
Discussion topic

Back to topic list

CVS update: /charles/src/testdir/

Reply

Author matthewjheaney
Full name Matthew Heaney
Date 2004-03-07 17:58:56 PST
Message User: matthewjheaney
Date: 04/03/07 17:58:56

Added:
 /charles/src/testdir/
  integer_character_ha​shed_maps.ads, integer_character_ha​shed_multimaps.ads,
  integer_hashed_multisets.ads, string_integer_hashed_maps.ads,
  string_integer_hashe​d_multimaps.ads, test_hashed_maps.adb,
  test_hashed_multimaps.adb, test_hashed_multisets.adb,
  test_hashed_string_maps.adb, test_hashed_string_m​ultimaps.adb

Log:
 initial release

File Changes:

Directory: /charles/src/testdir/
====================​============

File [added]: integer_character_ha​shed_maps.ads
Url: http://charles.tigri​s.org/source/browse/​charles/src/testdir/​integer_character_ha​shed_maps.ads?rev=1.​1&content-type=t​ext/vnd.viewcvs-mark​up
Added lines: 13
---------------
with Charles.Maps.Hashed.Unbounded;
pragma Elaborate_All (Charles.Maps.Hashed​.Unbounded);

with Charles.Hash_Integer;

package Integer_Character_Hashed_Maps is
   new Charles.Maps.Hashed.Unbounded (Integer, Character, Charles.Hash_Integer);

pragma Preelaborate (Integer_Character_H​ashed_Maps);





File [added]: integer_character_ha​shed_multimaps.ads
Url: http://charles.tigri​s.org/source/browse/​charles/src/testdir/​integer_character_ha​shed_multimaps.ads?r​ev=1.1&content-t​ype=text/vnd.viewcvs​-markup
Added lines: 14
---------------
with Charles.Multimaps.Ha​shed.Unbounded;
pragma Elaborate_All (Charles.Multimaps.H​ashed.Unbounded);

with Charles.Hash_Integer;

package Integer_Character_Ha​shed_Multimaps is
   new Charles.Multimaps.Ha​shed.Unbounded (Integer, Character, Charles.Hash_Integer);

pragma Preelaborate (Integer_Character_H​ashed_Multimaps);






File [added]: integer_hashed_multisets.ads
Url: http://charles.tigri​s.org/source/browse/​charles/src/testdir/​integer_hashed_multi​sets.ads?rev=1.1​&content-type=text/v​nd.viewcvs-markup
Added lines: 9
--------------
with Charles.Multisets.Ha​shed.Unbounded;
pragma Elaborate_All (Charles.Multisets.H​ashed.Unbounded);

with Charles.Hash_Integer;

package Integer_Hashed_Multisets is
   new Charles.Multisets.Ha​shed.Unbounded (Integer, Hash => Charles.Hash_Integer);

pragma Preelaborate (Integer_Hashed_Multisets);

File [added]: string_integer_hashed_maps.ads
Url: http://charles.tigri​s.org/source/browse/​charles/src/testdir/​string_integer_hashe​d_maps.ads?rev=1.1​&content-type=text​/vnd.viewcvs-markup
Added lines: 13
---------------
with Charles.Maps.Hashed.​Strings.Unbounded;
pragma Elaborate_All (Charles.Maps.Hashed​.Strings.Unbounded);​

package String_Integer_Hashed_Maps is
   new Charles.Maps.Hashed.​Strings.Unbounded (Integer);

pragma Preelaborate (String_Integer_Hashed_Maps);







File [added]: string_integer_hashe​d_multimaps.ads
Url: http://charles.tigri​s.org/source/browse/​charles/src/testdir/​string_integer_hashe​d_multimaps.ads?rev=​1.1&content-type​=text/vnd.viewcvs-ma​rkup
Added lines: 14
---------------
with Charles.Multimaps.Ha​shed.Strings.Unbound​ed;
pragma Elaborate_All (Charles.Multimaps.H​ashed.Strings.Unboun​ded);

package String_Integer_Hashed_Multimaps is
   new Charles.Multimaps.Ha​shed.Strings.Unbound​ed (Integer);

pragma Preelaborate (String_Integer_Hash​ed_Multimaps);








File [added]: test_hashed_maps.adb
Url: http://charles.tigri​s.org/source/browse/​charles/src/testdir/​test_hashed_maps.adb​?rev=1.1&content​-type=text/vnd.viewc​vs-markup
Added lines: 141
----------------
with Integer_Character_Hashed_Maps; use Integer_Character_Hashed_Maps;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Numerics.Discrete_Random;

procedure Test_Hashed_Maps is

   subtype Integer_Subtype is Integer range 1 .. 1000;

   package Random_Keys is
      new Ada.Numerics.Discrete_Random (Integer_Subtype);

   GK : Random_Keys.Generator;

   subtype Character_Subtype is
     Character range Character'Succ (' ') .. '~';

   package Random_Elements is
       new Ada.Numerics.Discrete_Random (Character_Subtype);

   GE : Random_Elements.Generator;

   use Random_Keys, Random_Elements;

   M, M2 : Container_Type;

   K : Integer;
   E : Character;

   I, J : Iterator_Type;
   B : Boolean;

   N : Natural;

begin

   Reset (GK);
   Reset (GE);

   pragma Assert (First (M) = Back (M));
   pragma Assert (Length (M) = 0);

   pragma Assert (M = M2);

   M2 := M;
   pragma Assert (M = M2);

   Assign (Target => M2, Source => M);
   pragma Assert (M = M2);

   E := Random (GE);

   Insert (M, 42, E, I, B);
   pragma Assert (Length (M) = 1);
   pragma Assert (B);
   pragma Assert (Key (I) = 42);
   pragma Assert (Element (I) = E);
   pragma Assert (I = First (M));
   pragma Assert (Succ (M, I) = Back (M));

   M2 := M;
   pragma Assert (M = M2);

   Assign (Target => M2, Source => M);
   pragma Assert (M = M2);

   J := Find (M, Key => 42);
   pragma Assert (J /= Back (M));
   pragma Assert (Key (J) = 42);
   pragma Assert (Element (J) = E);

   M2 := M;
   pragma Assert (M = M2);

   Assign (Target => M2, Source => M);
   pragma Assert (M = M2);

   Put_Line ("inserting");

   loop

      N := Length (M);

      exit when N > 900;

      K := Random (GK);
      E := Random (GE);

      Insert (M, K, E, I, B);

      pragma Assert (Key (I) = K);

      J := Find (M, K);
      pragma Assert (J /= Back (M));
      pragma Assert (Key (J) = K);

      if B then
         pragma Assert (Length (M) = N + 1);
         pragma Assert (Element (J) = E);
         null;
      else
         pragma Assert (Length (M) = N);
         null;
      end if;

      M2 := M;
      pragma Assert (M = M2);

      Assign (Target => M2, Source => M);
      pragma Assert (M = M2);

   end loop;

   Put_Line ("deleting");

   while not Is_Empty (M) loop

      I := First (M);

      for Index in 1 .. Random (GK) mod Length (M) loop
         Increment (M, I);
      end loop;

      pragma Assert (I /= Back (M));

      K := Key (I);

      Delete (M, I);

      pragma Assert (not Is_In (K, M));

      M2 := M;
      pragma Assert (M = M2);

      Assign (Target => M2, Source => M);
      pragma Assert (M = M2);

   end loop;

end Test_Hashed_Maps;



File [added]: test_hashed_multimaps.adb
Url: http://charles.tigri​s.org/source/browse/​charles/src/testdir/​test_hashed_multimap​s.adb?rev=1.1&co​ntent-type=text/vnd.​viewcvs-markup
Added lines: 130
----------------
with Integer_Character_Ha​shed_Multimaps; use Integer_Character_Ha​shed_Multimaps;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Numerics.Discrete_Random;

procedure Test_Hashed_Multimaps is

   subtype Integer_Subtype is Integer range 1 .. 1000;

   package Random_Keys is
      new Ada.Numerics.Discrete_Random (Integer_Subtype);

   GK : Random_Keys.Generator;

   subtype Character_Subtype is
     Character range Character'Succ (' ') .. '~';

   package Random_Elements is
       new Ada.Numerics.Discrete_Random (Character_Subtype);

   GE : Random_Elements.Generator;

   use Random_Keys, Random_Elements;

   M, M2 : Container_Type;

   K : Integer;
   E : Character;

   I, J : Iterator_Type;

   N : Natural;

begin

   Reset (GK);
   Reset (GE);

   pragma Assert (First (M) = Back (M));
   pragma Assert (Length (M) = 0);

   pragma Assert (M = M2);

   M2 := M;
   pragma Assert (M = M2);

   Assign (Target => M2, Source => M);
   pragma Assert (M = M2);

   E := Random (GE);

   Insert (M, 42, E, I);
   pragma Assert (Length (M) = 1);
   pragma Assert (Key (I) = 42);
   pragma Assert (Element (I) = E);
   pragma Assert (I = First (M));
   pragma Assert (Succ (M, I) = Back (M));

   M2 := M;
   pragma Assert (M = M2);

   Assign (Target => M2, Source => M);
   pragma Assert (M = M2);

   J := Find (M, Key => 42);
   pragma Assert (J /= Back (M));
   pragma Assert (Key (J) = 42);
   pragma Assert (Element (J) = E);

   M2 := M;
   pragma Assert (M = M2);

   Assign (Target => M2, Source => M);
   pragma Assert (M = M2);

   Put_Line ("inserting");

   loop

      N := Length (M);

      exit when N > 900;

      K := Random (GK);
      E := Random (GE);

      Insert (M, K, E, I);
      pragma Assert (Key (I) = K);

      J := Find (M, K);
      pragma Assert (J /= Back (M));
      pragma Assert (Key (J) = K);
      pragma Assert (Length (M) = N + 1);
      pragma Assert (Element (J) = E);

      M2 := M;
      pragma Assert (M = M2);

      Assign (Target => M2, Source => M);
      pragma Assert (M = M2);

   end loop;

   Put_Line ("deleting");

   while not Is_Empty (M) loop

      I := First (M);

      for Index in 1 .. Random (GK) mod Length (M) loop
         Increment (M, I);
      end loop;

      pragma Assert (I /= Back (M));

      K := Key (I);

      Delete (M, I);

      M2 := M;
      pragma Assert (M = M2);

      Assign (Target => M2, Source => M);
      pragma Assert (M = M2);

   end loop;

end Test_Hashed_Multimaps;




File [added]: test_hashed_multisets.adb
Url: http://charles.tigri​s.org/source/browse/​charles/src/testdir/​test_hashed_multiset​s.adb?rev=1.1&co​ntent-type=text/vnd.​viewcvs-markup
Added lines: 137
----------------
with Integer_Hashed_Multisets; use Integer_Hashed_Multisets;
--with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Numerics.Discrete_Random;

procedure Test_Hashed_Multisets is

   subtype Integer_Subtype is Integer range 1 .. 1000;

   package Random_Numbers is
      new Ada.Numerics.Discrete_Random (Integer_Subtype);

   use Random_Numbers;

   function In_Range (I : Iterator_Type;
                      S : Container_Type) return Boolean is

      J : Iterator_Type := Find (S, Element (I));
   begin
      if J = Back (S) then
         return False;
      end if;

      while J /= Null_Iterator
        and then Is_Equal_Key (J, I)
      loop
         if I = J then
            return True;
         end if;

         Increment (S, J);
      end loop;

      return False;
   end In_Range;

   G : Generator;

   S, S2 : Container_Type;

   E : Integer;
   I, J : Iterator_Type;

   N : Natural;

begin

   Reset (G);

   pragma Assert (Length (S) = 0);
   pragma Assert (S = S2);

   S2 := S;
   pragma Assert (S = S2);

   Assign (Target => S2, Source => S);
   pragma Assert (S = S2);

   pragma Assert (Find (S, Item => 42) = Back (S));

   Insert (S, 42, I);
   pragma Assert (Length (S) = 1);
   pragma Assert (Element (I) = 42);
   pragma Assert (I = First (S));
   pragma Assert (Succ (S, I) = Back (S));
   pragma Assert (In_Range (I, S));

   S2 := S;
   pragma Assert (S = S2);

   Assign (Target => S2, Source => S);
   pragma Assert (S = S2);

   J := Find (S, 42);
   pragma Assert (J /= Back (S));
   pragma Assert (Element (J) = 42);

   S2 := S;
   pragma Assert (S = S2);

   Assign (Target => S2, Source => S);
   pragma Assert (S = S2);

   Put_Line ("inserting");

   loop

      N := Length (S);

      exit when N > 900;

      E := Random (G);

      Insert (S, E, I);
      pragma Assert (Element (I) = E);
      pragma Assert (In_Range (I, S));

      J := Find (S, E);
      pragma Assert (J /= Back (S));
      pragma Assert (Element (J) = E);
      pragma Assert (Length (S) = N + 1);

      S2 := S;
      pragma Assert (S = S2);

      Assign (Target => S2, Source => S);
      pragma Assert (S = S2);

   end loop;

   Put_Line ("deleting");

   while not Is_Empty (S) loop

      I := First (S);

      for J in 1 .. Random (G) mod Length (S) loop
         Increment (S, I);
      end loop;

      pragma Assert (I /= Back (S));

      E := Element (I);

      Delete (S, I);

      S2 := S;
      pragma Assert (S = S2);

      Assign (Target => S2, Source => S);
      pragma Assert (S = S2);

   end loop;

end Test_Hashed_Multisets;



File [added]: test_hashed_string_maps.adb
Url: http://charles.tigri​s.org/source/browse/​charles/src/testdir/​test_hashed_string_m​aps.adb?rev=1.1&​content-type=text/vn​d.viewcvs-markup
Added lines: 151
----------------
with String_Integer_Hashed_Maps; use String_Integer_Hashed_Maps;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Numerics.Discrete_Random;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;

procedure Test_Hashed_String_Maps is

   subtype Integer_Subtype is Integer range 1 .. 1000;

   package Random_Elements is
       new Ada.Numerics.Discrete_Random (Integer_Subtype);

   GE : Random_Elements.Generator;
   use Random_Elements;

   subtype Character_Subtype is
     Character range Character'Succ (' ') .. '~';

   package Random_Characters is
      new Ada.Numerics.Discrete_Random (Character_Subtype);

   GK : Random_Characters.Generator;
   use Random_Characters;

   function Random_Key return String is

      N : constant Positive := 1 + Random (GE) mod 8;
      K : String (1 .. N);
   begin
      for I in K'Range loop
         K (I) := Random (GK);
      end loop;

      return K;
   end;

   M, M2 : Container_Type;

   K : Unbounded_String;
   E : Integer;

   I, J : Iterator_Type;
   B : Boolean;

   N : Natural;

begin

   Reset (GK);
   Reset (GE);

   pragma Assert (First (M) = Back (M));
   pragma Assert (Length (M) = 0);
   pragma Assert (M = M2);

   M2 := M;
   pragma Assert (M = M2);

   Assign (Target => M2, Source => M);
   pragma Assert (M = M2);

   E := Random (GE);

   K := To_Unbounded_String (Random_Key);

   Insert (M, To_String (K), E, I, B);
   pragma Assert (Length (M) = 1);
   pragma Assert (B);
   pragma Assert (Key (I) = To_String (K));
   pragma Assert (Element (I) = E);
   pragma Assert (I = First (M));
   pragma Assert (Succ (M, I) = Back (M));

   M2 := M;
   pragma Assert (M = M2);

   Assign (Target => M2, Source => M);
   pragma Assert (M = M2);

   J := Find (M, Key => To_String (K));
   pragma Assert (J /= Back (M));
   pragma Assert (Key (J) = To_String (K));
   pragma Assert (Element (J) = E);

   M2 := M;
   pragma Assert (M = M2);

   Assign (Target => M2, Source => M);
   pragma Assert (M = M2);

   Put_Line ("inserting");

   loop

      N := Length (M);

      exit when N > 900;

      K := To_Unbounded_String (Random_Key);
      E := Random (GE);

      Insert (M, To_String (K), E, I, B);
      pragma Assert (Key (I) = To_String (K));

      J := Find (M, Key => To_String (K));
      pragma Assert (J /= Back (M));
      pragma Assert (Key (J) = To_String (K));

      if B then
         pragma Assert (Length (M) = N + 1);
         pragma Assert (Element (J) = E);
         null;
      else
         pragma Assert (Length (M) = N);
         null;
      end if;

      M2 := M;
      pragma Assert (M = M2);

      Assign (Target => M2, Source => M);
      pragma Assert (M = M2);

   end loop;

   Put_Line ("deleting");

   while not Is_Empty (M) loop

      I := First (M);

      for Index in 1 .. Random (GE) mod Length (M) loop
         Increment (M, I);
      end loop;

      K := To_Unbounded_String (Key (I));

      Delete (M, I);
      pragma Assert (not Is_In (To_String (K), M));

      M2 := M;
      pragma Assert (M = M2);

      Assign (Target => M2, Source => M);
      pragma Assert (M = M2);

   end loop;

end Test_Hashed_String_Maps;



File [added]: test_hashed_string_m​ultimaps.adb
Url: http://charles.tigri​s.org/source/browse/​charles/src/testdir/​test_hashed_string_m​ultimaps.adb?rev=1.1​&content-type=te​xt/vnd.viewcvs-marku​p
Added lines: 142
----------------
with String_Integer_Hashe​d_Multimaps; use String_Integer_Hashe​d_Multimaps;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Numerics.Discrete_Random;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;

procedure Test_Hashed_String_Multimaps is

   subtype Integer_Subtype is Integer range 1 .. 1000;

   package Random_Elements is
       new Ada.Numerics.Discrete_Random (Integer_Subtype);

   GE : Random_Elements.Generator;
   use Random_Elements;

   subtype Character_Subtype is
     Character range Character'Succ (' ') .. '~';

   package Random_Characters is
      new Ada.Numerics.Discrete_Random (Character_Subtype);

   GK : Random_Characters.Generator;
   use Random_Characters;

   function Random_Key return String is

      N : constant Positive := 1 + Random (GE) mod 8;
      K : String (1 .. N);
   begin
      for I in K'Range loop
         K (I) := Random (GK);
      end loop;

      return K;
   end;

   M, M2 : Container_Type;

   K : Unbounded_String;
   E : Integer;

   I, J : Iterator_Type;

   N : Natural;

begin

   Reset (GK);
   Reset (GE);

   pragma Assert (First (M) = Back (M));
   pragma Assert (Length (M) = 0);
   pragma Assert (M = M2);

   M2 := M;
   pragma Assert (M = M2);

   Assign (Target => M2, Source => M);
   pragma Assert (M = M2);

   E := Random (GE);

   K := To_Unbounded_String (Random_Key);

   Insert (M, To_String (K), E, I);
   pragma Assert (Length (M) = 1);
   pragma Assert (Key (I) = To_String (K));
   pragma Assert (Element (I) = E);
   pragma Assert (I = First (M));
   pragma Assert (Succ (M, I) = Back (M));

   M2 := M;
   pragma Assert (M = M2);

   Assign (Target => M2, Source => M);
   pragma Assert (M = M2);

   J := Find (M, Key => To_String (K));
   pragma Assert (J /= Back (M));
   pragma Assert (Key (J) = To_String (K));
   pragma Assert (Element (J) = E);

   M2 := M;
   pragma Assert (M = M2);

   Assign (Target => M2, Source => M);
   pragma Assert (M = M2);

   Put_Line ("inserting");

   loop

      N := Length (M);

      exit when N > 900;

      K := To_Unbounded_String (Random_Key);
      E := Random (GE);

      Insert (M, To_String (K), E, I);
      pragma Assert (Key (I) = To_String (K));

      J := Find (M, Key => To_String (K));
      pragma Assert (J /= Back (M));
      pragma Assert (Key (J) = To_String (K));
      pragma Assert (Length (M) = N + 1);
      pragma Assert (Element (J) = E);

      M2 := M;
      pragma Assert (M = M2);

      Assign (Target => M2, Source => M);
      pragma Assert (M = M2);

   end loop;

   Put_Line ("deleting");

   while not Is_Empty (M) loop

      I := First (M);

      for Index in 1 .. Random (GE) mod Length (M) loop
         Increment (M, I);
      end loop;

      K := To_Unbounded_String (Key (I));

      Delete (M, I);

      M2 := M;
      pragma Assert (M = M2);

      Assign (Target => M2, Source => M);
      pragma Assert (M = M2);

   end loop;

end Test_Hashed_String_Multimaps;







--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: cvs-unsubscribe@char​les.tigris.org
For additional commands, e-mail: cvs-help at charles dot tigris dot org

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: /charles/src/testdir/ matthewjheaney Matthew Heaney 2004-03-07 17:58:56 PST
Messages per page: