[glib] Prevent division by zero if no tests



commit 08f473ffeff7524e619dc0459c07a981a3b4285c
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Jun 15 02:01:16 2010 -0400

    Prevent division by zero if no tests

 glib/gtester-report |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/glib/gtester-report b/glib/gtester-report
index a0ab600..71cbf1a 100755
--- a/glib/gtester-report
+++ b/glib/gtester-report
@@ -325,7 +325,10 @@ class HTMLReportWriter(ReportWriter):
                  (self.bcounter, self.total_tcounter, self.total_fcounter, self.total_tcounter - self.total_fcounter))
     self.oprint ('<td align="right">%f</td>\n' % self.total_duration)
     self.oprint ('<td align="center">-</td>\n')
-    perc = (self.total_tcounter - self.total_fcounter) * 100.0 / self.total_tcounter
+    if self.total_tcounter != 0:
+        perc = (self.total_tcounter - self.total_fcounter) * 100.0 / self.total_tcounter
+    else:
+        perc = 0.0
     pcolor = {
       100 : 'bgcolor="lightgreen"',
       0   : 'bgcolor="red"',



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]