:pserver:cvsanon@mok.lvcm.com:/CVS/ReactOS reactos
[reactos.git] / apps / tests / test_old / testsuite.c
1
2 #include <windows.h>
3 #include <stdio.h>
4
5 #include "testsuite.h"
6
7 static PTEST_RUNNER iTestRunner = 0;
8
9 void  tsRunTests (PTEST_RUNNER pTestRunner, PTEST_SUITE pTests)
10 {
11   int testIndex;
12
13   iTestRunner = pTestRunner;
14   for (testIndex = 0; pTests [testIndex].testFunc != 0; testIndex++)
15   {
16     pTests [testIndex].testFunc ();
17     pTestRunner->tests++;
18   }
19 }
20
21 void  tsReportResults (PTEST_RUNNER pTestRunner)
22 {
23   printf ("\nTotal of %d tests.\n"
24           "Assertions: %d\n"
25           "  Assertions which passed: %d\n"
26           "  Assertions which failed: %d\n",
27           pTestRunner->tests,
28           pTestRunner->assertions,
29           pTestRunner->successes,
30           pTestRunner->failures);
31   if (pTestRunner->failures == 0)
32   {
33     printf ("\n*** OK ***\n");
34   }
35   else
36   {
37     printf ("\n*** FAIL ***\n");
38   }
39 }
40
41 void  tsDoAssertion (BOOL  pTest, 
42                      PCHAR  pTestText, 
43                      PCHAR  pFunction, 
44                      int  pLine,
45                      ...)
46 {
47   va_list  ap;
48
49   iTestRunner->assertions++;
50   if (!pTest) 
51   {
52     va_start (ap, pLine);
53     printf ("%s(%d): ", pFunction, pLine);
54     vprintf (pTestText, ap); 
55     printf ("\n");
56     va_end(ap);
57     iTestRunner->failures++;
58   }
59   else
60   {
61     iTestRunner->successes++;
62   }
63 }
64
65