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

📄 cxa4030.a

📁 用于进行gcc测试
💻 A
📖 第 1 页 / 共 2 页
字号:
      then         Report.Failed("Incorrect results from Function Index, going "     &                       "in Backward direction, using a Character Mapping " &                       "Function parameter");      end if;      -- Function Index, Pattern_Error if Pattern = Null_String      declare         use Unbounded;         Null_String : constant String := "";         TC_Natural  : Natural         := 1000;      begin         TC_Natural := Index(To_Unbounded_String("A Valid Unbounded String"),                              Null_String,                             Going   => Ada.Strings.Forward,                             Mapping => Handling.To_Lower'Access);         Report.Failed("Pattern_Error not raised by Function Index when " &                       "given a null pattern string");      exception         when Pattern_Error => null;   -- OK, expected exception.         when others        =>            Report.Failed("Incorrect exception raised by Function Index " &                          "using a Character Mapping Function parameter " &                          "when given a null pattern string");      end;      -- Function Count.      if Unb.Count(Source  => Unb.To_Unbounded_String("ABABABA"),                          Pattern => "aba",                   Mapping => Map_To_Lower_Case_Ptr)   /=  2   or         Unb.Count(Unb.To_Unbounded_String("ABABABA"),                    "ABA",                    Mapping => Map_To_Lower_Case_Ptr)   /=  0   or         Unb.Count(Unb.To_Unbounded_String("This IS a MISmatched issue"),                   "is",                   Handling.To_Lower'Access)           /=  4   or         Unb.Count(Unb.To_Unbounded_String("ABABABA"),                    "ABA",                    Map_To_Upper_Case_Ptr)              /=  2   or         Unb.Count(Unb.To_Unbounded_String("This IS a MISmatched issue"),                   "is",                   Mapping => Map_To_Upper_Case_Ptr)   /=  0   or         Unb.Count(Unb.To_Unbounded_String(                     "She sells sea shells by the sea shore"),                   "s",                   Handling.To_Lower'Access)           /=  8   or         Unb.Count(Unb.Null_Unbounded_String,                         "match",                   Map_To_Upper_Case_Ptr)              /=  0      then         Report.Failed("Incorrect results from Function Count, using " &                       "a Character Mapping Function parameter");      end if;      -- Function Count, Pattern_Error if Pattern = Null_String      declare         use Ada.Strings.Unbounded;         Null_Pattern_String : constant String := "";         TC_Natural          : Natural         := 1000;      begin         TC_Natural := Count(To_Unbounded_String("A Valid String"),                              Null_Pattern_String,                             Map_To_Lower_Case_Ptr);         Report.Failed("Pattern_Error not raised by Function Count using " &                       "a Character Mapping Function parameter when "      &                       "given a null pattern string");      exception         when Pattern_Error => null;   -- OK, expected exception.         when others        =>            Report.Failed("Incorrect exception raised by Function Count " &                          "using a Character Mapping Function parameter " &                          "when given a null pattern string");      end;      -- Function Translate.      if Unb.Translate(Source  => Unb.To_Unbounded_String(                                    "A Sample Mixed Case String"),                       Mapping => Map_To_Lower_Case_Ptr)           /=          Unb.To_Unbounded_String("a sample mixed case string")       or         Unb.Translate(Unb.To_Unbounded_String("ALL LOWER CASE"),                       Handling.To_Lower'Access)                   /=          Unb.To_Unbounded_String("all lower case")                   or         Unb.Translate(Unb.To_Unbounded_String("end with lower case"),                       Map_To_Lower_Case_Ptr)                      /=          Unb.To_Unbounded_String("end with lower case")              or         Unb.Translate(Unb.Null_Unbounded_String,                       Handling.To_Lower'Access)                   /=         Unb.Null_Unbounded_String                                   or         Unb.Translate(Unb.To_Unbounded_String("start with lower case"),                       Map_To_Upper_Case_Ptr)                      /=          Unb.To_Unbounded_String("START WITH LOWER CASE")            or         Unb.Translate(Unb.To_Unbounded_String("ALL UPPER CASE STRING"),                       Handling.To_Upper'Access)                   /=         Unb.To_Unbounded_String("ALL UPPER CASE STRING")            or         Unb.Translate(Unb.To_Unbounded_String(                         "LoTs Of MiXeD CaSe ChArAcTeRs"),                       Map_To_Upper_Case_Ptr)                      /=         Unb.To_Unbounded_String("LOTS OF MIXED CASE CHARACTERS")    or         Unb.Translate(New_Character_String,                        Handling.To_Upper'Access)                   /=         TC_New_Character_String      then         Report.Failed("Incorrect results from Function Translate, using " &                       "a Character Mapping Function parameter");      end if;      -- Procedure Translate.      declare         use Ada.Strings.Unbounded;         use Ada.Characters.Handling;         Str_1    : Unbounded_String :=                       To_Unbounded_String("AN ALL UPPER CASE STRING");         Str_2    : Unbounded_String :=                       To_Unbounded_String("A Mixed Case String");         Str_3    : Unbounded_String :=                       To_Unbounded_String("a string with lower case letters");         TC_Str_1 : constant Unbounded_String := Str_1;         TC_Str_3 : constant Unbounded_String := Str_3;      begin         Translate(Source => Str_1, Mapping => Map_To_Lower_Case_Ptr);         if Str_1 /= To_Unbounded_String("an all upper case string") then            Report.Failed("Incorrect result from Procedure Translate - 1");         end if;         Translate(Source => Str_1, Mapping => Map_To_Upper_Case_Ptr);         if Str_1 /= TC_Str_1 then            Report.Failed("Incorrect result from Procedure Translate - 2");         end if;         Translate(Str_2, Mapping => Map_To_Lower_Case_Ptr);         if Str_2 /= To_Unbounded_String("a mixed case string") then            Report.Failed("Incorrect result from Procedure Translate - 3");         end if;         Translate(Str_2, Mapping => To_Upper'Access);         if Str_2 /= To_Unbounded_String("A MIXED CASE STRING") then            Report.Failed("Incorrect result from Procedure Translate - 4");         end if;         Translate(Str_3, To_Lower'Access);         if Str_3 /= TC_Str_3 then            Report.Failed("Incorrect result from Procedure Translate - 5");         end if;         Translate(Str_3, To_Upper'Access);         if Str_3 /=             To_Unbounded_String("A STRING WITH LOWER CASE LETTERS")         then            Report.Failed("Incorrect result from Procedure Translate - 6");         end if;         Translate(New_Character_String, Map_To_Upper_Case_Ptr);         if New_Character_String /= TC_New_Character_String then            Report.Failed("Incorrect result from Procedure Translate - 6");         end if;      end;   exception      when others => Report.Failed ("Exception raised in Test_Block");   end Test_Block;   Report.Result;end CXA4030;

⌨️ 快捷键说明

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