OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [ada/] [acats/] [tests/] [cxa/] [cxa4007.a] - Blame information for rev 720

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 720 jeremybenn
-- CXA4007.A
2
--
3
--                             Grant of Unlimited Rights
4
--
5
--     Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
6
--     F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
7
--     unlimited rights in the software and documentation contained herein.
8
--     Unlimited rights are defined in DFAR 252.227-7013(a)(19).  By making
9
--     this public release, the Government intends to confer upon all
10
--     recipients unlimited rights  equal to those held by the Government.
11
--     These rights include rights to use, duplicate, release or disclose the
12
--     released technical data and computer software in whole or in part, in
13
--     any manner and for any purpose whatsoever, and to have or permit others
14
--     to do so.
15
--
16
--                                    DISCLAIMER
17
--
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.
24
--*
25
--
26
-- OBJECTIVE:
27
--      Check that the subprograms defined in package Ada.Strings.Bounded are
28
--      available, and that they produce correct results. Specifically, check
29
--      the subprograms Append, Count, Element, Find_Token, Head,
30
--      Index_Non_Blank, Replace_Element, Replicate, Tail, To_Bounded_String,
31
--      "&", ">", "<", ">=", "<=", and "*".
32
--
33
-- TEST DESCRIPTION:
34
--      This test, when taken in conjunction with tests CXA400[6,8,9], will
35
--      constitute a test of all the functionality contained in package
36
--      Ada.Strings.Bounded.  This test uses a variety of the
37
--      subprograms defined in the bounded string package in ways typical
38
--      of common usage.  Different combinations of available subprograms
39
--      are used to accomplish similar bounded string processing goals.
40
--
41
--
42
-- CHANGE HISTORY:
43
--      06 Dec 94   SAIC    ACVC 2.0
44
--      22 Dec 94   SAIC    Changed obsolete constant to Ada.Strings.Space.
45
--
46
--!
47
 
48
with Ada.Strings;
49
with Ada.Strings.Bounded;
50
with Ada.Strings.Maps;
51
with Report;
52
 
53
procedure CXA4007 is
54
 
55
begin
56
 
57
   Report.Test ("CXA4007", "Check that the subprograms defined in package " &
58
                           "Ada.Strings.Bounded are available, and that "   &
59
                           "they produce correct results");
60
 
61
   Test_Block:
62
   declare
63
 
64
      package BS80 is new Ada.Strings.Bounded.Generic_Bounded_Length(80);
65
      use type BS80.Bounded_String;
66
 
67
      Part1 : constant String     := "Rum";
68
      Part2 : Character           := 'p';
69
      Part3 : BS80.Bounded_String := BS80.To_Bounded_String("el");
70
      Part4 : Character           := 's';
71
      Part5 : BS80.Bounded_String := BS80.To_Bounded_String("tilt");
72
      Part6 : String(1..3)        := "ski";
73
 
74
      Full_Catenate_String,
75
      Full_Append_String,
76
      Constructed_String,
77
      Drop_String,
78
      Replicated_String,
79
      Token_String         : BS80.Bounded_String;
80
 
81
      CharA : Character := 'A';
82
      CharB : Character := 'B';
83
      CharC : Character := 'C';
84
      CharD : Character := 'D';
85
      CharE : Character := 'E';
86
      CharF : Character := 'F';
87
 
88
      ABStr : String(1..15) := "AAAAABBBBBBBBBB";
89
      StrB  : String(1..2)  := "BB";
90
      StrE  : String(1..2)  := "EE";
91
 
92
 
93
   begin
94
 
95
      -- Evaluation of the overloaded forms of the "&" operator defined
96
      -- for instantiations of Bounded Strings.
97
 
98
      Full_Catenate_String :=
99
        BS80."&"(Part2,                            -- Char & Bnd Str
100
                 BS80."&"(Part3,                   -- Bnd Str & Bnd Str
101
                          BS80."&"(Part4,          -- Char & Bnd Str
102
                                   BS80."&"(Part5, -- Bnd Str & Bnd Str
103
                                           BS80.To_Bounded_String(Part6)))));
104
 
105
      Full_Catenate_String :=
106
        Part1 &  Full_Catenate_String;             -- Str & Bnd Str
107
      Full_Catenate_String :=
108
        Full_Catenate_String & 'n';                -- Bnd Str & Char
109
 
110
 
111
      -- Evaluation of the overloaded forms of function Append.
112
 
113
      Full_Append_String :=
114
        BS80.Append(Part2,                                      -- Char,Bnd
115
               BS80.Append(Part3,                               -- Bnd, Bnd
116
                      BS80.Append(Part4,                        -- Char,Bnd
117
                             BS80.Append(BS80.To_String(Part5), -- Str,Bnd
118
                                         BS80.To_Bounded_String(Part6)))));
119
 
120
      Full_Append_String :=
121
        BS80.Append(BS80.To_Bounded_String(Part1),            -- Bnd , Str
122
                    BS80.To_String(Full_Append_String));
123
 
124
      Full_Append_String :=
125
        BS80.Append(Left  => Full_Append_String,
126
                    Right => 'n');                            -- Bnd, Char
127
 
128
 
129
      -- Validate the resulting bounded strings.
130
 
131
      if Full_Catenate_String < Full_Append_String or
132
         Full_Catenate_String > Full_Append_String or
133
         not (Full_Catenate_String  = Full_Append_String and
134
              Full_Catenate_String <= Full_Append_String and
135
              Full_Catenate_String >= Full_Append_String)
136
      then
137
         Report.Failed("Incorrect results from bounded string catenation" &
138
                       " and comparison");
139
      end if;
140
 
141
 
142
      -- Evaluate the overloaded forms of the Constructor function "*" and
143
      -- the Replicate function.
144
 
145
      Constructed_String :=
146
        (2 * CharA) &                           -- "AA"
147
        (2 * StrB)  &                           -- "AABBBB"
148
        (3 * BS80."*"(2, CharC)) &              -- "AABBBBCCCCCC"
149
        BS80.Replicate(3,
150
                   BS80.Replicate(2, CharD)) &  -- "AABBBBCCCCCCDDDDDD"
151
        BS80.Replicate(2, StrE) &               -- "AABBBBCCCCCCDDDDDDEEEE"
152
        BS80.Replicate(2, CharF);               -- "AABBBBCCCCCCDDDDDDEEEEFF"
153
 
154
 
155
      -- Use of Function Replicate that involves dropping characters.  The
156
      -- attempt to replicate the 15 character string six times will exceed
157
      -- the 80 character bound of the string.  Therefore, the result should
158
      -- be the catenation of 5 copies of the 15 character string, followed
159
      -- by 5 'A' characters (the first five characters of the 6th
160
      -- replication) with the remaining characters of the 6th replication
161
      -- dropped.
162
 
163
      Drop_String :=
164
         BS80.Replicate(Count => 6,
165
                        Item  => ABStr,              -- "AAAAABBBBBBBBBB"
166
                        Drop  => Ada.Strings.Right);
167
 
168
      if BS80.Element(Drop_String, 1)  /= 'A' or
169
         BS80.Element(Drop_String, 6)  /= 'B' or
170
         BS80.Element(Drop_String, 76) /= 'A' or
171
         BS80.Element(Drop_String, 80) /= 'A'
172
      then
173
         Report.Failed("Incorrect result from Replicate with Drop");
174
      end if;
175
 
176
 
177
      -- Use function Index_Non_Blank in the evaluation of the
178
      -- Constructed_String.
179
 
180
      if BS80.Index_Non_Blank(Constructed_String, Ada.Strings.Forward)  /=
181
         BS80.To_String(Constructed_String)'First                         or
182
         BS80.Index_Non_Blank(Constructed_String, Ada.Strings.Backward) /=
183
         BS80.Length(Constructed_String)
184
      then
185
         Report.Failed("Incorrect results from constructor functions");
186
      end if;
187
 
188
 
189
 
190
      declare
191
 
192
         -- Define character set objects for use with the Count function.
193
         -- Constructed_String = "AABBBBCCCCCCDDDDDDEEEEFF" from above.
194
 
195
         A_Set : Ada.Strings.Maps.Character_Set :=
196
                 Ada.Strings.Maps.To_Set(BS80.Element(Constructed_String,1));
197
         B_Set : Ada.Strings.Maps.Character_Set :=
198
                 Ada.Strings.Maps.To_Set(BS80.Element(Constructed_String,3));
199
         C_Set : Ada.Strings.Maps.Character_Set :=
200
                 Ada.Strings.Maps.To_Set(BS80.Element(Constructed_String,7));
201
         D_Set : Ada.Strings.Maps.Character_Set :=
202
                 Ada.Strings.Maps.To_Set(BS80.Element(Constructed_String,13));
203
         E_Set : Ada.Strings.Maps.Character_Set :=
204
                 Ada.Strings.Maps.To_Set(BS80.Element(Constructed_String,19));
205
         F_Set : Ada.Strings.Maps.Character_Set :=
206
                 Ada.Strings.Maps.To_Set(BS80.Element(Constructed_String,23));
207
 
208
 
209
         Start : Positive;
210
         Stop  : Natural  := 0;
211
 
212
      begin
213
 
214
         -- Evaluate the results from function Count by comparing the number
215
         -- of A's to the number of F's, B's to E's, and C's to D's in the
216
         -- Constructed_String.
217
         -- There should be an equal number of each of the characters that
218
         -- are being compared (i.e., 2 A's and F's, 4 B's and E's, etc)
219
 
220
         if BS80.Count(Constructed_String, A_Set)      /=
221
            BS80.Count(Constructed_String, F_Set)        or
222
            BS80.Count(Constructed_String, B_Set)      /=
223
            BS80.Count(Constructed_String, E_Set)        or
224
            not (BS80.Count(Constructed_String, C_Set)  =
225
                 BS80.Count(Constructed_String, D_Set))
226
         then
227
            Report.Failed("Incorrect result from function Count");
228
         end if;
229
 
230
 
231
         -- Evaluate the functions Head, Tail, and Find_Token.
232
         -- Create the Token_String from the Constructed_String above.
233
 
234
         Token_String :=
235
           BS80.Tail(BS80.Head(Constructed_String,  3), 2) &     -- "AB" &
236
           BS80.Head(BS80.Tail(Constructed_String, 13), 2) &     -- "CD" &
237
           BS80.Head(BS80.Tail(Constructed_String,  3), 2);      -- "EF"
238
 
239
         if Token_String /= BS80.To_Bounded_String("ABCDEF") then
240
            Report.Failed("Incorrect result from Catenation of Token_String");
241
         end if;
242
 
243
 
244
         -- Find the starting/ending position of the first A in the
245
         -- Token_String (both should be 1, only one A appears in string).
246
         -- The Function Head uses the default pad character to return a
247
         -- bounded string longer than its input parameter bounded string.
248
 
249
         BS80.Find_Token(BS80.Head(Token_String, 10),  -- Default pad.
250
                         A_Set,
251
                         Ada.Strings.Inside,
252
                         Start,
253
                         Stop);
254
 
255
         if Start /= 1 and Stop /= 1 then
256
            Report.Failed("Incorrect result from Find_Token - 1");
257
         end if;
258
 
259
 
260
         -- Find the starting/ending position of the first non-AB slice in
261
         -- the "head" five characters of Token_String (slice CDE at
262
         -- positions 3-5)
263
 
264
         BS80.Find_Token(BS80.Head(Token_String, 5),            -- "ABCDE"
265
                         Ada.Strings.Maps."OR"(A_Set, B_Set),   -- Set (AB)
266
                         Ada.Strings.Outside,
267
                         Start,
268
                         Stop);
269
 
270
         if Start /= 3 and Stop /= 5 then
271
            Report.Failed("Incorrect result from Find_Token - 2");
272
         end if;
273
 
274
 
275
         -- Find the starting/ending position of the first CD slice in
276
         -- the "tail" eight characters (including two pad characters)
277
         -- of Token_String (slice CD at positions 5-6 of the tail
278
         -- portion specified)
279
 
280
         BS80.Find_Token(BS80.Tail(Token_String, 8,
281
                                   Ada.Strings.Space),         -- "  ABCDEF"
282
                         Ada.Strings.Maps."OR"(C_Set, D_Set),  -- Set (CD)
283
                         Ada.Strings.Inside,
284
                         Start,
285
                         Stop);
286
 
287
         if Start /= 5 and Stop /= 6 then
288
            Report.Failed("Incorrect result from Find_Token - 3");
289
         end if;
290
 
291
 
292
         -- Evaluate the Replace_Element procedure.
293
 
294
         -- Token_String = "ABCDEF"
295
 
296
         BS80.Replace_Element(Token_String, 3, BS80.Element(Token_String,4));
297
 
298
         -- Token_String = "ABDDEF"
299
 
300
         BS80.Replace_Element(Source => Token_String,
301
                              Index  => 2,
302
                              By     => BS80.Element(Token_String, 5));
303
 
304
         -- Token_String = "AEDDEF"
305
 
306
         BS80.Replace_Element(Token_String,
307
                              1,
308
                              BS80.Element(BS80.Tail(Token_String, 2), 2));
309
 
310
         -- Token_String = "FEDDEF"
311
         -- Evaluate this result.
312
 
313
         if BS80.Element(Token_String, BS80.To_String(Token_String)'First) /=
314
            BS80.Element(Token_String, BS80.To_String(Token_String)'Last)  or
315
            BS80.Count(Token_String, D_Set)                                /=
316
            BS80.Count(Token_String, E_Set)                                or
317
            BS80.Index_Non_Blank(BS80.Head(Token_String,6))                /=
318
            BS80.Index_Non_Blank(BS80.Tail(Token_String,6))                or
319
            BS80.Head(Token_String, 1)                                     /=
320
            BS80.Tail(Token_String, 1)
321
         then
322
            Report.Failed("Incorrect result from operations in combination");
323
         end if;
324
 
325
      end;
326
 
327
   exception
328
      when others => Report.Failed ("Exception raised in Test_Block");
329
   end Test_Block;
330
 
331
 
332
   Report.Result;
333
 
334
end CXA4007;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.