📄 cxa4033.a
字号:
-- Function To_Unbounded_Wide_String (version with Length parameter) if Length(To_Unbounded_Wide_String(Length => 10)) /= 10 or Length(To_Unbounded_Wide_String(0)) /= 0 or Length( To_Unbounded_Wide_String(10) & To_Unbounded_Wide_String(1) & To_Unbounded_Wide_String(0) ) /= 10 + 1 + 0 then Report.Failed ("Incorrect results from Function To_Unbounded_Wide_String " & "with Length parameter"); end if; -- Procedure Append (Wide_Unbounded - Wide_Unbounded) TC_Unb_String := Null_Unbounded_Wide_String; Append(TC_Unb_String, To_Unbounded_Wide_String("New Unbounded String")); if TC_Unb_String /= To_Unbounded_Wide_String("New Unbounded String") then Report.Failed("Incorrect results from Procedure Append with " & "unbounded wide string parameters"); end if; -- Procedure Append (Wide_Unbounded - Wide_String) TC_Unb_String := To_Unbounded_Wide_String("An Unbounded String and "); Append(Source => TC_Unb_String, New_Item => TC_String); if TC_Unb_String /= To_Unbounded_Wide_String("An Unbounded String and A Standard String") then Report.Failed("Incorrect results from Procedure Append with " & "an unbounded wide string parameter and a wide " & "string parameter"); end if; -- Procedure Append (Wide_Unbounded - Wide_Character) TC_Unb_String := To_Unbounded_Wide_String("Lower Case = "); for i in LC_Characters'Range loop Append(Source => TC_Unb_String, New_Item => LC_Characters(i)); end loop; if TC_Unb_String /= Unb.To_Unbounded_Wide_String ("Lower Case = abcdefghijklmnopqrstuvwxyz") then Report.Failed("Incorrect results from Procedure Append with " & "an unbounded wide string parameter and a wide " & "character parameter"); end if; -- Function "=" TC_Unb_String := To_Unbounded_Wide_String(TC_String); if not (TC_Unb_String = TC_String) or not "="("A Standard String", TC_Unb_String) or not ((Null_Unbounded_Wide_String = "") and ("Test String" = To_Unbounded_Wide_String("Test String"))) then Report.Failed("Incorrect results from Function ""="" with " & "wide_string - unbounded wide string parameters"); end if; -- Function "<" if not ("Extra Space" < To_Unbounded_Wide_String("Extra Space ") and To_Unbounded_Wide_String("tess") < "test" and To_Unbounded_Wide_String("best") < "test") then Report.Failed("Incorrect results from Function ""<"" with " & "wide string - unbounded wide string parameters"); end if; -- Function "<=" TC_Unb_String := To_Unbounded_Wide_String("Sample string"); if TC_Unb_String <= "Sample strin" or not("Sample string" <= TC_Unb_String) then Report.Failed("Incorrect results from Function ""<="" with " & "wide string - unbounded wide string parameters"); end if; -- Function ">" TC_Unb_String := To_Unbounded_Wide_String("A MUCH LONGER STRING"); if not ("A much longer string" > TC_Unb_String and To_Unbounded_Wide_String(TC_String) > "A Standard Strin" and "abcdefgh" > To_Unbounded_Wide_String("ABCDEFGH")) then Report.Failed("Incorrect results from Function "">"" with " & "wide string - unbounded wide string parameters"); end if; -- Function ">=" TC_Unb_String := To_Unbounded_Wide_String(TC_String); if not (TC_Unb_String >= TC_String and "test" >= To_Unbounded_Wide_String("tess") and To_Unbounded_Wide_String("Programming") >= "PROGRAMMING") then Report.Failed("Incorrect results from Function "">="" with " & "wide string - unbounded wide string parameters"); end if; -- Procedure Replace_Slice TC_Unb_String := To_Unbounded_Wide_String("Test String"); Replace_Slice(TC_Unb_String, 5, 5, TC_String_5); if TC_Unb_String /= To_Unbounded_Wide_String("TestABCDEString") then Report.Failed("Incorrect results from Replace_Slice - 1"); end if; Replace_Slice(TC_Unb_String, 1, 4, TC_String_5); if TC_Unb_String /= To_Unbounded_Wide_String("ABCDEABCDEString") then Report.Failed("Incorrect results from Replace_Slice - 2"); end if; -- Procedure Insert TC_Unb_String := To_Unbounded_Wide_String("Test String"); Insert(TC_Unb_String, 1, "**"); if TC_Unb_String /= To_Unbounded_Wide_String("**Test String") then Report.Failed("Incorrect results from Procedure Insert - 1"); end if; Insert(TC_Unb_String, Length(TC_Unb_String)+1, "**"); if TC_Unb_String /= To_Unbounded_Wide_String("**Test String**") then Report.Failed("Incorrect results from Procedure Insert - 2"); end if; -- Procedure Overwrite TC_Unb_String := To_Unbounded_Wide_String("Test String"); Overwrite(TC_Unb_String, 1, New_Item => "XXXX"); if TC_Unb_String /= To_Unbounded_Wide_String("XXXX String") then Report.Failed("Incorrect results from Procedure Overwrite - 1"); end if; Overwrite(TC_Unb_String, Length(TC_Unb_String)+1, "**"); if TC_Unb_String /= To_Unbounded_Wide_String("XXXX String**") then Report.Failed("Incorrect results from Procedure Overwrite - 2"); end if; -- Procedure Delete TC_Unb_String := To_Unbounded_Wide_String("Test String"); Delete(TC_Unb_String, 1, 0); if TC_Unb_String /= To_Unbounded_Wide_String("Test String") then Report.Failed("Incorrect results from Procedure Delete - 1"); end if; Delete(TC_Unb_String, 1, 5); if TC_Unb_String /= To_Unbounded_Wide_String("String") then Report.Failed("Incorrect results from Procedure Delete - 2"); end if; -- Procedure Trim TC_Unb_String := To_Unbounded_Wide_String(" Leading Spaces "); Trim(TC_Unb_String, Ada.Strings.Left); if TC_Unb_String /= To_Unbounded_Wide_String("Leading Spaces ") then Report.Failed("Incorrect results from Procedure Trim - 1"); end if; TC_Unb_String := To_Unbounded_Wide_String(" Spaces on both ends "); Trim(TC_Unb_String, Ada.Strings.Both); if TC_Unb_String /= To_Unbounded_Wide_String("Spaces on both ends") then Report.Failed("Incorrect results from Procedure Trim - 2"); end if; -- Procedure Trim (with Wide_Character_Set parameters) TC_Unb_String := To_Unbounded_Wide_String("012abcdefghGFEDCBA789ab"); Trim(TC_Unb_String, Ada.Strings.Wide_Maps.Wide_Constants.Hexadecimal_Digit_Set, Ada.Strings.Wide_Maps.Wide_Constants.Hexadecimal_Digit_Set); if TC_Unb_String /= To_Unbounded_Wide_String("ghG") then Report.Failed("Incorrect results from Procedure Trim with Sets"); end if; -- Procedure Head TC_Unb_String := To_Unbounded_Wide_String("Test String"); Head(Source => TC_Unb_String, Count => 0, Pad => '*'); if TC_Unb_String /= Null_Unbounded_Wide_String then Report.Failed("Incorrect results from Procedure Head - 1"); end if; TC_Unb_String := To_Unbounded_Wide_String("Test String"); Head(Source => TC_Unb_String, Count => 4, Pad => '*'); if TC_Unb_String /= To_Unbounded_Wide_String("Test") then Report.Failed("Incorrect results from Procedure Head - 2"); end if; -- Procedure Tail TC_Unb_String := To_Unbounded_Wide_String("Test String"); Tail(Source => TC_Unb_String, Count => 0, Pad => '*'); if TC_Unb_String /= Null_Unbounded_Wide_String then Report.Failed("Incorrect results from Procedure Tail - 1"); end if; TC_Unb_String := To_Unbounded_Wide_String("Test String"); Tail(TC_Unb_String, Length(TC_Unb_String) + 5, 'x'); if TC_Unb_String /= To_Unbounded_Wide_String("xxxxxTest String") then Report.Failed("Incorrect results from Procedure Tail - 2"); end if; exception when others => Report.Failed ("Exception raised in Test_Block"); end Test_Block; Report.Result;end CXA4033;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -