summaryrefslogtreecommitdiff
path: root/gcc/testsuite/ada/acats/tests/cd/cd40001.a
blob: 273271fdb8e6d36b3dd77baf255ba4016f4655db (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
-- CD40001.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 Enumeration_Representation_Clauses are supported for
--      codes in the range System.Min_Int..System.Max_Int.
--
-- TEST DESCRIPTION:
--      This test defines several types, and checks that the range of the 
--      enumeration clause is as expected.
--
-- APPLICABILITY CRITERIA:
--      All implementations must attempt to compile this test.
--
--      For implementations validating against Systems Programming Annex (C):
--        this test must execute and report PASSED.
--
--      For implementations not validating against Annex C:
--        this test may report compile time errors at one or more points
--        indicated by "-- ANX-C RQMT", in which case it may be graded as inapplicable.
--        Otherwise, the test must execute and report PASSED.
--
--
-- CHANGE HISTORY:
--      22 JUL 95   SAIC   Initial version
--      07 MAY 96   SAIC   Revised for 2.1
--      16 FEB 98   EDS    Modified Documentation.
--!

with System;
with Ada.Unchecked_Conversion;
package CD40001_0 is

  type Press_The_Bounds is ( Negative_Large, Positive_Large );

  for Press_The_Bounds use
      ( Negative_Large => System.Min_Int,                     -- ANX-C RQMT.
        Positive_Large => System.Max_Int );                   -- ANX-C RQMT.

  type Add_The_Bounds is 
    ( Monday, Tuesday, Wednesday, Thursday, Friday, Saturday);

  for Add_The_Bounds use
      ( Monday    => System.Min_Int,                          -- ANX-C RQMT.
        Tuesday   => System.Min_Int + 1,                      -- ANX-C RQMT.
        Wednesday => System.Min_Int + 2,                      -- ANX-C RQMT.
        Thursday  => System.Min_Int + 3,                      -- ANX-C RQMT.
        Friday    => System.Min_Int + 4,                      -- ANX-C RQMT.
        Saturday  => System.Min_Int + 5 );                    -- ANX-C RQMT.

  type Minus_The_Bounds is ( Jan, Feb, Mar, Apr);

  for Minus_The_Bounds use
      ( Apr => System.Max_Int,                                -- ANX-C RQMT.
        Mar => System.Max_Int - 1,                            -- ANX-C RQMT.
        Feb => System.Max_Int - 2,                            -- ANX-C RQMT.
        Jan => System.Max_Int - 3 );                          -- ANX-C RQMT.

  type TC_Integer is range System.Min_Int..System.Max_Int;

  procedure TC_Check_Press; 

  procedure TC_Check_Add; 

  procedure TC_Check_Minus; 

  function TC_Compare_Press is new Ada.Unchecked_Conversion 
    (Press_The_Bounds, TC_Integer);

  function TC_Compare_Add is new Ada.Unchecked_Conversion 
    (Add_The_Bounds, TC_Integer);

  function TC_Compare_Minus is new Ada.Unchecked_Conversion 
    (Minus_The_Bounds, TC_Integer);

end CD40001_0;

     --==================================================================--

with Report;
package body CD40001_0 is

  procedure TC_Check_Press is
    My_Press_First : Press_The_Bounds := Negative_Large;
    My_Press_Last  : Press_The_Bounds := Positive_Large;
  begin
    if TC_Compare_Press (My_Press_First) /= System.Min_Int or
       TC_Compare_Press (My_Press_Last)  /= System.Max_Int 
    then
      Report.Failed 
        ("Expected enumeration size of System.Min_Int and System.Max_Int " &
         "not available for this implementation");
    end if;
  end TC_Check_Press;

  ---------------------------------------------------------------------------
  procedure TC_Check_Add is
    My_Monday    : Add_The_Bounds := Monday;
    My_Tuesday   : Add_The_Bounds := Tuesday; 
    My_Wednesday : Add_The_Bounds := Wednesday; 
    My_Thursday  : Add_The_Bounds := Thursday;
    My_Friday    : Add_The_Bounds := Friday;
    My_Saturday  : Add_The_Bounds := Saturday; 
  begin
    if TC_Compare_Add (My_Monday)    /= (System.Min_Int)     or
       TC_Compare_Add (My_Thursday)  /= (System.Min_Int + 3) or
       TC_Compare_Add (My_Wednesday) /= (System.Min_Int + 2) or
       TC_Compare_Add (My_Tuesday)   /= (System.Min_Int + 1) or
       TC_Compare_Add (My_Saturday)  /= (System.Min_Int + 5) or
       TC_Compare_Add (My_Friday)    /= (System.Min_Int + 4)   
    then
      Report.Failed
        ("Expected enumeration size of System.Min_Int, System.Min_Int + 1 " &
         "through System.Min_Int + 5 not available for this implementation");
    end if;
  end TC_Check_Add;

  ---------------------------------------------------------------------------
  procedure TC_Check_Minus is
    My_Jan : Minus_The_Bounds := Jan;
    My_Feb : Minus_The_Bounds := Feb; 
    My_Mar : Minus_The_Bounds := Mar; 
    My_Apr : Minus_The_Bounds := Apr;
  begin
    if TC_Compare_Minus (My_Jan) /= (System.Max_Int - 3) or
       TC_Compare_Minus (My_Feb) /= (System.Max_Int - 2) or
       TC_Compare_Minus (My_Mar) /= (System.Max_Int - 1) or
       TC_Compare_Minus (My_Apr) /= (System.Max_Int)
    then
      Report.Failed
        ("Expected enumeration size of System.Max_Int, System.Max_Int - 1 " &
         "through System.Max_Int - 3 not available for this implementation");
    end if;
  end TC_Check_Minus;

end CD40001_0;

     --==================================================================--

with Report;
with CD40001_0;

procedure CD40001 is

begin  -- Main test procedure.

  Report.Test ("CD40001", "Check that Enumeration_Representation_Clauses " &
                          "are supported for codes in the range " &
                          "System.Min_Int..System.Max_Int" );
   
  CD40001_0.TC_Check_Press;

  CD40001_0.TC_Check_Add;

  CD40001_0.TC_Check_Minus;

  Report.Result;

end CD40001;