185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
CS := Count * Template;
if To_String (CS) /= Ref then
NT.Item (Report, Name, NT.Fail);
NT.Info (Report, "Final value: """ & To_String (CS) & '"');
NT.Info (Report, "Expected: """ & Ref & '"');
else
NT.Item (Report, Name, NT.Success);
end if;
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Procedure Chunked_Slice";
CS : Chunked_String;
Low : constant Positive := 11;
High : constant Positive := 17;
begin
Chunked_Slice (To_Chunked_String (Name), CS, Low, High);
if To_String (CS) /= Name (Low .. High) then
NT.Item (Report, Name, NT.Fail);
NT.Info (Report, "Final value: """ & To_String (CS) & '"');
NT.Info (Report, "Expected: """ & Name (Low .. High) & '"');
else
NT.Item (Report, Name, NT.Success);
end if;
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Procedure Chunked_Slice (empty)";
CS : Chunked_String;
begin
Chunked_Slice (To_Chunked_String (Name), CS, 1, 0);
if To_String (CS) /= "" then
NT.Item (Report, Name, NT.Fail);
NT.Info (Report, "Final value: """ & To_String (CS) & '"');
else
NT.Item (Report, Name, NT.Success);
end if;
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Function Index_Non_Blank with From";
CS : constant Chunked_String := To_Chunked_String (Name);
M, N : Natural;
begin
M := Index (CS, " ");
N := Index_Non_Blank (CS, M);
if N /= M + 1 then
NT.Item (Report, Name, NT.Fail);
NT.Info (Report, "Final value:" & Natural'Image (N));
NT.Info (Report, "Expected:" & Natural'Image (M + 1));
else
NT.Item (Report, Name, NT.Success);
end if;
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
declare
Name : constant String := "Function Find_Token at string end";
CS : constant Chunked_String := To_Chunked_String ("--end");
First : Positive;
Last : Natural;
begin
Find_Token
(Source => CS,
Set => Maps.To_Set ("abcdefghijklmnopqrst"),
Test => Ada.Strings.Inside,
First => First,
Last => Last);
if First /= 3 or Last /= 5 then
NT.Item (Report, Name, NT.Fail);
NT.Info (Report,
"Final interval:" & Natural'Image (First)
& " .." & Natural'Image (Last));
NT.Info (Report, "Expected: 3 .. 5");
else
NT.Item (Report, Name, NT.Success);
end if;
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
Natools.Tests.End_Section (Report);
end Natools.Chunked_Strings.Tests.Coverage;
|