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-13 08:04:19 PST
Message User: matthewjheaney
Date: 04/03/13 08:04:19

Modified:
 /charles/src/testdir/
  test_single_unbounded_merge.adb

Log:
 fixed bug in splice_after

File Changes:

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

File [changed]: test_single_unbounded_merge.adb
Url: http://charles.tigri​s.org/source/browse/​charles/src/testdir/​test_single_unbounde​d_merge.adb?r1=1.1​&r2=1.2
Delta lines: +101 -17
----------------------
--- test_single_unbounded_merge.adb 12 Mar 2004 23:23:12 -0000 1.1
+++ test_single_unbounded_merge.adb 13 Mar 2004 16:04:16 -0000 1.2
@@ -55,6 +55,20 @@
       end loop;
    end Is_Sorted;
 
+
+ function Count (C : Container_Type) return Natural is
+ I : Iterator_Type := First (C);
+ N : Integer'Base := 0;
+ begin
+ while I /= Back (C) loop
+ N := N + 1;
+ Increment (I);
+ end loop;
+
+ return N;
+ end;
+
+
    procedure Sort is
       new Single_Unbounded_Mer​ge_Lists.Generic_Sor​t;
 
@@ -105,18 +119,52 @@
       Print (C2);
       --New_Line;
 
--- I := First (C1);
+ I := First (C1);
 
--- if I /= Back (C1) then
--- N := Random (G) mod Length (C1);
+ if I /= Back (C1) then
+ N := Random (G) mod Length (C1);
 
--- for X in 1 .. N loop
--- Increment (I);
--- end loop;
--- end if;
+ for X in 1 .. N loop
+ Increment (I);
+ end loop;
+ end if;
+
+ J := First (C1);
+
+ if J /= Back (C1) then
+ N := Random (G) mod Length (C1);
+
+ for X in 1 .. N loop
+ Increment (J);
+ end loop;
+ end if;
 
--- Put_Line ("splice #1");
--- Splice_After (C1, I, C2);
+ Put ("splice #1: I=");
+
+ if I = Back (C1) then
+ Put ("<back>");
+ else
+ Put (Element (I).I, Width => 0);
+ Put (Element (I).C);
+ end if;
+
+ Put (" J=");
+
+ if J = Back (C1) then
+ Put ("<back>");
+ else
+ Put (Element (J).I, Width => 0);
+ Put (Element (J).C);
+ end if;
+
+ New_Line;
+
+ --Splice_After (C1, I, C2);
+ Splice_After (C1, Position => I, Pred => J);
+
+ Print (C1);
+ Print (C2);
+ --New_Line;
 
       I := First (C1);
 
@@ -166,6 +214,8 @@
 
             declare
                K : constant Iterator_Type := First (C2);
+ N1 : constant Natural := Length (C1);
+ N2 : constant Natural := Length (C2);
             begin
                Splice_After (C1, I, C2, J);
 
@@ -174,6 +224,10 @@
                New_Line;
 
                pragma Assert (K = First (C1));
+ pragma Assert (Length (C1) = Count (C1));
+ pragma Assert (Length (C2) = Count (C2));
+ pragma Assert (Length (C1) = N1 + 1);
+ pragma Assert (Length (C2) = N2 - 1);
             end;
 
          elsif J = Last (C2) then
@@ -184,6 +238,8 @@
 
                C1b : constant Container_Type := C1;
                C2b : constant Container_Type := C2;
+ N1 : constant Natural := Length (C1);
+ N2 : constant Natural := Length (C2);
             begin
                Splice_After (C1, I, C2, J);
 
@@ -193,6 +249,10 @@
 
                pragma Assert (C1 = C1b);
                pragma Assert (C2 = C2b);
+ pragma Assert (Length (C1) = Count (C1));
+ pragma Assert (Length (C2) = Count (C2));
+ pragma Assert (Length (C1) = N1);
+ pragma Assert (Length (C2) = N2);
             end;
 
          else
@@ -202,6 +262,8 @@
             declare
                K : constant Iterator_Type := Succ (J);
                pragma Assert (K /= Null_Iterator);
+ N1 : constant Natural := Length (C1);
+ N2 : constant Natural := Length (C2);
             begin
                Splice_After (C1, I, C2, J);
 
@@ -210,6 +272,10 @@
                New_Line;
 
                pragma Assert (K = First (C1));
+ pragma Assert (Length (C1) = Count (C1));
+ pragma Assert (Length (C2) = Count (C2));
+ pragma Assert (Length (C1) = N1 + 1);
+ pragma Assert (Length (C2) = N2 - 1);
             end;
 
          end if;
@@ -220,6 +286,8 @@
 
          declare
             K : constant Iterator_Type := First (C2);
+ N1 : constant Natural := Length (C1);
+ N2 : constant Natural := Length (C2);
          begin
             Splice_After (C1, I, C2, J);
 
@@ -228,6 +296,10 @@
             New_Line;
 
             pragma Assert (K = Succ (I));
+ pragma Assert (Length (C1) = Count (C1));
+ pragma Assert (Length (C2) = Count (C2));
+ pragma Assert (Length (C1) = N1 + 1);
+ pragma Assert (Length (C2) = N2 - 1);
          end;
 
       elsif J = Last (C2) then
@@ -238,6 +310,8 @@
 
             C1b : constant Container_Type := C1;
             C2b : constant Container_Type := C2;
+ N1 : constant Natural := Length (C1);
+ N2 : constant Natural := Length (C2);
          begin
             Splice_After (C1, I, C2, J);
 
@@ -247,6 +321,10 @@
 
             pragma Assert (C1 = C1b);
             pragma Assert (C2 = C2b);
+ pragma Assert (Length (C1) = Count (C1));
+ pragma Assert (Length (C2) = Count (C2));
+ pragma Assert (Length (C1) = N1);
+ pragma Assert (Length (C2) = N2);
          end;
 
       else
@@ -255,6 +333,8 @@
 
          declare
             K : constant Iterator_Type := Succ (J);
+ N1 : constant Natural := Length (C1);
+ N2 : constant Natural := Length (C2);
          begin
             Splice_After (C1, I, C2, J);
 
@@ -263,6 +343,10 @@
             New_Line;
 
             pragma Assert (K = Succ (I));
+ pragma Assert (Length (C1) = Count (C1));
+ pragma Assert (Length (C2) = Count (C2));
+ pragma Assert (Length (C1) = N1 + 1);
+ pragma Assert (Length (C2) = N2 - 1);
          end;
 
       end if;




--------------------​--------------------​--------------------​---------
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-13 08:04:19 PST
Messages per page: