OSSP CVS Repository

ossp - Difference in ossp-pkg/sa/ts.c versions 1.2 and 1.3
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/sa/ts.c 1.2 -> 1.3

--- ts.c 2001/10/10 15:11:42     1.2
+++ ts.c 2001/10/31 19:28:49     1.3
@@ -4,7 +4,7 @@
 **  Copyright (c) 2001 The OSSP Project <http://www.ossp.org/>
 **  Copyright (c) 2001 Cable & Wireless Deutschland <http://www.cw.com/de/>
 **
-**  This file is part of OSSP TS, a test suite library which
+**  This file is part of OSSP TS, a small test suite library which
 **  can be found at http://www.ossp.org/pkg/ts/.
 **
 **  Permission to use, copy, modify, and distribute this software for
@@ -95,23 +95,23 @@
 };
 
 /* test suite test */
-struct tst_st {
-    RING_ENTRY(tst_t)  next;
+struct ts_test_st {
+    RING_ENTRY(ts_test_t)  next;
     char              *title;
-    tst_func_t         func;
+    ts_test_cb_t         func;
     const char        *file;
     int                line;
     RING_HEAD(tstc_t)  checks;
 };
 
 /* test suite */
-struct ts_st {
+struct ts_suite_st {
     char              *title;
-    RING_HEAD(tst_t)   tests;
+    RING_HEAD(ts_test_t)   tests;
 };
 
 /* minimal output-independent vprintf(3) variant which supports %{c,s,d,%} only */
-static int ts_mvxprintf(char *buffer, size_t bufsize, const char *format, va_list ap)
+static int ts_suite_mvxprintf(char *buffer, size_t bufsize, const char *format, va_list ap)
 {
     /* sufficient integer buffer: <available-bits> x log_10(2) + safety */
     char ibuf[((sizeof(int)*8)/3)+10]; 
@@ -189,7 +189,7 @@
 }
 
 /* minimal vasprintf(3) variant which supports %{c,s,d} only */
-static char *ts_mvasprintf(const char *format, va_list ap)
+static char *ts_suite_mvasprintf(const char *format, va_list ap)
 {
     char *buffer;
     int n;
@@ -198,70 +198,70 @@
     if (format == NULL || ap == NULL)
         return NULL;
     ap2 = ap;
-    if ((n = ts_mvxprintf(NULL, 0, format, ap)) == -1)
+    if ((n = ts_suite_mvxprintf(NULL, 0, format, ap)) == -1)
         return NULL;
     if ((buffer = (char *)malloc(n+1)) == NULL)
         return NULL;
-    ts_mvxprintf(buffer, n+1, format, ap2);
+    ts_suite_mvxprintf(buffer, n+1, format, ap2);
     return buffer;
 }
 
 /* minimal asprintf(3) variant which supports %{c,s,d} only */
-static char *ts_masprintf(const char *format, ...)
+static char *ts_suite_masprintf(const char *format, ...)
 {
     va_list ap;
     char *cp;
 
     va_start(ap, format);
-    cp = ts_mvasprintf(format, ap);
+    cp = ts_suite_mvasprintf(format, ap);
     va_end(ap);
     return cp;
 }
 
 /* create test suite */
-ts_t *ts_new(const char *fmt, ...)
+ts_suite_t *ts_suite_new(const char *fmt, ...)
 {
-    ts_t *ts;
+    ts_suite_t *ts;
     va_list ap;
 
-    if ((ts = (ts_t *)malloc(sizeof(ts_t))) == NULL)
+    if ((ts = (ts_suite_t *)malloc(sizeof(ts_suite_t))) == NULL)
         return NULL;
     va_start(ap, fmt);
-    ts->title = ts_mvasprintf(fmt, ap);
-    RING_INIT(&ts->tests, tst_t, next);
+    ts->title = ts_suite_mvasprintf(fmt, ap);
+    RING_INIT(&ts->tests, ts_test_t, next);
     va_end(ap);
     return ts;
 }
 
 /* add test case to test suite */
-void ts_test(ts_t *ts, tst_func_t func, const char *fmt, ...)
+void ts_suite_test(ts_suite_t *ts, ts_test_cb_t func, const char *fmt, ...)
 {
-    tst_t *tst;
+    ts_test_t *tst;
     va_list ap;
 
     if (ts == NULL || func == NULL || fmt == NULL)
         return;
-    if ((tst = (tst_t *)malloc(sizeof(tst_t))) == NULL)
+    if ((tst = (ts_test_t *)malloc(sizeof(ts_test_t))) == NULL)
         return;
     RING_ELEM_INIT(tst, next);
     va_start(ap, fmt);
-    tst->title = ts_mvasprintf(fmt, ap);
+    tst->title = ts_suite_mvasprintf(fmt, ap);
     va_end(ap);
     tst->func = func;
     tst->file = NULL;
     tst->line = 0;
     RING_INIT(&tst->checks, tstc_t, next);
-    RING_INSERT_TAIL(&ts->tests, tst, tst_t, next);
+    RING_INSERT_TAIL(&ts->tests, tst, ts_test_t, next);
     return;
 }
 
 /* run test suite */
-int ts_run(ts_t *ts)
+int ts_suite_run(ts_suite_t *ts)
 {
-    tst_t *tst;
+    ts_test_t *tst;
     tstc_t *tstc;
     tstl_t *tstl;
-    int total_tests, total_tests_failed;
+    int total_tests, total_tests_suite_failed;
     int total_checks, total_checks_failed;
     int test_checks, test_checks_failed;
     const char *file;
@@ -273,7 +273,7 @@
 
     /* init total counters */
     total_tests         = 0;
-    total_tests_failed  = 0;
+    total_tests_suite_failed  = 0;
     total_checks        = 0;
     total_checks_failed = 0;
 
@@ -284,8 +284,8 @@
     fflush(stdout);
 
     /* iterate through all test cases */
-    RING_FOREACH(tst, &ts->tests, tst_t, next) {
-        cp = ts_masprintf(" Test: %s ........................................"
+    RING_FOREACH(tst, &ts->tests, ts_test_t, next) {
+        cp = ts_suite_masprintf(" Test: %s ........................................"
                                     "........................................", tst->title);
         cp[60] = '\0';
         fprintf(stdout, "%s", cp);
@@ -339,7 +339,7 @@
         total_tests++;
         if (test_checks_failed > 0) {
             total_checks_failed += test_checks_failed;
-            total_tests_failed++;
+            total_tests_suite_failed++;
         }
     }
 
@@ -347,9 +347,9 @@
     fprintf(stdout, " __________________________________________________________________\n");
     fprintf(stdout, "\n");
     fprintf(stdout, " Test Summary: %d tests (%d ok, %d failed), %d checks (%d ok, %d failed)\n", 
-            total_tests, (total_tests - total_tests_failed), total_tests_failed, 
+            total_tests, (total_tests - total_tests_suite_failed), total_tests_suite_failed, 
             total_checks, (total_checks - total_checks_failed), total_checks_failed); 
-    if (total_tests_failed > 0)
+    if (total_tests_suite_failed > 0)
         fprintf(stdout, " Test Suite: FAILED\n");
     else
         fprintf(stdout, " Test Suite: OK\n");
@@ -360,15 +360,15 @@
 }
 
 /* destroy test suite */
-void ts_free(ts_t *ts)
+void ts_suite_free(ts_suite_t *ts)
 {
-    tst_t *tst;
+    ts_test_t *tst;
     tstc_t *tstc;
     tstl_t *tstl;
 
     if (ts == NULL)
         return;
-    RING_FOREACH(tst, &ts->tests, tst_t, next) {
+    RING_FOREACH(tst, &ts->tests, ts_test_t, next) {
         RING_FOREACH(tstc, &tst->checks, tstc_t, next) {
             RING_FOREACH(tstl, &tstc->logs, tstl_t, next) {
                 free(tstl->text);
@@ -385,7 +385,7 @@
 }
 
 /* annotate test case with file name and line number */
-tst_t *tst_ctx(tst_t *tst, const char *file, int line)
+ts_test_t *ts_test_ctx(ts_test_t *tst, const char *file, int line)
 {
     if (tst != NULL && file != NULL) {
         tst->file = file;
@@ -395,7 +395,7 @@
 }
 
 /* annotate test case with check */
-void tst_check(tst_t *tst, const char *fmt, ...)
+void ts_test_check(ts_test_t *tst, const char *fmt, ...)
 {
     tstc_t *tstc;
     va_list ap;
@@ -406,7 +406,7 @@
         return;
     va_start(ap, fmt);
     RING_ELEM_INIT(tstc, next);
-    tstc->title = ts_mvasprintf(fmt, ap);
+    tstc->title = ts_suite_mvasprintf(fmt, ap);
     tstc->failed = 0;
     tstc->file = tst->file;
     tstc->line = tst->line;
@@ -417,7 +417,7 @@
 }
 
 /* annotate test case with log message and failure */
-void tst_fail(tst_t *tst, const char *fmt, ...)
+void ts_test_fail(ts_test_t *tst, const char *fmt, ...)
 {
     tstc_t *tstc;
     tstl_t *tstl;
@@ -428,7 +428,7 @@
     if ((tstl = (tstl_t *)malloc(sizeof(tstl_t))) == NULL)
         return;
     va_start(ap, fmt);
-    tstl->text = ts_mvasprintf(fmt, ap);
+    tstl->text = ts_suite_mvasprintf(fmt, ap);
     tstl->file = tst->file;
     tstl->line = tst->line;
     RING_ELEM_INIT(tstl, next);
@@ -440,7 +440,7 @@
 }
 
 /* annotate test case with log message only */
-void tst_log(tst_t *tst, const char *fmt, ...)
+void ts_test_log(ts_test_t *tst, const char *fmt, ...)
 {
     tstc_t *tstc;
     tstl_t *tstl;
@@ -451,7 +451,7 @@
     if ((tstl = (tstl_t *)malloc(sizeof(tstl_t))) == NULL)
         return;
     va_start(ap, fmt);
-    tstl->text = ts_mvasprintf(fmt, ap);
+    tstl->text = ts_suite_mvasprintf(fmt, ap);
     tstl->file = tst->file;
     tstl->line = tst->line;
     RING_ELEM_INIT(tstl, next);

CVSTrac 2.0.1