Natools

Check-in [a193bf89b9]
Login
Overview
Comment:time_keys-tests: add test for leap second to reach full coverage
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a193bf89b940b6df996d26340b4f09534b5e8c9d
User & Date: nat on 2016-01-09 20:43:34
Other Links: manifest | tags
Context
2016-09-02
20:48
smaz: new package providing a simple compressor for small strings check-in: d98a8c25da user: nat tags: trunk
2016-01-09
20:43
time_keys-tests: add test for leap second to reach full coverage check-in: a193bf89b9 user: nat tags: trunk
2016-01-08
18:05
cron-tests: lengthen test to help it pass on slow busy machines check-in: b3f94db9eb user: nat tags: trunk
Changes

Modified tests/natools-time_keys-tests.adb from [243ddc1759] to [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,

Modified tests/natools-time_keys-tests.ads from [71458af104] to [6f1760c243].

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         --
18
19
20
21
22
23
24

25
26
27
28

package Natools.Time_Keys.Tests is

   package NT renames Natools.Tests;

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


   procedure Roundtrips (Report : in out NT.Reporter'Class);
   procedure Subsecond_Rounding (Report : in out NT.Reporter'Class);

end Natools.Time_Keys.Tests;







>




18
19
20
21
22
23
24
25
26
27
28
29

package Natools.Time_Keys.Tests is

   package NT renames Natools.Tests;

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

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

end Natools.Time_Keys.Tests;