⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cxa4019.a

📁 Mac OS X 10.4.9 for x86 Source Code gcc 实现源代码
💻 A
📖 第 1 页 / 共 3 页
字号:
        B10.Index(Source  => B10.To_Bounded_Wide_String("foxy fox 2"),                  Pattern => "FOX",                  Going   => Ada.Strings.Backward,                  Mapping => ASWC.Upper_Case_Map);      if Location /= 6 then         Report.Failed("Incorrect result from Index, non-Identity map - 1");      end if;      Location :=         B10.Index(B10.To_Bounded_Wide_String("THE QUICK "),                  "quick",                  Ada.Strings.Forward,                  Ada.Strings.Wide_Maps.Wide_Constants.Lower_Case_Map);      if Location /= 5 then         Report.Failed("Incorrect result from Index, non-Identity map - 2");      end if;      Location := B10.Index(Source  => B10.To_Bounded_Wide_String("The the"),                            Pattern => "the",                            Going   => Ada.Strings.Forward,                            Mapping => ASWC.Lower_Case_Map);       if Location /= 1 then         Report.Failed("Incorrect result from Index, non-Identity map - 3");      end if;      if B10.Index(B10.To_Bounded_Wide_String("abcd"),   -- Pattern = Source                   "abcd")                       /= 1 or         B10.Index(B10.To_Bounded_Wide_String("abc"),    -- Pattern < Source                   "abcd")                       /= 0 or         B10.Index(B10.Null_Bounded_Wide_String,         -- Source = Null                   "abc")                        /= 0       then         Report.Failed("Incorrect result from Index with string patterns");      end if;      -- Function Index with access-to-subprogram mapping value.       -- Evaluate the function Index with a wide character mapping function      -- object that performs the mapping operation.      Location := B10.Index(Source  => B10.To_Bounded_Wide_String("My dog"),                            Pattern => "cat",                            Going   => Ada.Strings.Forward,                            Mapping => Map_Ptr);  -- change "dog" to "cat"      if Location /= 4 then         Report.Failed("Incorrect result from Index, w/map ptr - 1");      end if;      Location := B10.Index(B10.To_Bounded_Wide_String("cat or dog"),                            "cat",                            Ada.Strings.Backward,                            Map_Ptr);         if Location /= 8 then         Report.Failed("Incorrect result from Index, w/map ptr - 2");      end if;      if B10.Index(B10.To_Bounded_Wide_String("dog"),   -- Pattern = Source                   "cat",                   Ada.Strings.Forward,                   Map_Ptr)                            /= 1 or         B10.Index(B10.To_Bounded_Wide_String("dog"),    -- Pattern < Source                   "cats",                   Ada.Strings.Backward,                   Map_Ptr)                            /= 0 or         B10.Index(B10.Null_Bounded_Wide_String,         -- Source = Null                   "cat",                   Ada.Strings.Forward,                   Map_Ptr)                            /= 0 or         B10.Index(B10.To_Bounded_Wide_String("hot dog"),                   "dog",                   Ada.Strings.Backward,                   Map_Ptr)                            /= 0 or         B10.Index(B10.To_Bounded_Wide_String(" cat dog "),                   " cat",                   Ada.Strings.Backward,                   Map_Ptr)                           /= 5 or         B10.Index(B10.To_Bounded_Wide_String("dog CatDog"),                   "cat",                   Ada.Strings.Backward,                   Map_Ptr)                           /= 1 or         B10.Index(B10.To_Bounded_Wide_String("CatandDog"),                   "cat",                   Ada.Strings.Forward,                   Map_Ptr)                           /= 0 or         B10.Index(B10.To_Bounded_Wide_String("dddd"),                   "ccccc",                   Ada.Strings.Backward,                   Map_Ptr)                           /= 0      then         Report.Failed("Incorrect result from Index w/map ptr - 3");      end if;      -- Function Index (for Sets).                 -- This version of Index uses Sets as the basis of the search.      -- Test = Inside, Going = Forward  (Default case).      Location :=         B10.Index(Source => B10.To_Bounded_Wide_String(Equiv("abcdeabcde")),                  Set    => Wide_CD_Set,                   Test   => Ada.Strings.Inside,                  Going  => Ada.Strings.Forward);      if not (Location = 3) then -- position of first 'c' equivalent in source.         Report.Failed("Incorrect result from Index using Sets - 1");      end if;      -- Test = Inside, Going = Backward.      Location :=         B10.Index(Source => B10."&"(AtoE_Bnd_Str, AtoE_Bnd_Str),                   Set    => Wide_CD_Set,                   Test   => Ada.Strings.Inside,                  Going  => Ada.Strings.Backward);      if not (Location = 9) then   -- position of last 'd' in source.         Report.Failed("Incorrect result from Index using Sets - 2");      end if;      -- Test = Outside, Going = Forward.      Location := B10.Index(B10.To_Bounded_Wide_String("deddacd"),                              CD_Set,                            Test  => Ada.Strings.Outside,                            Going => Ada.Strings.Forward);      if Location /= 2  then  -- position of 'e' in source.         Report.Failed("Incorrect result from Index using Sets - 3");      end if;      -- Test = Outside, Going = Backward.      Location := B10.Index(B10.To_Bounded_Wide_String(Equiv("deddacd")),                            Wide_CD_Set,                            Ada.Strings.Outside,                            Ada.Strings.Backward);      if Location /= 5 then    -- position of 'a', correct.         Report.Failed("Incorrect result from Index using Sets - 4");      end if;      if B10.Index(B10.To_Bounded_Wide_String("cd"),   -- Source = Set                   CD_Set)                     /= 1 or         B10.Index(B10.To_Bounded_Wide_String("c"),    -- Source < Set                   CD_Set)                     /= 1 or         B10.Index(B10.Null_Bounded_Wide_String,       -- Source = Null                   Wide_CD_Set)                /= 0 or         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_Wide_String("THE THE TH"),                  Pattern => "th",                  Mapping => ASWC.Lower_Case_Map);      if Total_Count /= 3 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_Wide_String(Equiv("ABABABABAB")),                   Equiv("ABA"),                   Maps.Identity)                       /= 2 or         B10.Count(B10.To_Bounded_Wide_String("ADCBADABCD"),                   "AB",                   Maps.To_Mapping("CD", "AB"))         /= 5 or         B10.Count(B10.To_Bounded_Wide_String(Equiv("aaaaaaaaaa")),                   Equiv("aaa"))                        /= 3 or         B10.Count(B10.To_Bounded_Wide_String(Equiv("XX")),                   Equiv("XXX"),                   Maps.Identity)                       /= 0 or         B10.Count(AtoE_Bnd_Str,                        -- Source = Pattern                   Equiv("abcde"))                      /= 1 or         B10.Count(B10.Null_Bounded_Wide_String,        -- Source = Null                   " ")                                 /= 0      then         Report.Failed           ("Incorrect result from function Count, w,w/o mapping");      end if;                                               -- Function Count with access-to-subprogram mapping.       -- Evaluate the version function Count that uses an access-to-subprogram      -- map parameter.      Total_Count :=         B10.Count(Source  => B10.To_Bounded_Wide_String("dogdogdo"),                  Pattern => "ca",                  Mapping => Map_Ptr);      if Total_Count /= 3 then             Report.Failed           ("Incorrect result from function Count, w/map ptr - 1");      end if;      if B10.Count(B10.To_Bounded_Wide_String("DdOoGgod"),                   "c",                   Map_Ptr)                                 /= 2 or         B10.Count(B10.To_Bounded_Wide_String("dododododo"),                   "do",                   Map_Ptr)                                 /= 0 or         B10.Count(B10.To_Bounded_Wide_String("Dog or dog"),                   "cat",                   Map_Ptr)                                 /= 1 or         B10.Count(B10.To_Bounded_Wide_String("dddddddddd"),                   "ccccc",                   Map_Ptr)                                 /= 2 or         B10.Count(B10.To_Bounded_Wide_String("do"),    -- Source < Pattern                   "cat",                   Map_Ptr)                                 /= 0 or         B10.Count(B10.To_Bounded_Wide_String(" dog "), -- Source = Pattern                   " cat ",                   Map_Ptr)                                 /= 1 or         B10.Count(B10.Null_Bounded_Wide_String,        -- Source = Null                   " ",                   Map_Ptr)                                 /= 0      then         Report.Failed           ("Incorrect result from function Count, w/map ptr - 2");      end if;      -- Procedure Translate         -- Partial mapping of source.      Test_String := B10.To_Bounded_Wide_String("abcdeabcab");      B10.Translate(Source => Test_String, Mapping => AB_to_YZ_Map);      if Test_String /= B10.To_Bounded_Wide_String("yzcdeyzcyz") then         Report.Failed("Incorrect result from procedure Translate - 1");      end if;      -- Total mapping of source.      Test_String := B10.To_Bounded_Wide_String("abbaaababb");      B10.Translate(Source => Test_String, Mapping => ASWC.Upper_Case_Map);      if Test_String /= B10.To_Bounded_Wide_String("ABBAAABABB") then         Report.Failed("Incorrect result from procedure Translate - 2");      end if;      -- No mapping of source.      Test_String := B10.To_Bounded_Wide_String(Equiv("xyzsypcc"));      B10.Translate(Source => Test_String, Mapping => Wide_AB_to_YZ_Map);      if Test_String /= B10.To_Bounded_Wide_String(Equiv("xyzsypcc")) then         Report.Failed("Incorrect result from procedure Translate - 3");      end if;      -- Map > 2 characters, partial mapping.      Test_String := B10.To_Bounded_Wide_String("opabcdelmn");      B10.Translate(Test_String,                     Maps.To_Mapping("abcde", "lmnop"));      if Test_String /= B10.To_Bounded_Wide_String("oplmnoplmn") then         Report.Failed("Incorrect result from procedure Translate - 4");      end if;      -- Procedure Translate with access-to-subprogram mapping.      -- Use the version of Procedure Translate that takes an      -- access-to-subprogram parameter to perform the Source mapping.      -- Partial mapping of source.      Test_String := B10.To_Bounded_Wide_String("dogeatdog");      B10.Translate(Source => Test_String, Mapping => Map_Ptr);      if Test_String /= B10.To_Bounded_Wide_String("cateatcat") then         Report.Failed           ("Incorrect result from procedure Translate w/map ptr - 1");      end if;      Test_String := B10.To_Bounded_Wide_String("odogcatlmn");      B10.Translate(Test_String, Map_Ptr);      if Test_String /= B10.To_Bounded_Wide_String("acatcatlmn") then         Report.Failed           ("Incorrect result from procedure Translate w/map ptr - 2");      end if;      -- Total mapping of source.      Test_String := B10.To_Bounded_Wide_String("gggooooddd");      B10.Translate(Source => Test_String, Mapping => Map_Ptr);      if Test_String /= B10.To_Bounded_Wide_String("tttaaaaccc") then         Report.Failed           ("Incorrect result from procedure Translate w/map ptr- 3");      end if;      -- No mapping of source.      Test_String := B10.To_Bounded_Wide_String(" DOG cat ");      B10.Translate(Source => Test_String, Mapping => Map_Ptr);      if Test_String /= B10.To_Bounded_Wide_String(" DOG cat ") then         Report.Failed           ("Incorrect result from procedure Translate w/map ptr - 4");      end if;      Test_String := B10.Null_Bounded_Wide_String;      B10.Translate(Source => Test_String, Mapping => Map_Ptr);

⌨️ 快捷键说明

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