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

📄 cxa4026.a

📁 Mac OS X 10.4.9 for x86 Source Code gcc 实现源代码
💻 A
📖 第 1 页 / 共 2 页
字号:
      -- Function Count.      if Fixed.Count(Source  => "ABABABA",                             Pattern => "aba",                     Mapping => Map_To_Lower_Case_Ptr)        /=  2   or         Fixed.Count("ABABABA", "ABA", Map_To_Lower_Case_Ptr) /=  0   or         Fixed.Count("This IS a MISmatched issue",                     "is",                     Map_To_Lower_Case_Ptr)                   /=  4   or         Fixed.Count("ABABABA", "ABA", Map_To_Upper_Case_Ptr) /=  2   or         Fixed.Count("This IS a MISmatched issue",                     "is",                     Map_To_Upper_Case_Ptr)                   /=  0   or         Fixed.Count("She sells sea shells by the sea shore",                     "s",                     Map_To_Lower_Case_Ptr)                   /=  8   or         Fixed.Count("",                       -- Null 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.Fixed;         Null_Pattern_String : constant String := "";         TC_Natural          : Natural         := 1000;      begin         TC_Natural := Count("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 Fixed.Translate(Source  => "A Sample Mixed Case String",                         Mapping => Map_To_Lower_Case_Ptr) /=          "a sample mixed case string"                         or         Fixed.Translate("ALL LOWER CASE",                         Map_To_Lower_Case_Ptr)            /=          "all lower case"                                     or         Fixed.Translate("end with lower case",                         Map_To_Lower_Case_Ptr)            /=          "end with lower case"                                or         Fixed.Translate("", Map_To_Lower_Case_Ptr)        /=         ""                                                   or         Fixed.Translate("start with lower case",                         Map_To_Upper_Case_Ptr)            /=          "START WITH LOWER CASE"                              or         Fixed.Translate("ALL UPPER CASE STRING",                         Map_To_Upper_Case_Ptr)            /=         "ALL UPPER CASE STRING"                              or         Fixed.Translate("LoTs Of MiXeD CaSe ChArAcTeRs",                         Map_To_Upper_Case_Ptr)            /=         "LOTS OF MIXED CASE CHARACTERS"                      or         Fixed.Translate("", Map_To_Upper_Case_Ptr)        /=         ""                                                   or         Fixed.Translate(New_Character_String,                         Map_To_Upper_Case_Ptr)            /=         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.Fixed;         Str_1    : String(1..24)   := "AN ALL UPPER CASE STRING";         Str_2    : String(1..19)   := "A Mixed Case String";         Str_3    : String(1..32)   := "a string with lower case letters";         TC_Str_1 : constant String := Str_1;         TC_Str_3 : constant String := Str_3;      begin         Translate(Source => Str_1, Mapping => Map_To_Lower_Case_Ptr);         if Str_1 /= "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(Source => Str_2, Mapping => Map_To_Lower_Case_Ptr);         if Str_2 /= "a mixed case string" then            Report.Failed("Incorrect result from Procedure Translate - 3");         end if;         Translate(Source => Str_2, Mapping => Map_To_Upper_Case_Ptr);         if Str_2 /= "A MIXED CASE STRING" then            Report.Failed("Incorrect result from Procedure Translate - 4");         end if;         Translate(Source => Str_3, Mapping => Map_To_Lower_Case_Ptr);         if Str_3 /= TC_Str_3 then            Report.Failed("Incorrect result from Procedure Translate - 5");         end if;         Translate(Source => Str_3, Mapping => Map_To_Upper_Case_Ptr);         if Str_3 /= "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;      -- Procedure Trim.      declare         Use Ada.Strings.Fixed;         Trim_String : String(1..30) := "    A string of characters    ";      begin         Trim(Source  => Trim_String,              Side    => Ada.Strings.Left,              Justify => Ada.Strings.Right,              Pad     => 'x');                  if Trim_String /= "xxxxA string of characters    " then            Report.Failed("Incorrect result from Procedure Trim, trim " &                          "side = left, justify = right, pad = x");         end if;         Trim(Trim_String, Ada.Strings.Right, Ada.Strings.Center);         if Trim_String /= "  xxxxA string of characters  " then            Report.Failed("Incorrect result from Procedure Trim, trim " &                          "side = right, justify = center, default pad");         end if;         Trim(Trim_String, Ada.Strings.Both, Pad => '*');         if Trim_String /= "xxxxA string of characters****" then            Report.Failed("Incorrect result from Procedure Trim, trim " &                          "side = both, default justify, pad = *");         end if;      end;      -- Procedure Head.      declare         Fixed_String : String(1..20) := "A sample test string";      begin         Fixed.Head(Source  => Fixed_String,                    Count   => 14,                    Justify => Ada.Strings.Center,                    Pad     => '$');         if Fixed_String /= "$$$A sample test $$$" then            Report.Failed("Incorrect result from Procedure Head, " &                          "justify = center, pad = $");         end if;         Fixed.Head(Fixed_String, 11, Ada.Strings.Right);         if Fixed_String /= "         $$$A sample" then            Report.Failed("Incorrect result from Procedure Head, " &                          "justify = right, default pad");         end if;         Fixed.Head(Fixed_String, 9, Pad => '*');          if Fixed_String /= "         ***********" then            Report.Failed("Incorrect result from Procedure Head, " &                          "default justify, pad = *");         end if;      end;      -- Procedure Tail.      declare         Use Ada.Strings.Fixed;         Tail_String : String(1..20) := "ABCDEFGHIJKLMNOPQRST";      begin         Tail(Source => Tail_String, Count => 10, Pad => '-');         if Tail_String /= "KLMNOPQRST----------" then            Report.Failed("Incorrect result from Procedure Tail, " &                          "default justify, pad = -");         end if;         Tail(Tail_String, 6, Justify => Ada.Strings.Center, Pad => 'a');         if Tail_String /= "aaaaaaa------aaaaaaa" then            Report.Failed("Incorrect result from Procedure Tail, " &                          "justify = center, pad = a");         end if;         Tail(Tail_String, 1, Ada.Strings.Right);         if Tail_String /= "                   a" then            Report.Failed("Incorrect result from Procedure Tail, " &                          "justify = right, default pad");         end if;         Tail(Tail_String, 19, Ada.Strings.Right, 'A');         if Tail_String /= "A                  a" then            Report.Failed("Incorrect result from Procedure Tail, " &                          "justify = right, pad = A");         end if;      end;   exception      when others => Report.Failed ("Exception raised in Test_Block");   end Test_Block;   Report.Result;end CXA4026;

⌨️ 快捷键说明

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