OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [ada/] [acats/] [tests/] [cxa/] [cxa4023.a] - Diff between revs 154 and 816

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

Rev 154 Rev 816
-- CXA4023.A
-- CXA4023.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
--      Check that the subprograms defined in package
--      Ada.Strings.Wide_Unbounded are available, and that they produce
--      Ada.Strings.Wide_Unbounded are available, and that they produce
--      correct results. Specifically, check the subprograms Delete,
--      correct results. Specifically, check the subprograms Delete,
--      Find_Token, Translate, Trim, and "*".
--      Find_Token, Translate, Trim, and "*".
--
--
-- 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.Wide_Unbounded for use with unbounded wide
--      in package Ada.Strings.Wide_Unbounded for use with unbounded wide
--      strings.  The test simulates how unbounded wide strings
--      strings.  The test simulates how unbounded wide strings
--      will be processed in a user environment, using the subprograms
--      will be processed in a user environment, using the subprograms
--      provided in this package.
--      provided in this package.
--
--
--      This test, when taken in conjunction with tests CXA4021-22, will
--      This test, when taken in conjunction with tests CXA4021-22, will
--      constitute a test of the functionality contained in package
--      constitute a test of the functionality contained in package
--      Ada.Strings.Wide_Unbounded.  This test uses a variety
--      Ada.Strings.Wide_Unbounded.  This test uses a variety
--      of the subprograms defined in the unbounded wide string package
--      of the subprograms defined in the unbounded wide string package
--      in ways typical of common usage, with different combinations of
--      in ways typical of common usage, with different combinations of
--      available subprograms being used to accomplish similar
--      available subprograms being used to accomplish similar
--      unbounded wide string processing goals.
--      unbounded wide string processing goals.
--
--
--
--
-- CHANGE HISTORY:
-- CHANGE HISTORY:
--      06 Dec 94   SAIC    ACVC 2.0
--      06 Dec 94   SAIC    ACVC 2.0
--      08 Nov 95   SAIC    Corrected accessibility level and type
--      08 Nov 95   SAIC    Corrected accessibility level and type
--                          visibility problems for ACVC 2.0.1.
--                          visibility problems for ACVC 2.0.1.
--
--
--!
--!
with Ada.Characters.Handling;
with Ada.Characters.Handling;
with Ada.Strings;
with Ada.Strings;
package CXA40230 is
package CXA40230 is
   -- The following two functions are used to translate character and string
   -- The following two functions are used to translate character and string
   -- values to non-character "Wide" values.  They will be applied to all the
   -- values to non-character "Wide" values.  They will be applied to all the
   -- Wide_Bounded subprogram character and string parameters to simulate the
   -- Wide_Bounded subprogram character and string parameters to simulate the
   -- use of Wide_Characters and Wide_Strings in actual practice.
   -- use of Wide_Characters and Wide_Strings in actual practice.
   -- Note: These functions do not actually return "equivalent" wide
   -- Note: These functions do not actually return "equivalent" wide
   --       characters to their character inputs, just "non-character"
   --       characters to their character inputs, just "non-character"
   --       wide characters.
   --       wide characters.
   function Equiv (Ch : Character) return Wide_Character;
   function Equiv (Ch : Character) return Wide_Character;
   function Equiv (Str : String) return Wide_String;
   function Equiv (Str : String) return Wide_String;
   -- Functions and access-to-subprogram object used to supply mapping
   -- Functions and access-to-subprogram object used to supply mapping
   -- capability to the appropriate versions of Translate.
   -- capability to the appropriate versions of Translate.
   function AB_to_US_Mapping_Function (From : Wide_Character)
   function AB_to_US_Mapping_Function (From : Wide_Character)
     return Wide_Character;
     return Wide_Character;
   function AB_to_Blank_Mapping_Function (From : Wide_Character)
   function AB_to_Blank_Mapping_Function (From : Wide_Character)
     return Wide_Character;
     return Wide_Character;
end CXA40230;
end CXA40230;
package body CXA40230 is
package body CXA40230 is
   function Equiv (Ch : Character) return Wide_Character is
   function Equiv (Ch : Character) return Wide_Character is
      C : Character := Ch;
      C : Character := Ch;
   begin
   begin
      if Ch = ' ' then
      if Ch = ' ' then
         return Ada.Characters.Handling.To_Wide_Character(C);
         return Ada.Characters.Handling.To_Wide_Character(C);
      else
      else
         return Wide_Character'Val(Character'Pos(Ch) +
         return Wide_Character'Val(Character'Pos(Ch) +
                Character'Pos(Character'Last) + 1);
                Character'Pos(Character'Last) + 1);
      end if;
      end if;
   end Equiv;
   end Equiv;
   function Equiv (Str : String) return Wide_String is
   function Equiv (Str : String) return Wide_String is
      WS : Wide_String(Str'First..Str'Last);
      WS : Wide_String(Str'First..Str'Last);
   begin
   begin
      for i in Str'First..Str'Last loop
      for i in Str'First..Str'Last loop
         WS(i) := Equiv(Str(i));
         WS(i) := Equiv(Str(i));
      end loop;
      end loop;
      return WS;
      return WS;
   end Equiv;
   end Equiv;
   function AB_to_US_Mapping_Function (From : Wide_Character)
   function AB_to_US_Mapping_Function (From : Wide_Character)
     return Wide_Character is
     return Wide_Character is
      UnderScore : constant Wide_Character := Equiv('_');
      UnderScore : constant Wide_Character := Equiv('_');
   begin
   begin
      if From = Equiv('a')  or  From = Equiv('b')  then
      if From = Equiv('a')  or  From = Equiv('b')  then
         return UnderScore;
         return UnderScore;
      else
      else
         return From;
         return From;
      end if;
      end if;
   end AB_to_US_Mapping_Function;
   end AB_to_US_Mapping_Function;
   function AB_to_Blank_Mapping_Function (From : Wide_Character)
   function AB_to_Blank_Mapping_Function (From : Wide_Character)
     return Wide_Character is
     return Wide_Character is
   begin
   begin
      if From = Equiv('a')  or  From = Equiv('b') then
      if From = Equiv('a')  or  From = Equiv('b') then
         return Ada.Strings.Wide_Space;
         return Ada.Strings.Wide_Space;
      else
      else
         return From;
         return From;
      end if;
      end if;
   end AB_to_Blank_Mapping_Function;
   end AB_to_Blank_Mapping_Function;
end CXA40230;
end CXA40230;
with CXA40230;
with CXA40230;
with Report;
with Report;
with Ada.Characters.Handling;
with Ada.Characters.Handling;
with Ada.Strings.Wide_Maps;
with Ada.Strings.Wide_Maps;
with Ada.Strings.Wide_Unbounded;
with Ada.Strings.Wide_Unbounded;
procedure CXA4023 is
procedure CXA4023 is
begin
begin
   Report.Test ("CXA4023", "Check that the subprograms defined in "    &
   Report.Test ("CXA4023", "Check that the subprograms defined in "    &
                           "package Ada.Strings.Wide_Unbounded are "   &
                           "package Ada.Strings.Wide_Unbounded are "   &
                           "available, and that they produce correct " &
                           "available, and that they produce correct " &
                           "results");
                           "results");
   Test_Block:
   Test_Block:
   declare
   declare
      use CXA40230;
      use CXA40230;
      package ASW renames Ada.Strings.Wide_Unbounded;
      package ASW renames Ada.Strings.Wide_Unbounded;
      use Ada.Strings;
      use Ada.Strings;
      use type Wide_Maps.Wide_Character_Set;
      use type Wide_Maps.Wide_Character_Set;
      use type ASW.Unbounded_Wide_String;
      use type ASW.Unbounded_Wide_String;
      Test_String   : ASW.Unbounded_Wide_String;
      Test_String   : ASW.Unbounded_Wide_String;
      AtoE_Str      : ASW.Unbounded_Wide_String :=
      AtoE_Str      : ASW.Unbounded_Wide_String :=
                        ASW.To_Unbounded_Wide_String(Equiv("abcde"));
                        ASW.To_Unbounded_Wide_String(Equiv("abcde"));
      Cad_String    : ASW.Unbounded_Wide_String :=
      Cad_String    : ASW.Unbounded_Wide_String :=
                        ASW.To_Unbounded_Wide_String(Equiv("cad"));
                        ASW.To_Unbounded_Wide_String(Equiv("cad"));
      Magic_String  : ASW.Unbounded_Wide_String :=
      Magic_String  : ASW.Unbounded_Wide_String :=
                        ASW.To_Unbounded_Wide_String(Equiv("abracadabra"));
                        ASW.To_Unbounded_Wide_String(Equiv("abracadabra"));
      Incantation   : ASW.Unbounded_Wide_String := Magic_String;
      Incantation   : ASW.Unbounded_Wide_String := Magic_String;
      A_Small_G : Wide_Character := Equiv('g');
      A_Small_G : Wide_Character := Equiv('g');
      ABCD_Set  : Wide_Maps.Wide_Character_Set :=
      ABCD_Set  : Wide_Maps.Wide_Character_Set :=
                    Wide_Maps.To_Set(Equiv("abcd"));
                    Wide_Maps.To_Set(Equiv("abcd"));
      B_Set     : Wide_Maps.Wide_Character_Set :=
      B_Set     : Wide_Maps.Wide_Character_Set :=
                    Wide_Maps.To_Set(Equiv('b'));
                    Wide_Maps.To_Set(Equiv('b'));
      AB_Set    : Wide_Maps.Wide_Character_Set :=
      AB_Set    : Wide_Maps.Wide_Character_Set :=
                    Wide_Maps."OR"(Wide_Maps.To_Set(Equiv('a')), B_Set);
                    Wide_Maps."OR"(Wide_Maps.To_Set(Equiv('a')), B_Set);
      AB_to_YZ_Map     : Wide_Maps.Wide_Character_Mapping :=
      AB_to_YZ_Map     : Wide_Maps.Wide_Character_Mapping :=
                           Wide_Maps.To_Mapping(From => Equiv("ab"),
                           Wide_Maps.To_Mapping(From => Equiv("ab"),
                                                To   => Equiv("yz"));
                                                To   => Equiv("yz"));
      Code_Map         : Wide_Maps.Wide_Character_Mapping :=
      Code_Map         : Wide_Maps.Wide_Character_Mapping :=
                           Wide_Maps.To_Mapping(Equiv("abcd"), Equiv("wxyz"));
                           Wide_Maps.To_Mapping(Equiv("abcd"), Equiv("wxyz"));
      Reverse_Code_Map : Wide_Maps.Wide_Character_Mapping :=
      Reverse_Code_Map : Wide_Maps.Wide_Character_Mapping :=
                           Wide_Maps.To_Mapping(Equiv("wxyz"), Equiv("abcd"));
                           Wide_Maps.To_Mapping(Equiv("wxyz"), Equiv("abcd"));
      Non_Existent_Map : Wide_Maps.Wide_Character_Mapping :=
      Non_Existent_Map : Wide_Maps.Wide_Character_Mapping :=
                           Wide_Maps.To_Mapping(Equiv("jkl"), Equiv("mno"));
                           Wide_Maps.To_Mapping(Equiv("jkl"), Equiv("mno"));
      Token_Start      : Positive;
      Token_Start      : Positive;
      Token_End        : Natural := 0;
      Token_End        : Natural := 0;
      Map_Ptr  : Wide_Maps.Wide_Character_Mapping_Function :=
      Map_Ptr  : Wide_Maps.Wide_Character_Mapping_Function :=
                   AB_to_US_Mapping_Function'Access;
                   AB_to_US_Mapping_Function'Access;
   begin
   begin
      -- Find_Token
      -- Find_Token
      ASW.Find_Token(Magic_String,      -- Find location of first "ab" equiv.
      ASW.Find_Token(Magic_String,      -- Find location of first "ab" equiv.
                     AB_Set,            -- Should be (1..2).
                     AB_Set,            -- Should be (1..2).
                     Ada.Strings.Inside,
                     Ada.Strings.Inside,
                     Token_Start,
                     Token_Start,
                     Token_End);
                     Token_End);
      if Natural(Token_Start) /= ASW.To_Wide_String(Magic_String)'First  or
      if Natural(Token_Start) /= ASW.To_Wide_String(Magic_String)'First  or
         Token_End            /= ASW.Index(Magic_String, B_Set)          or
         Token_End            /= ASW.Index(Magic_String, B_Set)          or
         Token_End            /= 2
         Token_End            /= 2
      then
      then
         Report.Failed("Incorrect result from Procedure Find_Token - 1");
         Report.Failed("Incorrect result from Procedure Find_Token - 1");
      end if;
      end if;
      ASW.Find_Token(Source => Magic_String, -- Find location of char 'r'equiv
      ASW.Find_Token(Source => Magic_String, -- Find location of char 'r'equiv
                     Set    => ABCD_Set,     -- in wide str, should be (3..3)
                     Set    => ABCD_Set,     -- in wide str, should be (3..3)
                     Test   => Ada.Strings.Outside,
                     Test   => Ada.Strings.Outside,
                     First  => Token_Start,
                     First  => Token_Start,
                     Last   => Token_End);
                     Last   => Token_End);
      if Natural(Token_Start) /= 3  or  Token_End /= 3 then
      if Natural(Token_Start) /= 3  or  Token_End /= 3 then
         Report.Failed("Incorrect result from Procedure Find_Token - 2");
         Report.Failed("Incorrect result from Procedure Find_Token - 2");
      end if;
      end if;
      ASW.Find_Token(Magic_String,                -- No 'g' "equivalent in
      ASW.Find_Token(Magic_String,                -- No 'g' "equivalent in
                     Wide_Maps.To_Set(A_Small_G), -- the wide str, so the
                     Wide_Maps.To_Set(A_Small_G), -- the wide str, so the
                     Ada.Strings.Inside,          -- result params should be
                     Ada.Strings.Inside,          -- result params should be
                     First => Token_Start,        -- First = Source'First and
                     First => Token_Start,        -- First = Source'First and
                     Last  => Token_End);         -- Last = 0.
                     Last  => Token_End);         -- Last = 0.
      if Token_Start /= ASW.To_Wide_String(Magic_String)'First  or
      if Token_Start /= ASW.To_Wide_String(Magic_String)'First  or
         Token_End   /= 0
         Token_End   /= 0
      then
      then
         Report.Failed("Incorrect result from Procedure Find_Token - 3");
         Report.Failed("Incorrect result from Procedure Find_Token - 3");
      end if;
      end if;
      ASW.Find_Token(ASW.To_Unbounded_Wide_String(Equiv("abpqpqrttrcpqr")),
      ASW.Find_Token(ASW.To_Unbounded_Wide_String(Equiv("abpqpqrttrcpqr")),
                     Wide_Maps.To_Set(Equiv("trpq")),
                     Wide_Maps.To_Set(Equiv("trpq")),
                     Ada.Strings.Inside,
                     Ada.Strings.Inside,
                     Token_Start,
                     Token_Start,
                     Token_End);
                     Token_End);
      if Token_Start /= 3 or
      if Token_Start /= 3 or
         Token_End   /= 10
         Token_End   /= 10
      then
      then
         Report.Failed("Incorrect result from Procedure Find_Token - 4");
         Report.Failed("Incorrect result from Procedure Find_Token - 4");
      end if;
      end if;
      ASW.Find_Token(ASW.To_Unbounded_Wide_String(Equiv("abpqpqrttrcpqr")),
      ASW.Find_Token(ASW.To_Unbounded_Wide_String(Equiv("abpqpqrttrcpqr")),
                     Wide_Maps.To_Set(Equiv("abpq")),
                     Wide_Maps.To_Set(Equiv("abpq")),
                     Ada.Strings.Outside,
                     Ada.Strings.Outside,
                     Token_Start,
                     Token_Start,
                     Token_End);
                     Token_End);
      if Token_Start /= 7 or
      if Token_Start /= 7 or
         Token_End   /= 11
         Token_End   /= 11
      then
      then
         Report.Failed("Incorrect result from Procedure Find_Token - 5");
         Report.Failed("Incorrect result from Procedure Find_Token - 5");
      end if;
      end if;
      -- Translate
      -- Translate
      -- Use a mapping ("abcd" -> "wxyz") to transform the contents of
      -- Use a mapping ("abcd" -> "wxyz") to transform the contents of
      -- the unbounded wide string.
      -- the unbounded wide string.
      -- Magic_String = "abracadabra"
      -- Magic_String = "abracadabra"
      Incantation := ASW.Translate(Magic_String, Code_Map);
      Incantation := ASW.Translate(Magic_String, Code_Map);
      if Incantation /=
      if Incantation /=
         ASW.To_Unbounded_Wide_String(Equiv("wxrwywzwxrw"))
         ASW.To_Unbounded_Wide_String(Equiv("wxrwywzwxrw"))
      then
      then
         Report.Failed("Incorrect result from Function Translate - 1");
         Report.Failed("Incorrect result from Function Translate - 1");
      end if;
      end if;
      -- (Note: See below for additional testing of Function Translate)
      -- (Note: See below for additional testing of Function Translate)
      -- Use the inverse mapping of the one above to return the "translated"
      -- Use the inverse mapping of the one above to return the "translated"
      -- unbounded wide string to its original form.
      -- unbounded wide string to its original form.
      ASW.Translate(Incantation, Reverse_Code_Map);
      ASW.Translate(Incantation, Reverse_Code_Map);
      -- The map contained in the following call to Translate contains three
      -- The map contained in the following call to Translate contains three
      -- elements, and these elements are not found in the unbounded wide
      -- elements, and these elements are not found in the unbounded wide
      -- string, so this call to Translate should have no effect on it.
      -- string, so this call to Translate should have no effect on it.
      if Incantation /= ASW.Translate(Magic_String, Non_Existent_Map) then
      if Incantation /= ASW.Translate(Magic_String, Non_Existent_Map) then
         Report.Failed("Incorrect result from Procedure Translate - 1");
         Report.Failed("Incorrect result from Procedure Translate - 1");
      end if;
      end if;
      -- Partial mapping of source.
      -- Partial mapping of source.
      Test_String := ASW.To_Unbounded_Wide_String(Equiv("abcdeabcab"));
      Test_String := ASW.To_Unbounded_Wide_String(Equiv("abcdeabcab"));
      ASW.Translate(Source => Test_String, Mapping => AB_to_YZ_Map);
      ASW.Translate(Source => Test_String, Mapping => AB_to_YZ_Map);
      if Test_String /= ASW.To_Unbounded_Wide_String(Equiv("yzcdeyzcyz")) then
      if Test_String /= ASW.To_Unbounded_Wide_String(Equiv("yzcdeyzcyz")) then
         Report.Failed("Incorrect result from Procedure Translate - 2");
         Report.Failed("Incorrect result from Procedure Translate - 2");
      end if;
      end if;
      -- Total mapping of source.
      -- Total mapping of source.
      Test_String := ASW.To_Unbounded_Wide_String(Equiv("abbaaababb"));
      Test_String := ASW.To_Unbounded_Wide_String(Equiv("abbaaababb"));
      ASW.Translate(Source => Test_String, Mapping => AB_to_YZ_Map);
      ASW.Translate(Source => Test_String, Mapping => AB_to_YZ_Map);
      if Test_String /= ASW.To_Unbounded_Wide_String(Equiv("yzzyyyzyzz")) then
      if Test_String /= ASW.To_Unbounded_Wide_String(Equiv("yzzyyyzyzz")) then
         Report.Failed("Incorrect result from Procedure Translate - 3");
         Report.Failed("Incorrect result from Procedure Translate - 3");
      end if;
      end if;
      -- No mapping of source.
      -- No mapping of source.
      Test_String := ASW.To_Unbounded_Wide_String(Equiv("xyzsypcc"));
      Test_String := ASW.To_Unbounded_Wide_String(Equiv("xyzsypcc"));
      ASW.Translate(Source => Test_String, Mapping => AB_to_YZ_Map);
      ASW.Translate(Source => Test_String, Mapping => AB_to_YZ_Map);
      if Test_String /= ASW.To_Unbounded_Wide_String(Equiv("xyzsypcc")) then
      if Test_String /= ASW.To_Unbounded_Wide_String(Equiv("xyzsypcc")) then
         Report.Failed("Incorrect result from Procedure Translate - 4");
         Report.Failed("Incorrect result from Procedure Translate - 4");
      end if;
      end if;
      -- Map > 2 characters, partial mapping.
      -- Map > 2 characters, partial mapping.
      Test_String := ASW.To_Unbounded_Wide_String(Equiv("opabcdelmn"));
      Test_String := ASW.To_Unbounded_Wide_String(Equiv("opabcdelmn"));
      ASW.Translate(Test_String,
      ASW.Translate(Test_String,
                    Wide_Maps.To_Mapping(Equiv("abcde"), Equiv("lmnop")));
                    Wide_Maps.To_Mapping(Equiv("abcde"), Equiv("lmnop")));
      if Test_String /= ASW.To_Unbounded_Wide_String(Equiv("oplmnoplmn")) then
      if Test_String /= ASW.To_Unbounded_Wide_String(Equiv("oplmnoplmn")) then
         Report.Failed("Incorrect result from Procedure Translate - 5");
         Report.Failed("Incorrect result from Procedure Translate - 5");
      end if;
      end if;
      -- Various degrees of mapping of source (full, partial, none) used
      -- Various degrees of mapping of source (full, partial, none) used
      -- with Function Translate.
      -- with Function Translate.
      if ASW.Translate(
      if ASW.Translate(
               ASW.To_Unbounded_Wide_String(Equiv("abcdeabcabbbaaacaa")),
               ASW.To_Unbounded_Wide_String(Equiv("abcdeabcabbbaaacaa")),
                       AB_to_YZ_Map)                               /=
                       AB_to_YZ_Map)                               /=
         ASW.To_Unbounded_Wide_String(Equiv("yzcdeyzcyzzzyyycyy"))   or
         ASW.To_Unbounded_Wide_String(Equiv("yzcdeyzcyzzzyyycyy"))   or
         ASW.Translate(
         ASW.Translate(
               ASW.To_Unbounded_Wide_String(Equiv("abbaaababbaaaaba")),
               ASW.To_Unbounded_Wide_String(Equiv("abbaaababbaaaaba")),
                       AB_to_YZ_Map)                               /=
                       AB_to_YZ_Map)                               /=
         ASW.To_Unbounded_Wide_String(Equiv("yzzyyyzyzzyyyyzy"))     or
         ASW.To_Unbounded_Wide_String(Equiv("yzzyyyzyzzyyyyzy"))     or
         ASW.Translate(ASW.To_Unbounded_Wide_String(Equiv("cABcABBAc")),
         ASW.Translate(ASW.To_Unbounded_Wide_String(Equiv("cABcABBAc")),
                       Mapping => AB_to_YZ_Map)                    /=
                       Mapping => AB_to_YZ_Map)                    /=
         ASW.To_Unbounded_Wide_String(Equiv("cABcABBAc"))            or
         ASW.To_Unbounded_Wide_String(Equiv("cABcABBAc"))            or
         ASW.Translate(ASW.To_Unbounded_Wide_String("opabcdelmnddeaccabec"),
         ASW.Translate(ASW.To_Unbounded_Wide_String("opabcdelmnddeaccabec"),
                       Wide_Maps.To_Mapping("abcde", "lmnop"))     /=
                       Wide_Maps.To_Mapping("abcde", "lmnop"))     /=
         ASW.To_Unbounded_Wide_String("oplmnoplmnooplnnlmpn")
         ASW.To_Unbounded_Wide_String("oplmnoplmnooplnnlmpn")
      then
      then
         Report.Failed("Incorrect result from Function Translate - 2");
         Report.Failed("Incorrect result from Function Translate - 2");
      end if;
      end if;
      -- Procedure Translate using access-to-subprogram mapping.
      -- Procedure Translate using access-to-subprogram mapping.
      -- Partial mapping of source.
      -- Partial mapping of source.
      Map_Ptr := AB_to_Blank_Mapping_Function'Access;
      Map_Ptr := AB_to_Blank_Mapping_Function'Access;
      Test_String := ASW.To_Unbounded_Wide_String(Equiv("abABaABbaBAbba"));
      Test_String := ASW.To_Unbounded_Wide_String(Equiv("abABaABbaBAbba"));
      ASW.Translate(Source  => Test_String, -- change equivalent of 'a' and
      ASW.Translate(Source  => Test_String, -- change equivalent of 'a' and
                    Mapping => Map_Ptr);    -- 'b' to ' '
                    Mapping => Map_Ptr);    -- 'b' to ' '
      if Test_String /=
      if Test_String /=
         ASW.To_Unbounded_Wide_String(Equiv("  AB AB  BA   "))
         ASW.To_Unbounded_Wide_String(Equiv("  AB AB  BA   "))
      then
      then
         Report.Failed
         Report.Failed
           ("Incorrect result from Proc Translate, w/ access value map - 1");
           ("Incorrect result from Proc Translate, w/ access value map - 1");
      end if;
      end if;
      -- Total mapping of source to blanks.
      -- Total mapping of source to blanks.
      Test_String := ASW.To_Unbounded_Wide_String(Equiv("abbbab"));
      Test_String := ASW.To_Unbounded_Wide_String(Equiv("abbbab"));
      ASW.Translate(Source  => Test_String,
      ASW.Translate(Source  => Test_String,
                    Mapping => Map_Ptr);
                    Mapping => Map_Ptr);
      if Test_String /=
      if Test_String /=
         ASW.To_Unbounded_Wide_String(Equiv("      "))
         ASW.To_Unbounded_Wide_String(Equiv("      "))
      then
      then
         Report.Failed
         Report.Failed
           ("Incorrect result from Proc Translate, w/ access value map - 2");
           ("Incorrect result from Proc Translate, w/ access value map - 2");
      end if;
      end if;
      -- No mapping of source.
      -- No mapping of source.
      Map_Ptr := AB_to_US_Mapping_Function'Access;
      Map_Ptr := AB_to_US_Mapping_Function'Access;
      Test_String := ASW.To_Unbounded_Wide_String(Equiv("xyzsypcc"));
      Test_String := ASW.To_Unbounded_Wide_String(Equiv("xyzsypcc"));
      ASW.Translate(Source  => Test_String,
      ASW.Translate(Source  => Test_String,
                    Mapping => Map_Ptr);
                    Mapping => Map_Ptr);
      if Test_String /=
      if Test_String /=
         ASW.To_Unbounded_Wide_String(Equiv("xyzsypcc"))   -- no change
         ASW.To_Unbounded_Wide_String(Equiv("xyzsypcc"))   -- no change
      then
      then
         Report.Failed
         Report.Failed
           ("Incorrect result from Proc Translate, w/ access value map - 3");
           ("Incorrect result from Proc Translate, w/ access value map - 3");
      end if;
      end if;
      -- Function Translate using access-to-subprogram mapping value.
      -- Function Translate using access-to-subprogram mapping value.
      Map_Ptr  := AB_to_Blank_Mapping_Function'Access;
      Map_Ptr  := AB_to_Blank_Mapping_Function'Access;
      Test_String := ASW.To_Unbounded_Wide_String(Equiv("abAbBBAabbacD"));
      Test_String := ASW.To_Unbounded_Wide_String(Equiv("abAbBBAabbacD"));
      if ASW.Translate(ASW.Translate(Test_String, Map_Ptr), Map_Ptr)  /=
      if ASW.Translate(ASW.Translate(Test_String, Map_Ptr), Map_Ptr)  /=
         ASW.To_Unbounded_Wide_String(Equiv("  A BBA    cD"))
         ASW.To_Unbounded_Wide_String(Equiv("  A BBA    cD"))
      then
      then
         Report.Failed
         Report.Failed
           ("Incorrect result from Function Translate, access value map - 1");
           ("Incorrect result from Function Translate, access value map - 1");
      end if;
      end if;
      if ASW.Translate(Source  => ASW.To_Unbounded_Wide_String(Equiv("a")),
      if ASW.Translate(Source  => ASW.To_Unbounded_Wide_String(Equiv("a")),
                       Mapping => Map_Ptr)                            /=
                       Mapping => Map_Ptr)                            /=
         ASW.To_Unbounded_Wide_String(Equiv(" "))                       or
         ASW.To_Unbounded_Wide_String(Equiv(" "))                       or
         ASW.Translate(ASW.To_Unbounded_Wide_String
         ASW.Translate(ASW.To_Unbounded_Wide_String
                         (Equiv(" aa Aa A AAaaa a   aA")),
                         (Equiv(" aa Aa A AAaaa a   aA")),
                       Map_Ptr)                                       /=
                       Map_Ptr)                                       /=
         ASW.To_Unbounded_Wide_String(Equiv("    A  A AA         A"))   or
         ASW.To_Unbounded_Wide_String(Equiv("    A  A AA         A"))   or
         ASW.Translate(Source  => ASW.To_Unbounded_Wide_String(Equiv("a ")),
         ASW.Translate(Source  => ASW.To_Unbounded_Wide_String(Equiv("a ")),
                       Mapping => Map_Ptr)                            /=
                       Mapping => Map_Ptr)                            /=
         ASW.To_Unbounded_Wide_String(Equiv("  "))                      or
         ASW.To_Unbounded_Wide_String(Equiv("  "))                      or
         ASW.Translate(Source  => ASW.To_Unbounded_Wide_String(Equiv("xyz")),
         ASW.Translate(Source  => ASW.To_Unbounded_Wide_String(Equiv("xyz")),
                       Mapping => Map_Ptr)                            /=
                       Mapping => Map_Ptr)                            /=
         ASW.To_Unbounded_Wide_String(Equiv("xyz"))
         ASW.To_Unbounded_Wide_String(Equiv("xyz"))
      then
      then
         Report.Failed
         Report.Failed
           ("Incorrect result from Function Translate, access value map - 2");
           ("Incorrect result from Function Translate, access value map - 2");
      end if;
      end if;
      -- Trim
      -- Trim
      Trim_Block:
      Trim_Block:
      declare
      declare
         XYZ_Set     : Wide_Maps.Wide_Character_Set :=
         XYZ_Set     : Wide_Maps.Wide_Character_Set :=
                         Wide_Maps.To_Set(Equiv("xyz"));
                         Wide_Maps.To_Set(Equiv("xyz"));
         PQR_Set     : Wide_Maps.Wide_Character_Set :=
         PQR_Set     : Wide_Maps.Wide_Character_Set :=
                         Wide_Maps.To_Set(Equiv("pqr"));
                         Wide_Maps.To_Set(Equiv("pqr"));
         Pad         : constant ASW.Unbounded_Wide_String :=
         Pad         : constant ASW.Unbounded_Wide_String :=
                                 ASW.To_Unbounded_Wide_String(Equiv("Pad"));
                                 ASW.To_Unbounded_Wide_String(Equiv("Pad"));
         The_New_Ada : constant ASW.Unbounded_Wide_String :=
         The_New_Ada : constant ASW.Unbounded_Wide_String :=
                                 ASW.To_Unbounded_Wide_String(Equiv("Ada9X"));
                                 ASW.To_Unbounded_Wide_String(Equiv("Ada9X"));
         Space_Array : array (1..4) of ASW.Unbounded_Wide_String :=
         Space_Array : array (1..4) of ASW.Unbounded_Wide_String :=
                         (ASW.To_Unbounded_Wide_String(Equiv("  Pad    ")),
                         (ASW.To_Unbounded_Wide_String(Equiv("  Pad    ")),
                          ASW.To_Unbounded_Wide_String(Equiv("Pad   ")),
                          ASW.To_Unbounded_Wide_String(Equiv("Pad   ")),
                          ASW.To_Unbounded_Wide_String(Equiv("     Pad")),
                          ASW.To_Unbounded_Wide_String(Equiv("     Pad")),
                          Pad);
                          Pad);
         String_Array : array (1..5) of ASW.Unbounded_Wide_String :=
         String_Array : array (1..5) of ASW.Unbounded_Wide_String :=
                        (ASW.To_Unbounded_Wide_String(Equiv("xyzxAda9Xpqr")),
                        (ASW.To_Unbounded_Wide_String(Equiv("xyzxAda9Xpqr")),
                         ASW.To_Unbounded_Wide_String(Equiv("Ada9Xqqrp")),
                         ASW.To_Unbounded_Wide_String(Equiv("Ada9Xqqrp")),
                         ASW.To_Unbounded_Wide_String(Equiv("zxyxAda9Xqpqr")),
                         ASW.To_Unbounded_Wide_String(Equiv("zxyxAda9Xqpqr")),
                         ASW.To_Unbounded_Wide_String(Equiv("xxxyAda9X")),
                         ASW.To_Unbounded_Wide_String(Equiv("xxxyAda9X")),
                         The_New_Ada);
                         The_New_Ada);
      begin
      begin
         -- Examine the version of Trim that removes blanks from
         -- Examine the version of Trim that removes blanks from
         -- the left and/or right of a wide string.
         -- the left and/or right of a wide string.
         for i in 1..4 loop
         for i in 1..4 loop
            if ASW.Trim(Space_Array(i), Ada.Strings.Both) /= Pad then
            if ASW.Trim(Space_Array(i), Ada.Strings.Both) /= Pad then
               Report.Failed("Incorrect result from Trim for spaces - " &
               Report.Failed("Incorrect result from Trim for spaces - " &
                             Integer'Image(i));
                             Integer'Image(i));
            end if;
            end if;
         end loop;
         end loop;
         -- Examine the version of Trim that removes set characters from
         -- Examine the version of Trim that removes set characters from
         -- the left and right of a wide string.
         -- the left and right of a wide string.
         for i in 1..5 loop
         for i in 1..5 loop
            if ASW.Trim(String_Array(i),
            if ASW.Trim(String_Array(i),
                        Left   => XYZ_Set,
                        Left   => XYZ_Set,
                        Right  => PQR_Set) /= The_New_Ada then
                        Right  => PQR_Set) /= The_New_Ada then
               Report.Failed
               Report.Failed
                 ("Incorrect result from Trim for set characters - " &
                 ("Incorrect result from Trim for set characters - " &
                  Integer'Image(i));
                  Integer'Image(i));
            end if;
            end if;
         end loop;
         end loop;
         -- No trimming.
         -- No trimming.
         if ASW.Trim(
         if ASW.Trim(
              ASW.To_Unbounded_Wide_String(Equiv("prqqprAda9Xyzzxyzzyz")),
              ASW.To_Unbounded_Wide_String(Equiv("prqqprAda9Xyzzxyzzyz")),
                     XYZ_Set,
                     XYZ_Set,
                     PQR_Set)  /=
                     PQR_Set)  /=
            ASW.To_Unbounded_Wide_String(Equiv("prqqprAda9Xyzzxyzzyz"))
            ASW.To_Unbounded_Wide_String(Equiv("prqqprAda9Xyzzxyzzyz"))
         then
         then
            Report.Failed
            Report.Failed
              ("Incorrect result from Trim for set, no trimming");
              ("Incorrect result from Trim for set, no trimming");
         end if;
         end if;
      end Trim_Block;
      end Trim_Block;
      -- Delete
      -- Delete
      -- Use the Delete function to remove the first four and last four
      -- Use the Delete function to remove the first four and last four
      -- characters from the wide string.
      -- characters from the wide string.
      if ASW.Delete(Source  => ASW.Delete(Magic_String,
      if ASW.Delete(Source  => ASW.Delete(Magic_String,
                                          8,
                                          8,
                                          ASW.Length(Magic_String)),
                                          ASW.Length(Magic_String)),
                    From    => ASW.To_Wide_String(Magic_String)'First,
                    From    => ASW.To_Wide_String(Magic_String)'First,
                    Through => 4)   /=
                    Through => 4)   /=
         Cad_String
         Cad_String
      then
      then
         Report.Failed("Incorrect results from Function Delete");
         Report.Failed("Incorrect results from Function Delete");
      end if;
      end if;
      -- Constructors ("*")
      -- Constructors ("*")
      Constructor_Block:
      Constructor_Block:
      declare
      declare
         SOS      : ASW.Unbounded_Wide_String;
         SOS      : ASW.Unbounded_Wide_String;
         Dot      : constant ASW.Unbounded_Wide_String :=
         Dot      : constant ASW.Unbounded_Wide_String :=
                               ASW.To_Unbounded_Wide_String(Equiv("Dot_"));
                               ASW.To_Unbounded_Wide_String(Equiv("Dot_"));
         Dash     : constant Wide_String := Equiv("Dash_");
         Dash     : constant Wide_String := Equiv("Dash_");
         Distress : ASW.Unbounded_Wide_String :=
         Distress : ASW.Unbounded_Wide_String :=
                      ASW."&"(ASW.To_Unbounded_Wide_String
                      ASW."&"(ASW.To_Unbounded_Wide_String
                                (Equiv("Dot_Dot_Dot_")),
                                (Equiv("Dot_Dot_Dot_")),
                              ASW."&"(ASW.To_Unbounded_Wide_String
                              ASW."&"(ASW.To_Unbounded_Wide_String
                                        (Equiv("Dash_Dash_Dash_")),
                                        (Equiv("Dash_Dash_Dash_")),
                                      ASW.To_Unbounded_Wide_String
                                      ASW.To_Unbounded_Wide_String
                                        (Equiv("Dot_Dot_Dot"))));
                                        (Equiv("Dot_Dot_Dot"))));
         Repeat        : constant Natural        := 3;
         Repeat        : constant Natural        := 3;
         Separator     : constant Wide_Character := Equiv('_');
         Separator     : constant Wide_Character := Equiv('_');
         Separator_Set : Wide_Maps.Wide_Character_Set :=
         Separator_Set : Wide_Maps.Wide_Character_Set :=
                           Wide_Maps.To_Set(Separator);
                           Wide_Maps.To_Set(Separator);
      begin
      begin
         -- Use the following constructor forms to construct the wide string
         -- Use the following constructor forms to construct the wide string
         -- "Dot_Dot_Dot_Dash_Dash_Dash_Dot_Dot_Dot".  Note that the
         -- "Dot_Dot_Dot_Dash_Dash_Dash_Dot_Dot_Dot".  Note that the
         -- trailing underscore in the wide string is removed in the call to
         -- trailing underscore in the wide string is removed in the call to
         -- Trim in the If statement condition.
         -- Trim in the If statement condition.
         SOS := ASW."*"(Repeat, Dot);                   -- "*"(#, W Unb Str)
         SOS := ASW."*"(Repeat, Dot);                   -- "*"(#, W Unb Str)
         SOS := ASW."&"(SOS,
         SOS := ASW."&"(SOS,
                        ASW."&"(ASW."*"(Repeat, Dash),  -- "*"(#, W Str)
                        ASW."&"(ASW."*"(Repeat, Dash),  -- "*"(#, W Str)
                                ASW."*"(Repeat, Dot))); -- "*"(#, W Unb Str)
                                ASW."*"(Repeat, Dot))); -- "*"(#, W Unb Str)
         if ASW.Trim(SOS, Wide_Maps.Null_Set, Separator_Set) /= Distress then
         if ASW.Trim(SOS, Wide_Maps.Null_Set, Separator_Set) /= Distress then
            Report.Failed("Incorrect results from Function ""*""");
            Report.Failed("Incorrect results from Function ""*""");
         end if;
         end if;
      end Constructor_Block;
      end Constructor_Block;
   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;
   Report.Result;
   Report.Result;
end CXA4023;
end CXA4023;
 
 

powered by: WebSVN 2.1.0

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