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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [ada/] [acats/] [tests/] [cxa/] [cxa4020.a] - Blame information for rev 309

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 294 jeremybenn
-- CXA4020.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.Wide_Bounded
28
--      are available, and that they produce correct results, especially under
29
--      conditions where truncation of the result is required.  Specifically,
30
--      check the subprograms Overwrite (function and procedure), Delete,
31
--      Function Trim (blanks), Trim (Set wide characters, function and
32
--      procedure), Head, Tail, and Replicate (wide characters and wide
33
--      strings).
34
--
35
-- TEST DESCRIPTION:
36
--      This test, in conjunction with tests CXA4017, CXA4018, CXA4019,
37
--      will provide coverage of the most common usages of the functionality
38
--      found in the Ada.Strings.Wide_Bounded package.  It deals in large part
39
--      with truncation effects and options.  This test contains many small,
40
--      specific test cases, situations that are often difficult to generate
41
--      in large numbers in an application-based test.  These cases represent
42
--      specific usage paradigms in-the-small.
43
--
44
--
45
-- CHANGE HISTORY:
46
--      06 Dec 94   SAIC    ACVC 2.0
47
--      22 Dec 94   SAIC    Changed obsolete constant to Strings.Wide_Space.
48
--      13 Apr 95   SAIC    Corrected certain subtest acceptance conditions.
49
--
50
--!
51
 
52
with Report;
53
with Ada.Characters.Handling;
54
with Ada.Strings.Wide_Bounded;
55
with Ada.Strings.Wide_Maps;
56
 
57
procedure CXA4020 is
58
 
59
   -- The following two functions are used to translate character and string
60
   -- values to "Wide" values.  They will be applied to all the Wide_Bounded
61
   -- subprogram parameters to simulate the use of Wide_Characters and
62
   -- Wide_Strings in actual practice. Blanks are translated to Wide_Character
63
   -- blanks and all other characters are translated into Wide_Characters with
64
   -- position values 256 greater than their (narrow) character position
65
   -- values.
66
 
67
   function Translate (Ch : Character) return Wide_Character is
68
      C : Character := Ch;
69
   begin
70
      if Ch = ' ' then
71
         return Ada.Characters.Handling.To_Wide_Character(C);
72
      else
73
         return Wide_Character'Val(Character'Pos(Ch) +
74
                Character'Pos(Character'Last) + 1);
75
      end if;
76
   end Translate;
77
 
78
 
79
   function Translate (Str : String) return Wide_String is
80
      WS : Wide_String(Str'First..Str'Last);
81
   begin
82
      for i in Str'First..Str'Last loop
83
         WS(i) := Translate(Str(i));
84
      end loop;
85
      return WS;
86
   end Translate;
87
 
88
 
89
begin
90
 
91
   Report.Test("CXA4020", "Check that the subprograms defined in "      &
92
                          "package Ada.Strings.Wide_Bounded are "       &
93
                          "available, and that they produce correct "   &
94
                          "results, especially under conditions where " &
95
                          "truncation of the result is required");
96
 
97
   Test_Block:
98
   declare
99
 
100
      package AS   renames Ada.Strings;
101
      package ASW  renames Ada.Strings.Wide_Bounded;
102
      package Maps renames Ada.Strings.Wide_Maps;
103
 
104
      package B10 is new ASW.Generic_Bounded_Length(Max => 10);
105
      use type B10.Bounded_Wide_String;
106
 
107
      Result_String : B10.Bounded_Wide_String;
108
      Test_String   : B10.Bounded_Wide_String;
109
      AtoE_Bnd_Str  : B10.Bounded_Wide_String :=
110
                        B10.To_Bounded_Wide_String(Translate("abcde"));
111
      FtoJ_Bnd_Str  : B10.Bounded_Wide_String :=
112
                        B10.To_Bounded_Wide_String(Translate("fghij"));
113
      AtoJ_Bnd_Str  : B10.Bounded_Wide_String :=
114
                        B10.To_Bounded_Wide_String(Translate("abcdefghij"));
115
 
116
      Location     : Natural := 0;
117
      Total_Count  : Natural := 0;
118
 
119
      CD_Set       : Maps.Wide_Character_Set := Maps.To_Set(Translate("cd"));
120
      XY_Set       : Maps.Wide_Character_Set := Maps.To_Set(Translate("xy"));
121
 
122
 
123
   begin
124
 
125
      -- Function Overwrite with Truncation
126
      -- Drop = Error (Default).
127
 
128
      begin
129
         Test_String   := AtoJ_Bnd_Str;
130
         Result_String :=
131
           B10.Overwrite(Source   => Test_String, -- "abcdefghij"
132
                         Position => 9,
133
                         New_Item => Translate("xyz"),
134
                         Drop     => AS.Error);
135
         Report.Failed("Exception not raised by Function Overwrite");
136
      exception
137
         when AS.Length_Error => null;  -- Expected exception raised.
138
         when others          =>
139
           Report.Failed("Incorrect exception raised by Function Overwrite");
140
      end;
141
 
142
      -- Drop = Left
143
 
144
      Result_String :=
145
        B10.Overwrite(Source   => Test_String,  -- "abcdefghij"
146
                      Position => B10.Length(Test_String), -- 10
147
                      New_Item => Translate("xyz"),
148
                      Drop     => Ada.Strings.Left);
149
 
150
      if B10.To_Wide_String(Result_String) /=
151
         Translate("cdefghixyz") then   -- drop a,b
152
         Report.Failed
153
           ("Incorrect result from Function Overwrite, Drop = Left");
154
      end if;
155
 
156
      -- Drop = Right
157
 
158
      Result_String := B10.Overwrite(Test_String,  -- "abcdefghij"
159
                                     3,
160
                                     Translate("xxxyyyzzz"),
161
                                     Ada.Strings.Right);
162
 
163
      if B10.To_Wide_String(Result_String) /=
164
         Translate("abxxxyyyzz")
165
      then
166
         Report.Failed
167
           ("Incorrect result from Function Overwrite, Drop = Right");
168
      end if;
169
 
170
      -- Additional cases of function Overwrite.
171
 
172
      if B10.Overwrite(B10.To_Bounded_Wide_String(Translate("a")),
173
                       1,                                 -- Source length = 1
174
                       Translate("  abc  "))              /=
175
         B10.To_Bounded_Wide_String(Translate("  abc  "))       or
176
         B10.Overwrite(B10.Null_Bounded_Wide_String,      -- Null source
177
                       1,
178
                       Translate("abcdefghij"))           /=
179
         AtoJ_Bnd_Str                                or
180
         B10.Overwrite(AtoE_Bnd_Str,
181
                       B10.To_Wide_String(AtoE_Bnd_Str)'First,
182
                       Translate(" "))                    /=  -- New_Item = 1
183
         B10.To_Bounded_Wide_String(Translate(" bcde"))
184
      then
185
         Report.Failed("Incorrect result from Function Overwrite");
186
      end if;
187
 
188
 
189
 
190
      -- Procedure Overwrite
191
      -- Correct usage, no truncation.
192
 
193
      Test_String := AtoE_Bnd_Str;   -- "abcde"
194
      B10.Overwrite(Test_String, 2, Translate("xyz"));
195
 
196
      if Test_String /= B10.To_Bounded_Wide_String(Translate("axyze")) then
197
         Report.Failed("Incorrect result from Procedure Overwrite - 1");
198
      end if;
199
 
200
      Test_String := B10.To_Bounded_Wide_String(Translate("abc"));
201
      B10.Overwrite(Test_String, 2, "");   -- New_Item is null string.
202
 
203
      if Test_String /= B10.To_Bounded_Wide_String(Translate("abc")) then
204
         Report.Failed("Incorrect result from Procedure Overwrite - 2");
205
      end if;
206
 
207
      -- Drop = Error (Default).
208
 
209
      begin
210
         Test_String   := AtoJ_Bnd_Str;
211
         B10.Overwrite(Source   => Test_String, -- "abcdefghij"
212
                       Position => 8,
213
                       New_Item => Translate("uvwxyz"));
214
         Report.Failed("Exception not raised by Procedure Overwrite");
215
      exception
216
         when AS.Length_Error => null;  -- Expected exception raised.
217
         when others          =>
218
           Report.Failed("Incorrect exception raised by Procedure Overwrite");
219
      end;
220
 
221
      -- Drop = Left
222
 
223
      Test_String   := AtoJ_Bnd_Str;
224
      B10.Overwrite(Source   => Test_String,  -- "abcdefghij"
225
                    Position => B10.Length(Test_String) - 2, -- 8
226
                    New_Item => Translate("uvwxyz"),
227
                    Drop     => Ada.Strings.Left);
228
 
229
      if B10.To_Wide_String(Test_String) /=
230
         Translate("defguvwxyz")
231
      then
232
         Report.Failed
233
           ("Incorrect result from Procedure Overwrite, Drop = Left");
234
      end if;
235
 
236
      -- Drop = Right
237
 
238
      Test_String   := AtoJ_Bnd_Str;
239
      B10.Overwrite(Test_String,  -- "abcdefghij"
240
                    3,
241
                    Translate("xxxyyyzzz"),
242
                    Ada.Strings.Right);
243
 
244
      if B10.To_Wide_String(Test_String) /= Translate("abxxxyyyzz") then
245
         Report.Failed
246
           ("Incorrect result from Procedure Overwrite, Drop = Right");
247
      end if;
248
 
249
 
250
 
251
      -- Function Delete
252
 
253
      if B10.Delete(Source  => AtoJ_Bnd_Str,   -- "abcdefghij"
254
                    From    => 3,
255
                    Through => 8)                               /=
256
         B10."&"(B10.Head(AtoJ_Bnd_Str, 2),
257
                 B10.Tail(AtoJ_Bnd_Str, 2))                         or
258
         B10.Delete(AtoJ_Bnd_Str, 6, B10.Length(AtoJ_Bnd_Str))  /=
259
         AtoE_Bnd_Str                                               or
260
         B10.Delete(AtoJ_Bnd_Str, 1, 5)                         /=
261
         FtoJ_Bnd_Str
262
      then
263
         Report.Failed("Incorrect result from Function Delete - 1");
264
      end if;
265
 
266
      if B10.Delete(B10.To_Bounded_Wide_String(Translate("a")), 1, 1)  /=
267
         B10.Null_Bounded_Wide_String                                    or
268
         B10.Delete(AtoE_Bnd_Str,
269
                    5,
270
                    B10.To_Wide_String(AtoE_Bnd_Str)'First) /=
271
         AtoE_Bnd_Str                                           or
272
         B10.Delete(AtoE_Bnd_Str,
273
                    B10.To_Wide_String(AtoE_Bnd_Str)'Last,
274
                    B10.To_Wide_String(AtoE_Bnd_Str)'Last)  /=
275
         B10.To_Bounded_Wide_String(Translate("abcd"))
276
      then
277
         Report.Failed("Incorrect result from Function Delete - 2");
278
      end if;
279
 
280
 
281
 
282
      -- Function Trim
283
 
284
      declare
285
 
286
         Text : B10.Bounded_Wide_String :=
287
                  B10.To_Bounded_Wide_String(Translate("Text"));
288
         type Bnd_Array_Type is array (1..5) of B10.Bounded_Wide_String;
289
         Bnd_Array : Bnd_Array_Type :=
290
           (B10.To_Bounded_Wide_String(Translate("  Text")),
291
            B10.To_Bounded_Wide_String(Translate("Text    ")),
292
            B10.To_Bounded_Wide_String(Translate("   Text   ")),
293
            B10.To_Bounded_Wide_String(Translate("Text  Text")),
294
            B10.To_Bounded_Wide_String(Translate(" Text Text")));
295
 
296
      begin
297
 
298
         for i in Bnd_Array_Type'Range loop
299
            case i is
300
               when 4 =>
301
                  if B10.Trim(Bnd_Array(i), AS.Both) /=
302
                     Bnd_Array(i) then  -- no change
303
                     Report.Failed("Incorrect result from Function Trim - 4");
304
                  end if;
305
               when 5 =>
306
                  if B10.Trim(Bnd_Array(i), AS.Both) /=
307
                     B10."&"(Text, B10."&"(Translate(' '), Text))
308
                  then
309
                     Report.Failed("Incorrect result from Function Trim - 5");
310
                  end if;
311
               when others =>
312
                  if B10.Trim(Bnd_Array(i), AS.Both) /= Text then
313
                     Report.Failed("Incorrect result from Function Trim - " &
314
                                    Integer'Image(i));
315
                  end if;
316
            end case;
317
         end loop;
318
 
319
      end;
320
 
321
 
322
 
323
      -- Function Trim using Sets
324
 
325
      -- Trim characters in sets from both sides of the bounded wide string.
326
      if B10.Trim(Source => B10.To_Bounded_Wide_String(Translate("ddabbaxx")),
327
                  Left   => CD_Set,
328
                  Right  => XY_Set)  /=
329
         B10.To_Bounded_Wide_String(Translate("abba"))
330
      then
331
         Report.Failed
332
           ("Incorrect result from Fn Trim - Sets, Left & Right side - 1");
333
      end if;
334
 
335
      -- Ensure that the characters in the set provided as the actual to
336
      -- parameter Right are not trimmed from the left side of the bounded
337
      -- wide string; likewise for the opposite side.  Only "cd" trimmed
338
      -- from left side, and only "xy" trimmed from right side.
339
 
340
      if B10.Trim(B10.To_Bounded_Wide_String(Translate("cdxyabcdxy")),
341
                  CD_Set,
342
                  XY_Set) /=
343
         B10.To_Bounded_Wide_String(Translate("xyabcd"))
344
      then
345
         Report.Failed
346
           ("Incorrect result from Fn Trim - Sets, Left & Right side - 2");
347
      end if;
348
 
349
      -- Ensure that characters contained in the sets are not trimmed from
350
      -- the "interior" of the bounded wide string, just the appropriate ends.
351
 
352
      if B10.Trim(B10.To_Bounded_Wide_String(Translate("cdabdxabxy")),
353
                  CD_Set,
354
                  XY_Set) /=
355
         B10.To_Bounded_Wide_String(Translate("abdxab"))
356
      then
357
         Report.Failed
358
           ("Incorrect result from Fn Trim - Sets, Left & Right side - 3");
359
      end if;
360
 
361
      -- Trim characters in set from right side only.  No change to Left side.
362
 
363
      if B10.Trim(B10.To_Bounded_Wide_String(Translate("abxyzddcd")),
364
                  XY_Set,
365
                  CD_Set) /=
366
         B10.To_Bounded_Wide_String(Translate("abxyz"))
367
      then
368
         Report.Failed
369
           ("Incorrect result from Fn Trim - Sets, Right side");
370
      end if;
371
 
372
      -- Trim no characters on either side of the bounded string.
373
 
374
      Result_String := B10.Trim(AtoJ_Bnd_Str, CD_Set, XY_Set);
375
      if Result_String /= AtoJ_Bnd_Str then
376
         Report.Failed("Incorrect result from Fn Trim - Sets, Neither side");
377
      end if;
378
 
379
      if B10.Trim(AtoE_Bnd_Str, Maps.Null_Set, Maps.Null_Set) /=
380
         AtoE_Bnd_Str                                            or
381
         B10.Trim(B10.To_Bounded_Wide_String(Translate("dcddcxyyxx")),
382
                  CD_Set,
383
                  XY_Set)                                     /=
384
         B10.Null_Bounded_Wide_String
385
      then
386
         Report.Failed("Incorrect result from Function Trim");
387
      end if;
388
 
389
 
390
 
391
      -- Procedure Trim using Sets
392
 
393
      -- Trim characters in sets from both sides of the bounded wide string.
394
 
395
      Test_String := B10.To_Bounded_Wide_String(Translate("dcabbayx"));
396
      B10.Trim(Source => Test_String,
397
               Left   => CD_Set,
398
               Right  => XY_Set);
399
 
400
      if Test_String /= B10.To_Bounded_Wide_String(Translate("abba")) then
401
         Report.Failed
402
           ("Incorrect result from Proc Trim - Sets, Left & Right side - 1");
403
      end if;
404
 
405
      -- Ensure that the characters in the set provided as the actual to
406
      -- parameter Right are not trimmed from the left side of the bounded
407
      -- wide string; likewise for the opposite side.  Only "cd" trimmed
408
      -- from left side, and only "xy" trimmed from right side.
409
 
410
      Test_String := B10.To_Bounded_Wide_String(Translate("cdxyabcdxy"));
411
      B10.Trim(Test_String, CD_Set, XY_Set);
412
 
413
      if Test_String /= B10.To_Bounded_Wide_String(Translate("xyabcd")) then
414
         Report.Failed
415
           ("Incorrect result from Proc Trim - Sets, Left & Right side - 2");
416
      end if;
417
 
418
      -- Ensure that characters contained in the sets are not trimmed from
419
      -- the "interior" of the bounded wide string, just the appropriate ends.
420
 
421
      Test_String := B10.To_Bounded_Wide_String(Translate("cdabdxabxy"));
422
      B10.Trim(Test_String, CD_Set, XY_Set);
423
 
424
      if not
425
        (Test_String = B10.To_Bounded_Wide_String(Translate("abdxab"))) then
426
         Report.Failed
427
           ("Incorrect result from Proc Trim - Sets, Left & Right side - 3");
428
      end if;
429
 
430
      -- Trim characters in set from Left side only.  No change to Right side.
431
 
432
      Test_String := B10.To_Bounded_Wide_String(Translate("cccdabxyz"));
433
      B10.Trim(Test_String, CD_Set, XY_Set);
434
 
435
      if Test_String /= B10.To_Bounded_Wide_String(Translate("abxyz")) then
436
         Report.Failed
437
           ("Incorrect result from Proc Trim for Sets, Left side only");
438
      end if;
439
 
440
      -- Trim no characters on either side of the bounded wide string.
441
 
442
      Test_String := AtoJ_Bnd_Str;
443
      B10.Trim(Test_String, CD_Set, CD_Set);
444
 
445
      if Test_String /= AtoJ_Bnd_Str then
446
         Report.Failed("Incorrect result from Proc Trim-Sets, Neither side");
447
      end if;
448
 
449
 
450
 
451
      -- Function Head with Truncation
452
      -- Drop = Error (Default).
453
 
454
      begin
455
         Result_String := B10.Head(Source => AtoJ_Bnd_Str,   -- max length
456
                                   Count  => B10.Length(AtoJ_Bnd_Str) + 1,
457
                                   Pad    => Translate('X'));
458
         Report.Failed("Length_Error not raised by Function Head");
459
      exception
460
         when AS.Length_Error => null;  -- Expected exception raised.
461
         when others          =>
462
            Report.Failed("Incorrect exception raised by Function Head");
463
      end;
464
 
465
      -- Drop = Left
466
 
467
      -- Pad characters (5) are appended to the right end of the bounded
468
      -- wide string (which is initially at its maximum length), then the
469
      -- first five characters of the intermediate result are dropped to
470
      -- conform to the maximum size limit of the bounded wide string (10).
471
 
472
      Result_String :=
473
        B10.Head(B10.To_Bounded_Wide_String(Translate("ABCDEFGHIJ")),
474
                 15,
475
                 Translate('x'),
476
                 Ada.Strings.Left);
477
 
478
      if Result_String /=
479
         B10.To_Bounded_Wide_String(Translate("FGHIJxxxxx"))
480
      then
481
         Report.Failed("Incorrect result from Function Head, Drop = Left");
482
      end if;
483
 
484
      -- Drop = Right
485
 
486
      -- Pad characters (6) are appended to the left end of the bounded
487
      -- wide string (which is initially at one less than its maximum length),
488
      -- then the last five characters of the intermediate result are dropped
489
      -- (which in this case are the pad characters) to conform to the
490
      -- maximum size limit of the bounded wide string (10).
491
 
492
      Result_String :=
493
        B10.Head(B10.To_Bounded_Wide_String(Translate("ABCDEFGHI")),
494
                 15,
495
                 Translate('x'),
496
                 Ada.Strings.Right);
497
 
498
      if Result_String /=
499
         B10.To_Bounded_Wide_String(Translate("ABCDEFGHIx"))
500
      then
501
         Report.Failed("Incorrect result from Function Head, Drop = Right");
502
      end if;
503
 
504
      -- Additional cases.
505
 
506
      if B10.Head(B10.Null_Bounded_Wide_String, 5, Translate('a')) /=
507
         B10.To_Bounded_Wide_String(Translate("aaaaa"))          or
508
         B10.Head(AtoE_Bnd_Str,
509
                  B10.Length(AtoE_Bnd_Str))   /=
510
         AtoE_Bnd_Str
511
      then
512
         Report.Failed("Incorrect result from Function Head");
513
      end if;
514
 
515
 
516
 
517
      -- Function Tail with Truncation
518
      -- Drop = Error (Default Case)
519
 
520
      begin
521
         Result_String := B10.Tail(Source => AtoJ_Bnd_Str,   -- max length
522
                                   Count  => B10.Length(AtoJ_Bnd_Str) + 1,
523
                                   Pad    => Ada.Strings.Wide_Space,
524
                                   Drop   => Ada.Strings.Error);
525
         Report.Failed("Length_Error not raised by Function Tail");
526
      exception
527
         when AS.Length_Error => null;  -- Expected exception raised.
528
         when others          =>
529
            Report.Failed("Incorrect exception raised by Function Tail");
530
      end;
531
 
532
      -- Drop = Left
533
 
534
      -- Pad characters (5) are appended to the left end of the bounded wide
535
      -- string (which is initially at two less than its maximum length),
536
      -- then the first three characters of the intermediate result (in this
537
      -- case, 3 pad characters) are dropped.
538
 
539
      Result_String :=
540
        B10.Tail(B10.To_Bounded_Wide_String(Translate("ABCDEFGH")),
541
                 13,
542
                 Translate('x'),
543
                 Ada.Strings.Left);
544
 
545
      if Result_String /=
546
         B10.To_Bounded_Wide_String(Translate("xxABCDEFGH"))
547
      then
548
         Report.Failed("Incorrect result from Function Tail, Drop = Left");
549
      end if;
550
 
551
      -- Drop = Right
552
 
553
      -- Pad characters (3) are appended to the left end of the bounded wide
554
      -- string (which is initially at its maximum length), then the last
555
      -- three characters of the intermediate result are dropped.
556
 
557
      Result_String :=
558
        B10.Tail(B10.To_Bounded_Wide_String(Translate("ABCDEFGHIJ")),
559
                 13,
560
                 Translate('x'),
561
                 Ada.Strings.Right);
562
 
563
      if Result_String /=
564
         B10.To_Bounded_Wide_String(Translate("xxxABCDEFG"))
565
      then
566
         Report.Failed("Incorrect result from Function Tail, Drop = Right");
567
      end if;
568
 
569
      -- Additional cases.
570
 
571
      if B10.Tail(B10.Null_Bounded_Wide_String, 3, Translate(' ')) /=
572
         B10.To_Bounded_Wide_String(Translate("   "))                or
573
         B10.Tail(AtoE_Bnd_Str,
574
                  B10.To_Wide_String(AtoE_Bnd_Str)'First)  /=
575
         B10.To_Bounded_Wide_String(Translate("e"))
576
      then
577
         Report.Failed("Incorrect result from Function Tail");
578
      end if;
579
 
580
 
581
 
582
      -- Function Replicate (#, Char) with Truncation
583
      -- Drop = Error (Default).
584
 
585
      begin
586
         Result_String := B10.Replicate(Count => B10.Max_Length + 5,
587
                                        Item  => Translate('A'),
588
                                        Drop  => AS.Error);
589
         Report.Failed
590
           ("Length_Error not raised by Replicate for characters");
591
      exception
592
         when AS.Length_Error => null;  -- Expected exception raised.
593
         when others          =>
594
           Report.Failed
595
             ("Incorrect exception raised by Replicate for characters");
596
      end;
597
 
598
      -- Drop = Left, Right
599
      -- Since this version of Replicate uses wide character parameters, the
600
      -- result after truncation from left or right will appear the same.
601
      -- The result will be a 10 character bounded wide string, composed of
602
      -- 10 "Item" wide characters.
603
 
604
      if B10.Replicate(Count => 20,
605
                       Item => Translate('A'),
606
                       Drop => Ada.Strings.Left) /=
607
         B10.Replicate(15, Translate('A'), Ada.Strings.Right)
608
      then
609
         Report.Failed("Incorrect result from Replicate for characters - 1");
610
      end if;
611
 
612
      -- Blank-filled, 10 character bounded wide strings.
613
 
614
      if B10.Replicate(B10.Max_Length + 1,
615
                       Translate(' '),
616
                       Drop => Ada.Strings.Left) /=
617
         B10.Replicate(B10.Max_Length, Ada.Strings.Wide_Space)
618
      then
619
         Report.Failed("Incorrect result from Replicate for characters - 2");
620
      end if;
621
 
622
      -- Additional cases.
623
 
624
      if B10.Replicate(0, Translate('a')) /= B10.Null_Bounded_Wide_String or
625
         B10.Replicate(1, Translate('a')) /=
626
         B10.To_Bounded_Wide_String(Translate("a"))
627
      then
628
         Report.Failed("Incorrect result from Replicate for characters - 3");
629
      end if;
630
 
631
 
632
 
633
      -- Function Replicate (#, String) with Truncation
634
      -- Drop = Error (Default).
635
 
636
      begin
637
         Result_String := B10.Replicate(Count => 5,  -- result would be 15.
638
                                        Item  => Translate("abc"));
639
         Report.Failed
640
           ("Length_Error not raised by Replicate for wide strings");
641
      exception
642
         when AS.Length_Error => null;  -- Expected exception raised.
643
         when others          =>
644
           Report.Failed
645
             ("Incorrect exception raised by Replicate for wide strings");
646
      end;
647
 
648
      -- Drop = Left
649
 
650
      Result_String := B10.Replicate(3, Translate("abcd"), Ada.Strings.Left);
651
 
652
      if Result_String /=
653
         B10.To_Bounded_Wide_String(Translate("cdabcdabcd"))
654
      then
655
         Report.Failed
656
           ("Incorrect result from Replicate for wide strings, Drop = Left");
657
      end if;
658
 
659
      -- Drop = Right
660
 
661
      Result_String := B10.Replicate(3, Translate("abcd"), Ada.Strings.Right);
662
 
663
      if Result_String /=
664
         B10.To_Bounded_Wide_String(Translate("abcdabcdab")) then
665
         Report.Failed
666
           ("Incorrect result from Replicate for wide strings, Drop = Right");
667
      end if;
668
 
669
      -- Additional cases.
670
 
671
      if B10.Replicate(5, Translate("X"))    /=
672
         B10.To_Bounded_Wide_String(Translate("XXXXX"))   or
673
         B10.Replicate(10, "")               /=
674
         B10.Null_Bounded_Wide_String                     or
675
         B10.Replicate(0, Translate("ab"))   /=
676
         B10.Null_Bounded_Wide_String
677
      then
678
         Report.Failed("Incorrect result from Replicate for wide strings");
679
      end if;
680
 
681
 
682
   exception
683
      when others => Report.Failed("Exception raised in Test_Block");
684
   end Test_Block;
685
 
686
   Report.Result;
687
 
688
end CXA4020;

powered by: WebSVN 2.1.0

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