@@ -116,14 +116,27 @@ def test_get_dt(self):
116116 self .assertEqual (row ['testdateandtime' ], '2020-07-12T17:32:02.854000' )
117117
118118 def test_get_time (self ):
119- """
120- TIME extraction from bytearray
121- """
122- test_array = bytearray (_bytearray )
123-
124- row = util .DB_Row (test_array , test_spec , layout_offset = 4 )
125-
126- self .assertEqual (row ['testTime' ], '-21:17:57:28.193' )
119+ test_values = [
120+ (0 , '0:0:0:0.0' ),
121+ (1 , '0:0:0:0.1' ), # T#1MS
122+ (1000 , '0:0:0:1.0' ), # T#1S
123+ (60000 , '0:0:1:0.0' ), # T#1M
124+ (3600000 , '0:1:0:0.0' ), # T#1H
125+ (86400000 , '1:0:0:0.0' ), # T#1D
126+ (2147483647 , '24:20:31:23.647' ), # max range
127+ (- 0 , '0:0:0:0.0' ),
128+ (- 1 , '-0:0:0:0.1' ), # T#-1MS
129+ (- 1000 , '-0:0:0:1.0' ), # T#-1S
130+ (- 60000 , '-0:0:1:0.0' ), # T#-1M
131+ (- 3600000 , '-0:1:0:0.0' ), # T#-1H
132+ (- 86400000 , '-1:0:0:0.0' ), # T#-1D
133+ (- 2147483647 , '-24:20:31:23.647' ), # min range
134+ ]
135+
136+ data = bytearray (4 )
137+ for value_to_test , expected_value in test_values :
138+ data [:] = struct .pack (">i" , value_to_test )
139+ self .assertEqual (util .get_time (data , 0 ), expected_value )
127140
128141 def test_set_time (self ):
129142 test_array = bytearray (_new_bytearray )
0 commit comments