File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,10 @@ fn render_table(suites: BTreeMap<String, TestSuiteRecord>) -> String {
6767 let mut table = "| Test suite | Passed ✅ | Ignored 🚫 | Failed ❌ |\n " . to_string ( ) ;
6868 writeln ! ( table, "|:------|------:|------:|------:|" ) . unwrap ( ) ;
6969
70+ fn compute_pct ( value : f64 , total : f64 ) -> f64 {
71+ if total == 0.0 { 0.0 } else { value / total }
72+ }
73+
7074 fn write_row (
7175 buffer : & mut String ,
7276 name : & str ,
@@ -75,9 +79,9 @@ fn render_table(suites: BTreeMap<String, TestSuiteRecord>) -> String {
7579 ) -> std:: fmt:: Result {
7680 let TestSuiteRecord { passed, ignored, failed } = record;
7781 let total = ( record. passed + record. ignored + record. failed ) as f64 ;
78- let passed_pct = ( ( * passed as f64 ) / total) * 100.0 ;
79- let ignored_pct = ( ( * ignored as f64 ) / total) * 100.0 ;
80- let failed_pct = ( ( * failed as f64 ) / total) * 100.0 ;
82+ let passed_pct = compute_pct ( * passed as f64 , total) * 100.0 ;
83+ let ignored_pct = compute_pct ( * ignored as f64 , total) * 100.0 ;
84+ let failed_pct = compute_pct ( * failed as f64 , total) * 100.0 ;
8185
8286 write ! ( buffer, "| {surround}{name}{surround} |" ) ?;
8387 write ! ( buffer, " {surround}{passed} ({passed_pct:.0}%){surround} |" ) ?;
You can’t perform that action at this time.
0 commit comments