@@ -202,13 +202,19 @@ fn debug_formatting_precision_zero() {
202
202
assert_eq ! ( format!( "{:.0?}" , Duration :: new( 0 , 123 ) ) , "123ns" ) ;
203
203
204
204
assert_eq ! ( format!( "{:.0?}" , Duration :: new( 0 , 1_001 ) ) , "1µs" ) ;
205
- assert_eq ! ( format!( "{:.0?}" , Duration :: new( 0 , 1_999 ) ) , "1µs" ) ;
205
+ assert_eq ! ( format!( "{:.0?}" , Duration :: new( 0 , 1_499 ) ) , "1µs" ) ;
206
+ assert_eq ! ( format!( "{:.0?}" , Duration :: new( 0 , 1_500 ) ) , "2µs" ) ;
207
+ assert_eq ! ( format!( "{:.0?}" , Duration :: new( 0 , 1_999 ) ) , "2µs" ) ;
206
208
207
209
assert_eq ! ( format!( "{:.0?}" , Duration :: new( 0 , 1_000_001 ) ) , "1ms" ) ;
208
- assert_eq ! ( format!( "{:.0?}" , Duration :: new( 0 , 1_999_999 ) ) , "1ms" ) ;
210
+ assert_eq ! ( format!( "{:.0?}" , Duration :: new( 0 , 1_499_999 ) ) , "1ms" ) ;
211
+ assert_eq ! ( format!( "{:.0?}" , Duration :: new( 0 , 1_500_000 ) ) , "2ms" ) ;
212
+ assert_eq ! ( format!( "{:.0?}" , Duration :: new( 0 , 1_999_999 ) ) , "2ms" ) ;
209
213
210
214
assert_eq ! ( format!( "{:.0?}" , Duration :: new( 1 , 000_000_001 ) ) , "1s" ) ;
211
- assert_eq ! ( format!( "{:.0?}" , Duration :: new( 1 , 999_999_999 ) ) , "1s" ) ;
215
+ assert_eq ! ( format!( "{:.0?}" , Duration :: new( 1 , 499_999_999 ) ) , "1s" ) ;
216
+ assert_eq ! ( format!( "{:.0?}" , Duration :: new( 1 , 500_000_000 ) ) , "2s" ) ;
217
+ assert_eq ! ( format!( "{:.0?}" , Duration :: new( 1 , 999_999_999 ) ) , "2s" ) ;
212
218
}
213
219
214
220
#[ test]
@@ -222,15 +228,19 @@ fn debug_formatting_precision_two() {
222
228
assert_eq ! ( format!( "{:.2?}" , Duration :: new( 0 , 1_000 ) ) , "1.00µs" ) ;
223
229
assert_eq ! ( format!( "{:.2?}" , Duration :: new( 0 , 7_001 ) ) , "7.00µs" ) ;
224
230
assert_eq ! ( format!( "{:.2?}" , Duration :: new( 0 , 7_100 ) ) , "7.10µs" ) ;
225
- assert_eq ! ( format!( "{:.2?}" , Duration :: new( 0 , 1_999 ) ) , "1.99µs" ) ;
231
+ assert_eq ! ( format!( "{:.2?}" , Duration :: new( 0 , 7_109 ) ) , "7.11µs" ) ;
232
+ assert_eq ! ( format!( "{:.2?}" , Duration :: new( 0 , 7_199 ) ) , "7.20µs" ) ;
233
+ assert_eq ! ( format!( "{:.2?}" , Duration :: new( 0 , 1_999 ) ) , "2.00µs" ) ;
226
234
227
235
assert_eq ! ( format!( "{:.2?}" , Duration :: new( 0 , 1_000_000 ) ) , "1.00ms" ) ;
228
236
assert_eq ! ( format!( "{:.2?}" , Duration :: new( 0 , 3_001_000 ) ) , "3.00ms" ) ;
229
237
assert_eq ! ( format!( "{:.2?}" , Duration :: new( 0 , 3_100_000 ) ) , "3.10ms" ) ;
230
- assert_eq ! ( format!( "{:.2?}" , Duration :: new( 0 , 1_999_999 ) ) , "1.99ms " ) ;
238
+ assert_eq ! ( format!( "{:.2?}" , Duration :: new( 0 , 1_999_999 ) ) , "2.00ms " ) ;
231
239
232
240
assert_eq ! ( format!( "{:.2?}" , Duration :: new( 1 , 000_000_000 ) ) , "1.00s" ) ;
233
241
assert_eq ! ( format!( "{:.2?}" , Duration :: new( 4 , 001_000_000 ) ) , "4.00s" ) ;
234
242
assert_eq ! ( format!( "{:.2?}" , Duration :: new( 2 , 100_000_000 ) ) , "2.10s" ) ;
235
- assert_eq ! ( format!( "{:.2?}" , Duration :: new( 8 , 999_999_999 ) ) , "8.99s" ) ;
243
+ assert_eq ! ( format!( "{:.2?}" , Duration :: new( 2 , 104_990_000 ) ) , "2.10s" ) ;
244
+ assert_eq ! ( format!( "{:.2?}" , Duration :: new( 2 , 105_000_000 ) ) , "2.11s" ) ;
245
+ assert_eq ! ( format!( "{:.2?}" , Duration :: new( 8 , 999_999_999 ) ) , "9.00s" ) ;
236
246
}
0 commit comments