OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [ada/] [acats/] [tests/] [cxg/] [cxg1003.a] - Diff between revs 294 and 338

Only display areas with differences | Details | Blame | View Log

Rev 294 Rev 338
-- CXG1003.A
-- CXG1003.A
--
--
--                             Grant of Unlimited Rights
--                             Grant of Unlimited Rights
--
--
--     Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
--     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
--     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 in the software and documentation contained herein.
--     Unlimited rights are defined in DFAR 252.227-7013(a)(19).  By making
--     Unlimited rights are defined in DFAR 252.227-7013(a)(19).  By making
--     this public release, the Government intends to confer upon all
--     this public release, the Government intends to confer upon all
--     recipients unlimited rights  equal to those held by the Government.
--     recipients unlimited rights  equal to those held by the Government.
--     These rights include rights to use, duplicate, release or disclose the
--     These rights include rights to use, duplicate, release or disclose the
--     released technical data and computer software in whole or in part, in
--     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
--     any manner and for any purpose whatsoever, and to have or permit others
--     to do so.
--     to do so.
--
--
--                                    DISCLAIMER
--                                    DISCLAIMER
--
--
--     ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
--     ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
--     DISCLOSED ARE AS IS.  THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
--     DISCLOSED ARE AS IS.  THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
--     WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
--     WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
--     SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
--     SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
--     OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
--     OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
--     PARTICULAR PURPOSE OF SAID MATERIAL.
--     PARTICULAR PURPOSE OF SAID MATERIAL.
--*
--*
--
--
-- OBJECTIVE:
-- OBJECTIVE:
--      Check that the subprograms defined in the package Text_IO.Complex_IO
--      Check that the subprograms defined in the package Text_IO.Complex_IO
--      provide correct results.
--      provide correct results.
--
--
-- TEST DESCRIPTION:
-- TEST DESCRIPTION:
--      The generic package Ada.Numerics.Generic_Complex_Types is instantiated
--      The generic package Ada.Numerics.Generic_Complex_Types is instantiated
--      with a real type (new Float). The resulting new package is used as
--      with a real type (new Float). The resulting new package is used as
--      the generic actual to package Complex_IO.
--      the generic actual to package Complex_IO.
--      Two different versions of Put and Get are examined in this test,
--      Two different versions of Put and Get are examined in this test,
--      those that input/output complex data values from/to Text_IO files,
--      those that input/output complex data values from/to Text_IO files,
--      and those that input/output complex data values from/to strings.
--      and those that input/output complex data values from/to strings.
--      Two procedures are defined to perform the file data manipulations;
--      Two procedures are defined to perform the file data manipulations;
--      one to place complex data into the file, and one to retrieve the data
--      one to place complex data into the file, and one to retrieve the data
--      from the file and verify its correctness.
--      from the file and verify its correctness.
--      Complex data is also put into string variables using the Procedure
--      Complex data is also put into string variables using the Procedure
--      Put for strings, and this data is then retrieved and reconverted into
--      Put for strings, and this data is then retrieved and reconverted into
--      complex values using the Get procedure.
--      complex values using the Get procedure.
--
--
--
--
-- APPLICABILITY CRITERIA:
-- APPLICABILITY CRITERIA:
--      This test is only applicable to implementations that:
--      This test is only applicable to implementations that:
--         support Annex G,
--         support Annex G,
--         support Text_IO and external files
--         support Text_IO and external files
--
--
--
--
-- CHANGE HISTORY:
-- CHANGE HISTORY:
--      06 Dec 94   SAIC    ACVC 2.0
--      06 Dec 94   SAIC    ACVC 2.0
--      29 Dec 94   SAIC    Modified Width parameter in Get function calls.
--      29 Dec 94   SAIC    Modified Width parameter in Get function calls.
--      16 Nov 95   SAIC    Corrected visibility problems for ACVC 2.0.1.
--      16 Nov 95   SAIC    Corrected visibility problems for ACVC 2.0.1.
--      29 Sep 96   SAIC    Incorporated reviewer comments.
--      29 Sep 96   SAIC    Incorporated reviewer comments.
--
--
--!
--!
with Ada.Text_IO.Complex_IO;
with Ada.Text_IO.Complex_IO;
with Ada.Numerics.Generic_Complex_Types;
with Ada.Numerics.Generic_Complex_Types;
with Report;
with Report;
procedure CXG1003 is
procedure CXG1003 is
begin
begin
   Report.Test ("CXG1003", "Check that the subprograms defined in " &
   Report.Test ("CXG1003", "Check that the subprograms defined in " &
                           "the package Text_IO.Complex_IO " &
                           "the package Text_IO.Complex_IO " &
                           "provide correct results");
                           "provide correct results");
   Test_for_Text_IO_Support:
   Test_for_Text_IO_Support:
   declare
   declare
      use Ada;
      use Ada;
      Data_File     : Ada.Text_IO.File_Type;
      Data_File     : Ada.Text_IO.File_Type;
      Data_Filename : constant String := Report.Legal_File_Name;
      Data_Filename : constant String := Report.Legal_File_Name;
   begin
   begin
      -- An application creates a text file in mode Out_File, with the
      -- An application creates a text file in mode Out_File, with the
      -- intention of entering complex data into the file as appropriate.
      -- intention of entering complex data into the file as appropriate.
      -- In the event that the particular environment where the application
      -- In the event that the particular environment where the application
      -- is running does not support Text_IO, Use_Error or Name_Error will be
      -- is running does not support Text_IO, Use_Error or Name_Error will be
      -- raised on calls to Text_IO operations.  Either of these exceptions
      -- raised on calls to Text_IO operations.  Either of these exceptions
      -- will be handled to produce a Not_Applicable result.
      -- will be handled to produce a Not_Applicable result.
      Text_IO.Create (File => Data_File,
      Text_IO.Create (File => Data_File,
                      Mode => Ada.Text_IO.Out_File,
                      Mode => Ada.Text_IO.Out_File,
                      Name => Data_Filename);
                      Name => Data_Filename);
      Test_Block:
      Test_Block:
      declare
      declare
         TC_Verbose : Boolean := False;
         TC_Verbose : Boolean := False;
         type Real_Type is new Float;
         type Real_Type is new Float;
         package Complex_Pack is new
         package Complex_Pack is new
           Ada.Numerics.Generic_Complex_Types(Real_Type);
           Ada.Numerics.Generic_Complex_Types(Real_Type);
         package C_IO is new Ada.Text_IO.Complex_IO(Complex_Pack);
         package C_IO is new Ada.Text_IO.Complex_IO(Complex_Pack);
         use Ada.Text_IO, C_IO;
         use Ada.Text_IO, C_IO;
         use type Complex_Pack.Complex;
         use type Complex_Pack.Complex;
         Number_Of_Complex_Items : constant := 6;
         Number_Of_Complex_Items : constant := 6;
         Number_Of_Error_Items   : constant := 2;
         Number_Of_Error_Items   : constant := 2;
         TC_Complex              : Complex_Pack.Complex;
         TC_Complex              : Complex_Pack.Complex;
         TC_Last_Character_Read  : Positive;
         TC_Last_Character_Read  : Positive;
         Complex_Array : array (1..Number_Of_Complex_Items)
         Complex_Array : array (1..Number_Of_Complex_Items)
           of Complex_Pack.Complex := ( (3.0, 9.0),
           of Complex_Pack.Complex := ( (3.0, 9.0),
                                        (4.0, 7.0),
                                        (4.0, 7.0),
                                        (5.0, 6.0),
                                        (5.0, 6.0),
                                        (6.0, 3.0),
                                        (6.0, 3.0),
                                        (2.0, 5.0),
                                        (2.0, 5.0),
                                        (3.0, 7.0) );
                                        (3.0, 7.0) );
         procedure Load_Data_File (The_File : in out Text_IO.File_Type) is
         procedure Load_Data_File (The_File : in out Text_IO.File_Type) is
            use Ada.Text_IO;
            use Ada.Text_IO;
         begin
         begin
            -- This procedure does not create, open, or close the data file;
            -- This procedure does not create, open, or close the data file;
            -- The_File file object must be Open at this point.
            -- The_File file object must be Open at this point.
            -- This procedure is designed to load complex data into a data
            -- This procedure is designed to load complex data into a data
            -- file twice, first using Text_IO, then Complex_IO.  In this
            -- file twice, first using Text_IO, then Complex_IO.  In this
            -- first case, the complex data values are entered as strings,
            -- first case, the complex data values are entered as strings,
            -- assuming a variety of legal formats, as provided in the
            -- assuming a variety of legal formats, as provided in the
            -- reference manual.
            -- reference manual.
            Put_Line(The_File, "(3.0, 9.0)");
            Put_Line(The_File, "(3.0, 9.0)");
            Put_Line(The_File, "+4. +7.");    -- Relaxed real literal format.
            Put_Line(The_File, "+4. +7.");    -- Relaxed real literal format.
            Put_Line(The_File, "(5.0 6.)");
            Put_Line(The_File, "(5.0 6.)");
            Put_Line(The_File, "6., 3.0");
            Put_Line(The_File, "6., 3.0");
            Put_Line(The_File, "  (  2.0  ,  5.0  )  ");
            Put_Line(The_File, "  (  2.0  ,  5.0  )  ");
            Put_Line(The_File, "(");           -- Complex data separated over
            Put_Line(The_File, "(");           -- Complex data separated over
            Put_Line(The_File, "3.0");         -- several (5) lines.
            Put_Line(The_File, "3.0");         -- several (5) lines.
            Put_Line(The_File, " , ");
            Put_Line(The_File, " , ");
            Put_Line(The_File, "7.0  ");
            Put_Line(The_File, "7.0  ");
            Put_Line(The_File, ")");
            Put_Line(The_File, ")");
            if TC_Verbose then
            if TC_Verbose then
               Report.Comment("Complex values entered into data file using " &
               Report.Comment("Complex values entered into data file using " &
                              "Text_IO, Procedure Load_Data_File");
                              "Text_IO, Procedure Load_Data_File");
            end if;
            end if;
            -- Use the Complex_IO procedure Put to enter Complex data items
            -- Use the Complex_IO procedure Put to enter Complex data items
            -- into the data file.
            -- into the data file.
            -- Note: Data is being entered into the file for the *second* time
            -- Note: Data is being entered into the file for the *second* time
            --       at this point. (Using Complex_IO here, Text_IO above)
            --       at this point. (Using Complex_IO here, Text_IO above)
            for i in 1..Number_Of_Complex_Items loop
            for i in 1..Number_Of_Complex_Items loop
               C_IO.Put(File => The_File,
               C_IO.Put(File => The_File,
                        Item => Complex_Array(i),
                        Item => Complex_Array(i),
                        Fore => 1,
                        Fore => 1,
                        Aft  => 1,
                        Aft  => 1,
                        Exp  => 0);
                        Exp  => 0);
            end loop;
            end loop;
            if TC_Verbose then
            if TC_Verbose then
               Report.Comment("Complex values entered into data file using " &
               Report.Comment("Complex values entered into data file using " &
                              "Complex_IO, Procedure Load_Data_File");
                              "Complex_IO, Procedure Load_Data_File");
            end if;
            end if;
            Put_Line(The_File, "(5A,3)");      -- data to raise Data_Error.
            Put_Line(The_File, "(5A,3)");      -- data to raise Data_Error.
            Put_Line(The_File, "(3.0,,8.0)");  -- data to raise Data_Error.
            Put_Line(The_File, "(3.0,,8.0)");  -- data to raise Data_Error.
         end Load_Data_File;
         end Load_Data_File;
         procedure Process_Data_File (The_File : in out Text_IO.File_Type) is
         procedure Process_Data_File (The_File : in out Text_IO.File_Type) is
             TC_Complex : Complex_Pack.Complex := (0.0, 0.0);
             TC_Complex : Complex_Pack.Complex := (0.0, 0.0);
             TC_Width   : Integer := 0;
             TC_Width   : Integer := 0;
         begin
         begin
            -- This procedure does not create, open, or close the data file;
            -- This procedure does not create, open, or close the data file;
            -- The_File file object must be Open at this point.
            -- The_File file object must be Open at this point.
            -- Use procedure Get (for Files) to extract the complex data from
            -- Use procedure Get (for Files) to extract the complex data from
            -- the Text_IO file.  This data was placed into the file using
            -- the Text_IO file.  This data was placed into the file using
            -- Text_IO.
            -- Text_IO.
            for i in 1..Number_Of_Complex_Items loop
            for i in 1..Number_Of_Complex_Items loop
               C_IO.Get(The_File, TC_Complex, TC_Width);
               C_IO.Get(The_File, TC_Complex, TC_Width);
               if TC_Complex /= Complex_Array(i) then
               if TC_Complex /= Complex_Array(i) then
                  Report.Failed("Incorrect complex data read from file " &
                  Report.Failed("Incorrect complex data read from file " &
                                "when using Text_IO procedure Get, "     &
                                "when using Text_IO procedure Get, "     &
                                "data item #" & Integer'Image(i));
                                "data item #" & Integer'Image(i));
               end if;
               end if;
            end loop;
            end loop;
            if TC_Verbose then
            if TC_Verbose then
               Report.Comment("First set of complex values extracted " &
               Report.Comment("First set of complex values extracted " &
                              "from data file using Complex_IO, "      &
                              "from data file using Complex_IO, "      &
                              "Procedure Process_Data_File");
                              "Procedure Process_Data_File");
            end if;
            end if;
            -- Use procedure Get (for Files) to extract the complex data from
            -- Use procedure Get (for Files) to extract the complex data from
            -- the Text_IO file.  This data was placed into the file using
            -- the Text_IO file.  This data was placed into the file using
            -- procedure Complex_IO.Put.
            -- procedure Complex_IO.Put.
            -- Note: Data is being extracted from the file for the *second*
            -- Note: Data is being extracted from the file for the *second*
            --       time at this point (Using Complex_IO here, Text_IO above)
            --       time at this point (Using Complex_IO here, Text_IO above)
            for i in 1..Number_Of_Complex_Items loop
            for i in 1..Number_Of_Complex_Items loop
               C_IO.Get(The_File, TC_Complex, TC_Width);
               C_IO.Get(The_File, TC_Complex, TC_Width);
               if TC_Complex /= Complex_Array(i) then
               if TC_Complex /= Complex_Array(i) then
                  Report.Failed("Incorrect complex data read from file " &
                  Report.Failed("Incorrect complex data read from file " &
                                "when using Complex_IO procedure Get, "  &
                                "when using Complex_IO procedure Get, "  &
                                "data item #" & Integer'Image(i));
                                "data item #" & Integer'Image(i));
               end if;
               end if;
            end loop;
            end loop;
            if TC_Verbose then
            if TC_Verbose then
               Report.Comment("Second set of complex values extracted " &
               Report.Comment("Second set of complex values extracted " &
                              "from data file using Complex_IO, "       &
                              "from data file using Complex_IO, "       &
                              "Procedure Process_Data_File");
                              "Procedure Process_Data_File");
            end if;
            end if;
            -- The final items in the Data_File are complex values with
            -- The final items in the Data_File are complex values with
            -- incorrect syntax, which should raise Data_Error on an attempt
            -- incorrect syntax, which should raise Data_Error on an attempt
            -- to read them from the file.
            -- to read them from the file.
            TC_Width := 10;
            TC_Width := 10;
            for i in 1..Number_Of_Error_Items loop
            for i in 1..Number_Of_Error_Items loop
               begin
               begin
                  C_IO.Get(The_File, TC_Complex, TC_Width);
                  C_IO.Get(The_File, TC_Complex, TC_Width);
                  Report.Failed
                  Report.Failed
                    ("Exception Data_Error not raised when Complex_IO.Get " &
                    ("Exception Data_Error not raised when Complex_IO.Get " &
                     "was used to read complex data with incorrect "        &
                     "was used to read complex data with incorrect "        &
                     "syntax from the Data_File, data item #"               &
                     "syntax from the Data_File, data item #"               &
                     Integer'Image(i));
                     Integer'Image(i));
               exception
               exception
                  when Ada.Text_IO.Data_Error => -- OK, expected exception.
                  when Ada.Text_IO.Data_Error => -- OK, expected exception.
                     Text_IO.Skip_Line(The_File);
                     Text_IO.Skip_Line(The_File);
                  when others =>
                  when others =>
                     Report.Failed
                     Report.Failed
                       ("Unexpected exception raised when Complex_IO.Get " &
                       ("Unexpected exception raised when Complex_IO.Get " &
                        "was used to read complex data with incorrect "    &
                        "was used to read complex data with incorrect "    &
                        "syntax from the Data_File, data item #"           &
                        "syntax from the Data_File, data item #"           &
                         Integer'Image(i));
                         Integer'Image(i));
               end;
               end;
            end loop;
            end loop;
            if TC_Verbose then
            if TC_Verbose then
               Report.Comment("Erroneous set of complex values extracted " &
               Report.Comment("Erroneous set of complex values extracted " &
                              "from data file using Complex_IO, "          &
                              "from data file using Complex_IO, "          &
                              "Procedure Process_Data_File");
                              "Procedure Process_Data_File");
            end if;
            end if;
         exception
         exception
            when others =>
            when others =>
              Report.Failed
              Report.Failed
                ("Unexpected exception raised in Process_Data_File");
                ("Unexpected exception raised in Process_Data_File");
         end Process_Data_File;
         end Process_Data_File;
      begin  -- Test_Block.
      begin  -- Test_Block.
         -- Place complex values into data file.
         -- Place complex values into data file.
         Load_Data_File(Data_File);
         Load_Data_File(Data_File);
         Text_IO.Close(Data_File);
         Text_IO.Close(Data_File);
         if TC_Verbose then
         if TC_Verbose then
            Report.Comment("Data file loaded with Complex values");
            Report.Comment("Data file loaded with Complex values");
         end if;
         end if;
         -- Read complex values from data file.
         -- Read complex values from data file.
         Text_IO.Open(Data_File, Text_IO.In_File, Data_Filename);
         Text_IO.Open(Data_File, Text_IO.In_File, Data_Filename);
         Process_Data_File(Data_File);
         Process_Data_File(Data_File);
         if TC_Verbose then
         if TC_Verbose then
            Report.Comment("Complex values extracted from data file");
            Report.Comment("Complex values extracted from data file");
         end if;
         end if;
         -- Verify versions of Procedures Put and Get for Strings.
         -- Verify versions of Procedures Put and Get for Strings.
         declare
         declare
            TC_String_Array : array (1..Number_Of_Complex_Items)
            TC_String_Array : array (1..Number_Of_Complex_Items)
                              of String(1..15) := (others =>(others => ' '));
                              of String(1..15) := (others =>(others => ' '));
         begin
         begin
            -- Place complex values into strings using the Procedure Put.
            -- Place complex values into strings using the Procedure Put.
            for i in 1..Number_Of_Complex_Items loop
            for i in 1..Number_Of_Complex_Items loop
               C_IO.Put(To   => TC_String_Array(i),
               C_IO.Put(To   => TC_String_Array(i),
                        Item => Complex_Array(i),
                        Item => Complex_Array(i),
                        Aft  => 1,
                        Aft  => 1,
                        Exp  => 0);
                        Exp  => 0);
            end loop;
            end loop;
            if TC_Verbose then
            if TC_Verbose then
               Report.Comment("Complex values placed into string array");
               Report.Comment("Complex values placed into string array");
            end if;
            end if;
            -- Check the format of the strings containing a complex number.
            -- Check the format of the strings containing a complex number.
            -- The resulting strings are of 15 character length, with the
            -- The resulting strings are of 15 character length, with the
            -- real component left justified within the string, followed by
            -- real component left justified within the string, followed by
            -- a comma, and with the imaginary component and closing
            -- a comma, and with the imaginary component and closing
            -- parenthesis right justified in the string, with blank fill
            -- parenthesis right justified in the string, with blank fill
            -- for the balance of the string.
            -- for the balance of the string.
            if TC_String_Array(1) /= "(3.0,      9.0)" or
            if TC_String_Array(1) /= "(3.0,      9.0)" or
               TC_String_Array(2) /= "(4.0,      7.0)" or
               TC_String_Array(2) /= "(4.0,      7.0)" or
               TC_String_Array(3) /= "(5.0,      6.0)" or
               TC_String_Array(3) /= "(5.0,      6.0)" or
               TC_String_Array(4) /= "(6.0,      3.0)" or
               TC_String_Array(4) /= "(6.0,      3.0)" or
               TC_String_Array(5) /= "(2.0,      5.0)" or
               TC_String_Array(5) /= "(2.0,      5.0)" or
               TC_String_Array(6) /= "(3.0,      7.0)"
               TC_String_Array(6) /= "(3.0,      7.0)"
            then
            then
               Report.Failed("Incorrect format for complex values that " &
               Report.Failed("Incorrect format for complex values that " &
                             "have been placed into string variables "   &
                             "have been placed into string variables "   &
                             "using the Complex_IO.Put procedure for "   &
                             "using the Complex_IO.Put procedure for "   &
                             "strings");
                             "strings");
            end if;
            end if;
            if TC_Verbose then
            if TC_Verbose then
               Report.Comment("String format of Complex values verified");
               Report.Comment("String format of Complex values verified");
            end if;
            end if;
            -- Get complex values from strings using the Procedure Get.
            -- Get complex values from strings using the Procedure Get.
            -- Compare with expected complex values.
            -- Compare with expected complex values.
            for i in 1..Number_Of_Complex_Items loop
            for i in 1..Number_Of_Complex_Items loop
               C_IO.Get(From => TC_String_Array(i),
               C_IO.Get(From => TC_String_Array(i),
                        Item => TC_Complex,
                        Item => TC_Complex,
                        Last => TC_Last_Character_Read);
                        Last => TC_Last_Character_Read);
               if TC_Complex /= Complex_Array(i) then
               if TC_Complex /= Complex_Array(i) then
                  Report.Failed("Incorrect complex data value obtained "   &
                  Report.Failed("Incorrect complex data value obtained "   &
                                "from String following use of Procedures " &
                                "from String following use of Procedures " &
                                "Put and Get from Strings, Complex_Array " &
                                "Put and Get from Strings, Complex_Array " &
                                "item #" & Integer'Image(i));
                                "item #" & Integer'Image(i));
               end if;
               end if;
            end loop;
            end loop;
            if TC_Verbose then
            if TC_Verbose then
               Report.Comment("Complex values removed from String array");
               Report.Comment("Complex values removed from String array");
            end if;
            end if;
            -- Verify that Layout_Error is raised if the given string is
            -- Verify that Layout_Error is raised if the given string is
            -- too short to hold the formatted output.
            -- too short to hold the formatted output.
            Layout_Error_On_Put:
            Layout_Error_On_Put:
            declare
            declare
               Much_Too_Short : String(1..2);
               Much_Too_Short : String(1..2);
               Complex_Value  : Complex_Pack.Complex := (5.0, 0.0);
               Complex_Value  : Complex_Pack.Complex := (5.0, 0.0);
            begin
            begin
               C_IO.Put(Much_Too_Short, Complex_Value);
               C_IO.Put(Much_Too_Short, Complex_Value);
               Report.Failed("Layout_Error not raised by Procedure Put " &
               Report.Failed("Layout_Error not raised by Procedure Put " &
                             "when the given string was too short to "   &
                             "when the given string was too short to "   &
                             "hold the formatted output");
                             "hold the formatted output");
            exception
            exception
               when Layout_Error => null;  -- OK, expected exception.
               when Layout_Error => null;  -- OK, expected exception.
               when others =>
               when others =>
                  Report.Failed
                  Report.Failed
                    ("Unexpected exception raised by Procedure Put when " &
                    ("Unexpected exception raised by Procedure Put when " &
                     "the given string was too short to hold the "        &
                     "the given string was too short to hold the "        &
                     "formatted output");
                     "formatted output");
            end Layout_Error_On_Put;
            end Layout_Error_On_Put;
            if TC_Verbose then
            if TC_Verbose then
               Report.Comment("Layout Errors verified");
               Report.Comment("Layout Errors verified");
            end if;
            end if;
         exception
         exception
            when others =>
            when others =>
               Report.Failed("Unexpected exception raised during the " &
               Report.Failed("Unexpected exception raised during the " &
                             "evaluation of Put and Get for Strings");
                             "evaluation of Put and Get for Strings");
         end;
         end;
         -- Place complex values into strings using a variety of legal
         -- Place complex values into strings using a variety of legal
         -- complex data formats.
         -- complex data formats.
         declare
         declare
            type String_Ptr is access String;
            type String_Ptr is access String;
            TC_Complex_String_Array :
            TC_Complex_String_Array :
              array (1..Number_Of_Complex_Items) of String_Ptr :=
              array (1..Number_Of_Complex_Items) of String_Ptr :=
              (new String'( "(3.0, 9.0  )"           ),
              (new String'( "(3.0, 9.0  )"           ),
               new String'( "+4.0  +7.0"             ),
               new String'( "+4.0  +7.0"             ),
               new String'( "(5.0 6.0)"              ),
               new String'( "(5.0 6.0)"              ),
               new String'( "6.0, 3.0"               ),
               new String'( "6.0, 3.0"               ),
               new String'( "  (   2.0   , 5.0  )  " ),
               new String'( "  (   2.0   , 5.0  )  " ),
               new String'( "(3.0              7.0)" ));
               new String'( "(3.0              7.0)" ));
            -- The following array contains Positive values that correspond
            -- The following array contains Positive values that correspond
            -- to the last character that will be read by Procedure Get when
            -- to the last character that will be read by Procedure Get when
            -- given each of the above strings as input.
            -- given each of the above strings as input.
            TC_Last_Char_Array : array (1..Number_Of_Complex_Items)
            TC_Last_Char_Array : array (1..Number_Of_Complex_Items)
               of Positive := (12,10,9,8,20,22);
               of Positive := (12,10,9,8,20,22);
         begin
         begin
            -- Get complex values from strings using the Procedure Get.
            -- Get complex values from strings using the Procedure Get.
            -- Compare with expected complex values.
            -- Compare with expected complex values.
            for i in 1..Number_Of_Complex_Items loop
            for i in 1..Number_Of_Complex_Items loop
               C_IO.Get(TC_Complex_String_Array(i).all,
               C_IO.Get(TC_Complex_String_Array(i).all,
                        TC_Complex,
                        TC_Complex,
                        TC_Last_Character_Read);
                        TC_Last_Character_Read);
               if TC_Complex /= Complex_Array(i) then
               if TC_Complex /= Complex_Array(i) then
                  Report.Failed
                  Report.Failed
                    ("Incorrect complex data value obtained from " &
                    ("Incorrect complex data value obtained from " &
                     "Procedure Get with complex data input of: "  &
                     "Procedure Get with complex data input of: "  &
                     TC_Complex_String_Array(i).all);
                     TC_Complex_String_Array(i).all);
               end if;
               end if;
               if TC_Last_Character_Read /= TC_Last_Char_Array(i) then
               if TC_Last_Character_Read /= TC_Last_Char_Array(i) then
                  Report.Failed
                  Report.Failed
                    ("Incorrect value returned as the last character of " &
                    ("Incorrect value returned as the last character of " &
                     "the input string processed by Procedure Get, "      &
                     "the input string processed by Procedure Get, "      &
                     "string value : " & TC_Complex_String_Array(i).all   &
                     "string value : " & TC_Complex_String_Array(i).all   &
                     "  expected last character value read : "            &
                     "  expected last character value read : "            &
                     Positive'Image(TC_Last_Char_Array(i))                &
                     Positive'Image(TC_Last_Char_Array(i))                &
                     "  last character value read : "                     &
                     "  last character value read : "                     &
                     Positive'Image(TC_Last_Character_Read));
                     Positive'Image(TC_Last_Character_Read));
               end if;
               end if;
            end loop;
            end loop;
            if TC_Verbose then
            if TC_Verbose then
               Report.Comment("Complex values removed from strings and " &
               Report.Comment("Complex values removed from strings and " &
                              "verified against expected values");
                              "verified against expected values");
            end if;
            end if;
         exception
         exception
            when others =>
            when others =>
               Report.Failed("Unexpected exception raised during the " &
               Report.Failed("Unexpected exception raised during the " &
                             "evaluation of Get for Strings");
                             "evaluation of Get for Strings");
         end;
         end;
      exception
      exception
         when others => Report.Failed ("Exception raised in Test_Block");
         when others => Report.Failed ("Exception raised in Test_Block");
      end Test_Block;
      end Test_Block;
      -- Delete the external file.
      -- Delete the external file.
      if Ada.Text_IO.Is_Open(Data_File) then
      if Ada.Text_IO.Is_Open(Data_File) then
         Ada.Text_IO.Delete(Data_File);
         Ada.Text_IO.Delete(Data_File);
      else
      else
         Ada.Text_IO.Open(Data_File,
         Ada.Text_IO.Open(Data_File,
                          Ada.Text_IO.In_File,
                          Ada.Text_IO.In_File,
                          Data_Filename);
                          Data_Filename);
         Ada.Text_IO.Delete(Data_File);
         Ada.Text_IO.Delete(Data_File);
      end if;
      end if;
   exception
   exception
      -- Since Use_Error can be raised if, for the specified mode,
      -- Since Use_Error can be raised if, for the specified mode,
      -- the environment does not support Text_IO operations, the
      -- the environment does not support Text_IO operations, the
      -- following handlers are included:
      -- following handlers are included:
      when Ada.Text_IO.Use_Error  =>
      when Ada.Text_IO.Use_Error  =>
         Report.Not_Applicable ("Use_Error raised on Text_IO Create");
         Report.Not_Applicable ("Use_Error raised on Text_IO Create");
      when Ada.Text_IO.Name_Error  =>
      when Ada.Text_IO.Name_Error  =>
         Report.Not_Applicable ("Name_Error raised on Text_IO Create");
         Report.Not_Applicable ("Name_Error raised on Text_IO Create");
      when others             =>
      when others             =>
         Report.Failed ("Unexpected exception raised on text file Create");
         Report.Failed ("Unexpected exception raised on text file Create");
   end Test_for_Text_IO_Support;
   end Test_for_Text_IO_Support;
   Report.Result;
   Report.Result;
end CXG1003;
end CXG1003;
 
 

powered by: WebSVN 2.1.0

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