-- CXA4011.A
|
-- CXA4011.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 subprograms defined in package Ada.Strings.Unbounded
|
-- Check that the subprograms defined in package Ada.Strings.Unbounded
|
-- are available, and that they produce correct results. Specifically,
|
-- are available, and that they produce correct results. Specifically,
|
-- check the subprograms To_Unbounded_String, "&", ">", "<", Element,
|
-- check the subprograms To_Unbounded_String, "&", ">", "<", Element,
|
-- Replace_Element, Count, Find_Token, Translate, Trim, Delete, and
|
-- Replace_Element, Count, Find_Token, Translate, Trim, Delete, and
|
-- "*".
|
-- "*".
|
--
|
--
|
-- TEST DESCRIPTION:
|
-- TEST DESCRIPTION:
|
-- This test demonstrates the uses of many of the subprograms defined
|
-- This test demonstrates the uses of many of the subprograms defined
|
-- in package Ada.Strings.Unbounded for use with unbounded strings.
|
-- in package Ada.Strings.Unbounded for use with unbounded strings.
|
-- The test simulates how unbounded strings could be processed in a
|
-- The test simulates how unbounded strings could be processed in a
|
-- user environment, using the subprograms provided in this package.
|
-- user environment, using the subprograms provided in this package.
|
--
|
--
|
-- This test uses a variety of the subprograms defined in the unbounded
|
-- This test uses a variety of the subprograms defined in the unbounded
|
-- string package in ways typical of common usage, with different
|
-- string package in ways typical of common usage, with different
|
-- combinations of available subprograms being used to accomplish
|
-- combinations of available subprograms being used to accomplish
|
-- similar unbounded string processing goals.
|
-- similar unbounded string processing goals.
|
--
|
--
|
--
|
--
|
-- CHANGE HISTORY:
|
-- CHANGE HISTORY:
|
-- 06 Dec 94 SAIC ACVC 2.0
|
-- 06 Dec 94 SAIC ACVC 2.0
|
-- 27 Feb 95 SAIC Test description modification.
|
-- 27 Feb 95 SAIC Test description modification.
|
-- 01 Nov 95 SAIC Update and repair for ACVC 2.0.1.
|
-- 01 Nov 95 SAIC Update and repair for ACVC 2.0.1.
|
--
|
--
|
--!
|
--!
|
|
|
with Report;
|
with Report;
|
with Ada.Strings.Maps;
|
with Ada.Strings.Maps;
|
with Ada.Strings.Unbounded;
|
with Ada.Strings.Unbounded;
|
|
|
procedure CXA4011 is
|
procedure CXA4011 is
|
begin
|
begin
|
|
|
Report.Test ("CXA4011", "Check that the subprograms defined in " &
|
Report.Test ("CXA4011", "Check that the subprograms defined in " &
|
"package Ada.Strings.Unbounded are available, " &
|
"package Ada.Strings.Unbounded are available, " &
|
"and that they produce correct results");
|
"and that they produce correct results");
|
|
|
Test_Block:
|
Test_Block:
|
declare
|
declare
|
|
|
package ASUnb renames Ada.Strings.Unbounded;
|
package ASUnb renames Ada.Strings.Unbounded;
|
use Ada.Strings;
|
use Ada.Strings;
|
use type Maps.Character_Set;
|
use type Maps.Character_Set;
|
use type ASUnb.Unbounded_String;
|
use type ASUnb.Unbounded_String;
|
|
|
Cad_String : ASUnb.Unbounded_String :=
|
Cad_String : ASUnb.Unbounded_String :=
|
ASUnb.To_Unbounded_String("cad");
|
ASUnb.To_Unbounded_String("cad");
|
|
|
Complete_String : ASUnb.Unbounded_String :=
|
Complete_String : ASUnb.Unbounded_String :=
|
ASUnb.To_Unbounded_String("Incomplete") &
|
ASUnb.To_Unbounded_String("Incomplete") &
|
Ada.Strings.Space &
|
Ada.Strings.Space &
|
ASUnb.To_Unbounded_String("String");
|
ASUnb.To_Unbounded_String("String");
|
|
|
Incomplete_String : ASUnb.Unbounded_String :=
|
Incomplete_String : ASUnb.Unbounded_String :=
|
ASUnb.To_Unbounded_String("ncomplete Strin");
|
ASUnb.To_Unbounded_String("ncomplete Strin");
|
|
|
Incorrect_Spelling : ASUnb.Unbounded_String :=
|
Incorrect_Spelling : ASUnb.Unbounded_String :=
|
ASUnb.To_Unbounded_String("Guob Dai");
|
ASUnb.To_Unbounded_String("Guob Dai");
|
|
|
Magic_String : ASUnb.Unbounded_String :=
|
Magic_String : ASUnb.Unbounded_String :=
|
ASUnb.To_Unbounded_String("abracadabra");
|
ASUnb.To_Unbounded_String("abracadabra");
|
|
|
Incantation : ASUnb.Unbounded_String := Magic_String;
|
Incantation : ASUnb.Unbounded_String := Magic_String;
|
|
|
|
|
A_Small_G : Character := 'g';
|
A_Small_G : Character := 'g';
|
A_Small_D : Character := 'd';
|
A_Small_D : Character := 'd';
|
|
|
ABCD_Set : Maps.Character_Set := Maps.To_Set("abcd");
|
ABCD_Set : Maps.Character_Set := Maps.To_Set("abcd");
|
B_Set : Maps.Character_Set := Maps.To_Set('b');
|
B_Set : Maps.Character_Set := Maps.To_Set('b');
|
AB_Set : Maps.Character_Set := Maps."OR"(Maps.To_Set('a'), B_Set);
|
AB_Set : Maps.Character_Set := Maps."OR"(Maps.To_Set('a'), B_Set);
|
|
|
Code_Map : Maps.Character_Mapping :=
|
Code_Map : Maps.Character_Mapping :=
|
Maps.To_Mapping(From => "abcd", To => "wxyz");
|
Maps.To_Mapping(From => "abcd", To => "wxyz");
|
Reverse_Code_Map : Maps.Character_Mapping :=
|
Reverse_Code_Map : Maps.Character_Mapping :=
|
Maps.To_Mapping(From => "wxyz", To => "abcd");
|
Maps.To_Mapping(From => "wxyz", To => "abcd");
|
Non_Existent_Map : Maps.Character_Mapping :=
|
Non_Existent_Map : Maps.Character_Mapping :=
|
Maps.To_Mapping(From => "jkl", To => "mno");
|
Maps.To_Mapping(From => "jkl", To => "mno");
|
|
|
|
|
Token_Start : Positive;
|
Token_Start : Positive;
|
Token_End : Natural := 0;
|
Token_End : Natural := 0;
|
Matching_Letters : Natural := 0;
|
Matching_Letters : Natural := 0;
|
|
|
|
|
begin
|
begin
|
|
|
-- "&"
|
-- "&"
|
|
|
-- Prepend an 'I' and append a 'g' to the string.
|
-- Prepend an 'I' and append a 'g' to the string.
|
Incomplete_String := ASUnb."&"('I', Incomplete_String); -- Char & Unb
|
Incomplete_String := ASUnb."&"('I', Incomplete_String); -- Char & Unb
|
Incomplete_String := ASUnb."&"(Incomplete_String,
|
Incomplete_String := ASUnb."&"(Incomplete_String,
|
A_Small_G); -- Unb & Char
|
A_Small_G); -- Unb & Char
|
|
|
if Incomplete_String < Complete_String or
|
if Incomplete_String < Complete_String or
|
Incomplete_String > Complete_String or
|
Incomplete_String > Complete_String or
|
Incomplete_String /= Complete_String
|
Incomplete_String /= Complete_String
|
then
|
then
|
Report.Failed("Incorrect result from use of ""&"" operator");
|
Report.Failed("Incorrect result from use of ""&"" operator");
|
end if;
|
end if;
|
|
|
|
|
-- Element
|
-- Element
|
|
|
-- Last element of the unbounded string should be a 'g'.
|
-- Last element of the unbounded string should be a 'g'.
|
if ASUnb.Element(Incomplete_String, ASUnb.Length(Incomplete_String)) /=
|
if ASUnb.Element(Incomplete_String, ASUnb.Length(Incomplete_String)) /=
|
A_Small_G
|
A_Small_G
|
then
|
then
|
Report.Failed("Incorrect result from use of Function Element - 1");
|
Report.Failed("Incorrect result from use of Function Element - 1");
|
end if;
|
end if;
|
|
|
if ASUnb.Element(Incomplete_String, 2) /=
|
if ASUnb.Element(Incomplete_String, 2) /=
|
ASUnb.Element(ASUnb.Tail(Incomplete_String, 2), 1) or
|
ASUnb.Element(ASUnb.Tail(Incomplete_String, 2), 1) or
|
ASUnb.Element(ASUnb.Head(Incomplete_String, 4), 2) /=
|
ASUnb.Element(ASUnb.Head(Incomplete_String, 4), 2) /=
|
ASUnb.Element(ASUnb.To_Unbounded_String("wnqz"), 2)
|
ASUnb.Element(ASUnb.To_Unbounded_String("wnqz"), 2)
|
then
|
then
|
Report.Failed("Incorrect result from use of Function Element - 2");
|
Report.Failed("Incorrect result from use of Function Element - 2");
|
end if;
|
end if;
|
|
|
|
|
-- Replace_Element
|
-- Replace_Element
|
|
|
-- The unbounded string Incorrect_Spelling starts as "Guob Dai", and
|
-- The unbounded string Incorrect_Spelling starts as "Guob Dai", and
|
-- is transformed by the following three procedure calls to "Good Day".
|
-- is transformed by the following three procedure calls to "Good Day".
|
|
|
ASUnb.Replace_Element(Incorrect_Spelling, 2, 'o');
|
ASUnb.Replace_Element(Incorrect_Spelling, 2, 'o');
|
|
|
ASUnb.Replace_Element(Incorrect_Spelling,
|
ASUnb.Replace_Element(Incorrect_Spelling,
|
ASUnb.Index(Incorrect_Spelling, B_Set),
|
ASUnb.Index(Incorrect_Spelling, B_Set),
|
A_Small_D);
|
A_Small_D);
|
|
|
ASUnb.Replace_Element(Source => Incorrect_Spelling,
|
ASUnb.Replace_Element(Source => Incorrect_Spelling,
|
Index => ASUnb.Length(Incorrect_Spelling),
|
Index => ASUnb.Length(Incorrect_Spelling),
|
By => 'y');
|
By => 'y');
|
|
|
if Incorrect_Spelling /= ASUnb.To_Unbounded_String("Good Day") then
|
if Incorrect_Spelling /= ASUnb.To_Unbounded_String("Good Day") then
|
Report.Failed("Incorrect result from Procedure Replace_Element");
|
Report.Failed("Incorrect result from Procedure Replace_Element");
|
end if;
|
end if;
|
|
|
|
|
-- Count
|
-- Count
|
|
|
-- Determine the number of characters in the unbounded string that
|
-- Determine the number of characters in the unbounded string that
|
-- are contained in the set.
|
-- are contained in the set.
|
|
|
Matching_Letters := ASUnb.Count(Source => Magic_String,
|
Matching_Letters := ASUnb.Count(Source => Magic_String,
|
Set => ABCD_Set);
|
Set => ABCD_Set);
|
|
|
if Matching_Letters /= 9 then
|
if Matching_Letters /= 9 then
|
Report.Failed
|
Report.Failed
|
("Incorrect result from Function Count with Set parameter");
|
("Incorrect result from Function Count with Set parameter");
|
end if;
|
end if;
|
|
|
-- Determine the number of occurrences of the following pattern strings
|
-- Determine the number of occurrences of the following pattern strings
|
-- in the unbounded string Magic_String.
|
-- in the unbounded string Magic_String.
|
|
|
if ASUnb.Count(Magic_String, "ab") /=
|
if ASUnb.Count(Magic_String, "ab") /=
|
(ASUnb.Count(Magic_String, "ac") + ASUnb.Count(Magic_String, "ad")) or
|
(ASUnb.Count(Magic_String, "ac") + ASUnb.Count(Magic_String, "ad")) or
|
ASUnb.Count(Magic_String, "ab") /= 2
|
ASUnb.Count(Magic_String, "ab") /= 2
|
then
|
then
|
Report.Failed
|
Report.Failed
|
("Incorrect result from Function Count with String parameter");
|
("Incorrect result from Function Count with String parameter");
|
end if;
|
end if;
|
|
|
|
|
-- Find_Token
|
-- Find_Token
|
|
|
ASUnb.Find_Token(Magic_String, -- Find location of first "ab".
|
ASUnb.Find_Token(Magic_String, -- Find location of first "ab".
|
AB_Set, -- Should be (1..2).
|
AB_Set, -- Should be (1..2).
|
Ada.Strings.Inside,
|
Ada.Strings.Inside,
|
Token_Start,
|
Token_Start,
|
Token_End);
|
Token_End);
|
|
|
if Natural(Token_Start) /= ASUnb.To_String(Magic_String)'First or
|
if Natural(Token_Start) /= ASUnb.To_String(Magic_String)'First or
|
Token_End /= ASUnb.Index(Magic_String, B_Set)
|
Token_End /= ASUnb.Index(Magic_String, B_Set)
|
then
|
then
|
Report.Failed("Incorrect result from Procedure Find_Token - 1");
|
Report.Failed("Incorrect result from Procedure Find_Token - 1");
|
end if;
|
end if;
|
|
|
|
|
ASUnb.Find_Token(Source => Magic_String, -- Find location of char 'r'
|
ASUnb.Find_Token(Source => Magic_String, -- Find location of char 'r'
|
Set => ABCD_Set, -- in string, should be (3..3)
|
Set => ABCD_Set, -- in string, should be (3..3)
|
Test => Ada.Strings.Outside,
|
Test => Ada.Strings.Outside,
|
First => Token_Start,
|
First => Token_Start,
|
Last => Token_End);
|
Last => Token_End);
|
|
|
if Natural(Token_Start) /= 3 or
|
if Natural(Token_Start) /= 3 or
|
Token_End /= 3 then
|
Token_End /= 3 then
|
Report.Failed("Incorrect result from Procedure Find_Token - 2");
|
Report.Failed("Incorrect result from Procedure Find_Token - 2");
|
end if;
|
end if;
|
|
|
|
|
ASUnb.Find_Token(Magic_String, -- No 'g' is in the string, so
|
ASUnb.Find_Token(Magic_String, -- No 'g' is in the string, so
|
Maps.To_Set(A_Small_G), -- the result parameters should
|
Maps.To_Set(A_Small_G), -- the result parameters should
|
Ada.Strings.Inside, -- be First = Source'First and
|
Ada.Strings.Inside, -- be First = Source'First and
|
First => Token_Start, -- Last = 0.
|
First => Token_Start, -- Last = 0.
|
Last => Token_End);
|
Last => Token_End);
|
|
|
if Token_Start /= ASUnb.To_String(Magic_String)'First or
|
if Token_Start /= ASUnb.To_String(Magic_String)'First or
|
Token_End /= 0
|
Token_End /= 0
|
then
|
then
|
Report.Failed("Incorrect result from Procedure Find_Token - 3");
|
Report.Failed("Incorrect result from Procedure Find_Token - 3");
|
end if;
|
end if;
|
|
|
|
|
-- Translate
|
-- Translate
|
|
|
-- Use a mapping ("abcd" -> "wxyz") to transform the contents of
|
-- Use a mapping ("abcd" -> "wxyz") to transform the contents of
|
-- the unbounded string.
|
-- the unbounded string.
|
-- Magic_String = "abracadabra"
|
-- Magic_String = "abracadabra"
|
|
|
Incantation := ASUnb.Translate(Magic_String, Code_Map);
|
Incantation := ASUnb.Translate(Magic_String, Code_Map);
|
|
|
if Incantation /= ASUnb.To_Unbounded_String("wxrwywzwxrw") then
|
if Incantation /= ASUnb.To_Unbounded_String("wxrwywzwxrw") then
|
Report.Failed("Incorrect result from Function Translate");
|
Report.Failed("Incorrect result from Function Translate");
|
end if;
|
end if;
|
|
|
-- Use the inverse mapping of the one above to return the "translated"
|
-- Use the inverse mapping of the one above to return the "translated"
|
-- unbounded string to its original form.
|
-- unbounded string to its original form.
|
|
|
ASUnb.Translate(Incantation, Reverse_Code_Map);
|
ASUnb.Translate(Incantation, Reverse_Code_Map);
|
|
|
-- The map contained in the following call to Translate contains one
|
-- The map contained in the following call to Translate contains one
|
-- element, and this element is not found in the unbounded string, so
|
-- element, and this element is not found in the unbounded string, so
|
-- this call to Translate should have no effect on the unbounded string.
|
-- this call to Translate should have no effect on the unbounded string.
|
|
|
if Incantation /= ASUnb.Translate(Magic_String, Non_Existent_Map) then
|
if Incantation /= ASUnb.Translate(Magic_String, Non_Existent_Map) then
|
Report.Failed("Incorrect result from Procedure Translate");
|
Report.Failed("Incorrect result from Procedure Translate");
|
end if;
|
end if;
|
|
|
|
|
-- Trim
|
-- Trim
|
|
|
Trim_Block:
|
Trim_Block:
|
declare
|
declare
|
|
|
XYZ_Set : Maps.Character_Set := Maps.To_Set("xyz");
|
XYZ_Set : Maps.Character_Set := Maps.To_Set("xyz");
|
PQR_Set : Maps.Character_Set := Maps.To_Set("pqr");
|
PQR_Set : Maps.Character_Set := Maps.To_Set("pqr");
|
|
|
Pad : constant ASUnb.Unbounded_String :=
|
Pad : constant ASUnb.Unbounded_String :=
|
ASUnb.To_Unbounded_String("Pad");
|
ASUnb.To_Unbounded_String("Pad");
|
|
|
The_New_Ada : constant ASUnb.Unbounded_String :=
|
The_New_Ada : constant ASUnb.Unbounded_String :=
|
ASUnb.To_Unbounded_String("Ada9X");
|
ASUnb.To_Unbounded_String("Ada9X");
|
|
|
Space_Array : array (1..4) of ASUnb.Unbounded_String :=
|
Space_Array : array (1..4) of ASUnb.Unbounded_String :=
|
(ASUnb.To_Unbounded_String(" Pad "),
|
(ASUnb.To_Unbounded_String(" Pad "),
|
ASUnb.To_Unbounded_String("Pad "),
|
ASUnb.To_Unbounded_String("Pad "),
|
ASUnb.To_Unbounded_String(" Pad"),
|
ASUnb.To_Unbounded_String(" Pad"),
|
Pad);
|
Pad);
|
|
|
String_Array : array (1..5) of ASUnb.Unbounded_String :=
|
String_Array : array (1..5) of ASUnb.Unbounded_String :=
|
(ASUnb.To_Unbounded_String("xyzxAda9Xpqr"),
|
(ASUnb.To_Unbounded_String("xyzxAda9Xpqr"),
|
ASUnb.To_Unbounded_String("Ada9Xqqrp"),
|
ASUnb.To_Unbounded_String("Ada9Xqqrp"),
|
ASUnb.To_Unbounded_String("zxyxAda9Xqpqr"),
|
ASUnb.To_Unbounded_String("zxyxAda9Xqpqr"),
|
ASUnb.To_Unbounded_String("xxxyAda9X"),
|
ASUnb.To_Unbounded_String("xxxyAda9X"),
|
The_New_Ada);
|
The_New_Ada);
|
|
|
begin
|
begin
|
|
|
-- Examine the version of Trim that removes blanks from
|
-- Examine the version of Trim that removes blanks from
|
-- the left and/or right of a string.
|
-- the left and/or right of a string.
|
|
|
for i in 1..4 loop
|
for i in 1..4 loop
|
if ASUnb.Trim(Space_Array(i), Ada.Strings.Both) /= Pad then
|
if ASUnb.Trim(Space_Array(i), Ada.Strings.Both) /= Pad then
|
Report.Failed("Incorrect result from Trim for spaces - " &
|
Report.Failed("Incorrect result from Trim for spaces - " &
|
Integer'Image(i));
|
Integer'Image(i));
|
end if;
|
end if;
|
end loop;
|
end loop;
|
|
|
-- Examine the version of Trim that removes set characters from
|
-- Examine the version of Trim that removes set characters from
|
-- the left and right of a string.
|
-- the left and right of a string.
|
|
|
for i in 1..5 loop
|
for i in 1..5 loop
|
if ASUnb.Trim(String_Array(i),
|
if ASUnb.Trim(String_Array(i),
|
Left => XYZ_Set,
|
Left => XYZ_Set,
|
Right => PQR_Set) /= The_New_Ada then
|
Right => PQR_Set) /= The_New_Ada then
|
Report.Failed
|
Report.Failed
|
("Incorrect result from Trim for set characters - " &
|
("Incorrect result from Trim for set characters - " &
|
Integer'Image(i));
|
Integer'Image(i));
|
end if;
|
end if;
|
end loop;
|
end loop;
|
|
|
end Trim_Block;
|
end Trim_Block;
|
|
|
|
|
-- Delete
|
-- Delete
|
|
|
-- Use the Delete function to remove the first four and last four
|
-- Use the Delete function to remove the first four and last four
|
-- characters from the string.
|
-- characters from the string.
|
|
|
if ASUnb.Delete(Source => ASUnb.Delete(Magic_String,
|
if ASUnb.Delete(Source => ASUnb.Delete(Magic_String,
|
8,
|
8,
|
ASUnb.Length(Magic_String)),
|
ASUnb.Length(Magic_String)),
|
From => ASUnb.To_String(Magic_String)'First,
|
From => ASUnb.To_String(Magic_String)'First,
|
Through => 4) /=
|
Through => 4) /=
|
Cad_String
|
Cad_String
|
then
|
then
|
Report.Failed("Incorrect results from Function Delete");
|
Report.Failed("Incorrect results from Function Delete");
|
end if;
|
end if;
|
|
|
|
|
-- Constructors ("*")
|
-- Constructors ("*")
|
|
|
Constructor_Block:
|
Constructor_Block:
|
declare
|
declare
|
|
|
SOS : ASUnb.Unbounded_String;
|
SOS : ASUnb.Unbounded_String;
|
|
|
Dot : constant ASUnb.Unbounded_String :=
|
Dot : constant ASUnb.Unbounded_String :=
|
ASUnb.To_Unbounded_String("Dot_");
|
ASUnb.To_Unbounded_String("Dot_");
|
Dash : constant String := "Dash_";
|
Dash : constant String := "Dash_";
|
|
|
Distress : ASUnb.Unbounded_String :=
|
Distress : ASUnb.Unbounded_String :=
|
ASUnb.To_Unbounded_String("Dot_Dot_Dot_") &
|
ASUnb.To_Unbounded_String("Dot_Dot_Dot_") &
|
ASUnb.To_Unbounded_String("Dash_Dash_Dash_") &
|
ASUnb.To_Unbounded_String("Dash_Dash_Dash_") &
|
ASUnb.To_Unbounded_String("Dot_Dot_Dot");
|
ASUnb.To_Unbounded_String("Dot_Dot_Dot");
|
|
|
Repeat : constant Natural := 3;
|
Repeat : constant Natural := 3;
|
Separator : constant Character := '_';
|
Separator : constant Character := '_';
|
|
|
Separator_Set : Maps.Character_Set := Maps.To_Set(Separator);
|
Separator_Set : Maps.Character_Set := Maps.To_Set(Separator);
|
|
|
begin
|
begin
|
|
|
-- Use the following constructor forms to construct the string
|
-- Use the following constructor forms to construct the string
|
-- "Dot_Dot_Dot_Dash_Dash_Dash_Dot_Dot_Dot". Note that the
|
-- "Dot_Dot_Dot_Dash_Dash_Dash_Dot_Dot_Dot". Note that the
|
-- trailing underscore in the string is removed in the call to
|
-- trailing underscore in the string is removed in the call to
|
-- Trim in the If statement condition.
|
-- Trim in the If statement condition.
|
|
|
SOS := ASUnb."*"(Repeat, Dot); -- "*"(#, Unb Str)
|
SOS := ASUnb."*"(Repeat, Dot); -- "*"(#, Unb Str)
|
|
|
SOS := SOS &
|
SOS := SOS &
|
ASUnb."*"(Repeat, Dash) & -- "*"(#, Str)
|
ASUnb."*"(Repeat, Dash) & -- "*"(#, Str)
|
ASUnb."*"(Repeat, Dot); -- "*"(#, Unb Str)
|
ASUnb."*"(Repeat, Dot); -- "*"(#, Unb Str)
|
|
|
if ASUnb.Trim(SOS, Maps.Null_Set, Separator_Set) /= Distress then
|
if ASUnb.Trim(SOS, Maps.Null_Set, Separator_Set) /= Distress then
|
Report.Failed("Incorrect results from Function ""*""");
|
Report.Failed("Incorrect results from Function ""*""");
|
end if;
|
end if;
|
|
|
end Constructor_Block;
|
end Constructor_Block;
|
|
|
|
|
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 CXA4011;
|
end CXA4011;
|
|
|