aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/ada/acats/tests/cxa/cxa4005.a
blob: d61f853ca0e6f914761500355b1f3d84aeb2516f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
-- CXA4005.A
--
--                             Grant of Unlimited Rights
--
--     Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
--     F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
--     unlimited rights in the software and documentation contained herein.
--     Unlimited rights are defined in DFAR 252.227-7013(a)(19).  By making
--     this public release, the Government intends to confer upon all
--     recipients unlimited rights  equal to those held by the Government.
--     These rights include rights to use, duplicate, release or disclose the
--     released technical data and computer software in whole or in part, in
--     any manner and for any purpose whatsoever, and to have or permit others
--     to do so.
--
--                                    DISCLAIMER
--
--     ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
--     DISCLOSED ARE AS IS.  THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
--     WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
--     SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
--     OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
--     PARTICULAR PURPOSE OF SAID MATERIAL.
--*
--
-- OBJECTIVE:
--      Check that the subprograms defined in package Ada.Strings.Fixed are
--      available, and that they produce correct results.  Specifically,
--      check the subprograms Delete, Head, Insert, Overwrite, Replace_Slice,
--      Tail, Trim, and "*".
--
-- TEST DESCRIPTION:
--      This test, when combined with tests CXA4002-4 will provide coverage
--      of the functionality found in Ada.Strings.Fixed.
--      This test contains many small, specific test cases, situations that
--      although common in user environments, are often difficult to generate
--      in large numbers in a application-based test.  They represent
--      individual usage paradigms in-the-small.
--
--
-- CHANGE HISTORY:
--      06 Dec 94   SAIC    ACVC 2.0
--      11 Apr 95   SAIC    Corrected acceptance conditions of certain
--                          subtests.
--	06 Nov 95   SAIC    Fixed bugs for ACVC 2.0.1.
--      22 Feb 01   PHL     Check that the lower bound of the result is 1.
--      13 Mar 01   RLB     Fixed a couple of ACATS style violations;
--                          removed pointless checks of procedures.
--                          Added checks of other functions. These changes
--                          were made to test Defect Report 8652/0049, as
--                          reflected in Technical Corrigendum 1.
--
--!

with Report;
with Ada.Strings;
with Ada.Strings.Fixed;
with Ada.Strings.Maps;

procedure CXA4005 is

    type TC_Name_Holder is access String;
    Name : TC_Name_Holder;

    function TC_Check (S : String) return String is
    begin
        if S'First /= 1 then
            Report.Failed ("Lower bound of result of function " & Name.all &
                           " is" & Integer'Image (S'First));
        end if;
        return S;
    end TC_Check;

    procedure TC_Set_Name (N : String) is
    begin
        Name := new String'(N);
    end TC_Set_Name;

begin

   Report.Test("CXA4005", "Check that the subprograms defined in "    &
                          "package Ada.Strings.Fixed are available, " &
                          "and that they produce correct results");

   Test_Block:
   declare

      package ASF  renames Ada.Strings.Fixed;
      package Maps renames Ada.Strings.Maps;

      Result_String,
      Delete_String,
      Insert_String,
      Trim_String,
      Overwrite_String  : String(1..10) := (others => Ada.Strings.Space);

      Source_String1    : String(1..5)  := "abcde";     -- odd length string
      Source_String2    : String(1..6)  := "abcdef";    -- even length string
      Source_String3    : String(1..12) := "abcdefghijkl";
      Source_String4    : String(1..12) := "abcdefghij  "; -- last two ch pad
      Source_String5    : String(1..12) := "  cdefghijkl"; -- first two ch pad
      Source_String6    : String(1..12) := "abcdefabcdef";

      Location     : Natural := 0;
      Slice_Start  : Positive;
      Slice_End,
      Slice_Count  : Natural := 0;

      CD_Set       : Maps.Character_Set := Maps.To_Set("cd");
      X_Set        : Maps.Character_Set := Maps.To_Set('x');
      ABCD_Set     : Maps.Character_Set := Maps.To_Set("abcd");
      A_to_F_Set   : Maps.Character_Set := Maps.To_Set("abcdef");

      CD_to_XY_Map : Maps.Character_Mapping :=
                                 Maps.To_Mapping(From => "cd",  To => "xy");

   begin

      -- Procedure Replace_Slice
      -- The functionality of this procedure
      -- is similar to procedure Move, and
      -- is tested here in the same manner, evaluated
      -- with various combinations of parameters.

      -- Index_Error propagation when Low > Source'Last + 1

      begin
         ASF.Replace_Slice(Result_String,
                           Result_String'Last + 2, -- should raise exception
                           Result_String'Last,
                           "xxxxxxx");
         Report.Failed("Index_Error not raised by Replace_Slice - 1");
      exception
         when Ada.Strings.Index_Error => null; -- OK, expected exception.
         when others                  =>
            Report.Failed("Incorrect exception from Replace_Slice - 1");
      end;

      -- Index_Error propagation when High < Source'First - 1

      begin
         ASF.Replace_Slice(Result_String(5..10),
                           5,
                           3, -- should raise exception since < 'First - 1.
                           "xxxxxxx");
         Report.Failed("Index_Error not raised by Replace_Slice - 2");
      exception
         when Ada.Strings.Index_Error => null; -- OK, expected exception.
         when others                  =>
            Report.Failed("Incorrect exception from Replace_Slice - 2");
      end;

      -- Justify = Left (default case)

      Result_String := "XXXXXXXXXX";

      ASF.Replace_Slice(Source => Result_String,
                        Low    =>  1,
                        High   => 10,
                        By     => Source_String1);   -- "abcde"

      if Result_String /= "abcde     " then
         Report.Failed("Incorrect result from Replace_Slice - Justify = Left");
      end if;

      -- Justify = Right

      ASF.Replace_Slice(Source  => Result_String,
                        Low     => 1,
                        High    => Result_String'Last,
                        By      => Source_String2,      -- "abcdef"
                        Drop    => Ada.Strings.Error,
                        Justify => Ada.Strings.Right);

      if Result_String /= "    abcdef" then
         Report.Failed("Incorrect result from Replace_Slice - Justify=Right");
      end if;

      -- Justify = Center (two cases, odd and even pad lengths)

      ASF.Replace_Slice(Result_String,
                        1,
                        Result_String'Last,
                        Source_String1,      -- "abcde"
                        Ada.Strings.Error,
                        Ada.Strings.Center,
                        'x');                -- non-default padding.

      if Result_String /= "xxabcdexxx" then  -- Unequal padding added right
         Report.Failed("Incorrect result, Replace_Slice - Justify=Center - 1");
      end if;

      ASF.Replace_Slice(Result_String,
                        1,
                        Result_String'Last,
                        Source_String2,        -- "abcdef"
                        Ada.Strings.Error,
                        Ada.Strings.Center);

      if Result_String /= "  abcdef  " then    -- Equal padding added on L/R.
         Report.Failed("Incorrect result from Replace_Slice with " &
                       "Justify = Center - 2");
      end if;

      -- When the source string is longer than the target string, several
      -- cases can be examined, with the results depending on the value of
      -- the Drop parameter.

      -- Drop = Left

      ASF.Replace_Slice(Result_String,
                        1,
                        Result_String'Last,
                        Source_String3,            -- "abcdefghijkl"
                        Drop => Ada.Strings.Left);

      if Result_String /= "cdefghijkl" then
         Report.Failed("Incorrect result from Replace_Slice - Drop=Left");
      end if;

      -- Drop = Right

      ASF.Replace_Slice(Result_String,
                        1,
                        Result_String'Last,
                        Source_String3,        -- "abcdefghijkl"
                        Ada.Strings.Right);

      if Result_String /= "abcdefghij" then
         Report.Failed("Incorrect result, Replace_Slice with Drop=Right");
      end if;

      -- Drop = Error

      -- The effect in this case depends on the value of the justify
      -- parameter, and on whether any characters in Source other than
      -- Pad would fail to be copied.

      -- Drop = Error, Justify = Left, right overflow characters are pad.

      ASF.Replace_Slice(Result_String,
                        1,
                        Result_String'Last,
                        Source_String4,               -- "abcdefghij  "
                        Drop    => Ada.Strings.Error,
                        Justify => Ada.Strings.Left);

      if not(Result_String = "abcdefghij") then  -- leftmost 10 characters
          Report.Failed("Incorrect result, Replace_Slice - Drop = Error - 1");
      end if;

      -- Drop = Error, Justify = Right, left overflow characters are pad.

      ASF.Replace_Slice(Source   => Result_String,
                        Low      => 1,
                        High     => Result_String'Last,
                        By       => Source_String5,     -- "  cdefghijkl"
                        Drop     => Ada.Strings.Error,
                        Justify  => Ada.Strings.Right);

      if Result_String /= "cdefghijkl" then  -- rightmost 10 characters
         Report.Failed("Incorrect result, Replace_Slice - Drop = Error - 2");
      end if;

      -- In other cases of Drop=Error, Length_Error is propagated, such as:

      begin

         ASF.Replace_Slice(Source   => Result_String,
                           Low      => 1,
                           High     => Result_String'Last,
                           By       => Source_String3,    -- "abcdefghijkl"
                           Drop     => Ada.Strings.Error);

          Report.Failed("Length_Error not raised by Replace_Slice - 1");

      exception
         when Ada.Strings.Length_Error => null;   -- OK
         when others =>
            Report.Failed("Incorrect exception from Replace_Slice - 3");
      end;


      -- Function Replace_Slice

      TC_Set_Name ("Replace_Slice");

      if TC_Check (ASF.Replace_Slice("abcde", 3, 3, "x"))
                                           /= "abxde"  or -- High = Low
         TC_Check (ASF.Replace_Slice("abc",   2, 3, "xyz")) /= "axyz"   or
         TC_Check (ASF.Replace_Slice("abcd",  4, 1, "xy"))
                                           /= "abcxyd" or -- High < Low
         TC_Check (ASF.Replace_Slice("abc",   2, 3, "x"))   /= "ax"     or
         TC_Check (ASF.Replace_Slice("a",     1, 1, "z"))   /= "z"
      then
         Report.Failed("Incorrect result from Function Replace_Slice - 1");
      end if;

      if TC_Check (ASF.Replace_Slice("abcde", 5, 5, "z"))
                                           /= "abcdz" or  -- By length 1
         TC_Check (ASF.Replace_Slice("abc",   1, 3, "xyz"))
                                           /= "xyz"   or  -- High > Low
         TC_Check (ASF.Replace_Slice("abc",   3, 2, "xy"))
                                           /= "abxyc" or  -- insert
         TC_Check (ASF.Replace_Slice("a",     1, 1, "xyz")) /= "xyz"
      then
         Report.Failed("Incorrect result from Function Replace_Slice - 2");
      end if;



      -- Function Insert.

      TC_Set_Name ("Insert");

      declare
         New_String : constant String :=
           TC_Check (
              ASF.Insert(Source   => Source_String1(2..5),    -- "bcde"
                         Before   => 3,
                         New_Item => Source_String2));         -- "abcdef"
      begin
         if New_String /= "babcdefcde" then
            Report.Failed("Incorrect result from Function Insert - 1");
         end if;
      end;

      if TC_Check (ASF.Insert("a",   1, "z")) /= "za"   or
         TC_Check (ASF.Insert("abc", 3, ""))  /= "abc"  or
         TC_Check (ASF.Insert("abc", 1, "z")) /= "zabc"
      then
         Report.Failed("Incorrect result from Function Insert - 2");
      end if;

      begin
         if TC_Check (ASF.Insert(Source   => Source_String1(2..5), -- "bcde"
                         Before   => Report.Ident_Int(7),
                         New_Item => Source_String2))         -- "abcdef"
                /= "babcdefcde" then
            Report.Failed("Index_Error not raised by Insert - 3A");
         else
            Report.Failed("Index_Error not raised by Insert - 3B");
         end if;
      exception
         when Ada.Strings.Index_Error => null; -- OK, expected exception.
         when others                  =>
            Report.Failed("Incorrect exception from Insert - 3");
      end;


      -- Procedure Insert

      -- Drop = Right

      ASF.Insert(Source   => Insert_String,
                 Before   => 6,
                 New_Item => Source_String2,       -- "abcdef"
                 Drop     => Ada.Strings.Right);

      if Insert_String /= "     abcde" then  -- last char of New_Item dropped.
         Report.Failed("Incorrect result from Insert with Drop = Right");
      end if;

      -- Drop = Left

      ASF.Insert(Source   => Insert_String,     -- 10 char string
                 Before   => 2,                 -- 9 chars, 2..10 available
                 New_Item => Source_String3,    -- 12 characters long.
                 Drop     => Ada.Strings.Left); -- truncate from Left.

      if Insert_String /= "l    abcde" then     -- 10 chars, leading blank.
          Report.Failed("Incorrect result from Insert with Drop=Left");
      end if;

      -- Drop = Error

      begin
         ASF.Insert(Source   => Result_String,       -- 10 chars
                    Before   => Result_String'Last,
                    New_Item => "abcdefghijk",
                    Drop     => Ada.Strings.Error);
         Report.Failed("Exception not raised by Procedure Insert");
      exception
         when Ada.Strings.Length_Error => null; -- OK, expected exception
         when others                   =>
           Report.Failed("Incorrect exception raised by Procedure Insert");
      end;



      -- Function Overwrite

      TC_Set_Name ("Overwrite");

      Overwrite_String := TC_Check (
          ASF.Overwrite(Result_String,  -- 10 chars
                        1,              -- starting at pos=1
                        Source_String3(1..10)));

      if Overwrite_String /= Source_String3(1..10) then
         Report.Failed("Incorrect result from Function Overwrite - 1");
      end if;


      if TC_Check (ASF.Overwrite("abcdef", 4, "xyz")) /= "abcxyz" or
         TC_Check (ASF.Overwrite("a",      1, "xyz"))
                                           /= "xyz"    or  -- chars appended
         TC_Check (ASF.Overwrite("abc",    3, "   "))
                                           /= "ab   "  or  -- blanks appended
         TC_Check (ASF.Overwrite("abcde",  1, "z"  )) /= "zbcde"
      then
         Report.Failed("Incorrect result from Function Overwrite - 2");
      end if;



      -- Procedure Overwrite, with truncation.

      ASF.Overwrite(Source   => Overwrite_String,    -- 10 characters.
                    Position => 1,
                    New_Item => Source_String3,      -- 12 characters.
                    Drop     => Ada.Strings.Left);

      if Overwrite_String /= "cdefghijkl" then
         Report.Failed("Incorrect result from Overwrite with Drop=Left");
      end if;

      -- The default drop value is Right, used here.

      ASF.Overwrite(Source   => Overwrite_String,    -- 10 characters.
                    Position => 1,
                    New_Item => Source_String3);     -- 12 characters.

      if Overwrite_String /= "abcdefghij" then
         Report.Failed("Incorrect result from Overwrite with Drop=Right");
      end if;

      -- Drop = Error

      begin
         ASF.Overwrite(Source   => Overwrite_String,    -- 10 characters.
                       Position => 1,
                       New_Item => Source_String3,      -- 12 characters.
                       Drop     => Ada.Strings.Error);
         Report.Failed("Exception not raised by Procedure Overwrite");
      exception
         when Ada.Strings.Length_Error => null; -- OK, expected exception.
         when others                   =>
            Report.Failed
              ("Incorrect exception raised by Procedure Overwrite");
      end;

      Overwrite_String := "ababababab";
      ASF.Overwrite(Overwrite_String, Overwrite_String'Last, "z");
      ASF.Overwrite(Overwrite_String, Overwrite_String'First,"z");
      ASF.Overwrite(Overwrite_String, 5, "zz");

      if Overwrite_String /= "zbabzzabaz" then
         Report.Failed("Incorrect result from Procedure Overwrite");
      end if;



      -- Function Delete

      TC_Set_Name ("Delete");

      declare
         New_String1 : constant String :=    -- This returns a 4 char string.
           TC_Check (ASF.Delete(Source  => Source_String3,
                                From    => 3,
                                Through => 10));
         New_String2 : constant String :=    -- This returns Source.
           TC_Check (ASF.Delete(Source_String3, 10, 3));
      begin
           if New_String1 /= "abkl"  or
              New_String2 /= Source_String3
           then
               Report.Failed("Incorrect result from Function Delete - 1");
           end if;
      end;

      if TC_Check (ASF.Delete("a",   1, 1))
                              /= ""    or     -- Source length = 1
         TC_Check (ASF.Delete("abc", 1, 2))
                              /= "c"   or     -- From = Source'First
         TC_Check (ASF.Delete("abc", 3, 3))
                              /= "ab"  or     -- From = Source'Last
         TC_Check (ASF.Delete("abc", 3, 1))
                              /= "abc"        -- From > Through
      then
         Report.Failed("Incorrect result from Function Delete - 2");
      end if;



      -- Procedure Delete

      -- Justify = Left

      Delete_String := Source_String3(1..10);  -- Initialize to "abcdefghij"

      ASF.Delete(Source  => Delete_String,
                 From    => 6,
                 Through => Delete_String'Last,
                 Justify => Ada.Strings.Left,
                 Pad     => 'x');              -- pad with char 'x'

      if Delete_String /= "abcdexxxxx" then
          Report.Failed("Incorrect result from Delete - Justify = Left");
      end if;

      -- Justify = Right

      ASF.Delete(Source  => Delete_String,      -- Remove x"s from end and
                 From    => 6,                  -- shift right.
                 Through => Delete_String'Last,
                 Justify => Ada.Strings.Right,
                 Pad     => 'x');               -- pad with char 'x' on left.

      if Delete_String /= "xxxxxabcde" then
          Report.Failed("Incorrect result from Delete - Justify = Right");
      end if;

      -- Justify = Center

      ASF.Delete(Source  => Delete_String,
                 From    => 1,
                 Through => 5,
                 Justify => Ada.Strings.Center,
                 Pad     => 'z');

      if Delete_String /= "zzabcdezzz" then  -- extra pad char on right side.
          Report.Failed("Incorrect result from Delete - Justify = Center");
      end if;



      -- Function Trim
      -- Use non-identity character sets to perform the trim operation.

      TC_Set_Name ("Trim");

      Trim_String := "cdabcdefcd";

      -- Remove the "cd" from each end of the string.  This will not effect
      -- the "cd" slice at 5..6.

      declare
         New_String : constant String :=
           TC_Check (ASF.Trim(Source => Trim_String,
                              Left => CD_Set, Right => CD_Set));
      begin
         if New_String /= Source_String2 then    -- string "abcdef"
            Report.Failed("Incorrect result from Trim with character sets");
         end if;
      end;

      if TC_Check (ASF.Trim("abcdef", Maps.Null_Set, Maps.Null_Set))
             /= "abcdef" then
         Report.Failed("Incorrect result from Trim with Null sets");
      end if;

      if TC_Check (ASF.Trim("cdxx", CD_Set, X_Set)) /= "" then
         Report.Failed("Incorrect result from Trim, string removal");
      end if;


      -- Procedure Trim

      -- Justify = Right

      ASF.Trim(Source  => Trim_String,
               Left    => CD_Set,
               Right   => CD_Set,
               Justify => Ada.Strings.Right,
               Pad     => 'x');

      if Trim_String /= "xxxxabcdef" then
         Report.Failed("Incorrect result from Trim with Justify = Right");
      end if;

      -- Justify = Left

      ASF.Trim(Source  => Trim_String,
               Left    => X_Set,
               Right   => Maps.Null_Set,
               Justify => Ada.Strings.Left,
               Pad     => Ada.Strings.Space);

      if Trim_String /= "abcdef    " then  -- Padded with 4 blanks on right.
         Report.Failed("Incorrect result from Trim with Justify = Left");
      end if;

      -- Justify = Center

      ASF.Trim(Source  => Trim_String,
               Left    => ABCD_Set,
               Right   => CD_Set,
               Justify => Ada.Strings.Center,
               Pad     => 'x');

      if Trim_String /= "xxef    xx" then  -- Padded with 2 pad chars on L/R
         Report.Failed("Incorrect result from Trim with Justify = Center");
      end if;



      -- Function Head, demonstrating use of padding.

      TC_Set_Name ("Head");

      -- Use the characters of Source_String1 ("abcde") and pad the
      -- last five characters of Result_String with 'x' characters.


      Result_String := TC_CHeck (ASF.Head(Source_String1, 10, 'x'));

      if Result_String /= "abcdexxxxx" then
         Report.Failed("Incorrect result from Function Head with padding");
      end if;

      if TC_Check (ASF.Head("  ab  ", 2))        /= "  "     or
         TC_Check (ASF.Head("a", 6, 'A'))        /= "aAAAAA" or
         TC_Check (ASF.Head("abcdefgh", 3, 'x')) /= "abc"    or
         TC_Check (ASF.Head(ASF.Head("abc  ", 7, 'x'), 10, 'X'))
                   /= "abc  xxXXX"
      then
         Report.Failed("Incorrect result from Function Head");
      end if;



      -- Function Tail, demonstrating use of padding.

      TC_Set_Name ("Tail");

      -- Use the characters of Source_String1 ("abcde") and pad the
      -- first five characters of Result_String with 'x' characters.

      Result_String := TC_Check (ASF.Tail(Source_String1, 10, 'x'));

      if Result_String /= "xxxxxabcde" then
         Report.Failed("Incorrect result from Function Tail with padding");
      end if;

      if TC_Check (ASF.Tail("abcde  ", 5))
                            /= "cde  "    or  -- blanks, back
         TC_Check (ASF.Tail("  abc ",  8, ' '))
                            /= "    abc " or  -- blanks, front/back
         TC_Check (ASF.Tail("",        5, 'Z'))
                            /= "ZZZZZ"    or  -- pad characters only
         TC_Check (ASF.Tail("abc",     0))
                            /= ""         or  -- null result
         TC_Check (ASF.Tail("abcdefgh", 3))
                            /= "fgh"      or
         TC_Check (ASF.Tail(ASF.Tail(" abc ", 6, 'x'),
                  10,
                  'X'))              /= "XXXXx abc "
      then
         Report.Failed("Incorrect result from Function Tail");
      end if;


      -- Function "*"  - with (Natural, String) parameters

      TC_Set_Name ("""*""");

      if TC_Check (ASF."*"(3, Source_String1))       /= "abcdeabcdeabcde"  or
         TC_Check (ASF."*"(2, Source_String2))       /= Source_String6     or
         TC_Check (ASF."*"(4, Source_String1(1..2))) /= "abababab"         or
         TC_Check (ASF."*"(0, Source_String1))       /= ""
      then
         Report.Failed("Incorrect result from Function ""*"" with strings");
      end if;

   exception
      when others => Report.Failed("Exception raised in Test_Block");
   end Test_Block;

   Report.Result;

end CXA4005;