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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 720 jeremybenn
-- CXA4031.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.Unbounded
28
--      are available, and that they produce correct results. Specifically,
29
--      check the functions To_Unbounded_String (version with Length
30
--      parameter), "=", "<", "<=", ">", ">=" (all with String-Unbounded
31
--      String parameter mix), as well as three versions of Procedure Append.
32
--
33
-- TEST DESCRIPTION:
34
--      This test demonstrates the uses of many of the subprograms defined
35
--      in package Ada.Strings.Unbounded for use with unbounded strings.
36
--      The test simulates how unbounded strings could be processed in a
37
--      user environment, using the subprograms provided in this package.
38
--
39
--      This test, when taken in conjunction with tests CXA4010, CXA4011,
40
--      CXA4030, and CXA4032 will constitute a test of all the functionality
41
--      contained in package Ada.Strings.Unbounded.  This test uses a variety
42
--      of the subprograms defined in the unbounded string package in ways
43
--      typical of common usage.
44
--
45
--
46
-- CHANGE HISTORY:
47
--      27 Feb 95   SAIC    Initial prerelease version.
48
--      18 Apr 96   SAIC    Incorporated reviewer comments for ACVC 2.1.
49
--
50
--!
51
 
52
with Report;
53
with Ada.Exceptions;
54
with Ada.Strings.Maps;
55
with Ada.Strings.Unbounded;
56
 
57
procedure CXA4031 is
58
begin
59
 
60
   Report.Test ("CXA4031", "Check that the subprograms defined in "        &
61
                           "package Ada.Strings.Unbounded are available, " &
62
                           "and that they produce correct results");
63
 
64
   Test_Block:
65
   declare
66
 
67
      package Unb renames Ada.Strings.Unbounded;
68
      use Unb;
69
      use Ada.Exceptions;
70
 
71
      subtype LC_Characters is Character range 'a'..'z';
72
 
73
      Null_String       : constant String := "";
74
      TC_String         : constant String := "A Standard String";
75
 
76
      TC_Unb_String,
77
      TC_New_Unb_String : Unb.Unbounded_String := Unb.Null_Unbounded_String;
78
 
79
   begin
80
 
81
      -- Function To_Unbounded_String (version with Length parameter)
82
      -- returns an unbounded string that represents an uninitialized String
83
      -- whose length is Length.
84
      -- Note: Unbounded_String length can vary conceptually between 0 and
85
      --       Natural'Last.
86
 
87
      if Unb.Length(Unb.To_Unbounded_String(Length => 10)) /= 10 or
88
         Unb.Length(Unb.To_Unbounded_String(1))            /=  1 or
89
         Unb.Length(Unb.To_Unbounded_String(0))            /=  0 or
90
         Unb.Length(Unb."&"(Unb.To_Unbounded_String(Length => 10),
91
                    Unb."&"(Unb.To_Unbounded_String(1),
92
                            Unb.To_Unbounded_String(0) ))) /= 10+1+0
93
      then
94
         Report.Failed
95
           ("Incorrect results from Function To_Unbounded_String with " &
96
            "Length parameter");
97
      end if;
98
 
99
 
100
      -- Procedure Append (Unbounded - Unbounded)
101
      -- Note: For each of the Append procedures, the resulting string
102
      --       represented by the Source parameter is given by the
103
      --       concatenation of the original value of Source and the value
104
      --       of New_Item.
105
 
106
      TC_Unb_String := Unb.To_Unbounded_String("Sample string of length L");
107
      TC_New_Unb_String := Unb.To_Unbounded_String(" and then some");
108
 
109
      Unb.Append(Source => TC_Unb_String, New_Item => TC_New_Unb_String);
110
 
111
      if TC_Unb_String /=
112
         Unb.To_Unbounded_String("Sample string of length L and then some")
113
      then
114
         Report.Failed("Incorrect results from Procedure Append with " &
115
                       "unbounded string parameters - 1");
116
      end if;
117
 
118
 
119
      TC_Unb_String := Unb.To_Unbounded_String("Sample string of length L");
120
      TC_New_Unb_String := Unb.Null_Unbounded_String;
121
 
122
      Unb.Append(TC_Unb_String, TC_New_Unb_String);
123
 
124
      if TC_Unb_String /=
125
         Unb.To_Unbounded_String("Sample string of length L")
126
      then
127
         Report.Failed("Incorrect results from Procedure Append with " &
128
                       "unbounded string parameters - 2");
129
      end if;
130
 
131
 
132
      TC_Unb_String := Unb.Null_Unbounded_String;
133
 
134
      Unb.Append(TC_Unb_String,
135
                 Unb.To_Unbounded_String("New Unbounded String"));
136
 
137
      if TC_Unb_String /=
138
         Unb.To_Unbounded_String("New Unbounded String")
139
      then
140
         Report.Failed("Incorrect results from Procedure Append with " &
141
                       "unbounded string parameters - 3");
142
      end if;
143
 
144
 
145
      -- Procedure Append (Unbounded - String)
146
 
147
      TC_Unb_String := Unb.To_Unbounded_String("An Unbounded String and ");
148
 
149
      Unb.Append(Source => TC_Unb_String, New_Item => TC_String);
150
 
151
      if TC_Unb_String /=
152
         Unb.To_Unbounded_String("An Unbounded String and A Standard String")
153
      then
154
         Report.Failed("Incorrect results from Procedure Append with " &
155
                       "an unbounded string parameter and a string "   &
156
                       "parameter - 1");
157
      end if;
158
 
159
 
160
      TC_Unb_String := Unb.To_Unbounded_String("An Unbounded String");
161
 
162
      Unb.Append(TC_Unb_String, New_Item => Null_String);
163
 
164
      if TC_Unb_String /=
165
         Unb.To_Unbounded_String("An Unbounded String")
166
      then
167
         Report.Failed("Incorrect results from Procedure Append with " &
168
                       "an unbounded string parameter and a string "   &
169
                       "parameter - 2");
170
      end if;
171
 
172
 
173
      TC_Unb_String := Unb.Null_Unbounded_String;
174
 
175
      Unb.Append(TC_Unb_String, TC_String);
176
 
177
      if TC_Unb_String /= Unb.To_Unbounded_String("A Standard String") then
178
         Report.Failed("Incorrect results from Procedure Append with " &
179
                       "an unbounded string parameter and a string "   &
180
                       "parameter - 3");
181
      end if;
182
 
183
 
184
      -- Procedure Append (Unbounded - Character)
185
 
186
      TC_Unb_String := Unb.To_Unbounded_String("Lower Case = ");
187
 
188
      for i in LC_Characters'Range loop
189
         Unb.Append(Source => TC_Unb_String, New_Item => LC_Characters(i));
190
      end loop;
191
 
192
      if TC_Unb_String /=
193
         Unb.To_Unbounded_String("Lower Case = abcdefghijklmnopqrstuvwxyz")
194
      then
195
         Report.Failed("Incorrect results from Procedure Append with "  &
196
                       "an unbounded string parameter and a character " &
197
                       "parameter - 1");
198
      end if;
199
 
200
 
201
      TC_Unb_String := Unb.Null_Unbounded_String;
202
 
203
      Unb.Append(TC_Unb_String, New_Item => 'a');
204
 
205
      if TC_Unb_String /= Unb.To_Unbounded_String("a") then
206
         Report.Failed("Incorrect results from Procedure Append with "  &
207
                       "an unbounded string parameter and a character " &
208
                       "parameter - 2");
209
      end if;
210
 
211
 
212
      -- Function "="
213
 
214
      TC_Unb_String := Unb.To_Unbounded_String(TC_String);
215
 
216
      if not (TC_Unb_String = TC_String)                 or  -- (Unb_Str, Str)
217
         not Unb."="("A Standard String", TC_Unb_String) or  -- (Str, Unb_Str)
218
         not ((Unb.Null_Unbounded_String = "") and           -- (Unb_Str, Str)
219
              ("Test String" =                               -- (Str, Unb_Str)
220
               Unb.To_Unbounded_String("Test String")))
221
      then
222
         Report.Failed("Incorrect results from function ""="" with " &
223
                       "string - unbounded string parameter combinations");
224
      end if;
225
 
226
 
227
      -- Function "<"
228
 
229
      if not ("Extra Space" < Unb.To_Unbounded_String("Extra Space ") and
230
              Unb.To_Unbounded_String("tess") < "test"                and
231
              Unb.To_Unbounded_String("best") < "test")                or
232
         Unb.Null_Unbounded_String            < Null_String            or
233
         " leading blank"  < Unb.To_Unbounded_String(" leading blank") or
234
         "ending blank "   < Unb.To_Unbounded_String("ending blank ")
235
      then
236
         Report.Failed("Incorrect results from function ""<"" with " &
237
                       "string - unbounded string parameter combinations");
238
      end if;
239
 
240
 
241
      -- Function "<="
242
 
243
      TC_Unb_String := Unb.To_Unbounded_String("Sample string");
244
 
245
      if TC_Unb_String                 <= "Sample strin" or  -- (Unb_Str, Str)
246
         "sample string"               <= TC_Unb_String  or  -- (Str, Unb_Str)
247
         not(Unb.Null_Unbounded_String <= "")            or  -- (Unb_Str, Str)
248
         not("Sample string"           <= TC_Unb_String)     -- (Str, Unb_Str)
249
      then
250
         Report.Failed("Incorrect results from function ""<="" with " &
251
                       "string - unbounded string parameter combinations");
252
      end if;
253
 
254
 
255
      -- Function ">"
256
 
257
      TC_Unb_String := Unb.To_Unbounded_String("A MUCH LONGER STRING");
258
 
259
      if not ("A much longer string" > TC_Unb_String                  and
260
              Unb.To_Unbounded_String(TC_String) > "A Standard Strin" and
261
              "abcdefgh" > Unb.To_Unbounded_String("ABCDEFGH"))        or
262
         Unb.Null_Unbounded_String > Null_String
263
      then
264
         Report.Failed("Incorrect results from function "">"" with " &
265
                       "string - unbounded string parameter combinations");
266
      end if;
267
 
268
 
269
      -- Function ">="
270
 
271
      TC_Unb_String := Unb.To_Unbounded_String(TC_String);
272
 
273
      if not (TC_Unb_String >= TC_String                       and
274
              Null_String   >= Unb.Null_Unbounded_String       and
275
              "test"        >= Unb.To_Unbounded_String("tess") and
276
              Unb.To_Unbounded_String("Programming") >= "PROGRAMMING")
277
      then
278
         Report.Failed("Incorrect results from function "">="" with " &
279
                       "string - unbounded string parameter combinations");
280
      end if;
281
 
282
 
283
   exception
284
      when The_Error : others =>
285
         Report.Failed ("The following exception was raised in the " &
286
                        "Test_Block: " & Exception_Name(The_Error));
287
   end Test_Block;
288
 
289
   Report.Result;
290
 
291
end CXA4031;

powered by: WebSVN 2.1.0

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