1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
|
elsif R /= (First => 27, Length => 3) then
Report.Item (Name, NT.Fail);
Report.Info ("Unexpected ""fox"" slice found at "
& String_Slices.Image (R));
Dump (Report, Set);
return;
end if;
end;
Report.Item (Name, NT.Success);
exception
when Error : others => Report.Report_Exception (Name, Error);
end Test_Tokenization;
end Natools.String_Slice_Set_Tests;
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
|
elsif R /= (First => 27, Length => 3) then
Report.Item (Name, NT.Fail);
Report.Info ("Unexpected ""fox"" slice found at "
& String_Slices.Image (R));
Dump (Report, Set);
return;
end if;
declare
procedure Count_Word_Length (S : in String_Slices.Slice);
Word_Length : array (1 .. 5) of Natural := (others => 0);
procedure Count_Word_Length (S : in String_Slices.Slice) is
begin
Word_Length (S.Length) := Word_Length (S.Length) + 1;
end Count_Word_Length;
begin
Set.Query_Slices (Count_Word_Length'Access);
if Word_Length /= (0, 0, 3, 3, 3) then
Report.Item (Name, NT.Fail);
Report.Info ("Unexpected word lengths:"
& Integer'Image (Word_Length (1))
& Integer'Image (Word_Length (2))
& Integer'Image (Word_Length (3))
& Integer'Image (Word_Length (4))
& Integer'Image (Word_Length (5)));
Dump (Report, Set);
return;
end if;
end;
declare
function Kill_Three_Letters (S : String)
return String_Slices.String_Range;
function Kill_Three_Letters (S : String)
return String_Slices.String_Range is
begin
if S'Length = 3 then
return (S'First, 0);
else
return (S'First, S'Length);
end if;
end Kill_Three_Letters;
begin
Set.Trim_Slices (Kill_Three_Letters'Access);
if Set.To_String /= "quickbrownjumpsoverlazydog." then
Report.Item (Name, NT.Fail);
Report.Info ("Expected ""quickbrownjumpsoverlazydog.""");
Dump (Report, Set);
return;
end if;
end;
declare
use type Slice_Sets.Slice_Set;
Derived : Slice_Sets.Slice_Set := Set;
begin
Derived.Cut_Before (21);
Derived.Cut_Before (31);
if Derived /= Set then
Report.Item (Name, NT.Fail);
Report.Info ("Unexpected side effect of Cut_Before");
Dump (Report, Set);
Dump (Report, Derived);
return;
end if;
end;
end;
Report.Item (Name, NT.Success);
exception
when Error : others => Report.Report_Exception (Name, Error);
end Test_Tokenization;
end Natools.String_Slice_Set_Tests;
|