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/] [cxf/] [cxf3001.a] - Blame information for rev 294

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 294 jeremybenn
-- CXF3001.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 edited output string value returned by Function Image
28
--      is correct.
29
--
30
-- TEST DESCRIPTION:
31
--      This test is structured using tables of data, consisting of
32
--      numerical values, picture strings, and expected image
33
--      result strings.
34
--
35
--      Each picture string is checked for validity, and an invalid picture
36
--      string will cause immediate test failure on its first pass through
37
--      the evaluation loop.  Inside the evaluation loop, each decimal data
38
--      item is combined with each of the picture strings as parameters to a
39
--      call to Image, and the result of each call is compared to an
40
--      expected edited output result string.
41
--
42
--
43
-- CHANGE HISTORY:
44
--      24 Feb 95   SAIC    Initial prerelease version.
45
--      23 Jun 95   SAIC    Corrected call to functions Valid and To_Picture.
46
--      22 Aug 95   SAIC    Test name changed to CXF3001 (from CXF3301) to
47
--                          conform to naming conventions.
48
--      24 Feb 97   CTA.PWB Corrected picture strings and expected results.
49
--!
50
 
51
with Ada.Text_IO.Editing;
52
with Report;
53
 
54
procedure CXF3001 is
55
begin
56
 
57
   Report.Test ("CXF3001", "Check that the string value returned by " &
58
                           "Function Image is correct");
59
 
60
   Test_Block:
61
   declare
62
 
63
      use Ada.Text_IO;
64
 
65
      Number_Of_Decimal_Items    : constant := 5;
66
      Number_Of_Picture_Strings  : constant := 4;
67
      Number_Of_Expected_Results : constant := Number_Of_Decimal_Items *
68
                                               Number_Of_Picture_Strings;
69
 
70
      type String_Pointer_Type is access String;
71
 
72
      -- Define a decimal data type, and instantiate the Decimal_Output
73
      -- generic package for the data type.
74
 
75
      type Decimal_Data_Type is delta 0.01 digits 16;
76
      package Ed_Out is new Editing.Decimal_Output (Decimal_Data_Type);
77
 
78
      -- Define types for the arrays of data that will hold the decimal data
79
      -- values, picture strings, and expected edited output results.
80
 
81
      type Decimal_Data_Array_Type is
82
        array (Integer range <>) of Decimal_Data_Type;
83
 
84
      type Picture_String_Array_Type is
85
        array (Integer range <>) of String_Pointer_Type;
86
 
87
      type Edited_Output_Results_Array_Type is
88
        array (Integer range <>) of String_Pointer_Type;
89
 
90
      -- Define the data arrays for this test.
91
 
92
      Decimal_Data :
93
        Decimal_Data_Array_Type(1..Number_Of_Decimal_Items) :=
94
          ( 1 =>  5678.90,
95
            2 => -6789.01,
96
            3 =>     0.00,
97
            4 =>     0.20,
98
            5 =>     3.45
99
          );
100
 
101
      Picture_Strings :
102
        Picture_String_Array_Type(1..Number_Of_Picture_Strings) :=
103
          ( 1 => new String'("-$$_$$9.99"),
104
            2 => new String'("-$$_$$$.$$"),
105
            3 => new String'("-ZZZZ.ZZ"),
106
            4 => new String'("-$$$_999.99")
107
          );
108
 
109
      Edited_Output :
110
        Edited_Output_Results_Array_Type(1..Number_Of_Expected_Results) :=
111
          ( 1 => new String'(" $5,678.90"),
112
            2 => new String'(" $5,678.90"),
113
            3 => new String'(" 5678.90"),
114
            4 => new String'("  $5,678.90"),
115
 
116
            5 => new String'("-$6,789.01"),
117
            6 => new String'("-$6,789.01"),
118
            7 => new String'("-6789.01"),
119
            8 => new String'("- $6,789.01"),
120
 
121
            9 => new String'("     $0.00"),
122
           10 => new String'("          "),
123
           11 => new String'("        "),
124
           12 => new String'("   $ 000.00"),
125
 
126
           13 => new String'("     $0.20"),
127
           14 => new String'("      $.20"),
128
           15 => new String'("     .20"),
129
           16 => new String'("   $ 000.20"),
130
 
131
           17 => new String'("     $3.45"),
132
           18 => new String'("     $3.45"),
133
           19 => new String'("    3.45"),
134
           20 => new String'("   $ 003.45")
135
          );
136
 
137
      TC_Picture    : Editing.Picture;
138
      TC_Loop_Count : Natural := 0;
139
 
140
   begin
141
 
142
      -- Compare string result of Image with expected edited output string.
143
 
144
      Evaluate_Edited_Output:
145
      for i in 1..Number_Of_Decimal_Items loop
146
         for j in 1..Number_Of_Picture_Strings loop
147
 
148
            TC_Loop_Count := TC_Loop_Count + 1;
149
 
150
            -- Check on the validity of the picture strings prior to
151
            -- processing.
152
 
153
            if Editing.Valid(Picture_Strings(j).all) then
154
 
155
               -- Create the picture object from the picture string.
156
               TC_Picture := Editing.To_Picture(Picture_Strings(j).all);
157
 
158
               -- Compare actual edited output result of Function Image with
159
               -- the expected result.
160
 
161
               if Ed_Out.Image(Decimal_Data(i), TC_Picture) /=
162
                  Edited_Output(TC_Loop_Count).all
163
               then
164
                  Report.Failed("Incorrect result from Function Image, " &
165
                                "when used with decimal data item # "    &
166
                                Integer'Image(i)                         &
167
                                " and picture string # "                  &
168
                                Integer'Image(j));
169
               end if;
170
 
171
            else
172
               Report.Failed("Picture String # " & Integer'Image(j) &
173
                             "reported as being invalid");
174
               -- Immediate test failure if a string is invalid.
175
               exit Evaluate_Edited_Output;
176
            end if;
177
 
178
         end loop;
179
      end loop Evaluate_Edited_Output;
180
 
181
   exception
182
      when Editing.Picture_Error =>
183
         Report.Failed ("Picture_Error raised in Test_Block");
184
      when Layout_Error          =>
185
         Report.Failed ("Layout_Error raised in Test_Block");
186
      when others                =>
187
         Report.Failed ("Exception raised in Test_Block");
188
   end Test_Block;
189
 
190
   Report.Result;
191
 
192
end CXF3001;

powered by: WebSVN 2.1.0

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