@@ -202,13 +202,19 @@ fn debug_formatting_precision_zero() {
202202 assert_eq ! ( format!( "{:.0?}" , Duration :: new( 0 , 123 ) ) , "123ns" ) ;
203203
204204 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" ) ;
206208
207209 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" ) ;
209213
210214 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" ) ;
212218}
213219
214220#[ test]
@@ -222,15 +228,19 @@ fn debug_formatting_precision_two() {
222228 assert_eq ! ( format!( "{:.2?}" , Duration :: new( 0 , 1_000 ) ) , "1.00µs" ) ;
223229 assert_eq ! ( format!( "{:.2?}" , Duration :: new( 0 , 7_001 ) ) , "7.00µs" ) ;
224230 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" ) ;
226234
227235 assert_eq ! ( format!( "{:.2?}" , Duration :: new( 0 , 1_000_000 ) ) , "1.00ms" ) ;
228236 assert_eq ! ( format!( "{:.2?}" , Duration :: new( 0 , 3_001_000 ) ) , "3.00ms" ) ;
229237 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 " ) ;
231239
232240 assert_eq ! ( format!( "{:.2?}" , Duration :: new( 1 , 000_000_000 ) ) , "1.00s" ) ;
233241 assert_eq ! ( format!( "{:.2?}" , Duration :: new( 4 , 001_000_000 ) ) , "4.00s" ) ;
234242 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" ) ;
236246}
0 commit comments