annotate test/automated/SDL_at.c @ 3727:51900b161948 gsoc2009_unit_tests

Fixed accidentle broken compile.
author Edgar Simo <bobbens@gmail.com>
date Sat, 11 Jul 2009 19:08:06 +0000
parents 6eca2af6a86b
children 808fad5fb593
rev   line source
3711
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1 /*
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
2 * Common code for automated test suite.
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
3 *
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
4 * Written by Edgar Simo "bobbens"
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
5 *
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
6 * Released under Public Domain.
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
7 */
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
8
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
9
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
10 #include "SDL_at.h"
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
11
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
12 #include <stdio.h>
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
13 #include <stdarg.h>
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
14
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
15
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
16 /*
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
17 * Internal usage SDL_AT variables.
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
18 */
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
19 static const char *at_suite_msg = NULL; /**< Testsuite message. */
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
20 static const char *at_test_msg = NULL; /**< Testcase message. */
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
21 static int at_success = 0; /**< Number of successful testcases. */
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
22 static int at_failure = 0; /**< Number of failed testcases. */
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
23
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
24
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
25 /**
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
26 * @brief Cleans up the automated testsuite state.
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
27 */
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
28 static void SDL_ATcleanup (void)
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
29 {
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
30 at_suite_msg = NULL;
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
31 at_test_msg = NULL;
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
32 at_success = 0;
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
33 at_failure = 0;
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
34 }
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
35
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
36
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
37 /**
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
38 * @brief Begin testsuite.
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
39 */
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
40 void SDL_ATinit( const char *suite )
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
41 {
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
42 /* Do not open twice. */
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
43 if (at_suite_msg) {
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
44 SDL_ATprint( "AT suite '%s' not closed before opening suite '%s'\n",
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
45 at_suite_msg, suite );
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
46 }
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
47 /* Must have a name. */
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
48 if (suite == NULL) {
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
49 SDL_ATprint( "AT testsuite does not have a name.\n");
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
50 }
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
51 SDL_ATcleanup();
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
52 at_suite_msg = suite;
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
53 }
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
54
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
55
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
56 /**
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
57 * @brief Finish testsuite.
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
58 */
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
59 int SDL_ATfinish( int verbose )
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
60 {
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
61 int failed;
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
62
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
63 /* Make sure initialized. */
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
64 if (at_suite_msg == NULL) {
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
65 SDL_ATprint("Ended testcase without initializing.\n");
3722
d8772964e402 Added more strict warning flags.
Edgar Simo <bobbens@gmail.com>
parents: 3713
diff changeset
66 return 1;
3711
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
67 }
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
68
3725
6eca2af6a86b Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents: 3722
diff changeset
69 /* Finished without closing testcase. */
6eca2af6a86b Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents: 3722
diff changeset
70 if (at_test_msg) {
6eca2af6a86b Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents: 3722
diff changeset
71 SDL_ATprint( "AT suite '%s' finished without closing testcase '%s'\n",
3727
51900b161948 Fixed accidentle broken compile.
Edgar Simo <bobbens@gmail.com>
parents: 3725
diff changeset
72 at_suite_msg, at_test_msg );
3725
6eca2af6a86b Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents: 3722
diff changeset
73 }
6eca2af6a86b Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents: 3722
diff changeset
74
3711
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
75 /* Display message if verbose on failed. */
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
76 failed = at_failure;
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
77 if (verbose) {
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
78 if (at_failure > 0) {
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
79 SDL_ATprint( "%s : Failed %d out of %d testcases!\n",
3713
a34bab848c7e Better output.
Edgar Simo <bobbens@gmail.com>
parents: 3711
diff changeset
80 at_suite_msg, at_failure, at_failure+at_success );
3711
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
81 }
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
82 else {
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
83 SDL_ATprint( "%s : All tests successful (%d)\n",
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
84 at_suite_msg, at_success );
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
85 }
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
86 }
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
87
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
88 /* Clean up. */
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
89 SDL_ATcleanup();
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
90
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
91 /* Return failed. */
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
92 return failed;
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
93 }
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
94
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
95
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
96 /**
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
97 * @brief Begin testcase.
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
98 */
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
99 void SDL_ATbegin( const char *testcase )
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
100 {
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
101 /* Do not open twice. */
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
102 if (at_test_msg) {
3713
a34bab848c7e Better output.
Edgar Simo <bobbens@gmail.com>
parents: 3711
diff changeset
103 SDL_ATprint( "AT testcase '%s' not closed before opening testcase '%s'\n",
3711
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
104 at_test_msg, testcase );
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
105 }
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
106 /* Must have a name. */
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
107 if (testcase == NULL) {
3713
a34bab848c7e Better output.
Edgar Simo <bobbens@gmail.com>
parents: 3711
diff changeset
108 SDL_ATprint( "AT testcase does not have a name.\n");
3711
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
109 }
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
110 at_test_msg = testcase;
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
111 }
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
112
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
113
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
114 /**
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
115 * @brief Ends the testcase with a succes or failure.
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
116 */
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
117 static void SDL_ATendWith( int success )
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
118 {
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
119 /* Make sure initialized. */
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
120 if (at_test_msg == NULL) {
3713
a34bab848c7e Better output.
Edgar Simo <bobbens@gmail.com>
parents: 3711
diff changeset
121 SDL_ATprint("Ended testcase without initializing.\n");
3711
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
122 return;
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
123 }
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
124
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
125 /* Mark as success or failure. */
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
126 if (success)
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
127 at_success++;
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
128 else
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
129 at_failure++;
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
130
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
131 /* Clean up. */
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
132 at_test_msg = NULL;
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
133 }
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
134
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
135
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
136 /**
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
137 * @brief Testcase test.
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
138 */
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
139 int SDL_ATassert( const char *msg, int condition )
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
140 {
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
141 /* Condition failed. */
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
142 if (!condition) {
3725
6eca2af6a86b Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents: 3722
diff changeset
143 /* Print. */
3713
a34bab848c7e Better output.
Edgar Simo <bobbens@gmail.com>
parents: 3711
diff changeset
144 SDL_ATprint( "%s [%s] : %s\n", at_suite_msg, at_test_msg, msg );
3725
6eca2af6a86b Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents: 3722
diff changeset
145 /* End. */
6eca2af6a86b Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents: 3722
diff changeset
146 SDL_ATendWith(0);
6eca2af6a86b Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents: 3722
diff changeset
147 }
6eca2af6a86b Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents: 3722
diff changeset
148 return !condition;
6eca2af6a86b Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents: 3722
diff changeset
149 }
6eca2af6a86b Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents: 3722
diff changeset
150
6eca2af6a86b Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents: 3722
diff changeset
151
6eca2af6a86b Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents: 3722
diff changeset
152 /**
6eca2af6a86b Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents: 3722
diff changeset
153 * @brief Testcase test.
6eca2af6a86b Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents: 3722
diff changeset
154 */
6eca2af6a86b Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents: 3722
diff changeset
155 int SDL_ATvassert( int condition, const char *msg, ... )
6eca2af6a86b Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents: 3722
diff changeset
156 {
6eca2af6a86b Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents: 3722
diff changeset
157 va_list args;
6eca2af6a86b Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents: 3722
diff changeset
158 char buf[256];
6eca2af6a86b Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents: 3722
diff changeset
159
6eca2af6a86b Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents: 3722
diff changeset
160 /* Condition failed. */
6eca2af6a86b Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents: 3722
diff changeset
161 if (!condition) {
6eca2af6a86b Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents: 3722
diff changeset
162 /* Get message. */
6eca2af6a86b Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents: 3722
diff changeset
163 va_start( args, msg );
6eca2af6a86b Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents: 3722
diff changeset
164 vsnprintf( buf, sizeof(buf), msg, args );
6eca2af6a86b Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents: 3722
diff changeset
165 va_end( args );
6eca2af6a86b Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents: 3722
diff changeset
166 /* Print. */
6eca2af6a86b Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents: 3722
diff changeset
167 SDL_ATprint( "%s [%s] : %s\n", at_suite_msg, at_test_msg, buf );
6eca2af6a86b Added SDL_ATvassert for printf style printing.
Edgar Simo <bobbens@gmail.com>
parents: 3722
diff changeset
168 /* End. */
3711
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
169 SDL_ATendWith(0);
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
170 }
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
171 return !condition;
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
172 }
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
173
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
174
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
175 /**
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
176 * @brief End testcase.
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
177 */
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
178 void SDL_ATend (void)
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
179 {
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
180 SDL_ATendWith(1);
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
181 }
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
182
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
183
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
184 /**
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
185 * @brief Displays a message.
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
186 */
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
187 int SDL_ATprint( const char *msg, ... )
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
188 {
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
189 va_list ap;
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
190 int ret;
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
191
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
192 /* Make sure there is something to print. */
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
193 if (msg == NULL)
3722
d8772964e402 Added more strict warning flags.
Edgar Simo <bobbens@gmail.com>
parents: 3713
diff changeset
194 return 0;
3711
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
195 else {
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
196 va_start(ap, msg);
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
197 ret = vprintf(msg, ap);
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
198 va_end(ap);
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
199 }
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
200
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
201 return ret;
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
202 }
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
203
80839fc6b8e1 First revision of the automated test suite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
204