@@ -178,6 +178,56 @@ def test_farthest_with_equals():
178178 assert t2 == farthest
179179
180180
181+ def test_closest_with_microseconds ():
182+ instance = pendulum .time (12 , 0 , 0 , 900000 )
183+ t1 = pendulum .time (12 , 0 , 0 , 900000 )
184+ t2 = pendulum .time (12 , 0 , 1 , 100000 )
185+
186+ assert instance .closest (t1 , t2 ) == t1
187+ assert instance .closest (t2 , t1 ) == t1
188+
189+
190+ def test_closest_with_microseconds_across_a_second ():
191+ instance = pendulum .time (12 , 0 , 0 , 900000 )
192+ t1 = pendulum .time (12 , 0 , 1 )
193+ t2 = pendulum .time (12 , 0 , 0 )
194+
195+ assert instance .closest (t1 , t2 ) == t1
196+ assert instance .closest (t2 , t1 ) == t1
197+
198+
199+ def test_closest_with_microseconds_of_native_times ():
200+ instance = pendulum .time (12 , 0 , 0 , 900000 )
201+ closest = instance .closest (time (12 , 0 , 0 , 900000 ), time (12 , 0 , 1 , 100000 ))
202+
203+ assert_time (closest , 12 , 0 , 0 , 900000 )
204+
205+
206+ def test_farthest_with_microseconds ():
207+ instance = pendulum .time (12 , 0 , 0 , 900000 )
208+ t1 = pendulum .time (12 , 0 , 0 , 900000 )
209+ t2 = pendulum .time (12 , 0 , 1 , 100000 )
210+
211+ assert instance .farthest (t1 , t2 ) == t2
212+ assert instance .farthest (t2 , t1 ) == t2
213+
214+
215+ def test_farthest_with_microseconds_across_a_second ():
216+ instance = pendulum .time (12 , 0 , 0 , 900000 )
217+ t1 = pendulum .time (12 , 0 , 1 )
218+ t2 = pendulum .time (12 , 0 , 0 )
219+
220+ assert instance .farthest (t1 , t2 ) == t2
221+ assert instance .farthest (t2 , t1 ) == t2
222+
223+
224+ def test_farthest_with_microseconds_of_native_times ():
225+ instance = pendulum .time (12 , 0 , 0 , 900000 )
226+ farthest = instance .farthest (time (12 , 0 , 1 , 100000 ), time (12 , 0 , 0 , 900000 ))
227+
228+ assert_time (farthest , 12 , 0 , 1 , 100000 )
229+
230+
181231def test_comparison_to_unsupported ():
182232 t1 = pendulum .now ().time ()
183233
0 commit comments