Natools

Diff
Login

Differences From Artifact [243ddc1759]:

To Artifact [fd569e3ec6]:


1
2
3
4
5
6
7
8
9
------------------------------------------------------------------------------
-- Copyright (c) 2015, Natacha Porté                                        --
--                                                                          --
-- Permission to use, copy, modify, and distribute this software for any    --
-- purpose with or without fee is hereby granted, provided that the above   --
-- copyright notice and this permission notice appear in all copies.        --
--                                                                          --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF         --

|







1
2
3
4
5
6
7
8
9
------------------------------------------------------------------------------
-- Copyright (c) 2015-2016, Natacha Porté                                   --
--                                                                          --
-- Permission to use, copy, modify, and distribute this software for any    --
-- purpose with or without fee is hereby granted, provided that the above   --
-- copyright notice and this permission notice appear in all copies.        --
--                                                                          --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF         --
87
88
89
90
91
92
93

94
95
96
97
98
99
100
101
102







































103
104
105
106
107
108
109

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

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

      Roundtrips (Report);
      Subsecond_Rounding (Report);
   end All_Tests;



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








































   procedure Roundtrips (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Conversion Roundtrips");
   begin
      if Duration'Small <= 1.0 / 128.0 then
         Roundtrip_Test
           (Test,







>









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







87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149

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

   procedure All_Tests (Report : in out NT.Reporter'Class) is
   begin
      Leap_Second (Report);
      Roundtrips (Report);
      Subsecond_Rounding (Report);
   end All_Tests;



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

   procedure Leap_Second (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Leap second support");
   begin
      declare
         use type Ada.Calendar.Time;

         Year : constant Ada.Calendar.Year_Number                      := 2012;
         Month : constant Ada.Calendar.Month_Number                    := 6;
         Day : constant Ada.Calendar.Day_Number                        := 30;
         Hour : constant Ada.Calendar.Formatting.Hour_Number           := 23;
         Minute : constant Ada.Calendar.Formatting.Minute_Number       := 59;
         Second : constant Ada.Calendar.Formatting.Second_Number       := 59;
         Sub_Second : constant Ada.Calendar.Formatting.Second_Duration := 0.5;

         Expected_Time : constant Ada.Calendar.Time
           := Ada.Calendar.Formatting.Time_Of
              (Year, Month, Day, Hour, Minute, Second, Sub_Second, True);
         Expected_Key : constant String := "VS6UNwxW";

         Generated_Key : constant String := To_Key
           (Year, Month, Day, Hour, Minute, Second, Sub_Second, True, 1);
         Recovered_Time : constant Ada.Calendar.Time
           := To_Time (Generated_Key);
      begin
         if Generated_Key /= Expected_Key then
            Test.Fail ("Generated key """ & Generated_Key
              & """, expected """ & Expected_Key & '"');
         end if;

         if Recovered_Time /= Expected_Time then
            Test.Fail ("Roundtrip time: " & Image (Recovered_Time)
              & ", expected: " & Image (Expected_Time));
         end if;
      end;
   exception
      when Error : others => Test.Report_Exception (Error);
   end Leap_Second;


   procedure Roundtrips (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Conversion Roundtrips");
   begin
      if Duration'Small <= 1.0 / 128.0 then
         Roundtrip_Test
           (Test,