cxa4008.a

来自「Mac OS X 10.4.9 for x86 Source Code gcc」· A 代码 · 共 663 行 · 第 1/2 页

A
663
字号
         B10.Index(AtoE_Bnd_Str,                       -- "abcde"                   Maps.Null_Set)              /= 0 or -- Null set         B10.Index(AtoE_Bnd_Str,                   Maps.To_Set('x'))           /= 0    -- No match.      then         Report.Failed("Incorrect result from Index using Sets - 5");      end if;      -- Function Count with non-Identity mapping.      -- Evaluate the function Count with a non-identity map       -- parameter which will cause mapping of the source parameter       -- prior to the evaluation of the number of matching patterns.      Total_Count :=         B10.Count(Source  => B10.To_Bounded_String("abbabaabab"),                  Pattern => "yz",                  Mapping => AB_to_YZ_Map);      if Total_Count /= 4 then                                                          Report.Failed           ("Incorrect result from function Count, non-Identity map - 1");      end if;      -- And a few with identity maps as well.      if B10.Count(B10.To_Bounded_String("ABABABABAB"),                   "ABA",                   Maps.Identity)                       /= 2 or         B10.Count(B10.To_Bounded_String("ADCBADABCD"),                   "AB",                   Maps.To_Mapping("CD", "AB"))         /= 5 or         B10.Count(B10.To_Bounded_String("aaaaaaaaaa"),                   "aaa")                               /= 3 or         B10.Count(B10.To_Bounded_String("XX"),         -- Source < Pattern                   "XXX",                   Maps.Identity)                       /= 0 or         B10.Count(AtoE_Bnd_Str,                        -- Source = Pattern                   "abcde")                             /= 1 or         B10.Count(B10.Null_Bounded_String,             -- Source = Null                   " ")                                 /= 0      then         Report.Failed           ("Incorrect result from function Count, w,w/o mapping");      end if;                                               -- Procedure Translate      -- Partial mapping of source.      Test_String := B10.To_Bounded_String("abcdeabcab");      B10.Translate(Source => Test_String, Mapping => AB_to_YZ_Map);      if Test_String /= B10.To_Bounded_String("yzcdeyzcyz") then         Report.Failed("Incorrect result from procedure Translate - 1");      end if;      -- Total mapping of source.      Test_String := B10.To_Bounded_String("abbaaababb");      B10.Translate(Source => Test_String, Mapping => ASC.Upper_Case_Map);      if Test_String /= B10.To_Bounded_String("ABBAAABABB") then         Report.Failed("Incorrect result from procedure Translate - 2");      end if;      -- No mapping of source.      Test_String := B10.To_Bounded_String("xyzsypcc");      B10.Translate(Source => Test_String, Mapping => AB_to_YZ_Map);      if Test_String /= B10.To_Bounded_String("xyzsypcc") then         Report.Failed("Incorrect result from procedure Translate - 3");      end if;      -- Map > 2 characters, partial mapping.      Test_String := B10.To_Bounded_String("have faith");      B10.Translate(Test_String,                     Maps.To_Mapping("aeiou", "AEIOU"));      if Test_String /= B10.To_Bounded_String("hAvE fAIth") then         Report.Failed("Incorrect result from procedure Translate - 4");      end if;      -- Function Replace_Slice      -- Evaluate function Replace_Slice with       -- a variety of Truncation options.      -- Drop = Error (Default)      begin         Test_String   := AtoJ_Bnd_Str;         Result_String :=            B10.Replace_Slice(Source => Test_String,  -- "abcdefghij"                             Low    => 3,                             High   => 5,            -- 3-5, 3 chars.                             By     => "xxxxxx");    -- more than 3.         Report.Failed("Length_Error not raised by Function Replace_Slice");      exception         when AS.Length_Error => null;   -- Correct exception raised.         when others          =>            Report.Failed              ("Incorrect exception raised by Function Replace_Slice");      end;      -- Drop = Left                                                                Result_String :=         B10.Replace_Slice(Source => Test_String,  -- "abcdefghij"                          Low    =>  7,                          High   => 10,           -- 7-10, 4 chars.                          By     => "xxxxxx",     --  6 chars.                          Drop   => Ada.Strings.Left);      if Result_String /= B10.To_Bounded_String("cdefxxxxxx") then -- drop a,b         Report.Failed           ("Incorrect result from Function Replace Slice, Drop = Left");      end if;      -- Drop = Right      Result_String :=         B10.Replace_Slice(Source => Test_String, -- "abcdefghij"                          Low    =>  2,                          High   =>  5,          -- 2-5, 4 chars.                          By     => "xxxxxx",    --  6 chars.                          Drop   => Ada.Strings.Right);      if Result_String /= B10.To_Bounded_String("axxxxxxfgh") then -- drop i,j         Report.Failed           ("Incorrect result from Function Replace Slice, Drop = Right");      end if;      -- Low = High = Source'Last, "By" length = 1.      if B10.Replace_Slice(AtoE_Bnd_Str,                           B10.To_String(AtoE_Bnd_Str)'Last,                           B10.To_String(AtoE_Bnd_Str)'Last,                           "X",                           Ada.Strings.Error)  /=         B10.To_Bounded_String("abcdX")      then         Report.Failed("Incorrect result from Function Replace_Slice");      end if;      -- Procedure Replace_Slice      -- Evaluate procedure Replace_Slice with       -- a variety of Truncation options.      -- Drop = Error (Default)      begin         Test_String := AtoJ_Bnd_Str;         B10.Replace_Slice(Source => Test_String,  -- "abcdefghij"                           Low    => 3,                           High   => 5,            -- 3-5, 3 chars.                           By     => "xxxxxx");    -- more than 3.         Report.Failed("Length_Error not raised by Procedure Replace_Slice");      exception         when AS.Length_Error => null;   -- Correct exception raised.         when others          =>            Report.Failed              ("Incorrect exception raised by Procedure Replace_Slice");      end;      -- Drop = Left                                                                Test_String := AtoJ_Bnd_Str;      B10.Replace_Slice(Source => Test_String,  -- "abcdefghij"                        Low    =>  7,                        High   =>  9,           -- 7-9, 3 chars.                        By     => "xxxxx",      --  5 chars.                        Drop   => Ada.Strings.Left);      if Test_String /= B10.To_Bounded_String("cdefxxxxxj") then -- drop a,b         Report.Failed           ("Incorrect result from Procedure Replace Slice, Drop = Left");      end if;      -- Drop = Right      Test_String := AtoJ_Bnd_Str;      B10.Replace_Slice(Source => Test_String,  -- "abcdefghij"                        Low    =>  1,                        High   =>  3,           -- 1-3, 3chars.                        By     => "xxxx",       --  4 chars.                        Drop   => Ada.Strings.Right);      if Test_String /= B10.To_Bounded_String("xxxxdefghi") then  -- drop j         Report.Failed           ("Incorrect result from Procedure Replace Slice, Drop = Right");      end if;      -- High = Source'First, Low > High (Insert before Low).      Test_String := AtoE_Bnd_Str;      B10.Replace_Slice(Source => Test_String,  -- "abcde"                        Low    => B10.To_String(Test_String)'Last,                        High   => B10.To_String(Test_String)'First,                        By     => "XXXX",       --  4 chars.                        Drop   => Ada.Strings.Right);      if Test_String /= B10.To_Bounded_String("abcdXXXXe") then          Report.Failed           ("Incorrect result from Procedure Replace Slice");      end if;      -- Function Insert with Truncation      -- Drop = Error (Default).      begin         Result_String :=            B10.Insert(Source   => AtoJ_Bnd_Str,    -- "abcdefghij"                      Before   => 2,                      New_Item => "xyz");         Report.Failed("Length_Error not raised by Function Insert");      exception         when AS.Length_Error => null;  -- Correct exception raised.         when others          =>             Report.Failed("Incorrect exception raised by Function Insert");      end;      -- Drop = Left      Result_String :=        B10.Insert(Source   => AtoJ_Bnd_Str,      -- "abcdefghij"                   Before   => 5,                   New_Item => "xyz",             -- 3 additional chars.                   Drop     => Ada.Strings.Left);      if B10.To_String(Result_String) /= "dxyzefghij" then   -- drop a, b, c         Report.Failed("Incorrect result from Function Insert, Drop = Left");      end if;      -- Drop = Right      Result_String :=         B10.Insert(Source   => B10.To_Bounded_String("abcdef"),                   Before   => 2,                   New_Item => "vwxyz",             -- 5 additional chars.                   Drop     => Ada.Strings.Right);      if B10.To_String(Result_String) /= "avwxyzbcde" then     -- drop f.         Report.Failed("Incorrect result from Function Insert, Drop = Right");      end if;      -- Additional cases.      if B10.Insert(B10.To_Bounded_String("a"), 1, " B") /=            B10.To_Bounded_String(" Ba")                       or         B10.Insert(B10.Null_Bounded_String, 1, "abcde") /=         AtoE_Bnd_Str                                       or         B10.Insert(B10.To_Bounded_String("ab"), 2, "")  /=         B10.To_Bounded_String("ab")      then         Report.Failed("Incorrect result from Function Insert");      end if;      -- Procedure Insert      -- Drop = Error (Default).      begin         Test_String := AtoJ_Bnd_Str;         B10.Insert(Source   => Test_String,    -- "abcdefghij"                    Before   => 9,                    New_Item => "wxyz",                    Drop     => Ada.Strings.Error);         Report.Failed("Length_Error not raised by Procedure Insert");      exception         when AS.Length_Error => null;  -- Correct exception raised.         when others          =>             Report.Failed("Incorrect exception raised by Procedure Insert");      end;      -- Drop = Left            Test_String := AtoJ_Bnd_Str;      B10.Insert(Source   => Test_String,             -- "abcdefghij"                 Before   => B10.Length(Test_String), -- before last char                 New_Item => "xyz",                   -- 3 additional chars.                 Drop     => Ada.Strings.Left);      if B10.To_String(Test_String) /= "defghixyzj" then     -- drop a, b, c         Report.Failed("Incorrect result from Procedure Insert, Drop = Left");      end if;      -- Drop = Right      Test_String := AtoJ_Bnd_Str;      B10.Insert(Source   => Test_String,                 Before   => 4,                 New_Item => "yz",             -- 2 additional chars.                 Drop     => Ada.Strings.Right);      if B10.To_String(Test_String) /= "abcyzdefgh" then     -- drop i,j         Report.Failed           ("Incorrect result from Procedure Insert, Drop = Right");      end if;      -- Before = Source'First, New_Item length = 1.      Test_String := B10.To_Bounded_String(" abc ");      B10.Insert(Test_String,                  B10.To_String(Test_String)'First,                 "Z");      if Test_String /= B10.To_Bounded_String("Z abc ") then         Report.Failed("Incorrect result from Procedure Insert");      end if;   exception      when others => Report.Failed("Exception raised in  Test_Block");   end Test_Block;   Report.Result;end CXA4008;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?