AceUnitLogging.h

Go to the documentation of this file.
00001 /* Copyright (c) 2007, Christian Hujer
00002  * All rights reserved.
00003  *
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions are met:
00006  *     * Redistributions of source code must retain the above copyright
00007  *       notice, this list of conditions and the following disclaimer.
00008  *     * Redistributions in binary form must reproduce the above copyright
00009  *       notice, this list of conditions and the following disclaimer in the
00010  *       documentation and/or other materials provided with the distribution.
00011  *     * Neither the name of the AceUnit developers nor the
00012  *       names of its contributors may be used to endorse or promote products
00013  *       derived from this software without specific prior written permission.
00014  *
00015  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00016  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00017  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00018  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
00019  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00020  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00021  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00022  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00023  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00024  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00025  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026  */
00027 
00028 #ifndef ACEUNITLOGGING_H
00029 
00030 #define ACEUNITLOGGING_H 1
00031 
00032 #include "AceUnit.h"
00033 
00048 #define ACEUNIT_LOGGING_STYLE_SIMPLE 1
00049 
00054 #define ACEUNIT_LOGGING_STYLE_FULL 2
00055 
00056 #ifndef ACEUNIT_LOGGING_STYLE
00057 
00064 #ifdef ACEUNIT_EMBEDDED
00065 #define ACEUNIT_LOGGING_STYLE ACEUNIT_LOGGING_STYLE_SIMPLE
00066 #else
00067 #define ACEUNIT_LOGGING_STYLE ACEUNIT_LOGGING_STYLE_FULL
00068 #endif
00069 #endif
00070 
00071 #if ACEUNIT_LOGGING_STYLE == ACEUNIT_LOGGING_STYLE_FULL
00072 
00073 #define ACEUNIT_LOG_RUNNER
00074 #endif
00075 
00076 #if ACEUNIT_LOGGING_STYLE == ACEUNIT_LOGGING_STYLE_FULL
00077 
00078 #define ACEUNIT_LOG_SUITE
00079 #endif
00080 
00081 #if ACEUNIT_LOGGING_STYLE == ACEUNIT_LOGGING_STYLE_FULL
00082 
00083 #define ACEUNIT_LOG_FIXTURE
00084 #endif
00085 
00086 #if ACEUNIT_LOGGING_STYLE == ACEUNIT_LOGGING_STYLE_FULL
00087 
00088 #define ACEUNIT_LOG_TESTCASE
00089 #endif
00090 
00091 /* Note: Logging of failures cannot be turned off. */
00092 
00102 typedef struct {
00103 
00104 #ifdef ACEUNIT_LOG_RUNNER
00105 
00108     void(*runnerStarted)(void);
00109 #endif
00110 
00111 #ifdef ACEUNIT_LOG_SUITE
00112 
00115     void(*suiteStarted)(SuiteId_t const suiteId);
00116 #endif
00117 
00118 #ifdef ACEUNIT_LOG_FIXTURE
00119 
00123     void(*fixtureStarted)(const FixtureId_t fixture);
00124 #endif
00125 
00126 #ifdef ACEUNIT_LOG_TESTCASE
00127 
00131     void(*testCaseStarted)(TestCaseId_t testCase);
00132 #endif
00133 
00138     void(*testCaseFailed)(const AssertionError_t *error);
00139 
00140 #ifdef ACEUNIT_LOG_TESTCASE
00141 
00146     void(*testCaseEnded)(TestCaseId_t testCase);
00147 #endif
00148 
00149 #ifdef ACEUNIT_LOG_FIXTURE
00150 
00154     void(*fixtureEnded)(FixtureId_t fixture);
00155 #endif
00156 
00157 #ifdef ACEUNIT_LOG_SUITE
00158 
00161     void(*suiteEnded)(SuiteId_t const suiteId);
00162 #endif
00163 
00164 #ifdef ACEUNIT_LOG_RUNNER
00165 
00168     void(*runnerEnded)(void);
00169 #endif
00170 
00171 } TestLogger_t;
00172 
00187 /* TODO if somebody knows a simplier way... */
00188 #if   !defined(ACEUNIT_LOG_RUNNER) && !defined(ACEUNIT_LOG_SUITE) && !defined(ACEUNIT_LOG_FIXTURE) && !defined(ACEUNIT_LOG_TESTCASE)
00189 #define AceUnitNewLogger(name, runnerStarted, suiteStarted, fixtureStarted, testCaseStarted, testCaseFailed, testCaseEnded, fixtureEnded, suiteEnded, runnerEnded) TestLogger_t name = {\
00190     testCaseFailed\
00191 }
00192 #elif !defined(ACEUNIT_LOG_RUNNER) && !defined(ACEUNIT_LOG_SUITE) && !defined(ACEUNIT_LOG_FIXTURE) &&  defined(ACEUNIT_LOG_TESTCASE)
00193 #define AceUnitNewLogger(name, runnerStarted, suiteStarted, fixtureStarted, testCaseStarted, testCaseFailed, testCaseEnded, fixtureEnded, suiteEnded, runnerEnded) TestLogger_t name = {\
00194     testCaseStarted,\
00195     testCaseFailed,\
00196     testCaseEnded\
00197 }
00198 #elif !defined(ACEUNIT_LOG_RUNNER) && !defined(ACEUNIT_LOG_SUITE) &&  defined(ACEUNIT_LOG_FIXTURE) && !defined(ACEUNIT_LOG_TESTCASE)
00199 #define AceUnitNewLogger(name, runnerStarted, suiteStarted, fixtureStarted, testCaseStarted, testCaseFailed, testCaseEnded, fixtureEnded, suiteEnded, runnerEnded) TestLogger_t name = {\
00200     fixtureStarted,\
00201     testCaseFailed,\
00202     fixtureEnded,\
00203 }
00204 #elif !defined(ACEUNIT_LOG_RUNNER) && !defined(ACEUNIT_LOG_SUITE) &&  defined(ACEUNIT_LOG_FIXTURE) &&  defined(ACEUNIT_LOG_TESTCASE)
00205 #define AceUnitNewLogger(name, runnerStarted, suiteStarted, fixtureStarted, testCaseStarted, testCaseFailed, testCaseEnded, fixtureEnded, suiteEnded, runnerEnded) TestLogger_t name = {\
00206     fixtureStarted,\
00207     testCaseStarted,\
00208     testCaseFailed,\
00209     testCaseEnded,\
00210     fixtureEnded,\
00211 }
00212 #elif !defined(ACEUNIT_LOG_RUNNER) &&  defined(ACEUNIT_LOG_SUITE) && !defined(ACEUNIT_LOG_FIXTURE) && !defined(ACEUNIT_LOG_TESTCASE)
00213 #define AceUnitNewLogger(name, runnerStarted, suiteStarted, fixtureStarted, testCaseStarted, testCaseFailed, testCaseEnded, fixtureEnded, suiteEnded, runnerEnded) TestLogger_t name = {\
00214     suiteStarted,\
00215     testCaseFailed,\
00216     suiteEnded,\
00217 }
00218 #elif !defined(ACEUNIT_LOG_RUNNER) &&  defined(ACEUNIT_LOG_SUITE) && !defined(ACEUNIT_LOG_FIXTURE) &&  defined(ACEUNIT_LOG_TESTCASE)
00219 #define AceUnitNewLogger(name, runnerStarted, suiteStarted, fixtureStarted, testCaseStarted, testCaseFailed, testCaseEnded, fixtureEnded, suiteEnded, runnerEnded) TestLogger_t name = {\
00220     suiteStarted,\
00221     testCaseStarted,\
00222     testCaseFailed,\
00223     testCaseEnded,\
00224     suiteEnded\
00225 }
00226 #elif !defined(ACEUNIT_LOG_RUNNER) &&  defined(ACEUNIT_LOG_SUITE) &&  defined(ACEUNIT_LOG_FIXTURE) && !defined(ACEUNIT_LOG_TESTCASE)
00227 #define AceUnitNewLogger(name, runnerStarted, suiteStarted, fixtureStarted, testCaseStarted, testCaseFailed, testCaseEnded, fixtureEnded, suiteEnded, runnerEnded) TestLogger_t name = {\
00228     suiteStarted,\
00229     fixtureStarted,\
00230     testCaseFailed,\
00231     fixtureEnded,\
00232     suiteEnded\
00233 }
00234 #elif !defined(ACEUNIT_LOG_RUNNER) &&  defined(ACEUNIT_LOG_SUITE) &&  defined(ACEUNIT_LOG_FIXTURE) &&  defined(ACEUNIT_LOG_TESTCASE)
00235 #define AceUnitNewLogger(name, runnerStarted, suiteStarted, fixtureStarted, testCaseStarted, testCaseFailed, testCaseEnded, fixtureEnded, suiteEnded, runnerEnded) TestLogger_t name = {\
00236     suiteStarted,\
00237     fixtureStarted,\
00238     testCaseStarted,\
00239     testCaseFailed,\
00240     testCaseEnded,\
00241     fixtureEnded,\
00242     suiteEnded\
00243 }
00244 #elif  defined(ACEUNIT_LOG_RUNNER) && !defined(ACEUNIT_LOG_SUITE) && !defined(ACEUNIT_LOG_FIXTURE) && !defined(ACEUNIT_LOG_TESTCASE)
00245 #define AceUnitNewLogger(name, runnerStarted, suiteStarted, fixtureStarted, testCaseStarted, testCaseFailed, testCaseEnded, fixtureEnded, suiteEnded, runnerEnded) TestLogger_t name = {\
00246     runnerStarted,\
00247     testCaseFailed,\
00248     runnerEnded\
00249 }
00250 #elif  defined(ACEUNIT_LOG_RUNNER) && !defined(ACEUNIT_LOG_SUITE) && !defined(ACEUNIT_LOG_FIXTURE) &&  defined(ACEUNIT_LOG_TESTCASE)
00251 #define AceUnitNewLogger(name, runnerStarted, suiteStarted, fixtureStarted, testCaseStarted, testCaseFailed, testCaseEnded, fixtureEnded, suiteEnded, runnerEnded) TestLogger_t name = {\
00252     runnerStarted,\
00253     testCaseStarted,\
00254     testCaseFailed,\
00255     testCaseEnded,\
00256     runnerEnded\
00257 }
00258 #elif  defined(ACEUNIT_LOG_RUNNER) && !defined(ACEUNIT_LOG_SUITE) &&  defined(ACEUNIT_LOG_FIXTURE) && !defined(ACEUNIT_LOG_TESTCASE)
00259 #define AceUnitNewLogger(name, runnerStarted, suiteStarted, fixtureStarted, testCaseStarted, testCaseFailed, testCaseEnded, fixtureEnded, suiteEnded, runnerEnded) TestLogger_t name = {\
00260     runnerStarted,\
00261     fixtureStarted,\
00262     testCaseFailed,\
00263     fixtureEnded,\
00264     runnerEnded\
00265 }
00266 #elif  defined(ACEUNIT_LOG_RUNNER) && !defined(ACEUNIT_LOG_SUITE) &&  defined(ACEUNIT_LOG_FIXTURE) &&  defined(ACEUNIT_LOG_TESTCASE)
00267 #define AceUnitNewLogger(name, runnerStarted, suiteStarted, fixtureStarted, testCaseStarted, testCaseFailed, testCaseEnded, fixtureEnded, suiteEnded, runnerEnded) TestLogger_t name = {\
00268     runnerStarted,\
00269     fixtureStarted,\
00270     testCaseStarted,\
00271     testCaseFailed,\
00272     testCaseEnded,\
00273     fixtureEnded,\
00274     runnerEnded\
00275 }
00276 #elif  defined(ACEUNIT_LOG_RUNNER) &&  defined(ACEUNIT_LOG_SUITE) && !defined(ACEUNIT_LOG_FIXTURE) && !defined(ACEUNIT_LOG_TESTCASE)
00277 #define AceUnitNewLogger(name, runnerStarted, suiteStarted, fixtureStarted, testCaseStarted, testCaseFailed, testCaseEnded, fixtureEnded, suiteEnded, runnerEnded) TestLogger_t name = {\
00278     runnerStarted,\
00279     suiteStarted,\
00280     testCaseFailed,\
00281     suiteEnded,\
00282     runnerEnded\
00283 }
00284 #elif  defined(ACEUNIT_LOG_RUNNER) &&  defined(ACEUNIT_LOG_SUITE) && !defined(ACEUNIT_LOG_FIXTURE) &&  defined(ACEUNIT_LOG_TESTCASE)
00285 #define AceUnitNewLogger(name, runnerStarted, suiteStarted, fixtureStarted, testCaseStarted, testCaseFailed, testCaseEnded, fixtureEnded, suiteEnded, runnerEnded) TestLogger_t name = {\
00286     runnerStarted,\
00287     suiteStarted,\
00288     testCaseStarted,\
00289     testCaseFailed,\
00290     testCaseEnded,\
00291     suiteEnded,\
00292     runnerEnded\
00293 }
00294 #elif  defined(ACEUNIT_LOG_RUNNER) &&  defined(ACEUNIT_LOG_SUITE) &&  defined(ACEUNIT_LOG_FIXTURE) && !defined(ACEUNIT_LOG_TESTCASE)
00295 #define AceUnitNewLogger(name, runnerStarted, suiteStarted, fixtureStarted, testCaseStarted, testCaseFailed, testCaseEnded, fixtureEnded, suiteEnded, runnerEnded) TestLogger_t name = {\
00296     runnerStarted,\
00297     suiteStarted,\
00298     fixtureStarted,\
00299     testCaseFailed,\
00300     fixtureEnded,\
00301     suiteEnded,\
00302     runnerEnded\
00303 }
00304 #elif  defined(ACEUNIT_LOG_RUNNER) &&  defined(ACEUNIT_LOG_SUITE) &&  defined(ACEUNIT_LOG_FIXTURE) &&  defined(ACEUNIT_LOG_TESTCASE)
00305 #define AceUnitNewLogger(name, runnerStarted, suiteStarted, fixtureStarted, testCaseStarted, testCaseFailed, testCaseEnded, fixtureEnded, suiteEnded, runnerEnded) TestLogger_t name = {\
00306     runnerStarted,\
00307     suiteStarted,\
00308     fixtureStarted,\
00309     testCaseStarted,\
00310     testCaseFailed,\
00311     testCaseEnded,\
00312     fixtureEnded,\
00313     suiteEnded,\
00314     runnerEnded\
00315 }
00316 #else
00317 #error Internal error, missing log combination.
00318 #endif
00319 
00320 #endif /* ACEUNITLOGGING_H */

Generated on Sun Feb 13 11:10:16 2011 for AceUnit by  doxygen 1.5.3