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-03 21:54:00 PST
Message User: matthewjheaney
Date: 04/03/03 21:54:00

Added:
 /charles/src/testdir/
  .cvsignore, integer_character_so​rted_maps.ads, integer_sorted_sets.ads,
  test_sorted_maps.adb, test_sorted_sets.adb

Log:
 Repository : :pserver:matthewjhea​ney at cvs dot tigris dot org:/​cvs
 Module : charles/src
 Working dir: ~/tigris/charles/src/
 
 
 
 In directory .:
               Up-To-Date 1.2 .cvsignore
               Up-To-Date 1.1 COPYING.TXT
               Up-To-Date 1.1 README.txt
               Up-To-Date 1.1 charles-algorithms-g​eneric_adjacent_find​.adb
               Up-To-Date 1.1 charles-algorithms-g​eneric_adjacent_find​.ads
               Up-To-Date 1.1 charles-algorithms-g​eneric_compare.adb
               Up-To-Date 1.1 charles-algorithms-g​eneric_compare.ads
               Up-To-Date 1.1 charles-algorithms-g​eneric_lexicographic​al_compare.adb
               Up-To-Date 1.1 charles-algorithms-g​eneric_lexicographic​al_compare.ads
               Up-To-Date 1.1 charles-algorithms-g​eneric_next_permutat​ion.adb
               Up-To-Date 1.1 charles-algorithms-g​eneric_next_permutat​ion.ads
               Up-To-Date 1.1 charles-algorithms-g​eneric_reverse_bidir​ectional.adb
               Up-To-Date 1.1 charles-algorithms-g​eneric_reverse_bidir​ectional.ads
               Up-To-Date 1.1 charles-algorithms-g​eneric_reverse_rando​m_access.adb
               Up-To-Date 1.1 charles-algorithms-g​eneric_reverse_rando​m_access.ads
               Up-To-Date 1.1 charles-algorithms.ads
               Up-To-Date 1.1 charles-maps-sorted-​unbounded.adb
               Up-To-Date 1.1 charles-maps-sorted-​unbounded.ads
               Up-To-Date 1.1 charles-maps-sorted.ads
               Up-To-Date 1.1 charles-maps.ads
               Up-To-Date 1.2 charles-multisets-so​rted-unbounded.adb
               Up-To-Date 1.2 charles-multisets-so​rted-unbounded.ads
               Up-To-Date 1.1 charles-multisets-sorted.ads
               Up-To-Date 1.1 charles-multisets.ads
               Up-To-Date 1.1 charles-red_black_trees.adb
               Up-To-Date 1.1 charles-red_black_trees.ads
               Up-To-Date 1.1 charles-sets-sorted-​unbounded.adb
               Up-To-Date 1.1 charles-sets-sorted-​unbounded.ads
               Up-To-Date 1.1 charles-sets-sorted.ads
               Up-To-Date 1.1 charles-sets.ads
               Up-To-Date 1.2 charles.ads
 In directory testdir:
               Added testdir/.cvsignore
               Added testdir/integer_char​acter_sorted_maps.ad​s
               Added testdir/integer_sorted_sets.ads
               Added testdir/test_sorted_maps.adb
               Added testdir/test_sorted_sets.adb
 
 --------------------- End ---------------------
 -- last cmd: cvs -f status -v --

File Changes:

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

File [added]: .cvsignore
Url: http://charles.tigri​s.org/source/browse/​charles/src/testdir/​.cvsignore?rev=1.1​&content-type=text​/vnd.viewcvs-markup
Added lines: 21
---------------
b~test_sorted_maps.adb
b~test_sorted_maps.ads
b~test_sorted_maps.ali
b~test_sorted_sets.adb
b~test_sorted_sets.ads
b~test_sorted_sets.ali
charles-algorithms-g​eneric_compare.ali
charles-algorithms-g​eneric_lexicographic​al_compare.ali
charles-algorithms.ali
charles-maps-sorted-​unbounded.ali
charles-maps-sorted.ali
charles-maps.ali
charles-red_black_trees.ali
charles-sets-sorted-​unbounded.ali
charles-sets-sorted.ali
charles-sets.ali
charles.ali
integer_character_so​rted_maps.ali
integer_sorted_sets.ali
test_sorted_maps.ali
test_sorted_sets.ali

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

package Integer_Character_Sorted_Maps is
   new Charles.Maps.Sorted.Unbounded (Integer, Character);

pragma Preelaborate (Integer_Character_S​orted_Maps);




File [added]: integer_sorted_sets.ads
Url: http://charles.tigri​s.org/source/browse/​charles/src/testdir/​integer_sorted_sets.​ads?rev=1.1&cont​ent-type=text/vnd.vi​ewcvs-markup
Added lines: 9
--------------
with Charles.Sets.Sorted.Unbounded;
pragma Elaborate_All (Charles.Sets.Sorted​.Unbounded);

package Integer_Sorted_Sets is
   new Charles.Sets.Sorted.Unbounded (Integer);

pragma Preelaborate (Integer_Sorted_Sets);



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

procedure Test_Sorted_Maps is

   procedure Check_Sorted (C : Container_Type) is
      K : Integer := 0;

      procedure Process (I : Iterator_Type) is
         K2 : constant Integer := Key (I);
      begin
         pragma Assert (K2 > K);
         K := K2;
      end;

      procedure Iterate is
         new Integer_Character_So​rted_Maps.Generic_It​eration;
   begin
      Iterate (C);
   end;

   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 (Succ (First (M)) = First (M));
   pragma Assert (Pred (First (M)) = First (M));
   pragma Assert (Succ (Back (M)) = Back (M));
   pragma Assert (Pred (Back (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 (I = Last (M));
   pragma Assert (Pred (I) = Back (M));
   pragma Assert (Succ (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

      Check_Sorted (M);

      N := Length (M);

      exit when N > 900;

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

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

-- Put (E, Width => Integer_Subtype'Width);
-- Put (' ');
-- Put (Boolean'Image (B));
-- New_Line;

      pragma Assert (Pred (First (M)) = Back (M));
      pragma Assert (Succ (Back (M)) = First (M));
      pragma Assert (Key (I) = K);

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

      if I = First (M) then
         pragma Assert (Key (I) < Key (Succ (I)));
         null;
      elsif I = Last (M) then
         pragma Assert (Key (I) > Key (Pred (I)));
         null;
      else
         pragma Assert (Key (I) > Key (Pred (I)));
         pragma Assert (Key (I) < Key (Succ (I)));
         null;
      end if;

      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 := Succ (First (M), Offset => Random (GK) mod Length (M));
      K := Key (I);

-- Put (Length (S), Width => 0);
-- Put (' ');
-- Put (E, Width => 0);
--
-- if I = First (S) then
-- Put (" first");
--
-- if I = Last (S) then
-- Put (" last");
-- end if;
--
-- elsif I = Last (S) then
-- Put (" last");
--
-- end if;
--
-- New_Line;

      Delete (M, I);

      pragma Assert (Pred (First (M)) = Back (M));
      pragma Assert (Succ (Back (M)) = First (M));
      pragma Assert (not Is_In (K, M));

      Check_Sorted (M);

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

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

   end loop;

end Test_Sorted_Maps;


File [added]: test_sorted_sets.adb
Url: http://charles.tigri​s.org/source/browse/​charles/src/testdir/​test_sorted_sets.adb​?rev=1.1&content​-type=text/vnd.viewc​vs-markup
Added lines: 182
----------------
with Integer_Sorted_Sets; use Integer_Sorted_Sets;
--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_Sorted_Sets is

   procedure Check_Sorted (S : Container_Type) is
      E : Integer := 0;

      procedure Process (I : Iterator_Type) is
         E2 : constant Integer := Element (I);
      begin
         pragma Assert (E2 > E);
         E := E2;
      end;

      procedure Iterate is
         new Integer_Sorted_Sets.​Generic_Iteration;
   begin
      Iterate (S);
   end;

   subtype Integer_Subtype is Integer range 1 .. 1000;

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

   use Random_Numbers;

   G : Generator;

   S, S2 : Container_Type;

   E : Integer;
   I, J : Iterator_Type;
   B : Boolean;

   N : Natural;

begin

   --Reset (G, 0); --seed with 0 for now
   Reset (G);

   pragma Assert (First (S) = Back (S));
   pragma Assert (Succ (First (S)) = First (S));
   pragma Assert (Pred (First (S)) = First (S));
   pragma Assert (Succ (Back (S)) = Back (S));
   pragma Assert (Pred (Back (S)) = Back (S));
   pragma Assert (Length (S) = 0);

   pragma Assert (S = S2);

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

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

   Insert (S, 42, I, B);
   pragma Assert (Length (S) = 1);
   pragma Assert (B);
   pragma Assert (Element (I) = 42);
   pragma Assert (I = First (S));
   pragma Assert (I = Last (S));
   pragma Assert (Pred (I) = Back (S));
   pragma Assert (Succ (I) = Back (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

      Check_Sorted (S);

      N := Length (S);

      exit when N > 900;

      E := Random (G);

      Insert (S, E, I, B);

-- Put (E, Width => Integer_Subtype'Width);
-- Put (' ');
-- Put (Boolean'Image (B));
-- New_Line;

      pragma Assert (Pred (First (S)) = Back (S));
      pragma Assert (Succ (Back (S)) = First (S));
      pragma Assert (Element (I) = E);

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

      if I = First (S) then
         pragma Assert (Element (I) < Element (Succ (I)));
         null;
      elsif I = Last (S) then
         pragma Assert (Element (I) > Element (Pred (I)));
         null;
      else
         pragma Assert (Element (I) > Element (Pred (I)));
         pragma Assert (Element (I) < Element (Succ (I)));
         null;
      end if;

      if B then
         pragma Assert (Length (S) = N + 1);
         null;
      else
         pragma Assert (Length (S) = N);
         null;
      end if;

      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 := Succ (First (S), Offset => Random (G) mod Length (S));
      E := Element (I);

-- Put (Length (S), Width => 0);
-- Put (' ');
-- Put (E, Width => 0);
--
-- if I = First (S) then
-- Put (" first");
--
-- if I = Last (S) then
-- Put (" last");
-- end if;
--
-- elsif I = Last (S) then
-- Put (" last");
--
-- end if;
--
-- New_Line;

      Delete (S, I);

      pragma Assert (Pred (First (S)) = Back (S));
      pragma Assert (Succ (Back (S)) = First (S));
      pragma Assert (not Is_In (E, S));

      Check_Sorted (S);

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

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

   end loop;

end Test_Sorted_Sets;




--------------------​--------------------​--------------------​---------
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-03 21:54:00 PST
Messages per page: