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/] [cxa4001.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
-- CXA4001.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 types, operations, and other entities defined within
28
--      the package Ada.Strings.Maps are available and/or produce correct
29
--      results.
30
--
31
-- TEST DESCRIPTION:
32
--      This test demonstrates the availability and function of the types and
33
--      operations defined in package Ada.Strings.Maps.  It demonstrates the
34
--      use of these types and functions as they would be used in common
35
--      programming practice.
36
--      Character set creation, assignment, and comparison are evaluated
37
--      in this test.  Each of the functions provided in package
38
--      Ada.Strings.Maps is utilized in creating or manipulating set objects,
39
--      and the function results are evaluated for correctness.
40
--      Character sequences are examined using the functions provided for
41
--      manipulating objects of this type.  Likewise, character maps are
42
--      created, and their contents evaluated.  Exception raising conditions
43
--      from the function To_Mapping are also created.
44
--      Note: Throughout this test, the set logical operators are printed in
45
--      capital letters to enhance their visibility.
46
--
47
--
48
-- CHANGE HISTORY:
49
--      06 Dec 94   SAIC    ACVC 2.0
50
--
51
--!
52
 
53
with Ada.Strings.Maps;
54
with Report;
55
 
56
procedure CXA4001 is
57
 
58
   use Ada.Strings;
59
   use type Maps.Character_Set;
60
 
61
begin
62
 
63
   Report.Test ("CXA4001", "Check that the types, operations, and other "   &
64
                           "entities defined within the package "           &
65
                           "Ada.Strings.Maps are available and/or produce " &
66
                           "correct results");
67
 
68
   Test_Block:
69
   declare
70
 
71
      MidPoint_Letter  : constant := 13;
72
      Last_Letter      : constant := 26;
73
 
74
      Vowels           : constant Maps.Character_Sequence := "aeiou";
75
      Quasi_Vowel      : constant Character := 'y';
76
 
77
      Alphabet         :  Maps.Character_Sequence (1..Last_Letter);
78
      Half_Alphabet    :  Maps.Character_Sequence (1..MidPoint_Letter);
79
      Inverse_Alphabet :  Maps.Character_Sequence (1..Last_Letter);
80
 
81
      Alphabet_Set,
82
      Consonant_Set,
83
      Vowel_Set,
84
      Full_Vowel_Set,
85
      First_Half_Set,
86
      Second_Half_Set  : Maps.Character_Set;
87
 
88
   begin
89
 
90
      -- Load the alphabet string for use in creating sets.
91
 
92
 
93
      for i in 0..12 loop
94
         Half_Alphabet(i+1) := Character'Val(Character'Pos('a') + i);
95
      end loop;
96
 
97
      for i in 0..25 loop
98
         Alphabet(i+1) := Character'Val(Character'Pos('a') + i);
99
      end loop;
100
 
101
 
102
      -- Initialize a series of Character_Set objects.
103
 
104
      Alphabet_Set    := Maps.To_Set(Alphabet);
105
      Vowel_Set       := Maps.To_Set(Vowels);
106
      Full_Vowel_Set  := Vowel_Set   OR  Maps.To_Set(Quasi_Vowel);
107
      Consonant_Set   := Vowel_Set  XOR  Alphabet_Set;
108
 
109
      First_Half_Set  := Maps.To_Set(Half_Alphabet);
110
      Second_Half_Set := Alphabet_Set  XOR  First_Half_Set;
111
 
112
 
113
      -- Evaluation of Set objects, operators, and functions.
114
 
115
      if Alphabet_Set /= (Vowel_Set OR Consonant_Set) then
116
         Report.Failed("Incorrect set combinations using OR operator");
117
      end if;
118
 
119
 
120
      for i in 1..5 loop
121
         if not Maps.Is_In(Vowels(i), Vowel_Set)    or
122
            not Maps.Is_In(Vowels(i), Alphabet_Set) or
123
            Maps.Is_In(Vowels(i), Consonant_Set)
124
         then
125
            Report.Failed("Incorrect function Is_In use with set " &
126
                          "combinations - " & Integer'Image(i));
127
         end if;
128
      end loop;
129
 
130
 
131
      if Maps.Is_Subset(Vowel_Set, First_Half_Set)    or
132
         Maps."<="(Vowel_Set, Second_Half_Set)        or
133
         not Maps.Is_Subset(Vowel_Set, Alphabet_Set)
134
      then
135
         Report.Failed("Incorrect set evaluation using Is_Subset function");
136
      end if;
137
 
138
 
139
      if not (Full_Vowel_Set = Maps.To_Set("aeiouy")) then
140
         Report.Failed("Incorrect result for ""="" set operator");
141
      end if;
142
 
143
 
144
      if not ((Vowel_Set AND First_Half_Set) OR
145
              (Full_Vowel_Set AND Second_Half_Set)) = Full_Vowel_Set then
146
         Report.Failed
147
           ("Incorrect result for AND, OR, or ""="" set operators");
148
      end if;
149
 
150
 
151
      if (Alphabet_Set AND Maps.Null_Set) /= Maps.Null_Set  or
152
         (Alphabet_Set OR  Maps.Null_Set) /= Alphabet_Set
153
      then
154
         Report.Failed("Incorrect result for AND or OR set operators");
155
      end if;
156
 
157
 
158
      Vowel_Set := Full_Vowel_Set;
159
      Vowel_Set := Vowel_Set AND (NOT Maps.To_Set(Quasi_Vowel));
160
 
161
      if not (Vowels = Maps.To_Sequence(Vowel_Set)) then
162
         Report.Failed("Incorrect Set to Sequence translation");
163
      end if;
164
 
165
 
166
      for i in 1..26 loop
167
         Inverse_Alphabet(i) := Alphabet(27-i);
168
      end loop;
169
 
170
      declare
171
         Inverse_Map : Maps.Character_Mapping :=
172
                         Maps.To_Mapping(Alphabet, Inverse_Alphabet);
173
      begin
174
         if Maps.Value(Maps.Identity, 'b') /= Maps.Value(Inverse_Map,'y')
175
         then
176
            Report.Failed("Incorrect Inverse mapping");
177
         end if;
178
      end;
179
 
180
 
181
      -- Check that Translation_Error is raised when a character is
182
      -- repeated in the parameter "From" string.
183
      declare
184
         Bad_Map : Maps.Character_Mapping;
185
      begin
186
         Bad_Map := Maps.To_Mapping(From => "aa", To => "yz");
187
         Report.Failed("Exception not raised with repeated character");
188
      exception
189
         when Translation_Error => null;  -- OK
190
         when others            =>
191
            Report.Failed("Incorrect exception raised in To_Mapping with " &
192
                          "a repeated character");
193
      end;
194
 
195
 
196
      -- Check that Translation_Error is raised when the parameters of the
197
      -- function To_Mapping are of unequal lengths.
198
      declare
199
         Bad_Map : Maps.Character_Mapping;
200
      begin
201
         Bad_Map := Maps.To_Mapping("abc", "yz");
202
         Report.Failed("Exception not raised with unequal parameter lengths");
203
      exception
204
         when Translation_Error => null;  -- OK
205
         when others            =>
206
            Report.Failed("Incorrect exception raised in To_Mapping with " &
207
                          "unequal parameter lengths");
208
      end;
209
 
210
 
211
   exception
212
      when others => Report.Failed ("Exception raised in Test_Block");
213
   end Test_Block;
214
 
215
 
216
   Report.Result;
217
 
218
end CXA4001;

powered by: WebSVN 2.1.0

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