📄 cxb3016.a
字号:
end if; -- Case 2: Copying the Terminator Element. (Non-Default terminator) TC_char := 'b'; -- Second char in char_array pointed to by Char_Ptr Char_Pointers.Copy_Terminated_Array(Source => Char_Ptr, Target => TC_Char_Ptr, Terminator => TC_char); if TC_Ch_Array(0) /= Ch_Array(0) or -- Initial value modified. TC_Ch_Array(1) /= Ch_Array(1) or -- Initial value modified. TC_Ch_Array(2) = Ch_Array(2) or -- Initial value not modified. TC_Ch_Array(5) = Ch_Array(5) or -- Initial value not modified. TC_Ch_Array(15) = Ch_Array(15) or -- Initial value not modified. TC_Ch_Array(25) = Ch_Array(25) -- Initial value not modified. then Report.Failed("The appropriate portions of the two char arrays " & "are not equal following the call to " & "Copy_Terminated_Array, case of copying the " & "Terminator Element, using non-default terminator"); end if; if TC_Short_Array = Short_Array then Report.Failed("The two short int arrays are equivalent prior " & "to the call to Copy_Terminated_Array - 1"); end if; Short_Pointers.Copy_Terminated_Array(Source => Short_Ptr, Target => TC_Short_Ptr, Terminator => 2); if TC_Short_Array(0) /= Short_Array(0) or TC_Short_Array(1) /= Short_Array(1) or TC_Short_Array(2) /= Short_Array(2) or TC_Short_Array(3) /= 100 -- Initial value not modified. then Report.Failed("The appropriate portions of the two short int " & "arrays are not equal following the call to " & "Copy_Terminated_Array, case of copying the " & "Terminator Element, using non-default terminator"); end if; -- Case 3: Copying the number of elements specified in parameter Limit. if TC_Short_Array = Short_Array then Report.Failed("The two short int arrays are equivalent prior " & "to the call to Copy_Terminated_Array - 2"); end if; TC_ptrdiff_t := 5; Short_Pointers.Copy_Terminated_Array(Source => Short_Ptr, Target => TC_Short_Ptr, Limit => TC_ptrdiff_t, Terminator => Short_Terminator); if TC_Short_Array(0) /= Short_Array(0) or TC_Short_Array(1) /= Short_Array(1) or TC_Short_Array(2) /= Short_Array(2) or TC_Short_Array(3) /= Short_Array(3) or TC_Short_Array(4) /= Short_Array(4) or TC_Short_Array(5) /= 100 -- Initial value not modified. then Report.Failed("The appropriate portions of the two Short arrays " & "are not equal following the call to " & "Copy_Terminated_Array, case of copying the number " & "of elements specified in parameter Limit"); end if; -- Case 4: Copying the number of elements specified in parameter Limit, -- which also happens to be the number of elements up to and -- including the first terminator. -- Reset initial values for the array that holds short int values. for i in Min_Array_Size..Max_Array_Size loop Short_Array(i) := Interfaces.C.short(i); TC_Short_Array(i) := 100; end loop; if TC_Short_Array = Short_Array then Report.Failed("The two short int arrays are equivalent prior " & "to the call to Copy_Terminated_Array - 3"); end if; TC_ptrdiff_t := 3; -- Specifies three elements to be copied. Short_Terminator := 2; -- Value held in Short_Array third element, -- will serve as the "terminator" element. Short_Pointers.Copy_Terminated_Array(Source => Short_Ptr, Target => TC_Short_Ptr, Limit => TC_ptrdiff_t, Terminator => Short_Terminator); if TC_Short_Array(0) /= Short_Array(0) or -- First element copied. TC_Short_Array(1) /= Short_Array(1) or -- Second element copied. TC_Short_Array(2) /= Short_Array(2) or -- Third element copied. TC_Short_Array(3) /= 100 -- Initial value of fourth element then -- not modified. Report.Failed("The appropriate portions of the two Short arrays " & "are not equal following the call to " & "Copy_Terminated_Array, case of copying the number " & "of elements specified in parameter " & "Limit, which also happens to be the number of " & "elements up to and including the first terminator"); end if; -- Check that procedure Copy_Terminated_Array will propagate -- Dereference_Error if either the Source or Target parameter is null. Char_Ptr := null; begin Char_Pointers.Copy_Terminated_Array(Char_Ptr, TC_Char_Ptr); Report.Failed("Dereference_Error not raised by call to " & "Copy_Terminated_Array with null Source parameter"); if TC_Char_Ptr = null then -- To avoid optimization. Report.Comment("This should never be printed"); end if; exception when Dereference_Error => null; -- OK, expected exception. when others => Report.Failed("Incorrect exception raised by call to " & "Copy_Terminated_Array with null Source parameter"); end; TC_Short_Ptr := null; begin Short_Pointers.Copy_Terminated_Array(Short_Ptr, TC_Short_Ptr); Report.Failed("Dereference_Error not raised by call to " & "Copy_Terminated_Array with null Target parameter"); if Short_Ptr = null then -- To avoid optimization. Report.Comment("This should never be printed"); end if; exception when Dereference_Error => null; -- OK, expected exception. when others => Report.Failed("Incorrect exception raised by call to " & "Copy_Terminated_Array with null Target parameter"); end; -- Check that the procedure Copy_Array will copy the array of -- elements of length specified in parameter Length, referenced by -- the Pointer parameter Source, into the array pointed to by -- parameter Target. -- Reinitialize Target arrays prior to test cases below. TC_Ch_Array := Interfaces.C.To_C(Blank_String, True); for i in Min_Array_Size..Max_Array_Size loop TC_Short_Array(i) := 100; end loop; Char_Ptr := Ch_Array(0)'Access; TC_Char_Ptr := TC_Ch_Array(0)'Access; Short_Ptr := Short_Array(0)'Access; TC_Short_Ptr := TC_Short_Array(0)'Access; TC_ptrdiff_t := 4; Char_Pointers.Copy_Array(Source => Char_Ptr, Target => TC_Char_Ptr, Length => TC_ptrdiff_t); if TC_Ch_Array(0) /= Ch_Array(0) or TC_Ch_Array(1) /= Ch_Array(1) or TC_Ch_Array(2) /= Ch_Array(2) or TC_Ch_Array(3) /= Ch_Array(3) or TC_Ch_Array(4) = Ch_Array(4) then Report.Failed("Incorrect result from Copy_Array when using " & "char pointer arguments, partial array copied"); end if; TC_ptrdiff_t := Interfaces.C.ptrdiff_t(Max_Array_Size) + 1; Short_Pointers.Copy_Array(Short_Ptr, TC_Short_Ptr, TC_ptrdiff_t); if TC_Short_Array /= Short_Array then Report.Failed("Incorrect result from Copy_Array when using Short " & "pointer arguments, entire array copied"); end if; -- Check that procedure Copy_Array will propagate Dereference_Error -- if either the Source or Target parameter is null. Char_Ptr := null; begin Char_Pointers.Copy_Array(Char_Ptr, TC_Char_Ptr, TC_ptrdiff_t); Report.Failed("Dereference_Error not raised by call to " & "Copy_Array with null Source parameter"); if TC_Char_Ptr = null then -- To avoid optimization. Report.Comment("This should never be printed"); end if; exception when Dereference_Error => null; -- OK, expected exception. when others => Report.Failed("Incorrect exception raised by call to " & "Copy_Array with null Source parameter"); end; TC_Short_Ptr := null; begin Short_Pointers.Copy_Array(Short_Ptr, TC_Short_Ptr, TC_ptrdiff_t); Report.Failed("Dereference_Error not raised by call to " & "Copy_Array with null Target parameter"); if Short_Ptr = null then -- To avoid optimization. Report.Comment("This should never be printed"); end if; exception when Dereference_Error => null; -- OK, expected exception. when others => Report.Failed("Incorrect exception raised by call to " & "Copy_Array with null Target parameter"); end; -- Check that function Virtual_Length will propagate Dereference_Error -- if the Source parameter is null. Char_Ptr := null; begin TC_ptrdiff_t := Char_Pointers.Virtual_Length(Char_Ptr, Terminator => TC_char); Report.Failed("Dereference_Error not raised by call to " & "Virtual_Length with null Source parameter"); if TC_ptrdiff_t = 100 then -- To avoid optimization. Report.Comment("This should never be printed"); end if; exception when Dereference_Error => null; -- OK, expected exception. when others => Report.Failed("Incorrect exception raised by call to " & "Virtual_Length with null Source parameter"); 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 CXB3016;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -