3 -- Grant of Unlimited Rights
5 -- The Ada Conformity Assessment Authority (ACAA) holds unlimited
6 -- rights in the software and documentation contained herein. Unlimited
7 -- rights are the same as those granted by the U.S. Government for older
8 -- parts of the Ada Conformity Assessment Test Suite, and are defined
9 -- in DFAR 252.227-7013(a)(19). By making this public release, the ACAA
10 -- intends to confer upon all recipients unlimited rights equal to those
11 -- held by the ACAA. These rights include rights to use, duplicate,
12 -- release or disclose the released technical data and computer software
13 -- in whole or in part, in any manner and for any purpose whatsoever, and
14 -- to have or permit others to do so.
18 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
19 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
20 -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
21 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
22 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
23 -- PARTICULAR PURPOSE OF SAID MATERIAL.
27 -- Check that Ada.Strings.Bounded.Slice raises Index_Error if
28 -- High > Length (Source) or Low > Length (Source) + 1.
29 -- (Defect Report 8652/0049).
31 -- Check that Ada.Strings.Wide_Bounded.Slice raises Index_Error if
32 -- High > Length (Source) or Low > Length (Source) + 1.
35 -- 12 FEB 2001 PHL Initial version
36 -- 14 MAR 2001 RLB Added Wide_Bounded subtest.
41 with Ada
.Strings
.Bounded
;
42 with Ada
.Strings
.Wide_Bounded
;
48 package Bs
is new Ada
.Strings
.Bounded
.Generic_Bounded_Length
(40);
50 package WBs
is new Ada
.Strings
.Wide_Bounded
.Generic_Bounded_Length
(32);
52 Source
: String (Ident_Int
(1) .. Ident_Int
(30));
54 Wide_Source
: Wide_String (Ident_Int
(1) .. Ident_Int
(24));
56 X
: Bs
.Bounded_String
;
58 WX
: WBs
.Bounded_Wide_String
;
62 "Check that Slice raises Index_Error if either Low or High is " &
63 "greater than the Length(Source) for Ada.Strings.Bounded and " &
64 "Ada.Strings.Wide_Bounded");
66 -- Fill Source with "ABC..."
67 for I
in Source
'Range loop
68 Source
(I
) := Ident_Char
(Character'Val (I
+
69 Character'Pos ('A') - Source
'First));
71 -- and W with "ABC..."
72 for I
in Wide_Source
'Range loop
73 Wide_Source
(I
) := Ident_Wide_Char
(Wide_Character'Val (I
+
74 Wide_Character'Pos ('A') - Wide_Source
'First));
77 X
:= Bs
.To_Bounded_String
(Source
);
81 S
: constant String :=
82 Bs
.Slice
(X
, Low
=> Ident_Int
(28), High
=> Ident_Int
(41));
84 Failed
("No exception raised by Slice - 1");
86 Comment
("Don't optimize S");
91 null; -- Expected exception.
93 Failed
("Exception raised - " & Exception_Name
(E
) &
94 " - " & Exception_Message
(E
) & " - 1");
99 S
: constant String :=
100 Bs
.Slice
(X
, Low
=> Ident_Int
(8), High
=> Ident_Int
(31));
102 Failed
("No exception raised by Slice - 2");
104 Comment
("Don't optimize S");
109 null; -- Expected exception.
111 Failed
("Exception raised - " & Exception_Name
(E
) &
112 " - " & Exception_Message
(E
) & " - 2");
117 S
: constant String :=
118 Bs
.Slice
(X
, Low
=> Ident_Int
(15), High
=> Ident_Int
(30));
120 if S
/= Source
(15..30) then
121 Failed
("Wrong result - 3");
126 Failed
("Exception raised - " & Exception_Name
(E
) &
127 " - " & Exception_Message
(E
) & " - 3");
132 S
: constant String :=
133 Bs
.Slice
(X
, Low
=> Ident_Int
(42), High
=> Ident_Int
(28));
135 Failed
("No exception raised by Slice - 4");
137 Comment
("Don't optimize S");
142 null; -- Expected exception.
144 Failed
("Exception raised - " & Exception_Name
(E
) &
145 " - " & Exception_Message
(E
) & " - 4");
150 S
: constant String :=
151 Bs
.Slice
(X
, Low
=> Ident_Int
(31), High
=> Ident_Int
(28));
154 Failed
("Wrong result - 5");
159 Failed
("Exception raised - " & Exception_Name
(E
) &
160 " - " & Exception_Message
(E
) & " - 5");
165 S
: constant String :=
166 Bs
.Slice
(X
, Low
=> Ident_Int
(30), High
=> Ident_Int
(30));
168 if S
/= Source
(30..30) then
169 Failed
("Wrong result - 6");
174 Failed
("Exception raised - " & Exception_Name
(E
) &
175 " - " & Exception_Message
(E
) & " - 6");
178 WX
:= WBs
.To_Bounded_Wide_String
(Wide_Source
);
182 W
: constant Wide_String :=
183 WBs
.Slice
(WX
, Low
=> Ident_Int
(21), High
=> Ident_Int
(33));
185 Failed
("No exception raised by Slice - 7");
186 if W
= Wide_Source
then
187 Comment
("Don't optimize W");
192 null; -- Expected exception.
194 Failed
("Exception raised - " & Exception_Name
(E
) &
195 " - " & Exception_Message
(E
) & " - 7");
200 W
: constant Wide_String :=
201 WBs
.Slice
(WX
, Low
=> Ident_Int
(8), High
=> Ident_Int
(25));
203 Failed
("No exception raised by Slice - 8");
204 if W
= Wide_Source
then
205 Comment
("Don't optimize W");
210 null; -- Expected exception.
212 Failed
("Exception raised - " & Exception_Name
(E
) &
213 " - " & Exception_Message
(E
) & " - 8");
218 W
: constant Wide_String :=
219 WBs
.Slice
(WX
, Low
=> Ident_Int
(15), High
=> Ident_Int
(24));
221 if W
/= Wide_Source
(15..24) then
222 Failed
("Wrong result - 8");
227 Failed
("Exception raised - " & Exception_Name
(E
) &
228 " - " & Exception_Message
(E
) & " - 9");
233 W
: constant Wide_String :=
234 WBs
.Slice
(WX
, Low
=> Ident_Int
(36), High
=> Ident_Int
(20));
236 Failed
("No exception raised by Slice - 10");
237 if W
= Wide_Source
then
238 Comment
("Don't optimize W");
243 null; -- Expected exception.
245 Failed
("Exception raised - " & Exception_Name
(E
) &
246 " - " & Exception_Message
(E
) & " - 10");
251 W
: constant Wide_String :=
252 WBs
.Slice
(WX
, Low
=> Ident_Int
(25), High
=> Ident_Int
(21));
255 Failed
("Wrong result - 11");
260 Failed
("Exception raised - " & Exception_Name
(E
) &
261 " - " & Exception_Message
(E
) & " - 11");
266 W
: constant Wide_String :=
267 WBs
.Slice
(WX
, Low
=> Ident_Int
(24), High
=> Ident_Int
(24));
269 if W
/= Wide_Source
(24..24) then
270 Failed
("Wrong result - 12");
275 Failed
("Exception raised - " & Exception_Name
(E
) &
276 " - " & Exception_Message
(E
) & " - 12");