cxb3015.a

来自「Mac OS X 10.4.9 for x86 Source Code gcc」· A 代码 · 共 521 行 · 第 1/2 页

A
521
字号
         then            Report.Failed("Incorrect value returned following use " &                          "of the function +, incrementing by "     &                          Integer'Image(Integer(TC_Increment))      &                          ", array position : "                     &                          Integer'Image(Integer(TC_Count) +                                        Integer(TC_Increment)));            if not TC_Verbose then               exit;            end if;         end if;         TC_Count := TC_Count + Interfaces.C.size_t(TC_Increment);      end loop;      -- Check that the "-" function with Pointer and ptrdiff_t parameters,      -- that returns a Pointer result, produces correct results, based      -- on the size of the array elements.      -- Set the pointer to the last element in the char_array, which is a      -- nul char.      Char_Ptr := Ch_Array(Interfaces.C.size_t(Alphabet'Length))'Access;      if Char_Ptr.all /= Interfaces.C.nul then         Report.Failed("Incorrect initial value for the last " &                       "Ch_Array value");      end if;      Min_size_t := 1;      Max_size_t := Interfaces.C.size_t(Alphabet'Length);      for i in reverse Min_size_t..Max_size_t loop         -- Subtract 1 from the pointer; it should now point to the previous         -- element in the array.         Char_Ptr := Char_Ptr - 1;         if Char_Ptr.all /= Ch_Array(i-1) then            Report.Failed("Incorrect value returned following use "        &                          "of the function '-' with char element values, " &                          "array position : " & Integer'Image(Integer(i-1)));            if not TC_Verbose then               exit;            end if;         end if;      end loop;      Array_Ptr    := Array_of_Arrays(Max_Array_Size)'Access;      TC_Count     := Max_Array_Size;      TC_Increment := 3;      while TC_Count > Min_Array_Size+Interfaces.C.size_t(TC_Increment) loop         -- Decrement the pointer by 3.         Array_Ptr := Array_Pointers."-"(Array_Ptr, Right => 3);         if Array_Ptr.all /=            Array_of_Arrays(TC_Count - Interfaces.C.size_t(TC_Increment))         then            Report.Failed("Incorrect value returned following use " &                          "of the function -, decrementing by "     &                          Integer'Image(Integer(TC_Increment))      &                          ", array position : "                     &                          Integer'Image(Integer(TC_Count-3)));            if not TC_Verbose then               exit;            end if;         end if;         TC_Count := TC_Count - Interfaces.C.size_t(TC_Increment);      end loop;      -- Check that the "-" function with two Pointer parameters, that      -- returns a ptrdiff_t type result, produces correct results,      -- based on the size of the array elements.      TC_ptrdiff_t := 9;      if Char_Pointers."-"(Left  => End_Char_Ptr,                           Right => Start_Char_Ptr) /= TC_ptrdiff_t      then         Report.Failed("Incorrect result from pointer-pointer " &                       "subtraction - 1");      end if;      Start_Char_Ptr := Ch_Array(1)'Access;      End_Char_Ptr   := Ch_Array(25)'Access;      TC_ptrdiff_t := 24;      if Char_Pointers."-"(End_Char_Ptr,                           Right => Start_Char_Ptr) /= TC_ptrdiff_t      then         Report.Failed("Incorrect result from pointer-pointer " &                       "subtraction - 2");      end if;      TC_ptrdiff_t := 9;      if Array_Pointers."-"(End_Array_Ptr,                            Start_Array_Ptr) /= TC_ptrdiff_t      then         Report.Failed("Incorrect result from pointer-pointer " &                       "subtraction - 3");      end if;      Start_Array_Ptr := Array_of_Arrays(Min_Array_Size)'Access;      End_Array_Ptr   := Array_of_Arrays(Max_Array_Size)'Access;      TC_ptrdiff_t := Interfaces.C.ptrdiff_t(Max_Array_Size) -                      Interfaces.C.ptrdiff_t(Min_Array_Size);      if End_Array_Ptr - Start_Array_Ptr /= TC_ptrdiff_t then         Report.Failed("Incorrect result from pointer-pointer " &                       "subtraction - 4");      end if;      -- Check that the Increment procedure produces correct results,      -- based upon the size of the array elements.      Short_Ptr := Short_Array(0)'Access;      for i in Min_Array_Size + 1 .. Max_Array_Size loop         -- Increment the value of the Pointer; it should now point         -- to the next element in the array.         Increment(Ref => Short_Ptr);         if Short_Ptr.all /= Short_Array(i) then            Report.Failed("Incorrect value returned following use "      &                          "of the Procedure Increment on pointer to an " &                          "array of short values, array position : "     &                          Integer'Image(Integer(i)));            if not TC_Verbose then               exit;            end if;         end if;      end loop;      Array_Ptr := Array_of_Arrays(0)'Access;      for i in Min_Array_Size + 1 .. Max_Array_Size loop         -- Increment the value of the Pointer; it should now point         -- to the next element in the array.         Increment(Array_Ptr);         if Array_Ptr.all /= Array_of_Arrays(i) then            Report.Failed("Incorrect value returned following use "    &                          "of the Procedure Increment on an array of " &                          "arrays, array position : "                  &                          Integer'Image(Integer(i)));            if not TC_Verbose then               exit;            end if;         end if;      end loop;      -- Check that the Decrement procedure produces correct results,      -- based upon the size of the array elements.      Short_Ptr := Short_Array(Max_Array_Size)'Access;      for i in reverse Min_Array_Size .. Max_Array_Size - 1 loop         -- Decrement the value of the Pointer; it should now point         -- to the previous element in the array.         Decrement(Ref => Short_Ptr);         if Short_Ptr.all /= Short_Array(i) then            Report.Failed("Incorrect value returned following use "      &                          "of the Procedure Decrement on pointer to an " &                          "array of short values, array position : "     &                          Integer'Image(Integer(i)));            if not TC_Verbose then               exit;            end if;         end if;      end loop;      Array_Ptr := Array_of_Arrays(Max_Array_Size)'Access;      for i in reverse Min_Array_Size .. Max_Array_Size - 1 loop         -- Decrement the value of the Pointer; it should now point         -- to the previous array element.         Decrement(Array_Ptr);         if Array_Ptr.all /= Array_of_Arrays(i) then            Report.Failed("Incorrect value returned following use "    &                          "of the Procedure Decrement on an array of " &                          "arrays, array position : "                  &                          Integer'Image(Integer(i)));            if not TC_Verbose then               exit;            end if;         end if;      end loop;      -- Check that each of the "+" and "-" functions above will      -- propagate Pointer_Error if a Pointer parameter is null.      begin         Short_Ptr := null;         Short_Ptr := Short_Ptr + 4;         Report.Failed("Pointer_Error not raised by Function + when " &                       "the Pointer parameter is null");         if Short_Ptr /= null then  -- To avoid optimization.            Report.Comment("This should never be printed");         end if;      exception         when Short_Pointers.Pointer_Error => null; -- OK, expected exception.         when others =>           Report.Failed("Unexpected exception raised by Function + " &                         "when the Pointer parameter is null");      end;      begin         Char_Ptr := null;         Char_Ptr := Char_Ptr - 1;         Report.Failed("Pointer_Error not raised by Function - when " &                       "the Pointer parameter is null");         if Char_Ptr /= null then  -- To avoid optimization.            Report.Comment("This should never be printed");         end if;      exception         when Char_Pointers.Pointer_Error => null; -- OK, expected exception.         when others =>           Report.Failed("Unexpected exception raised by Function - " &                         "when the Pointer parameter is null");      end;      begin         Array_Ptr := null;         Decrement(Array_Ptr);         Report.Failed("Pointer_Error not raised by Procedure Decrement " &                       "when the Pointer parameter is null");         if Array_Ptr /= null then  -- To avoid optimization.            Report.Comment("This should never be printed");         end if;      exception         when Array_Pointers.Pointer_Error => null; -- OK, expected exception.         when others =>           Report.Failed("Unexpected exception raised by Procedure " &                         "Decrement when the Pointer parameter is null");      end;   exception      when The_Error : others =>         Report.Failed ("The following exception was raised in the " &                        "Test_Block: " & Exception_Name(The_Error));   end Test_Block;   Report.Result;end CXB3015;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?