-- CXA4018.A
|
-- CXA4018.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
|
-- Check that the subprograms defined in package
|
-- Ada.Strings.Wide_Bounded are available, and that they produce
|
-- Ada.Strings.Wide_Bounded are available, and that they produce
|
-- correct results. Specifically, check the subprograms Append,
|
-- correct results. Specifically, check the subprograms Append,
|
-- Count, Element, Find_Token, Head, Index_Non_Blank, Replace_Element,
|
-- Count, Element, Find_Token, Head, Index_Non_Blank, Replace_Element,
|
-- Replicate, Tail, To_Bounded_Wide_String, "&", ">", "<", ">=", "<=",
|
-- Replicate, Tail, To_Bounded_Wide_String, "&", ">", "<", ">=", "<=",
|
-- and "*".
|
-- and "*".
|
--
|
--
|
-- TEST DESCRIPTION:
|
-- TEST DESCRIPTION:
|
-- This test, when taken in conjunction with test CXA40[17,19,20], will
|
-- This test, when taken in conjunction with test CXA40[17,19,20], will
|
-- constitute a test of all the functionality contained in package
|
-- constitute a test of all the functionality contained in package
|
-- Ada.Strings.Wide_Bounded. This test uses a variety of the
|
-- Ada.Strings.Wide_Bounded. This test uses a variety of the
|
-- subprograms defined in the wide bounded string package in ways typical
|
-- subprograms defined in the wide bounded string package in ways typical
|
-- of common usage. Different combinations of available subprograms
|
-- of common usage. Different combinations of available subprograms
|
-- are used to accomplish similar wide bounded string processing goals.
|
-- are used to accomplish similar wide bounded string processing goals.
|
--
|
--
|
--
|
--
|
-- CHANGE HISTORY:
|
-- CHANGE HISTORY:
|
-- 06 Dec 94 SAIC ACVC 2.0
|
-- 06 Dec 94 SAIC ACVC 2.0
|
-- 22 Dec 94 SAIC Changed obsolete constant to Strings.Wide_Space.
|
-- 22 Dec 94 SAIC Changed obsolete constant to Strings.Wide_Space.
|
-- 06 Nov 95 SAIC Corrected evaluation string used in Head/Tail
|
-- 06 Nov 95 SAIC Corrected evaluation string used in Head/Tail
|
-- subtests for ACVC 2.0.1.
|
-- subtests for ACVC 2.0.1.
|
--
|
--
|
--!
|
--!
|
|
|
with Ada.Strings;
|
with Ada.Strings;
|
with Ada.Strings.Wide_Bounded;
|
with Ada.Strings.Wide_Bounded;
|
with Ada.Characters.Handling;
|
with Ada.Characters.Handling;
|
with Ada.Strings.Wide_Maps;
|
with Ada.Strings.Wide_Maps;
|
with Report;
|
with Report;
|
|
|
procedure CXA4018 is
|
procedure CXA4018 is
|
|
|
-- The following two functions are used to translate character and string
|
-- The following two functions are used to translate character and string
|
-- values to "Wide" values. They will be applied to all the Wide_Bounded
|
-- values to "Wide" values. They will be applied to all the Wide_Bounded
|
-- subprogram parameters to simulate the use of Wide_Characters and
|
-- subprogram parameters to simulate the use of Wide_Characters and
|
-- Wide_Strings in actual practice. Blanks are translated to Wide_Character
|
-- Wide_Strings in actual practice. Blanks are translated to Wide_Character
|
-- blanks and all other characters are translated into Wide_Characters with
|
-- blanks and all other characters are translated into Wide_Characters with
|
-- position values 256 greater than their (narrow) character position
|
-- position values 256 greater than their (narrow) character position
|
-- values.
|
-- values.
|
|
|
function Translate (Ch : Character) return Wide_Character is
|
function Translate (Ch : Character) return Wide_Character is
|
C : Character := Ch;
|
C : Character := Ch;
|
begin
|
begin
|
if Ch = ' ' then
|
if Ch = ' ' then
|
return Ada.Characters.Handling.To_Wide_Character(C);
|
return Ada.Characters.Handling.To_Wide_Character(C);
|
else
|
else
|
return Wide_Character'Val(Character'Pos(Ch) +
|
return Wide_Character'Val(Character'Pos(Ch) +
|
Character'Pos(Character'Last) + 1);
|
Character'Pos(Character'Last) + 1);
|
end if;
|
end if;
|
end Translate;
|
end Translate;
|
|
|
function Translate (Str : String) return Wide_String is
|
function Translate (Str : String) return Wide_String is
|
WS : Wide_String(Str'First..Str'Last);
|
WS : Wide_String(Str'First..Str'Last);
|
begin
|
begin
|
for i in Str'First..Str'Last loop
|
for i in Str'First..Str'Last loop
|
WS(i) := Translate(Str(i));
|
WS(i) := Translate(Str(i));
|
end loop;
|
end loop;
|
return WS;
|
return WS;
|
end Translate;
|
end Translate;
|
|
|
|
|
begin
|
begin
|
|
|
Report.Test ("CXA4018", "Check that the subprograms defined in package " &
|
Report.Test ("CXA4018", "Check that the subprograms defined in package " &
|
"Ada.Strings.Wide_Bounded are available, and " &
|
"Ada.Strings.Wide_Bounded are available, and " &
|
"that they produce correct results");
|
"that they produce correct results");
|
|
|
Test_Block:
|
Test_Block:
|
declare
|
declare
|
|
|
package BS80 is new Ada.Strings.Wide_Bounded.Generic_Bounded_Length(80);
|
package BS80 is new Ada.Strings.Wide_Bounded.Generic_Bounded_Length(80);
|
use type BS80.Bounded_Wide_String;
|
use type BS80.Bounded_Wide_String;
|
|
|
Part1 : constant Wide_String := Translate("Rum");
|
Part1 : constant Wide_String := Translate("Rum");
|
Part2 : Wide_Character := Translate('p');
|
Part2 : Wide_Character := Translate('p');
|
Part3 : BS80.Bounded_Wide_String :=
|
Part3 : BS80.Bounded_Wide_String :=
|
BS80.To_Bounded_Wide_String(Translate("el"));
|
BS80.To_Bounded_Wide_String(Translate("el"));
|
Part4 : Wide_Character := Translate('s');
|
Part4 : Wide_Character := Translate('s');
|
Part5 : BS80.Bounded_Wide_String :=
|
Part5 : BS80.Bounded_Wide_String :=
|
BS80.To_Bounded_Wide_String(Translate("tilt"));
|
BS80.To_Bounded_Wide_String(Translate("tilt"));
|
Part6 : Wide_String(1..3) := Translate("ski");
|
Part6 : Wide_String(1..3) := Translate("ski");
|
|
|
Full_Catenate_String,
|
Full_Catenate_String,
|
Full_Append_String,
|
Full_Append_String,
|
Constructed_String,
|
Constructed_String,
|
Drop_String,
|
Drop_String,
|
Replicated_String,
|
Replicated_String,
|
Token_String : BS80.Bounded_Wide_String;
|
Token_String : BS80.Bounded_Wide_String;
|
|
|
CharA : Wide_Character := Translate('A');
|
CharA : Wide_Character := Translate('A');
|
CharB : Wide_Character := Translate('B');
|
CharB : Wide_Character := Translate('B');
|
CharC : Wide_Character := Translate('C');
|
CharC : Wide_Character := Translate('C');
|
CharD : Wide_Character := Translate('D');
|
CharD : Wide_Character := Translate('D');
|
CharE : Wide_Character := Translate('E');
|
CharE : Wide_Character := Translate('E');
|
CharF : Wide_Character := Translate('F');
|
CharF : Wide_Character := Translate('F');
|
|
|
ABStr : Wide_String(1..15) := Translate("AAAAABBBBBBBBBB");
|
ABStr : Wide_String(1..15) := Translate("AAAAABBBBBBBBBB");
|
StrB : Wide_String(1..2) := Translate("BB");
|
StrB : Wide_String(1..2) := Translate("BB");
|
StrE : Wide_String(1..2) := Translate("EE");
|
StrE : Wide_String(1..2) := Translate("EE");
|
|
|
|
|
begin
|
begin
|
|
|
-- Evaluation of the overloaded forms of the "&" operator.
|
-- Evaluation of the overloaded forms of the "&" operator.
|
|
|
Full_Catenate_String :=
|
Full_Catenate_String :=
|
BS80."&"(Part2, -- WChar & Bnd WStr
|
BS80."&"(Part2, -- WChar & Bnd WStr
|
BS80."&"(Part3, -- Bnd WStr & Bnd WStr
|
BS80."&"(Part3, -- Bnd WStr & Bnd WStr
|
BS80."&"(Part4, -- WChar & Bnd WStr
|
BS80."&"(Part4, -- WChar & Bnd WStr
|
BS80."&"(Part5, -- Bnd WStr & Bnd WStr
|
BS80."&"(Part5, -- Bnd WStr & Bnd WStr
|
BS80.To_Bounded_Wide_String
|
BS80.To_Bounded_Wide_String
|
(Part6)))));
|
(Part6)))));
|
|
|
Full_Catenate_String :=
|
Full_Catenate_String :=
|
BS80."&"(Part1, Full_Catenate_String); -- WStr & Bnd WStr
|
BS80."&"(Part1, Full_Catenate_String); -- WStr & Bnd WStr
|
Full_Catenate_String :=
|
Full_Catenate_String :=
|
BS80."&"(Left => Full_Catenate_String,
|
BS80."&"(Left => Full_Catenate_String,
|
Right => Translate('n')); -- Bnd WStr & WChar
|
Right => Translate('n')); -- Bnd WStr & WChar
|
|
|
|
|
-- Evaluation of the overloaded forms of function Append.
|
-- Evaluation of the overloaded forms of function Append.
|
|
|
Full_Append_String :=
|
Full_Append_String :=
|
BS80.Append(Part2, -- WChar,Bnd WStr
|
BS80.Append(Part2, -- WChar,Bnd WStr
|
BS80.Append(Part3, -- Bnd WStr, Bnd WStr
|
BS80.Append(Part3, -- Bnd WStr, Bnd WStr
|
BS80.Append(Part4, -- WChar,Bnd WStr
|
BS80.Append(Part4, -- WChar,Bnd WStr
|
BS80.Append(BS80.To_Wide_String(Part5), -- WStr,Bnd WStr
|
BS80.Append(BS80.To_Wide_String(Part5), -- WStr,Bnd WStr
|
BS80.To_Bounded_Wide_String(Part6)))));
|
BS80.To_Bounded_Wide_String(Part6)))));
|
|
|
Full_Append_String :=
|
Full_Append_String :=
|
BS80.Append(BS80.To_Bounded_Wide_String(Part1), -- Bnd WStr, WStr
|
BS80.Append(BS80.To_Bounded_Wide_String(Part1), -- Bnd WStr, WStr
|
BS80.To_Wide_String(Full_Append_String));
|
BS80.To_Wide_String(Full_Append_String));
|
|
|
Full_Append_String :=
|
Full_Append_String :=
|
BS80.Append(Left => Full_Append_String,
|
BS80.Append(Left => Full_Append_String,
|
Right => Translate('n')); -- Bnd WStr, WChar
|
Right => Translate('n')); -- Bnd WStr, WChar
|
|
|
|
|
-- Validate the resulting bounded wide strings.
|
-- Validate the resulting bounded wide strings.
|
|
|
if BS80."<"(Full_Catenate_String, Full_Append_String) or
|
if BS80."<"(Full_Catenate_String, Full_Append_String) or
|
BS80.">"(Full_Catenate_String, Full_Append_String) or
|
BS80.">"(Full_Catenate_String, Full_Append_String) or
|
not (Full_Catenate_String = Full_Append_String and
|
not (Full_Catenate_String = Full_Append_String and
|
BS80."<="(Full_Catenate_String, Full_Append_String) and
|
BS80."<="(Full_Catenate_String, Full_Append_String) and
|
BS80.">="(Full_Catenate_String, Full_Append_String))
|
BS80.">="(Full_Catenate_String, Full_Append_String))
|
then
|
then
|
Report.Failed
|
Report.Failed
|
("Incorrect results from bounded wide string catenation" &
|
("Incorrect results from bounded wide string catenation" &
|
" and comparison");
|
" and comparison");
|
end if;
|
end if;
|
|
|
|
|
-- Evaluate the overloaded forms of the Constructor function "*" and
|
-- Evaluate the overloaded forms of the Constructor function "*" and
|
-- the Replicate function.
|
-- the Replicate function.
|
|
|
Constructed_String :=
|
Constructed_String :=
|
BS80."*"(2,CharA) & -- "AA"
|
BS80."*"(2,CharA) & -- "AA"
|
BS80."*"(2,StrB) & -- "AABBBB"
|
BS80."*"(2,StrB) & -- "AABBBB"
|
BS80."*"(3, BS80."*"(2, CharC)) & -- "AABBBBCCCCCC"
|
BS80."*"(3, BS80."*"(2, CharC)) & -- "AABBBBCCCCCC"
|
BS80.Replicate(3,
|
BS80.Replicate(3,
|
BS80.Replicate(2, CharD)) & -- "AABBBBCCCCCCDDDDDD"
|
BS80.Replicate(2, CharD)) & -- "AABBBBCCCCCCDDDDDD"
|
BS80.Replicate(2, StrE) & -- "AABBBBCCCCCCDDDDDDEEEE"
|
BS80.Replicate(2, StrE) & -- "AABBBBCCCCCCDDDDDDEEEE"
|
BS80.Replicate(2, CharF); -- "AABBBBCCCCCCDDDDDDEEEEFF"
|
BS80.Replicate(2, CharF); -- "AABBBBCCCCCCDDDDDDEEEEFF"
|
|
|
|
|
-- Use of Function Replicate that involves dropping wide characters.
|
-- Use of Function Replicate that involves dropping wide characters.
|
-- The attempt to replicate the 15 character wide string six times will
|
-- The attempt to replicate the 15 character wide string six times will
|
-- exceed the 80 wide character bound of the wide string. Therefore,
|
-- exceed the 80 wide character bound of the wide string. Therefore,
|
-- the result should be the catenation of 5 copies of the 15 character
|
-- 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
|
-- 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) with the remaining wide
|
-- characters of the 6th replication dropped.
|
-- characters of the 6th replication dropped.
|
|
|
Drop_String :=
|
Drop_String :=
|
BS80.Replicate(Count => 6,
|
BS80.Replicate(Count => 6,
|
Item => ABStr, -- "AAAAABBBBBBBBBB"
|
Item => ABStr, -- "AAAAABBBBBBBBBB"
|
Drop => Ada.Strings.Right);
|
Drop => Ada.Strings.Right);
|
|
|
if BS80.Element(Drop_String, 1) /= Translate('A') or
|
if BS80.Element(Drop_String, 1) /= Translate('A') or
|
BS80.Element(Drop_String, 6) /= Translate('B') or
|
BS80.Element(Drop_String, 6) /= Translate('B') or
|
BS80.Element(Drop_String, 76) /= Translate('A') or
|
BS80.Element(Drop_String, 76) /= Translate('A') or
|
BS80.Element(Drop_String, 80) /= Translate('A')
|
BS80.Element(Drop_String, 80) /= Translate('A')
|
then
|
then
|
Report.Failed("Incorrect result from Replicate with Drop");
|
Report.Failed("Incorrect result from Replicate with Drop");
|
end if;
|
end if;
|
|
|
|
|
-- Use function Index_Non_Blank in the evaluation of the
|
-- Use function Index_Non_Blank in the evaluation of the
|
-- Constructed_String.
|
-- Constructed_String.
|
|
|
if BS80.Index_Non_Blank(Constructed_String, Ada.Strings.Forward) /=
|
if BS80.Index_Non_Blank(Constructed_String, Ada.Strings.Forward) /=
|
BS80.To_Wide_String(Constructed_String)'First or
|
BS80.To_Wide_String(Constructed_String)'First or
|
BS80.Index_Non_Blank(Constructed_String, Ada.Strings.Backward) /=
|
BS80.Index_Non_Blank(Constructed_String, Ada.Strings.Backward) /=
|
BS80.Length(Constructed_String)
|
BS80.Length(Constructed_String)
|
then
|
then
|
Report.Failed("Incorrect results from constructor functions");
|
Report.Failed("Incorrect results from constructor functions");
|
end if;
|
end if;
|
|
|
|
|
|
|
declare
|
declare
|
|
|
-- Define wide character set objects for use with the Count function.
|
-- Define wide character set objects for use with the Count function.
|
-- Constructed_String = "AABBBBCCCCCCDDDDDDEEEEFF" from above.
|
-- Constructed_String = "AABBBBCCCCCCDDDDDDEEEEFF" from above.
|
|
|
A_Set : Ada.Strings.Wide_Maps.Wide_Character_Set :=
|
A_Set : Ada.Strings.Wide_Maps.Wide_Character_Set :=
|
Ada.Strings.Wide_Maps.To_Set(BS80.Element(Constructed_String,
|
Ada.Strings.Wide_Maps.To_Set(BS80.Element(Constructed_String,
|
1));
|
1));
|
B_Set : Ada.Strings.Wide_Maps.Wide_Character_Set :=
|
B_Set : Ada.Strings.Wide_Maps.Wide_Character_Set :=
|
Ada.Strings.Wide_Maps.To_Set(BS80.Element(Constructed_String,
|
Ada.Strings.Wide_Maps.To_Set(BS80.Element(Constructed_String,
|
3));
|
3));
|
C_Set : Ada.Strings.Wide_Maps.Wide_Character_Set :=
|
C_Set : Ada.Strings.Wide_Maps.Wide_Character_Set :=
|
Ada.Strings.Wide_Maps.To_Set(BS80.Element(Constructed_String,
|
Ada.Strings.Wide_Maps.To_Set(BS80.Element(Constructed_String,
|
7));
|
7));
|
D_Set : Ada.Strings.Wide_Maps.Wide_Character_Set :=
|
D_Set : Ada.Strings.Wide_Maps.Wide_Character_Set :=
|
Ada.Strings.Wide_Maps.To_Set(BS80.Element(Constructed_String,
|
Ada.Strings.Wide_Maps.To_Set(BS80.Element(Constructed_String,
|
13));
|
13));
|
E_Set : Ada.Strings.Wide_Maps.Wide_Character_Set :=
|
E_Set : Ada.Strings.Wide_Maps.Wide_Character_Set :=
|
Ada.Strings.Wide_Maps.To_Set(BS80.Element(Constructed_String,
|
Ada.Strings.Wide_Maps.To_Set(BS80.Element(Constructed_String,
|
19));
|
19));
|
F_Set : Ada.Strings.Wide_Maps.Wide_Character_Set :=
|
F_Set : Ada.Strings.Wide_Maps.Wide_Character_Set :=
|
Ada.Strings.Wide_Maps.To_Set(BS80.Element(Constructed_String,
|
Ada.Strings.Wide_Maps.To_Set(BS80.Element(Constructed_String,
|
23));
|
23));
|
Start : Positive;
|
Start : Positive;
|
Stop : Natural := 0;
|
Stop : Natural := 0;
|
|
|
begin
|
begin
|
|
|
-- Evaluate the results from function Count by comparing the number
|
-- 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
|
-- of A's to the number of F's, B's to E's, and C's to D's in the
|
-- Constructed_String.
|
-- Constructed_String.
|
-- There should be an equal number of each of the wide characters that
|
-- 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)
|
-- 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) /=
|
if BS80.Count(Constructed_String, A_Set) /=
|
BS80.Count(Constructed_String, F_Set) or
|
BS80.Count(Constructed_String, F_Set) or
|
BS80.Count(Constructed_String, B_Set) /=
|
BS80.Count(Constructed_String, B_Set) /=
|
BS80.Count(Constructed_String, E_Set) or
|
BS80.Count(Constructed_String, E_Set) or
|
not (BS80.Count(Constructed_String, C_Set) =
|
not (BS80.Count(Constructed_String, C_Set) =
|
BS80.Count(Constructed_String, D_Set))
|
BS80.Count(Constructed_String, D_Set))
|
then
|
then
|
Report.Failed("Incorrect result from function Count");
|
Report.Failed("Incorrect result from function Count");
|
end if;
|
end if;
|
|
|
|
|
-- Evaluate the functions Head, Tail, and Find_Token.
|
-- Evaluate the functions Head, Tail, and Find_Token.
|
-- Create the Token_String from the Constructed_String above.
|
-- Create the Token_String from the Constructed_String above.
|
|
|
Token_String :=
|
Token_String :=
|
BS80.Tail(BS80.Head(Constructed_String, 3), 2) & -- "AB" &
|
BS80.Tail(BS80.Head(Constructed_String, 3), 2) & -- "AB" &
|
BS80.Head(BS80.Tail(Constructed_String, 13), 2) & -- "CD" &
|
BS80.Head(BS80.Tail(Constructed_String, 13), 2) & -- "CD" &
|
BS80.Head(BS80.Tail(Constructed_String, 3), 2); -- "EF"
|
BS80.Head(BS80.Tail(Constructed_String, 3), 2); -- "EF"
|
|
|
if Token_String /=
|
if Token_String /=
|
BS80.To_Bounded_Wide_String(Translate("ABCDEF")) then
|
BS80.To_Bounded_Wide_String(Translate("ABCDEF")) then
|
Report.Failed("Incorrect result from Catenation of Token_String");
|
Report.Failed("Incorrect result from Catenation of Token_String");
|
end if;
|
end if;
|
|
|
|
|
-- Find the starting/ending position of the first A in the
|
-- Find the starting/ending position of the first A in the
|
-- Token_String (both should be 1, only one A appears in string).
|
-- Token_String (both should be 1, only one A appears in string).
|
-- The Function Head uses the default pad character to return a
|
-- The Function Head uses the default pad character to return a
|
-- bounded wide string longer than its input parameter bounded
|
-- bounded wide string longer than its input parameter bounded
|
-- wide string.
|
-- wide string.
|
|
|
BS80.Find_Token(BS80.Head(Token_String, 10), -- Default pad.
|
BS80.Find_Token(BS80.Head(Token_String, 10), -- Default pad.
|
A_Set,
|
A_Set,
|
Ada.Strings.Inside,
|
Ada.Strings.Inside,
|
Start,
|
Start,
|
Stop);
|
Stop);
|
|
|
if Start /= 1 and Stop /= 1 then
|
if Start /= 1 and Stop /= 1 then
|
Report.Failed("Incorrect result from Find_Token - 1");
|
Report.Failed("Incorrect result from Find_Token - 1");
|
end if;
|
end if;
|
|
|
|
|
-- Find the starting/ending position of the first non-AB slice in
|
-- Find the starting/ending position of the first non-AB slice in
|
-- the "head" five wide characters of Token_String (slice CDE at
|
-- the "head" five wide characters of Token_String (slice CDE at
|
-- positions 3-5)
|
-- positions 3-5)
|
|
|
BS80.Find_Token(BS80.Head(Token_String, 5), -- "ABCDE"
|
BS80.Find_Token(BS80.Head(Token_String, 5), -- "ABCDE"
|
Ada.Strings.Wide_Maps."OR"(A_Set, B_Set), -- Set (AB)
|
Ada.Strings.Wide_Maps."OR"(A_Set, B_Set), -- Set (AB)
|
Ada.Strings.Outside,
|
Ada.Strings.Outside,
|
Start,
|
Start,
|
Stop);
|
Stop);
|
|
|
if Start /= 3 and Stop /= 5 then
|
if Start /= 3 and Stop /= 5 then
|
Report.Failed("Incorrect result from Find_Token - 2");
|
Report.Failed("Incorrect result from Find_Token - 2");
|
end if;
|
end if;
|
|
|
|
|
-- Find the starting/ending position of the first CD slice in
|
-- Find the starting/ending position of the first CD slice in
|
-- the "tail" eight wide characters (including two pad wide
|
-- the "tail" eight wide characters (including two pad wide
|
-- characters) of Token_String (slice CD at positions 5-6 of
|
-- characters) of Token_String (slice CD at positions 5-6 of
|
-- the tail portion specified)
|
-- the tail portion specified)
|
|
|
BS80.Find_Token(BS80.Tail(Token_String, 8,
|
BS80.Find_Token(BS80.Tail(Token_String, 8,
|
Ada.Strings.Wide_Space),
|
Ada.Strings.Wide_Space),
|
Ada.Strings.Wide_Maps."OR"(C_Set, D_Set),
|
Ada.Strings.Wide_Maps."OR"(C_Set, D_Set),
|
Ada.Strings.Inside,
|
Ada.Strings.Inside,
|
Start,
|
Start,
|
Stop);
|
Stop);
|
|
|
if Start /= 5 and Stop /= 6 then
|
if Start /= 5 and Stop /= 6 then
|
Report.Failed("Incorrect result from Find_Token - 3");
|
Report.Failed("Incorrect result from Find_Token - 3");
|
end if;
|
end if;
|
|
|
|
|
-- Evaluate the Replace_Element function.
|
-- Evaluate the Replace_Element function.
|
|
|
-- Token_String = "ABCDEF"
|
-- Token_String = "ABCDEF"
|
|
|
BS80.Replace_Element(Token_String, 3, BS80.Element(Token_String,4));
|
BS80.Replace_Element(Token_String, 3, BS80.Element(Token_String,4));
|
|
|
-- Token_String = "ABDDEF"
|
-- Token_String = "ABDDEF"
|
|
|
BS80.Replace_Element(Source => Token_String,
|
BS80.Replace_Element(Source => Token_String,
|
Index => 2,
|
Index => 2,
|
By => BS80.Element(Token_String, 5));
|
By => BS80.Element(Token_String, 5));
|
|
|
-- Token_String = "AEDDEF"
|
-- Token_String = "AEDDEF"
|
|
|
BS80.Replace_Element(Token_String,
|
BS80.Replace_Element(Token_String,
|
1,
|
1,
|
BS80.Element(BS80.Tail(Token_String, 2), 2));
|
BS80.Element(BS80.Tail(Token_String, 2), 2));
|
|
|
-- Token_String = "FEDDEF"
|
-- Token_String = "FEDDEF"
|
-- Evaluate this result.
|
-- Evaluate this result.
|
|
|
if BS80.Element(Token_String,
|
if BS80.Element(Token_String,
|
BS80.To_Wide_String(Token_String)'First) /=
|
BS80.To_Wide_String(Token_String)'First) /=
|
BS80.Element(Token_String,
|
BS80.Element(Token_String,
|
BS80.To_Wide_String(Token_String)'Last) or
|
BS80.To_Wide_String(Token_String)'Last) or
|
BS80.Count(Token_String, D_Set) /=
|
BS80.Count(Token_String, D_Set) /=
|
BS80.Count(Token_String, E_Set) or
|
BS80.Count(Token_String, E_Set) or
|
BS80.Index_Non_Blank(BS80.Head(Token_String,6)) /=
|
BS80.Index_Non_Blank(BS80.Head(Token_String,6)) /=
|
BS80.Index_Non_Blank(BS80.Tail(Token_String,6)) or
|
BS80.Index_Non_Blank(BS80.Tail(Token_String,6)) or
|
BS80.Head(Token_String, 1) /=
|
BS80.Head(Token_String, 1) /=
|
BS80.Tail(Token_String, 1)
|
BS80.Tail(Token_String, 1)
|
then
|
then
|
Report.Failed("Incorrect result from operations in combination");
|
Report.Failed("Incorrect result from operations in combination");
|
end if;
|
end if;
|
|
|
end;
|
end;
|
|
|
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 CXA4018;
|
end CXA4018;
|
|
|