char *str;
str = sr_stat_str (sr);
- fprintf (file, str);
+ fprintf (file, "%s\n", str);
free(str);
}
return;
if ((print_mode >= CRVERBOSE && tr->rtype == CRPASS) ||
(tr->rtype != CRPASS && print_mode >= CRNORMAL)) {
char *trstr = tr_str (tr);
- fprintf (file, trstr);
+ fprintf (file,"%s\n", trstr);
free(trstr);
}
}
exact_msg = (tr->rtype == CRERROR) ? "(after this point) ": "";
rstr = emalloc(CMAXMSG);
- snprintf (rstr, CMAXMSG, "%s:%d:%s:%s: %s%s\n",
+ snprintf (rstr, CMAXMSG, "%s:%d:%s:%s: %s%s",
tr->file, tr->line,
rtype_str(tr->rtype), tr->tcname,
exact_msg, tr->msg);
ts = sr->stats;
str = emalloc (CMAXMSG);
- snprintf (str, CMAXMSG, "%d%%: Checks: %d, Failures: %d, Errors: %d\n",
+ snprintf (str, CMAXMSG, "%d%%: Checks: %d, Failures: %d, Errors: %d",
percent_passed (ts), ts->n_checked, ts->n_failed,
ts->n_errors);
return str;
{
if (t->n_failed == 0 && t->n_errors == 0)
return 100;
+ else if (t->n_checked == 0)
+ return 0;
else
return (int) ( (float) (t->n_checked - (t->n_failed + t->n_errors)) /
(float) t->n_checked * 100);
--- /dev/null
+#include <stdlib.h>
+#include <string.h>
+#include <check.h>
+#include "check_check.h"
+#include "check_str.h"
+
+
+static SRunner *sr;
+
+static void limit_setup (void)
+{
+ Suite *s = suite_create("Empty");
+ sr = srunner_create(s);
+ srunner_run_all(sr, CRSILENT);
+}
+
+static void limit_teardown (void)
+{
+ srunner_free(sr);
+}
+
+START_TEST(test_summary)
+{
+ fail_unless(strcmp(sr_stat_str(sr),
+ "100%: Checks: 0, Failures: 0, Errors: 0") == 0,
+ "Bad statistics string for empty suite");
+}
+END_TEST
+
+Suite *make_limit_suite (void)
+{
+ Suite *s = suite_create("Limit");
+ TCase *tc = tcase_create("Empty");
+
+ tcase_add_test(tc,test_summary);
+ tcase_set_fixture(tc,limit_setup,limit_teardown);
+
+ suite_add_tcase(s, tc);
+
+ return s;
+}