-- CXA4033.A
|
-- CXA4033.A
|
--
|
--
|
-- Grant of Unlimited Rights
|
-- Grant of Unlimited Rights
|
--
|
--
|
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
|
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
|
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
|
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
|
-- unlimited rights in the software and documentation contained herein.
|
-- unlimited rights in the software and documentation contained herein.
|
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
|
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
|
-- this public release, the Government intends to confer upon all
|
-- this public release, the Government intends to confer upon all
|
-- recipients unlimited rights equal to those held by the Government.
|
-- recipients unlimited rights equal to those held by the Government.
|
-- These rights include rights to use, duplicate, release or disclose the
|
-- These rights include rights to use, duplicate, release or disclose the
|
-- released technical data and computer software in whole or in part, in
|
-- released technical data and computer software in whole or in part, in
|
-- any manner and for any purpose whatsoever, and to have or permit others
|
-- any manner and for any purpose whatsoever, and to have or permit others
|
-- to do so.
|
-- to do so.
|
--
|
--
|
-- DISCLAIMER
|
-- DISCLAIMER
|
--
|
--
|
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
|
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
|
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
|
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
|
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
|
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
|
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
|
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
|
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
|
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
|
-- PARTICULAR PURPOSE OF SAID MATERIAL.
|
-- PARTICULAR PURPOSE OF SAID MATERIAL.
|
--*
|
--*
|
--
|
--
|
-- OBJECTIVE:
|
-- OBJECTIVE:
|
-- Check that the functionality found in packages Ada.Strings.Wide_Maps,
|
-- Check that the functionality found in packages Ada.Strings.Wide_Maps,
|
-- Ada.Strings.Wide_Unbounded, and Ada.Strings.Wide_Maps.Wide_Constants
|
-- Ada.Strings.Wide_Unbounded, and Ada.Strings.Wide_Maps.Wide_Constants
|
-- is available and produces correct results.
|
-- is available and produces correct results.
|
--
|
--
|
-- TEST DESCRIPTION:
|
-- TEST DESCRIPTION:
|
-- This test tests the subprograms found in the
|
-- This test tests the subprograms found in the
|
-- Ada.Strings.Wide_Unbounded package. It is based on the tests
|
-- Ada.Strings.Wide_Unbounded package. It is based on the tests
|
-- CXA4030-32, which are tests for the complementary "non-wide"
|
-- CXA4030-32, which are tests for the complementary "non-wide"
|
-- packages.
|
-- packages.
|
--
|
--
|
-- The functions found in CXA4033_0 provide mapping capability, when
|
-- The functions found in CXA4033_0 provide mapping capability, when
|
-- used in conjunction with Wide_Character_Mapping_Function objects.
|
-- used in conjunction with Wide_Character_Mapping_Function objects.
|
--
|
--
|
--
|
--
|
-- CHANGE HISTORY:
|
-- CHANGE HISTORY:
|
-- 23 Jun 95 SAIC Initial prerelease version.
|
-- 23 Jun 95 SAIC Initial prerelease version.
|
-- 24 Feb 97 PWB.CTA Removed attempt to create wide string of length
|
-- 24 Feb 97 PWB.CTA Removed attempt to create wide string of length
|
-- Natural'Last
|
-- Natural'Last
|
--!
|
--!
|
|
|
package CXA4033_0 is
|
package CXA4033_0 is
|
-- Functions used to supply mapping capability.
|
-- Functions used to supply mapping capability.
|
function Map_To_Lower_Case (From : Wide_Character) return Wide_Character;
|
function Map_To_Lower_Case (From : Wide_Character) return Wide_Character;
|
function Map_To_Upper_Case (From : Wide_Character) return Wide_Character;
|
function Map_To_Upper_Case (From : Wide_Character) return Wide_Character;
|
end CXA4033_0;
|
end CXA4033_0;
|
|
|
with Ada.Characters.Handling;
|
with Ada.Characters.Handling;
|
package body CXA4033_0 is
|
package body CXA4033_0 is
|
-- Function Map_To_Lower_Case will return the lower case form of
|
-- Function Map_To_Lower_Case will return the lower case form of
|
-- Wide_Characters in the range 'A'..'Z' only, and return the input
|
-- Wide_Characters in the range 'A'..'Z' only, and return the input
|
-- wide_character otherwise.
|
-- wide_character otherwise.
|
|
|
function Map_To_Lower_Case (From : Wide_Character)
|
function Map_To_Lower_Case (From : Wide_Character)
|
return Wide_Character is
|
return Wide_Character is
|
begin
|
begin
|
return Ada.Characters.Handling.To_Wide_Character(
|
return Ada.Characters.Handling.To_Wide_Character(
|
Ada.Characters.Handling.To_Lower(
|
Ada.Characters.Handling.To_Lower(
|
Ada.Characters.Handling.To_Character(From)));
|
Ada.Characters.Handling.To_Character(From)));
|
end Map_To_Lower_Case;
|
end Map_To_Lower_Case;
|
|
|
-- Function Map_To_Upper_Case will return the upper case form of
|
-- Function Map_To_Upper_Case will return the upper case form of
|
-- Wide_Characters in the range 'a'..'z', or whose position is in one
|
-- Wide_Characters in the range 'a'..'z', or whose position is in one
|
-- of the ranges 223..246 or 248..255, provided the wide_character has
|
-- of the ranges 223..246 or 248..255, provided the wide_character has
|
-- an upper case form.
|
-- an upper case form.
|
|
|
function Map_To_Upper_Case (From : Wide_Character)
|
function Map_To_Upper_Case (From : Wide_Character)
|
return Wide_Character is
|
return Wide_Character is
|
begin
|
begin
|
return Ada.Characters.Handling.To_Wide_Character(
|
return Ada.Characters.Handling.To_Wide_Character(
|
Ada.Characters.Handling.To_Upper(
|
Ada.Characters.Handling.To_Upper(
|
Ada.Characters.Handling.To_Character(From)));
|
Ada.Characters.Handling.To_Character(From)));
|
end Map_To_Upper_Case;
|
end Map_To_Upper_Case;
|
|
|
end CXA4033_0;
|
end CXA4033_0;
|
|
|
|
|
with CXA4033_0;
|
with CXA4033_0;
|
with Report;
|
with Report;
|
with Ada.Characters.Handling;
|
with Ada.Characters.Handling;
|
with Ada.Characters.Latin_1;
|
with Ada.Characters.Latin_1;
|
with Ada.Strings;
|
with Ada.Strings;
|
with Ada.Strings.Wide_Maps;
|
with Ada.Strings.Wide_Maps;
|
with Ada.Strings.Wide_Maps.Wide_Constants;
|
with Ada.Strings.Wide_Maps.Wide_Constants;
|
with Ada.Strings.Wide_Fixed;
|
with Ada.Strings.Wide_Fixed;
|
with Ada.Strings.Wide_Unbounded;
|
with Ada.Strings.Wide_Unbounded;
|
|
|
procedure CXA4033 is
|
procedure CXA4033 is
|
begin
|
begin
|
Report.Test ("CXA4033",
|
Report.Test ("CXA4033",
|
"Check that subprograms defined in the package " &
|
"Check that subprograms defined in the package " &
|
"Ada.Strings.Wide_Unbounded produce correct results");
|
"Ada.Strings.Wide_Unbounded produce correct results");
|
|
|
Test_Block:
|
Test_Block:
|
declare
|
declare
|
|
|
package ACL1 renames Ada.Characters.Latin_1;
|
package ACL1 renames Ada.Characters.Latin_1;
|
package Unb renames Ada.Strings.Wide_Unbounded;
|
package Unb renames Ada.Strings.Wide_Unbounded;
|
|
|
subtype LC_Characters is Wide_Character range 'a'..'z';
|
subtype LC_Characters is Wide_Character range 'a'..'z';
|
|
|
use Ada.Characters, Ada.Strings, Unb;
|
use Ada.Characters, Ada.Strings, Unb;
|
use type Wide_Maps.Wide_Character_Set;
|
use type Wide_Maps.Wide_Character_Set;
|
|
|
TC_String : constant Wide_String := "A Standard String";
|
TC_String : constant Wide_String := "A Standard String";
|
|
|
String_20 : Wide_String(1..20) := "ABCDEFGHIJKLMNOPQRST";
|
String_20 : Wide_String(1..20) := "ABCDEFGHIJKLMNOPQRST";
|
String_40 : Wide_String(1..40) := "abcdefghijklmnopqrst" &
|
String_40 : Wide_String(1..40) := "abcdefghijklmnopqrst" &
|
String_20;
|
String_20;
|
String_80 : Wide_String(1..80) := String_40 & String_40;
|
String_80 : Wide_String(1..80) := String_40 & String_40;
|
TC_String_5 : Wide_String(1..5) := "ABCDE";
|
TC_String_5 : Wide_String(1..5) := "ABCDE";
|
TC_Unb_String : Unbounded_Wide_String := Null_Unbounded_Wide_String;
|
TC_Unb_String : Unbounded_Wide_String := Null_Unbounded_Wide_String;
|
|
|
-- The following strings are used in examination of the Translation
|
-- The following strings are used in examination of the Translation
|
-- subprograms.
|
-- subprograms.
|
New_Character_String : Wide_String(1..10) :=
|
New_Character_String : Wide_String(1..10) :=
|
Handling.To_Wide_String(
|
Handling.To_Wide_String(
|
ACL1.LC_A_Grave & ACL1.LC_A_Ring & ACL1.LC_AE_Diphthong &
|
ACL1.LC_A_Grave & ACL1.LC_A_Ring & ACL1.LC_AE_Diphthong &
|
ACL1.LC_C_Cedilla & ACL1.LC_E_Acute & ACL1.LC_I_Circumflex &
|
ACL1.LC_C_Cedilla & ACL1.LC_E_Acute & ACL1.LC_I_Circumflex &
|
ACL1.LC_Icelandic_Eth & ACL1.LC_N_Tilde &
|
ACL1.LC_Icelandic_Eth & ACL1.LC_N_Tilde &
|
ACL1.LC_O_Oblique_Stroke & ACL1.LC_Icelandic_Thorn);
|
ACL1.LC_O_Oblique_Stroke & ACL1.LC_Icelandic_Thorn);
|
|
|
TC_New_Character_String : Wide_String(1..10) :=
|
TC_New_Character_String : Wide_String(1..10) :=
|
Handling.To_Wide_String(
|
Handling.To_Wide_String(
|
ACL1.UC_A_Grave & ACL1.UC_A_Ring & ACL1.UC_AE_Diphthong &
|
ACL1.UC_A_Grave & ACL1.UC_A_Ring & ACL1.UC_AE_Diphthong &
|
ACL1.UC_C_Cedilla & ACL1.UC_E_Acute & ACL1.UC_I_Circumflex &
|
ACL1.UC_C_Cedilla & ACL1.UC_E_Acute & ACL1.UC_I_Circumflex &
|
ACL1.UC_Icelandic_Eth & ACL1.UC_N_Tilde &
|
ACL1.UC_Icelandic_Eth & ACL1.UC_N_Tilde &
|
ACL1.UC_O_Oblique_Stroke & ACL1.UC_Icelandic_Thorn);
|
ACL1.UC_O_Oblique_Stroke & ACL1.UC_Icelandic_Thorn);
|
|
|
New_UB_Character_String : Unbounded_Wide_String :=
|
New_UB_Character_String : Unbounded_Wide_String :=
|
To_Unbounded_Wide_String(New_Character_String);
|
To_Unbounded_Wide_String(New_Character_String);
|
|
|
TC_New_UB_Character_String : Unbounded_Wide_String :=
|
TC_New_UB_Character_String : Unbounded_Wide_String :=
|
To_Unbounded_Wide_String(TC_New_Character_String);
|
To_Unbounded_Wide_String(TC_New_Character_String);
|
|
|
-- Access objects that will be provided as parameters to the
|
-- Access objects that will be provided as parameters to the
|
-- subprograms.
|
-- subprograms.
|
Map_To_Lower_Case_Ptr : Wide_Maps.Wide_Character_Mapping_Function :=
|
Map_To_Lower_Case_Ptr : Wide_Maps.Wide_Character_Mapping_Function :=
|
CXA4033_0.Map_To_Lower_Case'Access;
|
CXA4033_0.Map_To_Lower_Case'Access;
|
Map_To_Upper_Case_Ptr : Wide_Maps.Wide_Character_Mapping_Function :=
|
Map_To_Upper_Case_Ptr : Wide_Maps.Wide_Character_Mapping_Function :=
|
CXA4033_0.Map_To_Upper_Case'Access;
|
CXA4033_0.Map_To_Upper_Case'Access;
|
|
|
begin
|
begin
|
|
|
-- Testing functionality found in Package Ada.Strings.Wide_Unbounded.
|
-- Testing functionality found in Package Ada.Strings.Wide_Unbounded.
|
--
|
--
|
-- Function Index.
|
-- Function Index.
|
|
|
if Index(To_Unbounded_Wide_String("AAABBBaaabbb"),
|
if Index(To_Unbounded_Wide_String("AAABBBaaabbb"),
|
"aabb",
|
"aabb",
|
Mapping => Map_To_Lower_Case_Ptr) /= 2 or
|
Mapping => Map_To_Lower_Case_Ptr) /= 2 or
|
Index(To_Unbounded_Wide_String("Case of a Mixed Case String"),
|
Index(To_Unbounded_Wide_String("Case of a Mixed Case String"),
|
"case",
|
"case",
|
Ada.Strings.Backward,
|
Ada.Strings.Backward,
|
Map_To_Lower_Case_Ptr) /= 17
|
Map_To_Lower_Case_Ptr) /= 17
|
then
|
then
|
Report.Failed("Incorrect results from Function Index, " &
|
Report.Failed("Incorrect results from Function Index, " &
|
"using a Wide Character Mapping Function parameter");
|
"using a Wide Character Mapping Function parameter");
|
end if;
|
end if;
|
|
|
-- Function Count.
|
-- Function Count.
|
if Count(Source => To_Unbounded_Wide_String("ABABABA"),
|
if Count(Source => To_Unbounded_Wide_String("ABABABA"),
|
Pattern => "aba",
|
Pattern => "aba",
|
Mapping => Map_To_Lower_Case_Ptr) /= 2 or
|
Mapping => Map_To_Lower_Case_Ptr) /= 2 or
|
Count(Null_Unbounded_Wide_String, "mat", Map_To_Upper_Case_Ptr) /= 0
|
Count(Null_Unbounded_Wide_String, "mat", Map_To_Upper_Case_Ptr) /= 0
|
then
|
then
|
Report.Failed("Incorrect results from Function Count, using " &
|
Report.Failed("Incorrect results from Function Count, using " &
|
"a Character Mapping Function parameter");
|
"a Character Mapping Function parameter");
|
end if;
|
end if;
|
|
|
-- Function Translate.
|
-- Function Translate.
|
if Translate(To_Unbounded_Wide_String("A Sample Mixed Case String"),
|
if Translate(To_Unbounded_Wide_String("A Sample Mixed Case String"),
|
Mapping => Map_To_Lower_Case_Ptr) /=
|
Mapping => Map_To_Lower_Case_Ptr) /=
|
To_Unbounded_Wide_String("a sample mixed case string") or
|
To_Unbounded_Wide_String("a sample mixed case string") or
|
Translate(New_UB_Character_String, Map_To_Upper_Case_Ptr) /=
|
Translate(New_UB_Character_String, Map_To_Upper_Case_Ptr) /=
|
TC_New_UB_Character_String
|
TC_New_UB_Character_String
|
then
|
then
|
Report.Failed("Incorrect results from Function Translate, " &
|
Report.Failed("Incorrect results from Function Translate, " &
|
"using a Character Mapping Function parameter");
|
"using a Character Mapping Function parameter");
|
end if;
|
end if;
|
|
|
-- Procedure Translate.
|
-- Procedure Translate.
|
declare
|
declare
|
use Ada.Characters.Handling;
|
use Ada.Characters.Handling;
|
Str : Unbounded_Wide_String :=
|
Str : Unbounded_Wide_String :=
|
To_Unbounded_Wide_String("AN ALL UPPER CASE STRING");
|
To_Unbounded_Wide_String("AN ALL UPPER CASE STRING");
|
begin
|
begin
|
Translate(Source => Str, Mapping => Map_To_Lower_Case_Ptr);
|
Translate(Source => Str, Mapping => Map_To_Lower_Case_Ptr);
|
if Str /= To_Unbounded_Wide_String("an all upper case string") then
|
if Str /= To_Unbounded_Wide_String("an all upper case string") then
|
Report.Failed("Incorrect result from Procedure Translate 1");
|
Report.Failed("Incorrect result from Procedure Translate 1");
|
end if;
|
end if;
|
|
|
Translate(New_UB_Character_String, Map_To_Upper_Case_Ptr);
|
Translate(New_UB_Character_String, Map_To_Upper_Case_Ptr);
|
if New_UB_Character_String /= TC_New_UB_Character_String then
|
if New_UB_Character_String /= TC_New_UB_Character_String then
|
Report.Failed("Incorrect result from Procedure Translate 2");
|
Report.Failed("Incorrect result from Procedure Translate 2");
|
end if;
|
end if;
|
end;
|
end;
|
|
|
-- Function To_Unbounded_Wide_String (version with Length parameter)
|
-- Function To_Unbounded_Wide_String (version with Length parameter)
|
if Length(To_Unbounded_Wide_String(Length => 10)) /= 10 or
|
if Length(To_Unbounded_Wide_String(Length => 10)) /= 10 or
|
Length(To_Unbounded_Wide_String(0)) /= 0 or
|
Length(To_Unbounded_Wide_String(0)) /= 0 or
|
Length( To_Unbounded_Wide_String(10) &
|
Length( To_Unbounded_Wide_String(10) &
|
To_Unbounded_Wide_String(1) &
|
To_Unbounded_Wide_String(1) &
|
To_Unbounded_Wide_String(0) ) /= 10 + 1 + 0
|
To_Unbounded_Wide_String(0) ) /= 10 + 1 + 0
|
then
|
then
|
Report.Failed
|
Report.Failed
|
("Incorrect results from Function To_Unbounded_Wide_String " &
|
("Incorrect results from Function To_Unbounded_Wide_String " &
|
"with Length parameter");
|
"with Length parameter");
|
end if;
|
end if;
|
|
|
-- Procedure Append (Wide_Unbounded - Wide_Unbounded)
|
-- Procedure Append (Wide_Unbounded - Wide_Unbounded)
|
TC_Unb_String := Null_Unbounded_Wide_String;
|
TC_Unb_String := Null_Unbounded_Wide_String;
|
Append(TC_Unb_String, To_Unbounded_Wide_String("New Unbounded String"));
|
Append(TC_Unb_String, To_Unbounded_Wide_String("New Unbounded String"));
|
if TC_Unb_String /= To_Unbounded_Wide_String("New Unbounded String")
|
if TC_Unb_String /= To_Unbounded_Wide_String("New Unbounded String")
|
then
|
then
|
Report.Failed("Incorrect results from Procedure Append with " &
|
Report.Failed("Incorrect results from Procedure Append with " &
|
"unbounded wide string parameters");
|
"unbounded wide string parameters");
|
end if;
|
end if;
|
|
|
|
|
-- Procedure Append (Wide_Unbounded - Wide_String)
|
-- Procedure Append (Wide_Unbounded - Wide_String)
|
TC_Unb_String := To_Unbounded_Wide_String("An Unbounded String and ");
|
TC_Unb_String := To_Unbounded_Wide_String("An Unbounded String and ");
|
Append(Source => TC_Unb_String, New_Item => TC_String);
|
Append(Source => TC_Unb_String, New_Item => TC_String);
|
if TC_Unb_String /=
|
if TC_Unb_String /=
|
To_Unbounded_Wide_String("An Unbounded String and A Standard String")
|
To_Unbounded_Wide_String("An Unbounded String and A Standard String")
|
then
|
then
|
Report.Failed("Incorrect results from Procedure Append with " &
|
Report.Failed("Incorrect results from Procedure Append with " &
|
"an unbounded wide string parameter and a wide " &
|
"an unbounded wide string parameter and a wide " &
|
"string parameter");
|
"string parameter");
|
end if;
|
end if;
|
|
|
-- Procedure Append (Wide_Unbounded - Wide_Character)
|
-- Procedure Append (Wide_Unbounded - Wide_Character)
|
TC_Unb_String := To_Unbounded_Wide_String("Lower Case = ");
|
TC_Unb_String := To_Unbounded_Wide_String("Lower Case = ");
|
for i in LC_Characters'Range loop
|
for i in LC_Characters'Range loop
|
Append(Source => TC_Unb_String, New_Item => LC_Characters(i));
|
Append(Source => TC_Unb_String, New_Item => LC_Characters(i));
|
end loop;
|
end loop;
|
if TC_Unb_String /=
|
if TC_Unb_String /=
|
Unb.To_Unbounded_Wide_String
|
Unb.To_Unbounded_Wide_String
|
("Lower Case = abcdefghijklmnopqrstuvwxyz")
|
("Lower Case = abcdefghijklmnopqrstuvwxyz")
|
then
|
then
|
Report.Failed("Incorrect results from Procedure Append with " &
|
Report.Failed("Incorrect results from Procedure Append with " &
|
"an unbounded wide string parameter and a wide " &
|
"an unbounded wide string parameter and a wide " &
|
"character parameter");
|
"character parameter");
|
end if;
|
end if;
|
|
|
-- Function "="
|
-- Function "="
|
TC_Unb_String := To_Unbounded_Wide_String(TC_String);
|
TC_Unb_String := To_Unbounded_Wide_String(TC_String);
|
if not (TC_Unb_String = TC_String) or
|
if not (TC_Unb_String = TC_String) or
|
not "="("A Standard String", TC_Unb_String) or
|
not "="("A Standard String", TC_Unb_String) or
|
not ((Null_Unbounded_Wide_String = "") and
|
not ((Null_Unbounded_Wide_String = "") and
|
("Test String" = To_Unbounded_Wide_String("Test String")))
|
("Test String" = To_Unbounded_Wide_String("Test String")))
|
then
|
then
|
Report.Failed("Incorrect results from Function ""="" with " &
|
Report.Failed("Incorrect results from Function ""="" with " &
|
"wide_string - unbounded wide string parameters");
|
"wide_string - unbounded wide string parameters");
|
end if;
|
end if;
|
|
|
-- Function "<"
|
-- Function "<"
|
if not ("Extra Space" < To_Unbounded_Wide_String("Extra Space ") and
|
if not ("Extra Space" < To_Unbounded_Wide_String("Extra Space ") and
|
To_Unbounded_Wide_String("tess") < "test" and
|
To_Unbounded_Wide_String("tess") < "test" and
|
To_Unbounded_Wide_String("best") < "test")
|
To_Unbounded_Wide_String("best") < "test")
|
then
|
then
|
Report.Failed("Incorrect results from Function ""<"" with " &
|
Report.Failed("Incorrect results from Function ""<"" with " &
|
"wide string - unbounded wide string parameters");
|
"wide string - unbounded wide string parameters");
|
end if;
|
end if;
|
|
|
-- Function "<="
|
-- Function "<="
|
TC_Unb_String := To_Unbounded_Wide_String("Sample string");
|
TC_Unb_String := To_Unbounded_Wide_String("Sample string");
|
if TC_Unb_String <= "Sample strin" or
|
if TC_Unb_String <= "Sample strin" or
|
not("Sample string" <= TC_Unb_String)
|
not("Sample string" <= TC_Unb_String)
|
then
|
then
|
Report.Failed("Incorrect results from Function ""<="" with " &
|
Report.Failed("Incorrect results from Function ""<="" with " &
|
"wide string - unbounded wide string parameters");
|
"wide string - unbounded wide string parameters");
|
end if;
|
end if;
|
|
|
-- Function ">"
|
-- Function ">"
|
TC_Unb_String := To_Unbounded_Wide_String("A MUCH LONGER STRING");
|
TC_Unb_String := To_Unbounded_Wide_String("A MUCH LONGER STRING");
|
if not ("A much longer string" > TC_Unb_String and
|
if not ("A much longer string" > TC_Unb_String and
|
To_Unbounded_Wide_String(TC_String) > "A Standard Strin" and
|
To_Unbounded_Wide_String(TC_String) > "A Standard Strin" and
|
"abcdefgh" > To_Unbounded_Wide_String("ABCDEFGH"))
|
"abcdefgh" > To_Unbounded_Wide_String("ABCDEFGH"))
|
then
|
then
|
Report.Failed("Incorrect results from Function "">"" with " &
|
Report.Failed("Incorrect results from Function "">"" with " &
|
"wide string - unbounded wide string parameters");
|
"wide string - unbounded wide string parameters");
|
end if;
|
end if;
|
|
|
-- Function ">="
|
-- Function ">="
|
TC_Unb_String := To_Unbounded_Wide_String(TC_String);
|
TC_Unb_String := To_Unbounded_Wide_String(TC_String);
|
if not (TC_Unb_String >= TC_String and
|
if not (TC_Unb_String >= TC_String and
|
"test" >= To_Unbounded_Wide_String("tess") and
|
"test" >= To_Unbounded_Wide_String("tess") and
|
To_Unbounded_Wide_String("Programming") >= "PROGRAMMING")
|
To_Unbounded_Wide_String("Programming") >= "PROGRAMMING")
|
then
|
then
|
Report.Failed("Incorrect results from Function "">="" with " &
|
Report.Failed("Incorrect results from Function "">="" with " &
|
"wide string - unbounded wide string parameters");
|
"wide string - unbounded wide string parameters");
|
end if;
|
end if;
|
|
|
-- Procedure Replace_Slice
|
-- Procedure Replace_Slice
|
TC_Unb_String := To_Unbounded_Wide_String("Test String");
|
TC_Unb_String := To_Unbounded_Wide_String("Test String");
|
Replace_Slice(TC_Unb_String, 5, 5, TC_String_5);
|
Replace_Slice(TC_Unb_String, 5, 5, TC_String_5);
|
if TC_Unb_String /= To_Unbounded_Wide_String("TestABCDEString") then
|
if TC_Unb_String /= To_Unbounded_Wide_String("TestABCDEString") then
|
Report.Failed("Incorrect results from Replace_Slice - 1");
|
Report.Failed("Incorrect results from Replace_Slice - 1");
|
end if;
|
end if;
|
|
|
Replace_Slice(TC_Unb_String, 1, 4, TC_String_5);
|
Replace_Slice(TC_Unb_String, 1, 4, TC_String_5);
|
if TC_Unb_String /= To_Unbounded_Wide_String("ABCDEABCDEString") then
|
if TC_Unb_String /= To_Unbounded_Wide_String("ABCDEABCDEString") then
|
Report.Failed("Incorrect results from Replace_Slice - 2");
|
Report.Failed("Incorrect results from Replace_Slice - 2");
|
end if;
|
end if;
|
|
|
-- Procedure Insert
|
-- Procedure Insert
|
TC_Unb_String := To_Unbounded_Wide_String("Test String");
|
TC_Unb_String := To_Unbounded_Wide_String("Test String");
|
Insert(TC_Unb_String, 1, "**");
|
Insert(TC_Unb_String, 1, "**");
|
if TC_Unb_String /= To_Unbounded_Wide_String("**Test String") then
|
if TC_Unb_String /= To_Unbounded_Wide_String("**Test String") then
|
Report.Failed("Incorrect results from Procedure Insert - 1");
|
Report.Failed("Incorrect results from Procedure Insert - 1");
|
end if;
|
end if;
|
|
|
Insert(TC_Unb_String, Length(TC_Unb_String)+1, "**");
|
Insert(TC_Unb_String, Length(TC_Unb_String)+1, "**");
|
if TC_Unb_String /= To_Unbounded_Wide_String("**Test String**") then
|
if TC_Unb_String /= To_Unbounded_Wide_String("**Test String**") then
|
Report.Failed("Incorrect results from Procedure Insert - 2");
|
Report.Failed("Incorrect results from Procedure Insert - 2");
|
end if;
|
end if;
|
|
|
-- Procedure Overwrite
|
-- Procedure Overwrite
|
TC_Unb_String := To_Unbounded_Wide_String("Test String");
|
TC_Unb_String := To_Unbounded_Wide_String("Test String");
|
Overwrite(TC_Unb_String, 1, New_Item => "XXXX");
|
Overwrite(TC_Unb_String, 1, New_Item => "XXXX");
|
if TC_Unb_String /= To_Unbounded_Wide_String("XXXX String") then
|
if TC_Unb_String /= To_Unbounded_Wide_String("XXXX String") then
|
Report.Failed("Incorrect results from Procedure Overwrite - 1");
|
Report.Failed("Incorrect results from Procedure Overwrite - 1");
|
end if;
|
end if;
|
|
|
Overwrite(TC_Unb_String, Length(TC_Unb_String)+1, "**");
|
Overwrite(TC_Unb_String, Length(TC_Unb_String)+1, "**");
|
if TC_Unb_String /= To_Unbounded_Wide_String("XXXX String**") then
|
if TC_Unb_String /= To_Unbounded_Wide_String("XXXX String**") then
|
Report.Failed("Incorrect results from Procedure Overwrite - 2");
|
Report.Failed("Incorrect results from Procedure Overwrite - 2");
|
end if;
|
end if;
|
|
|
-- Procedure Delete
|
-- Procedure Delete
|
TC_Unb_String := To_Unbounded_Wide_String("Test String");
|
TC_Unb_String := To_Unbounded_Wide_String("Test String");
|
Delete(TC_Unb_String, 1, 0);
|
Delete(TC_Unb_String, 1, 0);
|
if TC_Unb_String /= To_Unbounded_Wide_String("Test String") then
|
if TC_Unb_String /= To_Unbounded_Wide_String("Test String") then
|
Report.Failed("Incorrect results from Procedure Delete - 1");
|
Report.Failed("Incorrect results from Procedure Delete - 1");
|
end if;
|
end if;
|
|
|
Delete(TC_Unb_String, 1, 5);
|
Delete(TC_Unb_String, 1, 5);
|
if TC_Unb_String /= To_Unbounded_Wide_String("String") then
|
if TC_Unb_String /= To_Unbounded_Wide_String("String") then
|
Report.Failed("Incorrect results from Procedure Delete - 2");
|
Report.Failed("Incorrect results from Procedure Delete - 2");
|
end if;
|
end if;
|
|
|
-- Procedure Trim
|
-- Procedure Trim
|
TC_Unb_String := To_Unbounded_Wide_String(" Leading Spaces ");
|
TC_Unb_String := To_Unbounded_Wide_String(" Leading Spaces ");
|
Trim(TC_Unb_String, Ada.Strings.Left);
|
Trim(TC_Unb_String, Ada.Strings.Left);
|
if TC_Unb_String /= To_Unbounded_Wide_String("Leading Spaces ") then
|
if TC_Unb_String /= To_Unbounded_Wide_String("Leading Spaces ") then
|
Report.Failed("Incorrect results from Procedure Trim - 1");
|
Report.Failed("Incorrect results from Procedure Trim - 1");
|
end if;
|
end if;
|
|
|
TC_Unb_String :=
|
TC_Unb_String :=
|
To_Unbounded_Wide_String(" Spaces on both ends ");
|
To_Unbounded_Wide_String(" Spaces on both ends ");
|
Trim(TC_Unb_String, Ada.Strings.Both);
|
Trim(TC_Unb_String, Ada.Strings.Both);
|
if TC_Unb_String /=
|
if TC_Unb_String /=
|
To_Unbounded_Wide_String("Spaces on both ends")
|
To_Unbounded_Wide_String("Spaces on both ends")
|
then
|
then
|
Report.Failed("Incorrect results from Procedure Trim - 2");
|
Report.Failed("Incorrect results from Procedure Trim - 2");
|
end if;
|
end if;
|
|
|
-- Procedure Trim (with Wide_Character_Set parameters)
|
-- Procedure Trim (with Wide_Character_Set parameters)
|
TC_Unb_String := To_Unbounded_Wide_String("012abcdefghGFEDCBA789ab");
|
TC_Unb_String := To_Unbounded_Wide_String("012abcdefghGFEDCBA789ab");
|
Trim(TC_Unb_String,
|
Trim(TC_Unb_String,
|
Ada.Strings.Wide_Maps.Wide_Constants.Hexadecimal_Digit_Set,
|
Ada.Strings.Wide_Maps.Wide_Constants.Hexadecimal_Digit_Set,
|
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
|
if TC_Unb_String /= To_Unbounded_Wide_String("ghG") then
|
Report.Failed("Incorrect results from Procedure Trim with Sets");
|
Report.Failed("Incorrect results from Procedure Trim with Sets");
|
end if;
|
end if;
|
|
|
-- Procedure Head
|
-- Procedure Head
|
TC_Unb_String := To_Unbounded_Wide_String("Test String");
|
TC_Unb_String := To_Unbounded_Wide_String("Test String");
|
Head(Source => TC_Unb_String, Count => 0, Pad => '*');
|
Head(Source => TC_Unb_String, Count => 0, Pad => '*');
|
if TC_Unb_String /= Null_Unbounded_Wide_String then
|
if TC_Unb_String /= Null_Unbounded_Wide_String then
|
Report.Failed("Incorrect results from Procedure Head - 1");
|
Report.Failed("Incorrect results from Procedure Head - 1");
|
end if;
|
end if;
|
|
|
TC_Unb_String := To_Unbounded_Wide_String("Test String");
|
TC_Unb_String := To_Unbounded_Wide_String("Test String");
|
Head(Source => TC_Unb_String, Count => 4, Pad => '*');
|
Head(Source => TC_Unb_String, Count => 4, Pad => '*');
|
if TC_Unb_String /= To_Unbounded_Wide_String("Test") then
|
if TC_Unb_String /= To_Unbounded_Wide_String("Test") then
|
Report.Failed("Incorrect results from Procedure Head - 2");
|
Report.Failed("Incorrect results from Procedure Head - 2");
|
end if;
|
end if;
|
|
|
-- Procedure Tail
|
-- Procedure Tail
|
TC_Unb_String := To_Unbounded_Wide_String("Test String");
|
TC_Unb_String := To_Unbounded_Wide_String("Test String");
|
Tail(Source => TC_Unb_String, Count => 0, Pad => '*');
|
Tail(Source => TC_Unb_String, Count => 0, Pad => '*');
|
if TC_Unb_String /= Null_Unbounded_Wide_String then
|
if TC_Unb_String /= Null_Unbounded_Wide_String then
|
Report.Failed("Incorrect results from Procedure Tail - 1");
|
Report.Failed("Incorrect results from Procedure Tail - 1");
|
end if;
|
end if;
|
|
|
TC_Unb_String := To_Unbounded_Wide_String("Test String");
|
TC_Unb_String := To_Unbounded_Wide_String("Test String");
|
Tail(TC_Unb_String, Length(TC_Unb_String) + 5, 'x');
|
Tail(TC_Unb_String, Length(TC_Unb_String) + 5, 'x');
|
if TC_Unb_String /= To_Unbounded_Wide_String("xxxxxTest String") then
|
if TC_Unb_String /= To_Unbounded_Wide_String("xxxxxTest String") then
|
Report.Failed("Incorrect results from Procedure Tail - 2");
|
Report.Failed("Incorrect results from Procedure Tail - 2");
|
end if;
|
end if;
|
|
|
exception
|
exception
|
when others => Report.Failed ("Exception raised in Test_Block");
|
when others => Report.Failed ("Exception raised in Test_Block");
|
end Test_Block;
|
end Test_Block;
|
|
|
Report.Result;
|
Report.Result;
|
|
|
end CXA4033;
|
end CXA4033;
|
|
|