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

📄 cxa4018.a

📁 用于进行gcc测试
💻 A
📖 第 1 页 / 共 2 页
字号:
      -- Use of Function Replicate that involves dropping wide characters.      -- The attempt to replicate the 15 character wide string six times will      -- exceed the 80 wide character bound of the wide string.  Therefore,       -- the result should be the catenation of 5 copies of the 15 character       -- wide string, followed by 5 'A' wide characters (the first five wide       -- characters of the 6th replication) with the remaining wide       -- characters of the 6th replication dropped.      Drop_String :=          BS80.Replicate(Count => 6,                                           Item  => ABStr,              -- "AAAAABBBBBBBBBB"                        Drop  => Ada.Strings.Right);       if BS80.Element(Drop_String, 1)  /= Translate('A') or         BS80.Element(Drop_String, 6)  /= Translate('B') or         BS80.Element(Drop_String, 76) /= Translate('A') or         BS80.Element(Drop_String, 80) /= Translate('A')       then         Report.Failed("Incorrect result from Replicate with Drop");      end if;      -- Use function Index_Non_Blank in the evaluation of the      -- Constructed_String.      if BS80.Index_Non_Blank(Constructed_String, Ada.Strings.Forward)  /=         BS80.To_Wide_String(Constructed_String)'First                    or         BS80.Index_Non_Blank(Constructed_String, Ada.Strings.Backward) /=         BS80.Length(Constructed_String)      then         Report.Failed("Incorrect results from constructor functions");      end if;      declare         -- Define wide character set objects for use with the Count function.         -- Constructed_String = "AABBBBCCCCCCDDDDDDEEEEFF" from above.         A_Set : Ada.Strings.Wide_Maps.Wide_Character_Set :=                 Ada.Strings.Wide_Maps.To_Set(BS80.Element(Constructed_String,                                                           1));         B_Set : Ada.Strings.Wide_Maps.Wide_Character_Set :=                 Ada.Strings.Wide_Maps.To_Set(BS80.Element(Constructed_String,                                                           3));         C_Set : Ada.Strings.Wide_Maps.Wide_Character_Set :=                 Ada.Strings.Wide_Maps.To_Set(BS80.Element(Constructed_String,                                                           7));         D_Set : Ada.Strings.Wide_Maps.Wide_Character_Set :=                 Ada.Strings.Wide_Maps.To_Set(BS80.Element(Constructed_String,                                                           13));         E_Set : Ada.Strings.Wide_Maps.Wide_Character_Set :=                 Ada.Strings.Wide_Maps.To_Set(BS80.Element(Constructed_String,                                                           19));         F_Set : Ada.Strings.Wide_Maps.Wide_Character_Set :=                 Ada.Strings.Wide_Maps.To_Set(BS80.Element(Constructed_String,                                                           23));         Start : Positive;         Stop  : Natural  := 0;      begin         -- Evaluate the results from function Count by comparing the number         -- of A's to the number of F's, B's to E's, and C's to D's in the         -- Constructed_String.           -- There should be an equal number of each of the wide characters that          -- are being compared (i.e., 2 A's and F's, 4 B's and E's, etc)         if BS80.Count(Constructed_String, A_Set)      /=             BS80.Count(Constructed_String, F_Set)        or            BS80.Count(Constructed_String, B_Set)      /=             BS80.Count(Constructed_String, E_Set)        or            not (BS80.Count(Constructed_String, C_Set)  =                   BS80.Count(Constructed_String, D_Set))           then            Report.Failed("Incorrect result from function Count");         end if;         -- Evaluate the functions Head, Tail, and Find_Token.         -- Create the Token_String from the Constructed_String above.         Token_String :=            BS80.Tail(BS80.Head(Constructed_String,  3), 2) &     -- "AB" &           BS80.Head(BS80.Tail(Constructed_String, 13), 2) &     -- "CD" &           BS80.Head(BS80.Tail(Constructed_String,  3), 2);      -- "EF"         if Token_String /=             BS80.To_Bounded_Wide_String(Translate("ABCDEF")) then            Report.Failed("Incorrect result from Catenation of Token_String");         end if;         -- Find the starting/ending position of the first A in the          -- Token_String (both should be 1, only one A appears in string).         -- The Function Head uses the default pad character to return a         -- bounded wide string longer than its input parameter bounded          -- wide string.         BS80.Find_Token(BS80.Head(Token_String, 10),  -- Default pad.                         A_Set,                         Ada.Strings.Inside,                         Start,                         Stop);         if Start /= 1 and Stop /= 1 then            Report.Failed("Incorrect result from Find_Token - 1");         end if;         -- Find the starting/ending position of the first non-AB slice in         -- the "head" five wide characters of Token_String (slice CDE at          -- positions 3-5)         BS80.Find_Token(BS80.Head(Token_String, 5),               -- "ABCDE"                         Ada.Strings.Wide_Maps."OR"(A_Set, B_Set), -- Set (AB)                         Ada.Strings.Outside,                         Start,                         Stop);         if Start /= 3 and Stop /= 5 then            Report.Failed("Incorrect result from Find_Token - 2");         end if;         -- Find the starting/ending position of the first CD slice in         -- the "tail" eight wide characters (including two pad wide          -- characters) of Token_String (slice CD at positions 5-6 of          -- the tail portion specified)         BS80.Find_Token(BS80.Tail(Token_String, 8,                                    Ada.Strings.Wide_Space),                          Ada.Strings.Wide_Maps."OR"(C_Set, D_Set),                         Ada.Strings.Inside,                         Start,                         Stop);         if Start /= 5 and Stop /= 6 then            Report.Failed("Incorrect result from Find_Token - 3");         end if;         -- Evaluate the Replace_Element function.         -- Token_String = "ABCDEF"         BS80.Replace_Element(Token_String, 3, BS80.Element(Token_String,4));         -- Token_String = "ABDDEF"         BS80.Replace_Element(Source => Token_String,                              Index  => 2,                              By     => BS80.Element(Token_String, 5));         -- Token_String = "AEDDEF"         BS80.Replace_Element(Token_String,                               1,                               BS80.Element(BS80.Tail(Token_String, 2), 2));         -- Token_String = "FEDDEF"         -- Evaluate this result.         if BS80.Element(Token_String,                          BS80.To_Wide_String(Token_String)'First)  /=            BS80.Element(Token_String,                          BS80.To_Wide_String(Token_String)'Last)     or            BS80.Count(Token_String, D_Set)                        /=            BS80.Count(Token_String, E_Set)                          or            BS80.Index_Non_Blank(BS80.Head(Token_String,6))        /=            BS80.Index_Non_Blank(BS80.Tail(Token_String,6))          or            BS80.Head(Token_String, 1)                             /=            BS80.Tail(Token_String, 1)         then            Report.Failed("Incorrect result from operations in combination");         end if;      end;   exception      when others => Report.Failed ("Exception raised in Test_Block");   end Test_Block;   Report.Result;end CXA4018;

⌨️ 快捷键说明

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