Natools

Diff
Login

Differences From Artifact [d05f8e5e43]:

To Artifact [2b967f59a6]:


9
10
11
12
13
14
15


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

33
34
35
36
37
38
39





































40
41
42
43
44
45
46
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF         --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR  --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES   --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN    --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF  --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.           --
------------------------------------------------------------------------------



package body Natools.Time_Statistics.Tests is

   procedure Check is new NT.Generic_Check
     (Natural, "=", Natural'Image, False);

   procedure Check is new NT.Generic_Check
     (Duration, "=", Duration'Image, False);


   -------------------------
   -- Complete Test Suite --
   -------------------------

   procedure All_Tests (Report : in out NT.Reporter'Class) is
   begin
      Summary_Accumulator (Report);

   end All_Tests;



   -----------------------
   -- Inidividual Tests --
   -----------------------






































   procedure Summary_Accumulator (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Summary accumulator");
   begin
      declare
         Stats : Summary;
      begin







>
>

















>







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







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF         --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR  --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES   --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN    --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF  --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.           --
------------------------------------------------------------------------------

with Natools.Time_Statistics.Coarse_Timers;

package body Natools.Time_Statistics.Tests is

   procedure Check is new NT.Generic_Check
     (Natural, "=", Natural'Image, False);

   procedure Check is new NT.Generic_Check
     (Duration, "=", Duration'Image, False);


   -------------------------
   -- Complete Test Suite --
   -------------------------

   procedure All_Tests (Report : in out NT.Reporter'Class) is
   begin
      Summary_Accumulator (Report);
      Coarse_Timer (Report);
   end All_Tests;



   -----------------------
   -- Inidividual Tests --
   -----------------------

   procedure Coarse_Timer (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Coarse timer standard use");
      Total_Length : constant Duration := 0.2;
   begin
      declare
         Stats : aliased Summary;
      begin
         declare
            Actual_Auto : Coarse_Timers.Auto_Timer (Stats'Access);
            Aborted_Auto : Coarse_Timers.Auto_Timer (Stats'Access);
            Manual : Coarse_Timers.Manual_Timer (Stats'Access);

            pragma Unreferenced (Actual_Auto);
         begin
            Manual.Start;
            Check (Test, 0, Stats.Sample_Count);

            delay Total_Length / 2;

            Aborted_Auto.Cancel;
            Manual.Stop;
            Check (Test, 1, Stats.Sample_Count, "Sample count");
            Manual.Start;

            delay Total_Length / 2;

            Manual.Cancel;
            Check (Test, 1, Stats.Sample_Count, "Sample count");
         end;

         Check (Test, 2, Stats.Sample_Count, "Sample count");
      end;
   exception
      when Error : others => Test.Report_Exception (Error);
   end Coarse_Timer;


   procedure Summary_Accumulator (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Summary accumulator");
   begin
      declare
         Stats : Summary;
      begin