CVS difference for acats/cxa/cxai006.a

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

--- acats/cxa/cxai006.a	2014/03/11 05:58:38	1.1
+++ acats/cxa/cxai006.a	2014/04/05 01:03:02	1.2
@@ -48,6 +48,8 @@
 --                          Ada 2012 features.
 --      10 Mar 14   RLB     Created ACATS 4.0 version, replaced Ada 2012
 --                          features.
+--      02 Apr 14   RLB     Merged in tampering checks from third pre-release
+--                          version.
 --!
 with Ada.Containers.Ordered_Sets;
 with Report;
@@ -79,15 +81,15 @@
    My_Set_2 : My_Ordered_Sets.Set;
    My_Set_3 : My_Ordered_Sets.Set;
 
-   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
-   -- Values in increasing order as this is what determines the order for a set
+   -- No fractional parts so that can compare values for equality.
+   -- Values in increasing order as this is what determines the order for a set.
 
    Value_In_Array  : constant array (Array_Bounds_Type) of My_Float :=
-     (1.0, 12.0, 23.0, 34.0, 45.0, 56.0, 67.0, 78.0, 89.0, 99.0);
+     (12.0, 23.0, 34.0, 45.0, 56.0, 67.0, 78.0, 89.0, 100.0, 111.0);
 
    My_Cursor_1 : My_Ordered_Sets.Cursor;
    My_Cursor_2 : My_Ordered_Sets.Cursor;
@@ -95,6 +97,37 @@
 
    My_Inserted : Boolean;
 
+   procedure Tampering_Check
+     (Container : in out My_Ordered_Sets.Set;
+      Where     : in     String) is
+
+      Program_Error_Raised : Boolean := False;
+
+   begin
+
+      declare
+      begin
+
+         -- Use a value not already in set
+
+         Container.Insert (New_Item => My_Default_Value * 3.0);
+
+      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_Ordered_Sets.Cursor;
    use type My_Ordered_Sets.Set;
@@ -112,19 +145,19 @@
 
    if My_Set_1 /= My_Ordered_Sets.Empty_Set then
 
-      Report.Failed ("Not initially empty");
+      Report.Failed ("Not initially empty #1");
 
    end if;
 
    if not My_Set_1.Is_Empty then
 
-      Report.Failed ("Not initially empty");
+      Report.Failed ("Not initially empty #2");
 
    end if;
 
    if My_Set_1.Length /= 0 then
 
-      Report.Failed ("Not initially empty");
+      Report.Failed ("Not initially empty #3");
 
    end if;
 
@@ -153,6 +186,10 @@
          procedure My_Query (Element : in My_Float) is
          begin
 
+            Tampering_Check
+              (Container => My_Set_1,
+               Where     => "Query_Element");
+
             if Element /= Value_In_Array (I) then
 
                Report.Failed
@@ -212,7 +249,7 @@
 
       My_Set_2.Insert (New_Item => Value_In_Array (I));
 
-      if My_Set_2.Length /= No_Tests - I + 1 then
+      if My_Set_2.Length /= Num_Tests - I + 1 then
 
          Report.Failed ("Wrong Length after inserting");
 
@@ -273,7 +310,7 @@
 
    declare
 
-      My_Set_3 : constant My_Ordered_Sets.Set := My_Set_1;
+      My_Set_3 : My_Ordered_Sets.Set := My_Set_1;
 
       I : Array_Bounds_Type := Array_Bounds_Type'First;
 
@@ -281,6 +318,10 @@
         (Position : in My_Ordered_Sets.Cursor) is
       begin
 
+         Tampering_Check
+           (Container => My_Set_3,
+            Where     => "Iterate");
+
          if My_Ordered_Sets.Element (Position) /= Value_In_Array (I) then
 
             Report.Failed ("Iterate hasn't found the expected value");
@@ -347,7 +388,7 @@
 
    if My_Set_1 /= My_Set_2 then
 
-      Report.Failed ("Doubled Ordered_Sets not equal");
+      Report.Failed ("Incremented Ordered_Sets not equal");
 
    end if;
 
@@ -554,7 +595,8 @@
 
    end;
 
-   -- Element with double Default_Value.  Should insert at end
+   -- Element with double Default_Value (double to avoid clash with existing
+   -- element with that value).  Should insert at end.
    My_Set_2.Insert
      (New_Item => My_Default_Value * 2.0,
       Position => My_Cursor_2, -- Added element
@@ -851,7 +893,7 @@
 
    -- My_Set_3 should contain the test values (in forward order)
 
-   if My_Set_3.Length /= No_Tests then
+   if My_Set_3.Length /= Num_Tests then
 
       Report.Failed ("Length not as expected after Union #2");
 
@@ -877,7 +919,7 @@
 
    -- My_Set_3 should contain the test values (in forward order)
 
-   if My_Set_3.Length /= No_Tests then
+   if My_Set_3.Length /= Num_Tests then
 
       Report.Failed ("Length not as expected after Union #3");
 
@@ -995,7 +1037,7 @@
    -- My_Set_3 should contain the test values (in forward order) except for
    -- Value_In_Array (2)
 
-   if My_Set_3.Length /= No_Tests - 1 then
+   if My_Set_3.Length /= Num_Tests - 1 then
 
       Report.Failed ("Length not as expected after Difference #2");
 
@@ -1007,7 +1049,7 @@
    -- My_Set_3 should contain the test values (in forward order) except for
    -- Value_In_Array (2)
 
-   if My_Set_3.Length /= No_Tests - 1 then
+   if My_Set_3.Length /= Num_Tests - 1 then
 
       Report.Failed ("Length not as expected after Difference #2");
 
@@ -1059,7 +1101,7 @@
    -- My_Set_3 should contain the test values (in forward order) except for
    -- Value_In_Array (2), followed by Default_Value
 
-   if My_Set_3.Length /= No_Tests then
+   if My_Set_3.Length /= Num_Tests then
 
       Report.Failed ("Length not as expected after Symmetric_Difference #2");
 
@@ -1071,7 +1113,7 @@
    -- My_Set_3 should contain the test values (in forward order), followed by
    -- Default_Value
 
-   if My_Set_3.Length /= No_Tests + 1 then
+   if My_Set_3.Length /= Num_Tests + 1 then
 
       Report.Failed ("Length not as expected after Symmetric_Difference #3");
 
@@ -1096,7 +1138,7 @@
 
    if My_Keys.Element
      (Container => My_Set_3,
-      Key       => 1) /= Value_In_Array (1) then
+      Key       => My_Key_Type (Value_In_Array (1))) /= Value_In_Array (1) then
 
       Report.Failed ("Wrong element for key");
 
@@ -1119,7 +1161,7 @@
 
    end;
 
-   if My_Set_3.Length /= No_Tests + 1 then
+   if My_Set_3.Length /= Num_Tests + 1 then
 
       Report.Failed ("Length not as expected after Replace (key form)");
 
@@ -1129,7 +1171,7 @@
      (Container => My_Set_3,
       Key       => My_Key_Type (Value_In_Array (4)));
 
-   if My_Set_3.Length /= No_Tests then
+   if My_Set_3.Length /= Num_Tests then
 
       Report.Failed ("Length not as expected after Exclude (key form) #1");
 
@@ -1152,7 +1194,7 @@
 
    end;
 
-   if My_Set_3.Length /= No_Tests then
+   if My_Set_3.Length /= Num_Tests then
 
       Report.Failed ("Length not as expected after Exclude (key form) #2");
 
@@ -1162,7 +1204,7 @@
      (Container => My_Set_3,
       Key       => My_Key_Type (Value_In_Array (3)));
 
-   if My_Set_3.Length /= No_Tests - 1 then
+   if My_Set_3.Length /= Num_Tests - 1 then
 
       Report.Failed ("Length not as expected after Delete (key form)");
 
@@ -1202,6 +1244,10 @@
       procedure My_Update (Element : in out My_Float) is
       begin
 
+         Tampering_Check
+           (Container => My_Set_3,
+            Where     => "Update_Element");
+
          Element := Element + 0.1; -- Some small amount that doesn't change key
 
       end My_Update;
@@ -1263,13 +1309,13 @@
 
    My_Set_2.Assign (Source => My_Set_1);
 
-   if My_Set_2.Length /= No_Tests then
+   if My_Set_2.Length /= Num_Tests then
 
       Report.Failed ("Target set length not as expected after Assign");
 
    end if;
 
-   if My_Set_1.Length /= No_Tests then
+   if My_Set_1.Length /= Num_Tests then
 
       Report.Failed ("Source set length not left alone by Assign");
 
@@ -1277,13 +1323,13 @@
 
    My_Set_2 := My_Ordered_Sets.Copy (Source => My_Set_1);
 
-   if My_Set_2.Length /= No_Tests then
+   if My_Set_2.Length /= Num_Tests then
 
       Report.Failed ("Result set length not as expected after Copy");
 
    end if;
 
-   if My_Set_1.Length /= No_Tests then
+   if My_Set_1.Length /= Num_Tests then
 
       Report.Failed ("Source set length not left alone by Copy");
 

Questions? Ask the ACAA Technical Agent