00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00047 #ifndef XCOVER_INCL_XCOVER_H_XCOVER
00048 #define XCOVER_INCL_XCOVER_H_XCOVER
00049
00050 #ifndef XCOVER_DOCUMENTATION_SKIP_SECTION
00051 # define XCOVER_VER_XCOVER_H_XCOVER_MAJOR 1
00052 # define XCOVER_VER_XCOVER_H_XCOVER_MINOR 1
00053 # define XCOVER_VER_XCOVER_H_XCOVER_REVISION 2
00054 # define XCOVER_VER_XCOVER_H_XCOVER_EDIT 5
00055 #endif
00056
00057
00058
00059
00060
00075 #define XCOVER_VER_MAJOR 0
00076 #define XCOVER_VER_MINOR 2
00077 #define XCOVER_VER_REVISION 1
00078
00079 #define XCOVER_VER 0x000201ff
00080
00081
00082
00083
00084
00085 #ifndef STLSOFT_INCL_STLSOFT_H_STLSOFT
00086 # include <stlsoft/stlsoft.h>
00087 #endif
00088
00089
00090
00091
00092
00093 #if _STLSOFT_VER < 0x010941ff
00094 # error xCover requires version 1.9.65 (or later) of STLSoft; download from www.stlsoft.org
00095 #endif
00096
00097 #ifndef __COUNTER__
00098 # error xCover can only be used with compilers that support the (non-standard) predefined pre-processor symbol __COUNTER__
00099 #endif
00100
00101 #ifndef __FUNCTION__
00102 # error xCover can only be used with compilers that support the (standard) predefined pre-processor symbol __FUNCTION__
00103 #endif
00104
00105
00106
00107
00108
00109 #ifdef __cplusplus
00110 # include <stdexcept>
00111 #endif
00112
00113 #include <stdio.h>
00114
00115
00116
00117
00118
00119 #if defined(_STLSOFT_NO_NAMESPACE)
00120 # define XCOVER_NO_NAMESPACE
00121 #endif
00122
00123 #ifndef XCOVER_NO_NAMESPACE
00124 namespace xcover
00125 {
00126 #endif
00127
00128
00129
00130
00131
00132 #ifndef XCOVER_DOCUMENTATION_SKIP_SECTION
00133
00134 # ifndef XCOVER_NO_NAMESPACE
00135 # define XCOVER_NS_QUAL(ns, sym) ns::sym
00136 # else
00137 # define XCOVER_NS_QUAL(ns, sym) sym
00138 # endif
00139
00140 # if !defined(XCOVER_CALLCONV)
00141 # define XCOVER_CALLCONV
00142 # endif
00143
00144 # ifndef XCOVER_CALL
00145 # ifdef __cplusplus
00146 # define XCOVER_CALL(x) extern "C" x
00147 # else
00148 # define XCOVER_CALL(x) extern x
00149 # endif
00150 # endif
00151
00152 #endif
00153
00154
00155
00156
00157
00158
00159
00160
00161
00171 #define XCOVER_MARK_FILE_START() XCOVER_NS_QUAL(::xcover, xcover_markFileStart)(__FILE__, __LINE__, __FUNCTION__, __COUNTER__)
00172
00182 #define XCOVER_MARK_FILE_END() XCOVER_NS_QUAL(::xcover, xcover_markFileEnd)(__FILE__, __LINE__, __FUNCTION__, __COUNTER__)
00183
00188 #define XCOVER_MARK_LINE() XCOVER_NS_QUAL(::xcover, xcover_markLine)(__FILE__, __LINE__, __FUNCTION__, __COUNTER__)
00189
00198 #define XCOVER_CREATE_FILE_ALIAS(aliasName) XCOVER_NS_QUAL(::xcover, xcover_createFileAlias)(__FILE__, __LINE__, aliasName)
00199
00209 #define XCOVER_ASSOCIATE_FILE_WITH_GROUP(groupName) XCOVER_NS_QUAL(::xcover, xcover_associateFileWithGroup)(__FILE__, __LINE__, groupName)
00210
00220 #define XCOVER_START_GROUP_COVERAGE(groupName) XCOVER_NS_QUAL(::xcover, xcover_startGroupCoverage)(__FILE__, __LINE__, groupName)
00221
00231 #define XCOVER_END_GROUP_COVERAGE(groupName) XCOVER_NS_QUAL(::xcover, xcover_endGroupCoverage)(__FILE__, __LINE__, groupName)
00232
00240 #define XCOVER_REPORT_GROUP_COVERAGE(groupName, reporter) XCOVER_NS_QUAL(::xcover, xcover_reportGroupCoverage)(__FILE__, __LINE__, groupName, reporter)
00241
00249 #define XCOVER_REPORT_FILE_COVERAGE(fileName, reporter) XCOVER_NS_QUAL(::xcover, xcover_reportFileCoverage)(fileName, reporter)
00250
00257 #define XCOVER_REPORT_THIS_FILE_COVERAGE(reporter) XCOVER_NS_QUAL(::xcover, xcover_reportFileCoverage)(__FILE__, reporter)
00258
00266 #define XCOVER_REPORT_ALIAS_COVERAGE(aliasName, reporter) XCOVER_NS_QUAL(::xcover, xcover_reportAliasCoverage)(aliasName, reporter)
00267
00268
00269
00270
00271
00273 enum xcover_rc_t
00274 {
00276 XCOVER_RC_SUCCESS = 0,
00277
00279 XCOVER_RC_EXCEPTION = -1001,
00280
00282 XCOVER_RC_OUT_OF_MEMORY,
00283
00285 XCOVER_RC_UNEXPECTED,
00286
00288 XCOVER_RC_GROUP_NOT_FOUND,
00289
00291 XCOVER_RC_FILE_NOT_FOUND,
00292
00294 XCOVER_RC_ALIAS_NOT_FOUND,
00295
00297 XCOVER_RC_ALIAS_ALREADY_USED,
00298 };
00299
00300 #ifndef XCOVER_NO_NAMESPACE
00301 typedef xcover_rc_t rc_t;
00302 #endif
00303 #ifndef __cplusplus
00304 typedef enum xcover_rc_t xcover_rc_t;
00305 #endif
00306
00307
00308
00309
00310
00313 struct xcover_coverItem_t
00314 {
00315 char const* groupName;
00316 char const* fileName;
00317 int markIndex;
00318 int priorMarkLine;
00319 int posteriorMarkLine;
00320 };
00321 #ifndef XCOVER_NO_NAMESPACE
00322 typedef xcover_coverItem_t coverItem_t;
00323 #endif
00324 #ifndef __cplusplus
00325 typedef struct xcover_coverItem_t xcover_coverItem_t;
00326 #endif
00327
00328 struct xcover_reporter_t;
00329 #ifndef XCOVER_NO_NAMESPACE
00330 typedef xcover_reporter_t reporter_t;
00331 #endif
00332 #ifndef __cplusplus
00333 typedef struct xcover_reporter_t xcover_reporter_t;
00334 #endif
00335
00336 #include <xcover/internal/reporter.h>
00337
00338
00339
00340
00341
00344 XCOVER_CALL(xcover_rc_t) xcover_init(void);
00345
00348 XCOVER_CALL(void) xcover_uninit(void);
00349
00356 XCOVER_CALL(xcover_rc_t) xcover_createFileAlias(char const* fileName, int line, char const* aliasName);
00357
00364 XCOVER_CALL(xcover_rc_t) xcover_associateFileWithGroup(char const* fileName, int line, char const* groupName);
00365
00375 XCOVER_CALL(xcover_rc_t) xcover_markFileStart(char const* fileName, int line, char const* function, int counter);
00376
00386 XCOVER_CALL(xcover_rc_t) xcover_markFileEnd(char const* fileName, int line, char const* function, int counter);
00387
00395 XCOVER_CALL(xcover_rc_t) xcover_markLine(char const* fileName, int line, char const* function, int counter);
00396
00403 XCOVER_CALL(xcover_rc_t) xcover_startGroupCoverage(char const* fileName, int line, char const* groupName);
00404
00411 XCOVER_CALL(xcover_rc_t) xcover_endGroupCoverage(char const* fileName, int line, char const* groupName);
00412
00423 XCOVER_CALL(xcover_rc_t) xcover_reportGroupCoverage(char const* fileName, int line, char const* groupName, xcover_reporter_t* reporter);
00424
00432 XCOVER_CALL(xcover_rc_t) xcover_reportFileCoverage(char const* fileName, xcover_reporter_t* reporter);
00433
00441 XCOVER_CALL(xcover_rc_t) xcover_reportAliasCoverage(char const* aliasName, xcover_reporter_t* reporter);
00442
00443
00444
00445
00446
00447 #if defined(__cplusplus)
00448
00449 # ifndef XCOVER_DOCUMENTATION_SKIP_SECTION
00450 # define XCOVER_DEFINE_FILE_STARTER() static XCOVER_NS_QUAL(::xcover, xcover_SchwarzMarker) xcover_file_starter(XCOVER_NS_QUAL(::xcover, xcover_markFileStart), __FILE__, __LINE__, __COUNTER__)
00451 # define XCOVER_DEFINE_FILE_ENDER() static XCOVER_NS_QUAL(::xcover, xcover_SchwarzMarker) xcover_file_ender(XCOVER_NS_QUAL(::xcover, xcover_markFileEnd), __FILE__, __LINE__, __COUNTER__)
00452
00453 class xcover_SchwarzMarker
00454 {
00455 public:
00456 xcover_SchwarzMarker(int (XCOVER_CALLCONV* pfn)(char const*, int, char const*, int), char const* fileName, int line, int counter)
00457 {
00458 (*pfn)(fileName, line, __FUNCTION__, counter);
00459 }
00460 };
00461
00462 # endif
00463
00464
00465 # if !defined(XCOVER_NO_AUTO_INIT) || \
00466 defined(XCOVER_FORCE_AUTO_INIT)
00467
00470 class xcover_initialiser
00471 {
00472 public:
00473 typedef xcover_initialiser class_type;
00474
00475 public:
00476 xcover_initialiser()
00477 {
00478 if(xcover_init() < 0)
00479 {
00480 throw std::runtime_error("could not initialise the xCover library");
00481 }
00482 }
00483 ~xcover_initialiser()
00484 {
00485 xcover_uninit();
00486 }
00487 private:
00488 xcover_initialiser(class_type const&);
00489 class_type& operator =(class_type const&);
00490 };
00491
00492 namespace
00493 {
00494 static xcover_initialiser xc_init;
00495
00496 }
00497
00498 #endif
00499 #endif
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513 #ifndef XCOVER_NO_NAMESPACE
00514
00515 inline xcover_rc_t init()
00516 {
00517 return xcover_init();
00518 }
00519
00520 inline void uninit()
00521 {
00522 xcover_uninit();
00523 }
00524
00525 #endif
00526
00527
00528
00529
00530
00531 #ifndef XCOVER_NO_NAMESPACE
00532 }
00533 #endif
00534
00535
00536
00537 #endif
00538
00539