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/] [cxa/] [cxa4031.a] - Diff between revs 294 and 338

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

Rev 294 Rev 338
-- CXA4031.A
-- CXA4031.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 package Ada.Strings.Unbounded
--      Check that the subprograms defined in package Ada.Strings.Unbounded
--      are available, and that they produce correct results. Specifically,
--      are available, and that they produce correct results. Specifically,
--      check the functions To_Unbounded_String (version with Length
--      check the functions To_Unbounded_String (version with Length
--      parameter), "=", "<", "<=", ">", ">=" (all with String-Unbounded
--      parameter), "=", "<", "<=", ">", ">=" (all with String-Unbounded
--      String parameter mix), as well as three versions of Procedure Append.
--      String parameter mix), as well as three versions of Procedure Append.
--
--
-- TEST DESCRIPTION:
-- TEST DESCRIPTION:
--      This test demonstrates the uses of many of the subprograms defined
--      This test demonstrates the uses of many of the subprograms defined
--      in package Ada.Strings.Unbounded for use with unbounded strings.
--      in package Ada.Strings.Unbounded for use with unbounded strings.
--      The test simulates how unbounded strings could be processed in a
--      The test simulates how unbounded strings could be processed in a
--      user environment, using the subprograms provided in this package.
--      user environment, using the subprograms provided in this package.
--
--
--      This test, when taken in conjunction with tests CXA4010, CXA4011,
--      This test, when taken in conjunction with tests CXA4010, CXA4011,
--      CXA4030, and CXA4032 will constitute a test of all the functionality
--      CXA4030, and CXA4032 will constitute a test of all the functionality
--      contained in package Ada.Strings.Unbounded.  This test uses a variety
--      contained in package Ada.Strings.Unbounded.  This test uses a variety
--      of the subprograms defined in the unbounded string package in ways
--      of the subprograms defined in the unbounded string package in ways
--      typical of common usage.
--      typical of common usage.
--
--
--
--
-- CHANGE HISTORY:
-- CHANGE HISTORY:
--      27 Feb 95   SAIC    Initial prerelease version.
--      27 Feb 95   SAIC    Initial prerelease version.
--      18 Apr 96   SAIC    Incorporated reviewer comments for ACVC 2.1.
--      18 Apr 96   SAIC    Incorporated reviewer comments for ACVC 2.1.
--
--
--!
--!
with Report;
with Report;
with Ada.Exceptions;
with Ada.Exceptions;
with Ada.Strings.Maps;
with Ada.Strings.Maps;
with Ada.Strings.Unbounded;
with Ada.Strings.Unbounded;
procedure CXA4031 is
procedure CXA4031 is
begin
begin
   Report.Test ("CXA4031", "Check that the subprograms defined in "        &
   Report.Test ("CXA4031", "Check that the subprograms defined in "        &
                           "package Ada.Strings.Unbounded are available, " &
                           "package Ada.Strings.Unbounded are available, " &
                           "and that they produce correct results");
                           "and that they produce correct results");
   Test_Block:
   Test_Block:
   declare
   declare
      package Unb renames Ada.Strings.Unbounded;
      package Unb renames Ada.Strings.Unbounded;
      use Unb;
      use Unb;
      use Ada.Exceptions;
      use Ada.Exceptions;
      subtype LC_Characters is Character range 'a'..'z';
      subtype LC_Characters is Character range 'a'..'z';
      Null_String       : constant String := "";
      Null_String       : constant String := "";
      TC_String         : constant String := "A Standard String";
      TC_String         : constant String := "A Standard String";
      TC_Unb_String,
      TC_Unb_String,
      TC_New_Unb_String : Unb.Unbounded_String := Unb.Null_Unbounded_String;
      TC_New_Unb_String : Unb.Unbounded_String := Unb.Null_Unbounded_String;
   begin
   begin
      -- Function To_Unbounded_String (version with Length parameter)
      -- Function To_Unbounded_String (version with Length parameter)
      -- returns an unbounded string that represents an uninitialized String
      -- returns an unbounded string that represents an uninitialized String
      -- whose length is Length.
      -- whose length is Length.
      -- Note: Unbounded_String length can vary conceptually between 0 and
      -- Note: Unbounded_String length can vary conceptually between 0 and
      --       Natural'Last.
      --       Natural'Last.
      if Unb.Length(Unb.To_Unbounded_String(Length => 10)) /= 10 or
      if Unb.Length(Unb.To_Unbounded_String(Length => 10)) /= 10 or
         Unb.Length(Unb.To_Unbounded_String(1))            /=  1 or
         Unb.Length(Unb.To_Unbounded_String(1))            /=  1 or
         Unb.Length(Unb.To_Unbounded_String(0))            /=  0 or
         Unb.Length(Unb.To_Unbounded_String(0))            /=  0 or
         Unb.Length(Unb."&"(Unb.To_Unbounded_String(Length => 10),
         Unb.Length(Unb."&"(Unb.To_Unbounded_String(Length => 10),
                    Unb."&"(Unb.To_Unbounded_String(1),
                    Unb."&"(Unb.To_Unbounded_String(1),
                            Unb.To_Unbounded_String(0) ))) /= 10+1+0
                            Unb.To_Unbounded_String(0) ))) /= 10+1+0
      then
      then
         Report.Failed
         Report.Failed
           ("Incorrect results from Function To_Unbounded_String with " &
           ("Incorrect results from Function To_Unbounded_String with " &
            "Length parameter");
            "Length parameter");
      end if;
      end if;
      -- Procedure Append (Unbounded - Unbounded)
      -- Procedure Append (Unbounded - Unbounded)
      -- Note: For each of the Append procedures, the resulting string
      -- Note: For each of the Append procedures, the resulting string
      --       represented by the Source parameter is given by the
      --       represented by the Source parameter is given by the
      --       concatenation of the original value of Source and the value
      --       concatenation of the original value of Source and the value
      --       of New_Item.
      --       of New_Item.
      TC_Unb_String := Unb.To_Unbounded_String("Sample string of length L");
      TC_Unb_String := Unb.To_Unbounded_String("Sample string of length L");
      TC_New_Unb_String := Unb.To_Unbounded_String(" and then some");
      TC_New_Unb_String := Unb.To_Unbounded_String(" and then some");
      Unb.Append(Source => TC_Unb_String, New_Item => TC_New_Unb_String);
      Unb.Append(Source => TC_Unb_String, New_Item => TC_New_Unb_String);
      if TC_Unb_String /=
      if TC_Unb_String /=
         Unb.To_Unbounded_String("Sample string of length L and then some")
         Unb.To_Unbounded_String("Sample string of length L and then some")
      then
      then
         Report.Failed("Incorrect results from Procedure Append with " &
         Report.Failed("Incorrect results from Procedure Append with " &
                       "unbounded string parameters - 1");
                       "unbounded string parameters - 1");
      end if;
      end if;
      TC_Unb_String := Unb.To_Unbounded_String("Sample string of length L");
      TC_Unb_String := Unb.To_Unbounded_String("Sample string of length L");
      TC_New_Unb_String := Unb.Null_Unbounded_String;
      TC_New_Unb_String := Unb.Null_Unbounded_String;
      Unb.Append(TC_Unb_String, TC_New_Unb_String);
      Unb.Append(TC_Unb_String, TC_New_Unb_String);
      if TC_Unb_String /=
      if TC_Unb_String /=
         Unb.To_Unbounded_String("Sample string of length L")
         Unb.To_Unbounded_String("Sample string of length L")
      then
      then
         Report.Failed("Incorrect results from Procedure Append with " &
         Report.Failed("Incorrect results from Procedure Append with " &
                       "unbounded string parameters - 2");
                       "unbounded string parameters - 2");
      end if;
      end if;
      TC_Unb_String := Unb.Null_Unbounded_String;
      TC_Unb_String := Unb.Null_Unbounded_String;
      Unb.Append(TC_Unb_String,
      Unb.Append(TC_Unb_String,
                 Unb.To_Unbounded_String("New Unbounded String"));
                 Unb.To_Unbounded_String("New Unbounded String"));
      if TC_Unb_String /=
      if TC_Unb_String /=
         Unb.To_Unbounded_String("New Unbounded String")
         Unb.To_Unbounded_String("New Unbounded String")
      then
      then
         Report.Failed("Incorrect results from Procedure Append with " &
         Report.Failed("Incorrect results from Procedure Append with " &
                       "unbounded string parameters - 3");
                       "unbounded string parameters - 3");
      end if;
      end if;
      -- Procedure Append (Unbounded - String)
      -- Procedure Append (Unbounded - String)
      TC_Unb_String := Unb.To_Unbounded_String("An Unbounded String and ");
      TC_Unb_String := Unb.To_Unbounded_String("An Unbounded String and ");
      Unb.Append(Source => TC_Unb_String, New_Item => TC_String);
      Unb.Append(Source => TC_Unb_String, New_Item => TC_String);
      if TC_Unb_String /=
      if TC_Unb_String /=
         Unb.To_Unbounded_String("An Unbounded String and A Standard String")
         Unb.To_Unbounded_String("An Unbounded String and A Standard String")
      then
      then
         Report.Failed("Incorrect results from Procedure Append with " &
         Report.Failed("Incorrect results from Procedure Append with " &
                       "an unbounded string parameter and a string "   &
                       "an unbounded string parameter and a string "   &
                       "parameter - 1");
                       "parameter - 1");
      end if;
      end if;
      TC_Unb_String := Unb.To_Unbounded_String("An Unbounded String");
      TC_Unb_String := Unb.To_Unbounded_String("An Unbounded String");
      Unb.Append(TC_Unb_String, New_Item => Null_String);
      Unb.Append(TC_Unb_String, New_Item => Null_String);
      if TC_Unb_String /=
      if TC_Unb_String /=
         Unb.To_Unbounded_String("An Unbounded String")
         Unb.To_Unbounded_String("An Unbounded String")
      then
      then
         Report.Failed("Incorrect results from Procedure Append with " &
         Report.Failed("Incorrect results from Procedure Append with " &
                       "an unbounded string parameter and a string "   &
                       "an unbounded string parameter and a string "   &
                       "parameter - 2");
                       "parameter - 2");
      end if;
      end if;
      TC_Unb_String := Unb.Null_Unbounded_String;
      TC_Unb_String := Unb.Null_Unbounded_String;
      Unb.Append(TC_Unb_String, TC_String);
      Unb.Append(TC_Unb_String, TC_String);
      if TC_Unb_String /= Unb.To_Unbounded_String("A Standard String") then
      if TC_Unb_String /= Unb.To_Unbounded_String("A Standard String") then
         Report.Failed("Incorrect results from Procedure Append with " &
         Report.Failed("Incorrect results from Procedure Append with " &
                       "an unbounded string parameter and a string "   &
                       "an unbounded string parameter and a string "   &
                       "parameter - 3");
                       "parameter - 3");
      end if;
      end if;
      -- Procedure Append (Unbounded - Character)
      -- Procedure Append (Unbounded - Character)
      TC_Unb_String := Unb.To_Unbounded_String("Lower Case = ");
      TC_Unb_String := Unb.To_Unbounded_String("Lower Case = ");
      for i in LC_Characters'Range loop
      for i in LC_Characters'Range loop
         Unb.Append(Source => TC_Unb_String, New_Item => LC_Characters(i));
         Unb.Append(Source => TC_Unb_String, New_Item => LC_Characters(i));
      end loop;
      end loop;
      if TC_Unb_String /=
      if TC_Unb_String /=
         Unb.To_Unbounded_String("Lower Case = abcdefghijklmnopqrstuvwxyz")
         Unb.To_Unbounded_String("Lower Case = abcdefghijklmnopqrstuvwxyz")
      then
      then
         Report.Failed("Incorrect results from Procedure Append with "  &
         Report.Failed("Incorrect results from Procedure Append with "  &
                       "an unbounded string parameter and a character " &
                       "an unbounded string parameter and a character " &
                       "parameter - 1");
                       "parameter - 1");
      end if;
      end if;
      TC_Unb_String := Unb.Null_Unbounded_String;
      TC_Unb_String := Unb.Null_Unbounded_String;
      Unb.Append(TC_Unb_String, New_Item => 'a');
      Unb.Append(TC_Unb_String, New_Item => 'a');
      if TC_Unb_String /= Unb.To_Unbounded_String("a") then
      if TC_Unb_String /= Unb.To_Unbounded_String("a") then
         Report.Failed("Incorrect results from Procedure Append with "  &
         Report.Failed("Incorrect results from Procedure Append with "  &
                       "an unbounded string parameter and a character " &
                       "an unbounded string parameter and a character " &
                       "parameter - 2");
                       "parameter - 2");
      end if;
      end if;
      -- Function "="
      -- Function "="
      TC_Unb_String := Unb.To_Unbounded_String(TC_String);
      TC_Unb_String := Unb.To_Unbounded_String(TC_String);
      if not (TC_Unb_String = TC_String)                 or  -- (Unb_Str, Str)
      if not (TC_Unb_String = TC_String)                 or  -- (Unb_Str, Str)
         not Unb."="("A Standard String", TC_Unb_String) or  -- (Str, Unb_Str)
         not Unb."="("A Standard String", TC_Unb_String) or  -- (Str, Unb_Str)
         not ((Unb.Null_Unbounded_String = "") and           -- (Unb_Str, Str)
         not ((Unb.Null_Unbounded_String = "") and           -- (Unb_Str, Str)
              ("Test String" =                               -- (Str, Unb_Str)
              ("Test String" =                               -- (Str, Unb_Str)
               Unb.To_Unbounded_String("Test String")))
               Unb.To_Unbounded_String("Test String")))
      then
      then
         Report.Failed("Incorrect results from function ""="" with " &
         Report.Failed("Incorrect results from function ""="" with " &
                       "string - unbounded string parameter combinations");
                       "string - unbounded string parameter combinations");
      end if;
      end if;
      -- Function "<"
      -- Function "<"
      if not ("Extra Space" < Unb.To_Unbounded_String("Extra Space ") and
      if not ("Extra Space" < Unb.To_Unbounded_String("Extra Space ") and
              Unb.To_Unbounded_String("tess") < "test"                and
              Unb.To_Unbounded_String("tess") < "test"                and
              Unb.To_Unbounded_String("best") < "test")                or
              Unb.To_Unbounded_String("best") < "test")                or
         Unb.Null_Unbounded_String            < Null_String            or
         Unb.Null_Unbounded_String            < Null_String            or
         " leading blank"  < Unb.To_Unbounded_String(" leading blank") or
         " leading blank"  < Unb.To_Unbounded_String(" leading blank") or
         "ending blank "   < Unb.To_Unbounded_String("ending blank ")
         "ending blank "   < Unb.To_Unbounded_String("ending blank ")
      then
      then
         Report.Failed("Incorrect results from function ""<"" with " &
         Report.Failed("Incorrect results from function ""<"" with " &
                       "string - unbounded string parameter combinations");
                       "string - unbounded string parameter combinations");
      end if;
      end if;
      -- Function "<="
      -- Function "<="
      TC_Unb_String := Unb.To_Unbounded_String("Sample string");
      TC_Unb_String := Unb.To_Unbounded_String("Sample string");
      if TC_Unb_String                 <= "Sample strin" or  -- (Unb_Str, Str)
      if TC_Unb_String                 <= "Sample strin" or  -- (Unb_Str, Str)
         "sample string"               <= TC_Unb_String  or  -- (Str, Unb_Str)
         "sample string"               <= TC_Unb_String  or  -- (Str, Unb_Str)
         not(Unb.Null_Unbounded_String <= "")            or  -- (Unb_Str, Str)
         not(Unb.Null_Unbounded_String <= "")            or  -- (Unb_Str, Str)
         not("Sample string"           <= TC_Unb_String)     -- (Str, Unb_Str)
         not("Sample string"           <= TC_Unb_String)     -- (Str, Unb_Str)
      then
      then
         Report.Failed("Incorrect results from function ""<="" with " &
         Report.Failed("Incorrect results from function ""<="" with " &
                       "string - unbounded string parameter combinations");
                       "string - unbounded string parameter combinations");
      end if;
      end if;
      -- Function ">"
      -- Function ">"
      TC_Unb_String := Unb.To_Unbounded_String("A MUCH LONGER STRING");
      TC_Unb_String := Unb.To_Unbounded_String("A MUCH LONGER STRING");
      if not ("A much longer string" > TC_Unb_String                  and
      if not ("A much longer string" > TC_Unb_String                  and
              Unb.To_Unbounded_String(TC_String) > "A Standard Strin" and
              Unb.To_Unbounded_String(TC_String) > "A Standard Strin" and
              "abcdefgh" > Unb.To_Unbounded_String("ABCDEFGH"))        or
              "abcdefgh" > Unb.To_Unbounded_String("ABCDEFGH"))        or
         Unb.Null_Unbounded_String > Null_String
         Unb.Null_Unbounded_String > Null_String
      then
      then
         Report.Failed("Incorrect results from function "">"" with " &
         Report.Failed("Incorrect results from function "">"" with " &
                       "string - unbounded string parameter combinations");
                       "string - unbounded string parameter combinations");
      end if;
      end if;
      -- Function ">="
      -- Function ">="
      TC_Unb_String := Unb.To_Unbounded_String(TC_String);
      TC_Unb_String := Unb.To_Unbounded_String(TC_String);
      if not (TC_Unb_String >= TC_String                       and
      if not (TC_Unb_String >= TC_String                       and
              Null_String   >= Unb.Null_Unbounded_String       and
              Null_String   >= Unb.Null_Unbounded_String       and
              "test"        >= Unb.To_Unbounded_String("tess") and
              "test"        >= Unb.To_Unbounded_String("tess") and
              Unb.To_Unbounded_String("Programming") >= "PROGRAMMING")
              Unb.To_Unbounded_String("Programming") >= "PROGRAMMING")
      then
      then
         Report.Failed("Incorrect results from function "">="" with " &
         Report.Failed("Incorrect results from function "">="" with " &
                       "string - unbounded string parameter combinations");
                       "string - unbounded string parameter combinations");
      end if;
      end if;
   exception
   exception
      when The_Error : others =>
      when The_Error : others =>
         Report.Failed ("The following exception was raised in the " &
         Report.Failed ("The following exception was raised in the " &
                        "Test_Block: " & Exception_Name(The_Error));
                        "Test_Block: " & Exception_Name(The_Error));
   end Test_Block;
   end Test_Block;
   Report.Result;
   Report.Result;
end CXA4031;
end CXA4031;
 
 

powered by: WebSVN 2.1.0

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