CVS difference for acats/cxa/cxai001.a

Differences between 1.1 and version 1.2
Log of other versions for file acats/cxa/cxai001.a

--- acats/cxa/cxai001.a	2014/03/11 05:58:38	1.1
+++ acats/cxa/cxai001.a	2014/04/05 01:03:02	1.2
@@ -49,6 +49,8 @@
 --                          Ada 2012 features.
 --      10 Mar 14   RLB     Created ACATS 4.0 version, replaced Ada 2012
 --                          features.
+--      31 Mar 14   RLB     Merged in tampering checks from third pre-release
+--                          version.
 --!
 with Ada.Containers.Vectors;
 with Report;
@@ -71,9 +73,9 @@
    My_Vector_2 : My_Vectors.Vector;
    My_Vector_3 : My_Vectors.Vector;
 
-   No_Tests : constant := 10;
+   Num_Tests : constant := 10;
 
-   subtype Array_Bounds_Type is Ada.Containers.Count_Type range 1 .. No_Tests;
+   subtype Array_Bounds_Type is Ada.Containers.Count_Type range 1 .. Num_Tests;
 
    -- No fractional parts so that can compare values for equality
 
@@ -86,6 +88,35 @@
 
    My_Index_1 : Natural;
 
+   procedure Tampering_Check
+     (Container : in out My_Vectors.Vector;
+      Where     : in     String) is
+
+      Program_Error_Raised : Boolean := False;
+
+   begin
+
+      declare
+      begin
+
+         Container.Append (New_Item => Value_In_Array (1));
+
+      exception
+
+         when Program_Error =>
+
+            Program_Error_Raised := True;
+
+      end;
+
+      if not Program_Error_Raised then
+
+         Report.Failed ("Tampering should have raised error in " & Where);
+
+      end if;
+
+   end Tampering_Check;
+
    use type Ada.Containers.Count_Type;
    use type My_Vectors.Cursor;
    use type My_Vectors.Vector;
@@ -101,11 +132,11 @@
 
    -- Test Reserve_Capacity and Capacity
 
-   My_Vector_1.Reserve_Capacity (Capacity => No_Tests);
+   My_Vector_1.Reserve_Capacity (Capacity => Num_Tests);
 
-   My_Vector_2.Reserve_Capacity (Capacity => No_Tests / 2);
+   My_Vector_2.Reserve_Capacity (Capacity => Num_Tests / 2);
 
-   if My_Vector_1.Capacity < No_Tests then
+   if My_Vector_1.Capacity < Num_Tests then
 
       Report.Failed ("Capacity less than expected after Reserve_Capacity");
 
@@ -116,25 +147,25 @@
 
    if My_Vector_1 /= My_Vectors.Empty_Vector then
 
-      Report.Failed ("Not initially empty");
+      Report.Failed ("Not initially empty #1");
 
    end if;
 
    if not My_Vector_1.Is_Empty then
 
-      Report.Failed ("Not initially empty");
+      Report.Failed ("Not initially empty #2");
 
    end if;
 
    if My_Vector_1.Length /= 0 then
 
-      Report.Failed ("Not initially empty");
+      Report.Failed ("Not initially empty #3");
 
    end if;
 
    if My_Vector_1.Last_Index /= My_Vectors.No_Index then
 
-      Report.Failed ("Not initially empty");
+      Report.Failed ("Not initially empty #4");
 
    end if;
 
@@ -163,6 +194,10 @@
          procedure My_Query (Element : in My_Float) is
          begin
 
+            Tampering_Check
+              (Container => My_Vector_1,
+               Where     => "Query_Element");
+
             if Element /= Value_In_Array (I) then
 
                Report.Failed
@@ -229,7 +264,7 @@
    end if;
 
    -- Index_Type begins at 0 so last if N elements will have index N - 1
-   if My_Vector_1.Last_Index /= No_Tests - 1 then
+   if My_Vector_1.Last_Index /= Num_Tests - 1 then
 
       Report.Failed ("Last_Index not as expected");
 
@@ -258,7 +293,7 @@
 
       My_Vector_2.Prepend (New_Item => Value_In_Array (I));
 
-      if My_Vector_2.Length /= No_Tests - I + 1 then
+      if My_Vector_2.Length /= Num_Tests - I + 1 then
 
          Report.Failed ("Wrong Length after prepending");
 
@@ -297,7 +332,7 @@
    end if;
 
 
-   if My_Vector_2.Capacity < No_Tests then
+   if My_Vector_2.Capacity < Num_Tests then
 
       Report.Failed
         ("Capacity not grown as expected after adding elements beyond" &
@@ -319,7 +354,7 @@
 
    declare
 
-      My_Vector_3 : constant My_Vectors.Vector := My_Vector_1;
+      My_Vector_3 : My_Vectors.Vector := My_Vector_1;
 
       I : Array_Bounds_Type := Array_Bounds_Type'First;
 
@@ -327,6 +362,10 @@
         (Position : in My_Vectors.Cursor) is
       begin
 
+         Tampering_Check
+           (Container => My_Vector_3,
+            Where     => "Iterate");
+
          if My_Vectors.Element (Position) /= Value_In_Array (I) then
 
             Report.Failed ("Iterate hasn't found the expected value");
@@ -345,6 +384,10 @@
         (Position : in My_Vectors.Cursor) is
       begin
 
+         Tampering_Check
+           (Container => My_Vector_3,
+            Where     => "Reverse_Iterate");
+
          if My_Vectors.Element (Position) /= Value_In_Array (I) then
 
             Report.Failed ("Reverse_Iterate hasn't found the expected value");
@@ -383,6 +426,10 @@
          procedure My_Update (Element : in out My_Float) is
          begin
 
+            Tampering_Check
+              (Container => My_Vector_2,
+               Where     => "Update_Element");
+
             Element := Element * 2.0;
 
          end My_Update;
@@ -459,7 +506,7 @@
    for I in Array_Bounds_Type loop
 
       if My_Vectors.Element (Position => My_Cursor_1) /=
-        Value_In_Array (No_Tests - I + 1) then
+        Value_In_Array (Num_Tests - I + 1) then
 
          Report.Failed ("Reversed array not as expected");
 
@@ -602,6 +649,8 @@
 
    end if;
 
+   -- The outer level My_Vector_3 should still be empty
+
    My_Vector_3.Insert
      (Before   => My_Vectors.No_Element, -- At end
       New_Item => My_Vector_2);
@@ -732,8 +781,8 @@
       New_Item => My_Vector_1.Element (Index => My_Index_1));
 
    -- My_Cursor_1 is now "ambiguous" as an element has been inserted earlier in
-   -- the vector.  (In the GNAT v7.1.2 implementation it is still pointing to the
-   -- 11th element, but the original Value_In_Array (9) is now the 12th
+   -- the vector.  (In the GNAT v7.1.2 implementation it is still pointing to
+   -- the 11th element, but the original Value_In_Array (9) is now the 12th
    -- element).  So find again, using Reverse_Find_Index to find the original
    -- Value_In_Array (9) not the copy before Value_In_Array (2)
 
@@ -908,7 +957,7 @@
 
    end if;
 
-   if My_Vector_1.Length /= 2 * No_Tests + 4 then
+   if My_Vector_1.Length /= 2 * Num_Tests + 4 then
 
       Report.Failed ("Target vector hasn't grown as expected after Merge");
 
@@ -922,13 +971,13 @@
 
    My_Vector_2 := My_Vectors.Copy (Source => My_Vector_1);
 
-   if My_Vector_2.Length /= 2 * No_Tests + 4 then
+   if My_Vector_2.Length /= 2 * Num_Tests + 4 then
 
       Report.Failed ("Result length not as expected after Copy");
 
    end if;
 
-   if My_Vector_1.Length /= 2 * No_Tests + 4 then
+   if My_Vector_1.Length /= 2 * Num_Tests + 4 then
 
       Report.Failed ("Source length not left alone by Copy");
 
@@ -937,9 +986,9 @@
 
    -- Test To_Vector (two forms) and Element (index form)
 
-   My_Vector_1 := My_Vectors.To_Vector (Length => No_Tests);
+   My_Vector_1 := My_Vectors.To_Vector (Length => Num_Tests);
 
-   if My_Vector_1.Length /= No_Tests then
+   if My_Vector_1.Length /= Num_Tests then
 
       Report.Failed ("To_Vector didn't create vector of given length");
 
@@ -950,7 +999,7 @@
 
    My_Vector_1 := My_Vectors.To_Vector
      (New_Item => My_Default_Value,
-      Length   => No_Tests);
+      Length   => Num_Tests);
 
    for I in Array_Bounds_Type loop
 
@@ -965,9 +1014,9 @@
 
    -- Test Set_Length
 
-   My_Vector_1.Set_Length (Length => No_Tests * 2);
+   My_Vector_1.Set_Length (Length => Num_Tests * 2);
 
-   if My_Vector_1.Length /= No_Tests * 2 then
+   if My_Vector_1.Length /= Num_Tests * 2 then
 
       Report.Failed ("Set_Length didn't change the length to the given value");
 
@@ -978,9 +1027,9 @@
 
    My_Vector_1.Insert_Space
      (Before => My_Vector_1.Last_Index,
-      Count  => No_Tests);
+      Count  => Num_Tests);
 
-   if My_Vector_1.Length /= No_Tests * 3 then
+   if My_Vector_1.Length /= Num_Tests * 3 then
 
       Report.Failed ("Insert_Space didn't grow the length as expected");
 
@@ -989,9 +1038,9 @@
    My_Vector_1.Insert_Space
      (Before   => My_Vectors.No_Element, -- At end
       Position => My_Cursor_1,
-      Count    => No_Tests);
+      Count    => Num_Tests);
 
-   if My_Vector_1.Length /= No_Tests * 4 then
+   if My_Vector_1.Length /= Num_Tests * 4 then
 
       Report.Failed ("Insert_Space didn't grow the length as expected");
 

Questions? Ask the ACAA Technical Agent