Natools

Check-in [b5759ad827]
Login
Overview
Comment:s_expressions-test_tools: new helper procedures to update and test a Descriptor in a single call
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b5759ad827466e11ec072340e442d681fc48f633
User & Date: nat on 2014-02-19 20:43:09
Other Links: manifest | tags
Context
2014-02-20
21:55
s_expressions-parsers-tests: use new helper procedures to test Descriptor interface of Subparser objects check-in: 0a35973c17 user: nat tags: trunk
2014-02-19
20:43
s_expressions-test_tools: new helper procedures to update and test a Descriptor in a single call check-in: b5759ad827 user: nat tags: trunk
2014-02-18
20:34
s_expressions-test_tools: new helper procedure to test exception throwing from all atom accessors check-in: 04e35d38a1 user: nat tags: trunk
Changes

Modified tests/natools-s_expressions-test_tools.adb from [25a91785a5] to [5acb00bfe2].

373
374
375
376
377
378
379












































380
381
382
383
384
385
386
         when Program_Error => null;
         when Error : others =>
            Test.Fail ("Wrong exception raised in Read_Atom");
            Test.Report_Exception (Error, NT.Fail);
      end Read_Atom_Test;
   end Test_Atom_Accessor_Exceptions;















































   -------------------
   -- Memory Stream --
   -------------------

   overriding procedure Read







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







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
418
419
420
421
422
423
424
425
426
427
428
429
430
         when Program_Error => null;
         when Error : others =>
            Test.Fail ("Wrong exception raised in Read_Atom");
            Test.Report_Exception (Error, NT.Fail);
      end Read_Atom_Test;
   end Test_Atom_Accessor_Exceptions;


   procedure Next_And_Check
     (Test : in out NT.Test;
      Tested : in out Descriptor'Class;
      Expected : in Events.Event;
      Level : in Natural)
   is
      Event : Events.Event;
   begin
      Tested.Next (Event);
      if Event /= Expected then
         Test.Fail ("Found event "
           & Events.Event'Image (Event)
           & ", expected "
           & Events.Event'Image (Expected));
      elsif Tested.Current_Level /= Level then
         Test.Fail ("Found event "
           & Events.Event'Image (Event)
           & " at level"
           & Integer'Image (Tested.Current_Level)
           & ", expected"
           & Integer'Image (Level));
      end if;
   end Next_And_Check;


   procedure Next_And_Check
     (Test : in out NT.Test;
      Tested : in out Descriptor'Class;
      Expected : in Atom;
      Level : in Natural)
   is
      Event : Events.Event;
   begin
      Tested.Next (Event);
      if Event /= Events.Add_Atom then
         Test.Fail ("Found event "
           & Events.Event'Image (Event)
           & ", expected Add_Atom");
      else
         Test_Tools.Test_Atom_Accessors (Test, Tested, Expected, Level);
      end if;
   end Next_And_Check;



   -------------------
   -- Memory Stream --
   -------------------

   overriding procedure Read

Modified tests/natools-s_expressions-test_tools.ads from [e24a8f627e] to [c7139c29da].

64
65
66
67
68
69
70















71
72
73
74
75
76
77
      --  Test all the ways of accessing atom in Tested

   procedure Test_Atom_Accessor_Exceptions
     (Test : in out NT.Test;
      Tested : in Descriptor'Class);
      --  Check that all atom accessors raise Program_Error

















   type Memory_Stream is new Ada.Streams.Root_Stream_Type with private;

   overriding procedure Read
     (Stream : in out Memory_Stream;
      Item : out Ada.Streams.Stream_Element_Array;
      Last : out Ada.Streams.Stream_Element_Offset);







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







64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
      --  Test all the ways of accessing atom in Tested

   procedure Test_Atom_Accessor_Exceptions
     (Test : in out NT.Test;
      Tested : in Descriptor'Class);
      --  Check that all atom accessors raise Program_Error

   procedure Next_And_Check
     (Test : in out NT.Test;
      Tested : in out Descriptor'Class;
      Expected : in Events.Event;
      Level : in Natural);
      --  Call Tested.Next and check the current event and level

   procedure Next_And_Check
     (Test : in out NT.Test;
      Tested : in out Descriptor'Class;
      Expected : in Atom;
      Level : in Natural);
      --  Call Tested.Next and check current event is Add_Atom with Expected,
      --  using Test_Atom_Accessors.


   type Memory_Stream is new Ada.Streams.Root_Stream_Type with private;

   overriding procedure Read
     (Stream : in out Memory_Stream;
      Item : out Ada.Streams.Stream_Element_Array;
      Last : out Ada.Streams.Stream_Element_Offset);