Natools

Check-in [71a9406a61]
Login
Overview
Comment:s_expressions-atom_buffers-tests: add tests for the new octet stack interface
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 71a9406a61a523287496ea60911180558832afce
User & Date: nat on 2014-01-20 19:48:39
Other Links: manifest | tags
Context
2014-01-21
20:16
s_expressions-parsers: fix parsing of nested subexpressions check-in: edac345527 user: nat tags: trunk
2014-01-20
19:48
s_expressions-atom_buffers-tests: add tests for the new octet stack interface check-in: 71a9406a61 user: nat tags: trunk
2014-01-19
22:04
s_expressions-atom_buffers: add primitives to use atom buffers as octet stacks check-in: 7b0544e9fc user: nat tags: trunk
Changes

Modified tests/natools-s_expressions-atom_buffers-tests.adb from [50f8825dfd] to [535648874b].

26
27
28
29
30
31
32

33
34
35
36
37
38
39
   begin
      Test_Block_Append (Report);
      Test_Octet_Append (Report);
      Test_Preallocate (Report);
      Test_Query (Report);
      Test_Query_Null (Report);
      Test_Reset (Report);

   end All_Tests;



   ----------------------
   -- Individual Tests --
   ----------------------







>







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
         end if;

         if Buffer.Element (25) /= Data (24) then
            Report.Item (Name, NT.Fail);
            Report.Info ("Element, returning an octet");
            return;
         end if;






























         declare
            Retrieved : Atom (10 .. 310);
            Length : Count;
         begin
            Buffer.Read (Retrieved, Length);
            if Length /= Data'Length







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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




































      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;

























































|
>
>
>
>
>
>
>
>
>
>
>
>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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;


   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;

Modified tests/natools-s_expressions-atom_buffers-tests.ads from [3ff19dfc01] to [a50548f9b2].

30
31
32
33
34
35
36

37
38

   procedure Test_Block_Append (Report : in out NT.Reporter'Class);
   procedure Test_Octet_Append (Report : in out NT.Reporter'Class);
   procedure Test_Preallocate (Report : in out NT.Reporter'Class);
   procedure Test_Query (Report : in out NT.Reporter'Class);
   procedure Test_Query_Null (Report : in out NT.Reporter'Class);
   procedure Test_Reset (Report : in out NT.Reporter'Class);


end Natools.S_Expressions.Atom_Buffers.Tests;







>


30
31
32
33
34
35
36
37
38
39

   procedure Test_Block_Append (Report : in out NT.Reporter'Class);
   procedure Test_Octet_Append (Report : in out NT.Reporter'Class);
   procedure Test_Preallocate (Report : in out NT.Reporter'Class);
   procedure Test_Query (Report : in out NT.Reporter'Class);
   procedure Test_Query_Null (Report : in out NT.Reporter'Class);
   procedure Test_Reset (Report : in out NT.Reporter'Class);
   procedure Test_Reverse_Append (Report : in out NT.Reporter'Class);

end Natools.S_Expressions.Atom_Buffers.Tests;