26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
+
|
begin
Test_Block_Append (Report);
Test_Octet_Append (Report);
Test_Preallocate (Report);
Test_Query (Report);
Test_Query_Null (Report);
Test_Reset (Report);
Test_Reverse_Append (Report);
end All_Tests;
----------------------
-- Individual Tests --
----------------------
|
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
end if;
if Buffer.Element (25) /= Data (24) then
Report.Item (Name, NT.Fail);
Report.Info ("Element, returning an octet");
return;
end if;
declare
O, P : Octet;
begin
Buffer.Pop (O);
Buffer.Pop (P);
if O /= Data (Data'Last)
or P /= Data (Data'Last - 1)
or Buffer.Data /= Data (Data'First .. Data'Last - 2)
then
Report.Item (Name, NT.Fail);
Report.Info ("Pop of an octet: "
& Octet'Image (P) & " " & Octet'Image (O));
Test_Tools.Dump_Atom (Report, Buffer.Data, "Remaining");
Test_Tools.Dump_Atom (Report, Data, "Expected");
return;
end if;
Buffer.Append ((P, O));
if Buffer.Data /= Data then
Report.Item (Name, NT.Fail);
Report.Info ("Append back after Pop");
Test_Tools.Dump_Atom (Report, Buffer.Data, "Found");
Test_Tools.Dump_Atom (Report, Data, "Expected");
return;
end if;
end;
declare
Retrieved : Atom (10 .. 310);
Length : Count;
begin
Buffer.Read (Retrieved, Length);
if Length /= Data'Length
|
330
331
332
333
334
335
336
337
338
|
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
|
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
end;
Report.Item (Name, NT.Success);
exception
when Error : others => Report.Report_Exception (Name, Error);
end Test_Reset;
end Natools.S_Expressions.Atom_Buffers.Tests;
procedure Test_Reverse_Append (Report : in out NT.Reporter'Class) is
Name : constant String := "procedure Append_Reverse";
Source_1 : Atom (1 .. 10);
Source_2 : Atom (1 .. 1);
Source_3 : Atom (51 .. 65);
Source_4 : Atom (1 .. 0);
Source_5 : Atom (101 .. 114);
Expected : Atom (1 .. 40);
begin
for I in Source_1'Range loop
Source_1 (I) := 10 + Octet (I);
Expected (Expected'First + Source_1'Last - I) := Source_1 (I);
end loop;
for I in Source_2'Range loop
Source_2 (I) := 42;
Expected (Expected'First + Source_1'Length + Source_2'Last - I)
:= Source_2 (I);
end loop;
for I in Source_3'Range loop
Source_3 (I) := Octet (I);
Expected (Expected'First + Source_1'Length + Source_2'Length
+ I - Source_3'First)
:= Source_3 (I);
end loop;
for I in Source_5'Range loop
Source_5 (I) := Octet (I);
Expected (Expected'First + Source_1'Length + Source_2'Length
+ Source_3'Length + Source_5'Last - I)
:= Source_5 (I);
end loop;
declare
Buffer : Atom_Buffer;
begin
Buffer.Append_Reverse (Source_1);
Buffer.Append_Reverse (Source_2);
Buffer.Append (Source_3);
Buffer.Append_Reverse (Source_4);
Buffer.Append_Reverse (Source_5);
Test_Tools.Test_Atom (Report, Name, Expected, Buffer.Data);
end;
exception
when Error : others => Report.Report_Exception (Name, Error);
end Test_Reverse_Append;
end Natools.S_Expressions.Atom_Buffers.Tests;
|