first commit
This commit is contained in:
35
3rdparty/CMakeLists.txt
vendored
Normal file
35
3rdparty/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
|
||||
if (NOT SYSTEM_SQLITE)
|
||||
add_subdirectory(sqlite3)
|
||||
endif()
|
||||
|
||||
if (ENABLE_IAX)
|
||||
add_subdirectory(iaxclient/lib)
|
||||
endif()
|
||||
|
||||
add_subdirectory(mongoose)
|
||||
add_subdirectory(cjson)
|
||||
|
||||
add_subdirectory(flite_hts_engine)
|
||||
|
||||
if (NOT SYSTEM_HTS_ENGINE)
|
||||
add_subdirectory(hts_engine_API)
|
||||
endif()
|
||||
|
||||
if (ENABLE_HID_INPUT)
|
||||
add_subdirectory(hidapi)
|
||||
endif()
|
||||
|
||||
add_subdirectory(fonts)
|
||||
|
||||
if (ENABLE_PLIB_JOYSTICK)
|
||||
add_subdirectory(joystick)
|
||||
endif()
|
||||
|
||||
if (NOT SYSTEM_CPPUNIT)
|
||||
add_subdirectory(cppunit)
|
||||
endif()
|
||||
|
||||
if (ENABLE_OSGXR AND NOT ENABLE_SYSTEM_OSGXR)
|
||||
add_subdirectory(osgXR)
|
||||
endif()
|
||||
11
3rdparty/cjson/CMakeLists.txt
vendored
Normal file
11
3rdparty/cjson/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
include(FlightGearComponent)
|
||||
|
||||
set(SOURCES
|
||||
cJSON.c
|
||||
)
|
||||
|
||||
set(HEADERS
|
||||
cJSON.h
|
||||
)
|
||||
|
||||
flightgear_component(CJSON "${SOURCES}" "${HEADERS}")
|
||||
20
3rdparty/cjson/LICENSE
vendored
Normal file
20
3rdparty/cjson/LICENSE
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
Copyright (c) 2009 Dave Gamble
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
247
3rdparty/cjson/README
vendored
Normal file
247
3rdparty/cjson/README
vendored
Normal file
@@ -0,0 +1,247 @@
|
||||
/*
|
||||
Copyright (c) 2009 Dave Gamble
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
Welcome to cJSON.
|
||||
|
||||
cJSON aims to be the dumbest possible parser that you can get your job done with.
|
||||
It's a single file of C, and a single header file.
|
||||
|
||||
JSON is described best here: http://www.json.org/
|
||||
It's like XML, but fat-free. You use it to move data around, store things, or just
|
||||
generally represent your program's state.
|
||||
|
||||
|
||||
First up, how do I build?
|
||||
Add cJSON.c to your project, and put cJSON.h somewhere in the header search path.
|
||||
For example, to build the test app:
|
||||
|
||||
gcc cJSON.c test.c -o test -lm
|
||||
./test
|
||||
|
||||
|
||||
As a library, cJSON exists to take away as much legwork as it can, but not get in your way.
|
||||
As a point of pragmatism (i.e. ignoring the truth), I'm going to say that you can use it
|
||||
in one of two modes: Auto and Manual. Let's have a quick run-through.
|
||||
|
||||
|
||||
I lifted some JSON from this page: http://www.json.org/fatfree.html
|
||||
That page inspired me to write cJSON, which is a parser that tries to share the same
|
||||
philosophy as JSON itself. Simple, dumb, out of the way.
|
||||
|
||||
Some JSON:
|
||||
{
|
||||
"name": "Jack (\"Bee\") Nimble",
|
||||
"format": {
|
||||
"type": "rect",
|
||||
"width": 1920,
|
||||
"height": 1080,
|
||||
"interlace": false,
|
||||
"frame rate": 24
|
||||
}
|
||||
}
|
||||
|
||||
Assume that you got this from a file, a webserver, or magic JSON elves, whatever,
|
||||
you have a char * to it. Everything is a cJSON struct.
|
||||
Get it parsed:
|
||||
cJSON *root = cJSON_Parse(my_json_string);
|
||||
|
||||
This is an object. We're in C. We don't have objects. But we do have structs.
|
||||
What's the framerate?
|
||||
|
||||
cJSON *format = cJSON_GetObjectItem(root,"format");
|
||||
int framerate = cJSON_GetObjectItem(format,"frame rate")->valueint;
|
||||
|
||||
|
||||
Want to change the framerate?
|
||||
cJSON_GetObjectItem(format,"frame rate")->valueint=25;
|
||||
|
||||
Back to disk?
|
||||
char *rendered=cJSON_Print(root);
|
||||
|
||||
Finished? Delete the root (this takes care of everything else).
|
||||
cJSON_Delete(root);
|
||||
|
||||
That's AUTO mode. If you're going to use Auto mode, you really ought to check pointers
|
||||
before you dereference them. If you want to see how you'd build this struct in code?
|
||||
cJSON *root,*fmt;
|
||||
root=cJSON_CreateObject();
|
||||
cJSON_AddItemToObject(root, "name", cJSON_CreateString("Jack (\"Bee\") Nimble"));
|
||||
cJSON_AddItemToObject(root, "format", fmt=cJSON_CreateObject());
|
||||
cJSON_AddStringToObject(fmt,"type", "rect");
|
||||
cJSON_AddNumberToObject(fmt,"width", 1920);
|
||||
cJSON_AddNumberToObject(fmt,"height", 1080);
|
||||
cJSON_AddFalseToObject (fmt,"interlace");
|
||||
cJSON_AddNumberToObject(fmt,"frame rate", 24);
|
||||
|
||||
Hopefully we can agree that's not a lot of code? There's no overhead, no unnecessary setup.
|
||||
Look at test.c for a bunch of nice examples, mostly all ripped off the json.org site, and
|
||||
a few from elsewhere.
|
||||
|
||||
What about manual mode? First up you need some detail.
|
||||
Let's cover how the cJSON objects represent the JSON data.
|
||||
cJSON doesn't distinguish arrays from objects in handling; just type.
|
||||
Each cJSON has, potentially, a child, siblings, value, a name.
|
||||
|
||||
The root object has: Object Type and a Child
|
||||
The Child has name "name", with value "Jack ("Bee") Nimble", and a sibling:
|
||||
Sibling has type Object, name "format", and a child.
|
||||
That child has type String, name "type", value "rect", and a sibling:
|
||||
Sibling has type Number, name "width", value 1920, and a sibling:
|
||||
Sibling has type Number, name "height", value 1080, and a sibling:
|
||||
Sibling hs type False, name "interlace", and a sibling:
|
||||
Sibling has type Number, name "frame rate", value 24
|
||||
|
||||
Here's the structure:
|
||||
typedef struct cJSON {
|
||||
struct cJSON *next,*prev;
|
||||
struct cJSON *child;
|
||||
|
||||
int type;
|
||||
|
||||
char *valuestring;
|
||||
int valueint;
|
||||
double valuedouble;
|
||||
|
||||
char *string;
|
||||
} cJSON;
|
||||
|
||||
By default all values are 0 unless set by virtue of being meaningful.
|
||||
|
||||
next/prev is a doubly linked list of siblings. next takes you to your sibling,
|
||||
prev takes you back from your sibling to you.
|
||||
Only objects and arrays have a "child", and it's the head of the doubly linked list.
|
||||
A "child" entry will have prev==0, but next potentially points on. The last sibling has next=0.
|
||||
The type expresses Null/True/False/Number/String/Array/Object, all of which are #defined in
|
||||
cJSON.h
|
||||
|
||||
A Number has valueint and valuedouble. If you're expecting an int, read valueint, if not read
|
||||
valuedouble.
|
||||
|
||||
Any entry which is in the linked list which is the child of an object will have a "string"
|
||||
which is the "name" of the entry. When I said "name" in the above example, that's "string".
|
||||
"string" is the JSON name for the 'variable name' if you will.
|
||||
|
||||
Now you can trivially walk the lists, recursively, and parse as you please.
|
||||
You can invoke cJSON_Parse to get cJSON to parse for you, and then you can take
|
||||
the root object, and traverse the structure (which is, formally, an N-tree),
|
||||
and tokenise as you please. If you wanted to build a callback style parser, this is how
|
||||
you'd do it (just an example, since these things are very specific):
|
||||
|
||||
void parse_and_callback(cJSON *item,const char *prefix)
|
||||
{
|
||||
while (item)
|
||||
{
|
||||
char *newprefix=malloc(strlen(prefix)+strlen(item->name)+2);
|
||||
sprintf(newprefix,"%s/%s",prefix,item->name);
|
||||
int dorecurse=callback(newprefix, item->type, item);
|
||||
if (item->child && dorecurse) parse_and_callback(item->child,newprefix);
|
||||
item=item->next;
|
||||
free(newprefix);
|
||||
}
|
||||
}
|
||||
|
||||
The prefix process will build you a separated list, to simplify your callback handling.
|
||||
The 'dorecurse' flag would let the callback decide to handle sub-arrays on it's own, or
|
||||
let you invoke it per-item. For the item above, your callback might look like this:
|
||||
|
||||
int callback(const char *name,int type,cJSON *item)
|
||||
{
|
||||
if (!strcmp(name,"name")) { /* populate name */ }
|
||||
else if (!strcmp(name,"format/type") { /* handle "rect" */ }
|
||||
else if (!strcmp(name,"format/width") { /* 800 */ }
|
||||
else if (!strcmp(name,"format/height") { /* 600 */ }
|
||||
else if (!strcmp(name,"format/interlace") { /* false */ }
|
||||
else if (!strcmp(name,"format/frame rate") { /* 24 */ }
|
||||
return 1;
|
||||
}
|
||||
|
||||
Alternatively, you might like to parse iteratively.
|
||||
You'd use:
|
||||
|
||||
void parse_object(cJSON *item)
|
||||
{
|
||||
int i; for (i=0;i<cJSON_GetArraySize(item);i++)
|
||||
{
|
||||
cJSON *subitem=cJSON_GetArrayItem(item,i);
|
||||
// handle subitem.
|
||||
}
|
||||
}
|
||||
|
||||
Or, for PROPER manual mode:
|
||||
|
||||
void parse_object(cJSON *item)
|
||||
{
|
||||
cJSON *subitem=item->child;
|
||||
while (subitem)
|
||||
{
|
||||
// handle subitem
|
||||
if (subitem->child) parse_object(subitem->child);
|
||||
|
||||
subitem=subitem->next;
|
||||
}
|
||||
}
|
||||
|
||||
Of course, this should look familiar, since this is just a stripped-down version
|
||||
of the callback-parser.
|
||||
|
||||
This should cover most uses you'll find for parsing. The rest should be possible
|
||||
to infer.. and if in doubt, read the source! There's not a lot of it! ;)
|
||||
|
||||
|
||||
In terms of constructing JSON data, the example code above is the right way to do it.
|
||||
You can, of course, hand your sub-objects to other functions to populate.
|
||||
Also, if you find a use for it, you can manually build the objects.
|
||||
For instance, suppose you wanted to build an array of objects?
|
||||
|
||||
cJSON *objects[24];
|
||||
|
||||
cJSON *Create_array_of_anything(cJSON **items,int num)
|
||||
{
|
||||
int i;cJSON *prev, *root=cJSON_CreateArray();
|
||||
for (i=0;i<24;i++)
|
||||
{
|
||||
if (!i) root->child=objects[i];
|
||||
else prev->next=objects[i], objects[i]->prev=prev;
|
||||
prev=objects[i];
|
||||
}
|
||||
return root;
|
||||
}
|
||||
|
||||
and simply: Create_array_of_anything(objects,24);
|
||||
|
||||
cJSON doesn't make any assumptions about what order you create things in.
|
||||
You can attach the objects, as above, and later add children to each
|
||||
of those objects.
|
||||
|
||||
As soon as you call cJSON_Print, it renders the structure to text.
|
||||
|
||||
|
||||
|
||||
The test.c code shows how to handle a bunch of typical cases. If you uncomment
|
||||
the code, it'll load, parse and print a bunch of test files, also from json.org,
|
||||
which are more complex than I'd care to try and stash into a const char array[].
|
||||
|
||||
|
||||
Enjoy cJSON!
|
||||
|
||||
|
||||
- Dave Gamble, Aug 2009
|
||||
603
3rdparty/cjson/cJSON.c
vendored
Normal file
603
3rdparty/cjson/cJSON.c
vendored
Normal file
@@ -0,0 +1,603 @@
|
||||
/*
|
||||
Copyright (c) 2009 Dave Gamble
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* cJSON */
|
||||
/* JSON parser in C. */
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <float.h>
|
||||
#include <limits.h>
|
||||
#include <ctype.h>
|
||||
#include "cJSON.h"
|
||||
|
||||
static const char *ep;
|
||||
|
||||
const char *cJSON_GetErrorPtr(void) {return ep;}
|
||||
|
||||
static int cJSON_strcasecmp(const char *s1,const char *s2)
|
||||
{
|
||||
if (!s1) return (s1==s2)?0:1;
|
||||
if (!s2) return 1;
|
||||
for(; tolower(*s1) == tolower(*s2); ++s1, ++s2) if(*s1 == 0) return 0;
|
||||
return tolower(*(const unsigned char *)s1) - tolower(*(const unsigned char *)s2);
|
||||
}
|
||||
|
||||
static void *(*cJSON_malloc)(size_t sz) = malloc;
|
||||
static void (*cJSON_free)(void *ptr) = free;
|
||||
|
||||
static char* cJSON_strdup(const char* str)
|
||||
{
|
||||
size_t len;
|
||||
char* copy;
|
||||
|
||||
len = strlen(str) + 1;
|
||||
if (!(copy = (char*)cJSON_malloc(len))) return 0;
|
||||
memcpy(copy,str,len);
|
||||
return copy;
|
||||
}
|
||||
|
||||
void cJSON_InitHooks(cJSON_Hooks* hooks)
|
||||
{
|
||||
if (!hooks) { /* Reset hooks */
|
||||
cJSON_malloc = malloc;
|
||||
cJSON_free = free;
|
||||
return;
|
||||
}
|
||||
|
||||
cJSON_malloc = (hooks->malloc_fn)?hooks->malloc_fn:malloc;
|
||||
cJSON_free = (hooks->free_fn)?hooks->free_fn:free;
|
||||
}
|
||||
|
||||
/* Internal constructor. */
|
||||
static cJSON *cJSON_New_Item(void)
|
||||
{
|
||||
cJSON* node = (cJSON*)cJSON_malloc(sizeof(cJSON));
|
||||
if (node) memset(node,0,sizeof(cJSON));
|
||||
return node;
|
||||
}
|
||||
|
||||
/* Delete a cJSON structure. */
|
||||
void cJSON_Delete(cJSON *c)
|
||||
{
|
||||
cJSON *next;
|
||||
while (c)
|
||||
{
|
||||
next=c->next;
|
||||
if (!(c->type&cJSON_IsReference) && c->child) cJSON_Delete(c->child);
|
||||
if (!(c->type&cJSON_IsReference) && c->valuestring) cJSON_free(c->valuestring);
|
||||
if (c->string) cJSON_free(c->string);
|
||||
cJSON_free(c);
|
||||
c=next;
|
||||
}
|
||||
}
|
||||
|
||||
/* Parse the input text to generate a number, and populate the result into item. */
|
||||
static const char *parse_number(cJSON *item,const char *num)
|
||||
{
|
||||
double n=0,sign=1,scale=0;int subscale=0,signsubscale=1;
|
||||
|
||||
if (*num=='-') sign=-1,num++; /* Has sign? */
|
||||
if (*num=='0') num++; /* is zero */
|
||||
if (*num>='1' && *num<='9') do n=(n*10.0)+(*num++ -'0'); while (*num>='0' && *num<='9'); /* Number? */
|
||||
if (*num=='.' && num[1]>='0' && num[1]<='9') {num++; do n=(n*10.0)+(*num++ -'0'),scale--; while (*num>='0' && *num<='9');} /* Fractional part? */
|
||||
if (*num=='e' || *num=='E') /* Exponent? */
|
||||
{ num++;if (*num=='+') num++; else if (*num=='-') signsubscale=-1,num++; /* With sign? */
|
||||
while (*num>='0' && *num<='9') subscale=(subscale*10)+(*num++ - '0'); /* Number? */
|
||||
}
|
||||
|
||||
n=sign*n*pow(10.0,(scale+subscale*signsubscale)); /* number = +/- number.fraction * 10^+/- exponent */
|
||||
|
||||
item->valuedouble=n;
|
||||
item->valueint=(int)n;
|
||||
item->type=cJSON_Number;
|
||||
return num;
|
||||
}
|
||||
|
||||
/* Render the number nicely from the given item into a string. */
|
||||
static char *print_number(cJSON *item)
|
||||
{
|
||||
char *str;
|
||||
double d=item->valuedouble;
|
||||
if (fabs(((double)item->valueint)-d)<=DBL_EPSILON && d<=INT_MAX && d>=INT_MIN)
|
||||
{
|
||||
str=(char*)cJSON_malloc(21); /* 2^64+1 can be represented in 21 chars. */
|
||||
if (str) sprintf(str,"%d",item->valueint);
|
||||
}
|
||||
else
|
||||
{
|
||||
str=(char*)cJSON_malloc(64); /* This is a nice tradeoff. */
|
||||
if (str)
|
||||
{
|
||||
if (fabs(floor(d)-d)<=DBL_EPSILON && fabs(d)<1.0e60)sprintf(str,"%.0f",d);
|
||||
else if (fabs(d)<1.0e-6 || fabs(d)>1.0e9) sprintf(str,"%e",d);
|
||||
else sprintf(str,"%f",d);
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
static unsigned parse_hex4(const char *str)
|
||||
{
|
||||
unsigned h=0;
|
||||
if (*str>='0' && *str<='9') h+=(*str)-'0'; else if (*str>='A' && *str<='F') h+=10+(*str)-'A'; else if (*str>='a' && *str<='f') h+=10+(*str)-'a'; else return 0;
|
||||
h=h<<4;str++;
|
||||
if (*str>='0' && *str<='9') h+=(*str)-'0'; else if (*str>='A' && *str<='F') h+=10+(*str)-'A'; else if (*str>='a' && *str<='f') h+=10+(*str)-'a'; else return 0;
|
||||
h=h<<4;str++;
|
||||
if (*str>='0' && *str<='9') h+=(*str)-'0'; else if (*str>='A' && *str<='F') h+=10+(*str)-'A'; else if (*str>='a' && *str<='f') h+=10+(*str)-'a'; else return 0;
|
||||
h=h<<4;str++;
|
||||
if (*str>='0' && *str<='9') h+=(*str)-'0'; else if (*str>='A' && *str<='F') h+=10+(*str)-'A'; else if (*str>='a' && *str<='f') h+=10+(*str)-'a'; else return 0;
|
||||
return h;
|
||||
}
|
||||
|
||||
/* Parse the input text into an unescaped cstring, and populate item. */
|
||||
static const unsigned char firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
|
||||
static const char *parse_string(cJSON *item,const char *str)
|
||||
{
|
||||
const char *ptr=str+1;char *ptr2;char *out;int len=0;unsigned uc,uc2;
|
||||
if (*str!='\"') {ep=str;return 0;} /* not a string! */
|
||||
|
||||
while (*ptr!='\"' && *ptr && ++len) if (*ptr++ == '\\') ptr++; /* Skip escaped quotes. */
|
||||
|
||||
out=(char*)cJSON_malloc(len+1); /* This is how long we need for the string, roughly. */
|
||||
if (!out) return 0;
|
||||
|
||||
ptr=str+1;ptr2=out;
|
||||
while (*ptr!='\"' && *ptr)
|
||||
{
|
||||
if (*ptr!='\\') *ptr2++=*ptr++;
|
||||
else
|
||||
{
|
||||
ptr++;
|
||||
switch (*ptr)
|
||||
{
|
||||
case 'b': *ptr2++='\b'; break;
|
||||
case 'f': *ptr2++='\f'; break;
|
||||
case 'n': *ptr2++='\n'; break;
|
||||
case 'r': *ptr2++='\r'; break;
|
||||
case 't': *ptr2++='\t'; break;
|
||||
case 'u': /* transcode utf16 to utf8. */
|
||||
uc=parse_hex4(ptr+1);ptr+=4; /* get the unicode char. */
|
||||
|
||||
if ((uc>=0xDC00 && uc<=0xDFFF) || uc==0) break; /* check for invalid. */
|
||||
|
||||
if (uc>=0xD800 && uc<=0xDBFF) /* UTF16 surrogate pairs. */
|
||||
{
|
||||
if (ptr[1]!='\\' || ptr[2]!='u') break; /* missing second-half of surrogate. */
|
||||
uc2=parse_hex4(ptr+3);ptr+=6;
|
||||
if (uc2<0xDC00 || uc2>0xDFFF) break; /* invalid second-half of surrogate. */
|
||||
uc=0x10000 + (((uc&0x3FF)<<10) | (uc2&0x3FF));
|
||||
}
|
||||
|
||||
len=4;if (uc<0x80) len=1;else if (uc<0x800) len=2;else if (uc<0x10000) len=3; ptr2+=len;
|
||||
|
||||
switch (len) {
|
||||
case 4: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
|
||||
case 3: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
|
||||
case 2: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
|
||||
case 1: *--ptr2 =(uc | firstByteMark[len]);
|
||||
}
|
||||
ptr2+=len;
|
||||
break;
|
||||
default: *ptr2++=*ptr; break;
|
||||
}
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
*ptr2=0;
|
||||
if (*ptr=='\"') ptr++;
|
||||
item->valuestring=out;
|
||||
item->type=cJSON_String;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/* Render the cstring provided to an escaped version that can be printed. */
|
||||
static char *print_string_ptr(const char *str)
|
||||
{
|
||||
const char *ptr;char *ptr2,*out;int len=0;unsigned char token;
|
||||
|
||||
if (!str) return cJSON_strdup("");
|
||||
ptr=str;while ((token=*ptr) && ++len) {if (strchr("\"\\\b\f\n\r\t",token)) len++; else if (token<32) len+=5;ptr++;}
|
||||
|
||||
out=(char*)cJSON_malloc(len+3);
|
||||
if (!out) return 0;
|
||||
|
||||
ptr2=out;ptr=str;
|
||||
*ptr2++='\"';
|
||||
while (*ptr)
|
||||
{
|
||||
if ((unsigned char)*ptr>31 && *ptr!='\"' && *ptr!='\\') *ptr2++=*ptr++;
|
||||
else
|
||||
{
|
||||
*ptr2++='\\';
|
||||
switch (token=*ptr++)
|
||||
{
|
||||
case '\\': *ptr2++='\\'; break;
|
||||
case '\"': *ptr2++='\"'; break;
|
||||
case '\b': *ptr2++='b'; break;
|
||||
case '\f': *ptr2++='f'; break;
|
||||
case '\n': *ptr2++='n'; break;
|
||||
case '\r': *ptr2++='r'; break;
|
||||
case '\t': *ptr2++='t'; break;
|
||||
default: sprintf(ptr2,"u%04x",token);ptr2+=5; break; /* escape and print */
|
||||
}
|
||||
}
|
||||
}
|
||||
*ptr2++='\"';*ptr2++=0;
|
||||
return out;
|
||||
}
|
||||
/* Invote print_string_ptr (which is useful) on an item. */
|
||||
static char *print_string(cJSON *item) {return print_string_ptr(item->valuestring);}
|
||||
|
||||
/* Predeclare these prototypes. */
|
||||
static const char *parse_value(cJSON *item,const char *value);
|
||||
static char *print_value(cJSON *item,int depth,int fmt);
|
||||
static const char *parse_array(cJSON *item,const char *value);
|
||||
static char *print_array(cJSON *item,int depth,int fmt);
|
||||
static const char *parse_object(cJSON *item,const char *value);
|
||||
static char *print_object(cJSON *item,int depth,int fmt);
|
||||
|
||||
/* Utility to jump whitespace and cr/lf */
|
||||
static const char *skip(const char *in) {while (in && *in && (unsigned char)*in<=32) in++; return in;}
|
||||
|
||||
/* Parse an object - create a new root, and populate. */
|
||||
cJSON *cJSON_ParseWithOpts(const char *value,const char **return_parse_end,int require_null_terminated)
|
||||
{
|
||||
const char *end=0;
|
||||
cJSON *c=cJSON_New_Item();
|
||||
ep=0;
|
||||
if (!c) return 0; /* memory fail */
|
||||
|
||||
end=parse_value(c,skip(value));
|
||||
if (!end) {cJSON_Delete(c);return 0;} /* parse failure. ep is set. */
|
||||
|
||||
/* if we require null-terminated JSON without appended garbage, skip and then check for a null terminator */
|
||||
if (require_null_terminated) {end=skip(end);if (*end) {cJSON_Delete(c);ep=end;return 0;}}
|
||||
if (return_parse_end) *return_parse_end=end;
|
||||
return c;
|
||||
}
|
||||
/* Default options for cJSON_Parse */
|
||||
cJSON *cJSON_Parse(const char *value) {return cJSON_ParseWithOpts(value,0,0);}
|
||||
|
||||
/* Render a cJSON item/entity/structure to text. */
|
||||
char *cJSON_Print(cJSON *item) {return print_value(item,0,1);}
|
||||
char *cJSON_PrintUnformatted(cJSON *item) {return print_value(item,0,0);}
|
||||
|
||||
/* Parser core - when encountering text, process appropriately. */
|
||||
static const char *parse_value(cJSON *item,const char *value)
|
||||
{
|
||||
if (!value) return 0; /* Fail on null. */
|
||||
if (!strncmp(value,"null",4)) { item->type=cJSON_NULL; return value+4; }
|
||||
if (!strncmp(value,"false",5)) { item->type=cJSON_False; return value+5; }
|
||||
if (!strncmp(value,"true",4)) { item->type=cJSON_True; item->valueint=1; return value+4; }
|
||||
if (*value=='\"') { return parse_string(item,value); }
|
||||
if (*value=='-' || (*value>='0' && *value<='9')) { return parse_number(item,value); }
|
||||
if (*value=='[') { return parse_array(item,value); }
|
||||
if (*value=='{') { return parse_object(item,value); }
|
||||
|
||||
ep=value;return 0; /* failure. */
|
||||
}
|
||||
|
||||
/* Render a value to text. */
|
||||
static char *print_value(cJSON *item,int depth,int fmt)
|
||||
{
|
||||
char *out=0;
|
||||
if (!item) return 0;
|
||||
switch ((item->type)&255)
|
||||
{
|
||||
case cJSON_NULL: out=cJSON_strdup("null"); break;
|
||||
case cJSON_False: out=cJSON_strdup("false");break;
|
||||
case cJSON_True: out=cJSON_strdup("true"); break;
|
||||
case cJSON_Number: out=print_number(item);break;
|
||||
case cJSON_String: out=print_string(item);break;
|
||||
case cJSON_Array: out=print_array(item,depth,fmt);break;
|
||||
case cJSON_Object: out=print_object(item,depth,fmt);break;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/* Build an array from input text. */
|
||||
static const char *parse_array(cJSON *item,const char *value)
|
||||
{
|
||||
cJSON *child;
|
||||
if (*value!='[') {ep=value;return 0;} /* not an array! */
|
||||
|
||||
item->type=cJSON_Array;
|
||||
value=skip(value+1);
|
||||
if (*value==']') return value+1; /* empty array. */
|
||||
|
||||
item->child=child=cJSON_New_Item();
|
||||
if (!item->child) return 0; /* memory fail */
|
||||
value=skip(parse_value(child,skip(value))); /* skip any spacing, get the value. */
|
||||
if (!value) return 0;
|
||||
|
||||
while (*value==',')
|
||||
{
|
||||
cJSON *new_item;
|
||||
if (!(new_item=cJSON_New_Item())) return 0; /* memory fail */
|
||||
child->next=new_item;new_item->prev=child;child=new_item;
|
||||
value=skip(parse_value(child,skip(value+1)));
|
||||
if (!value) return 0; /* memory fail */
|
||||
}
|
||||
|
||||
if (*value==']') return value+1; /* end of array */
|
||||
ep=value;return 0; /* malformed. */
|
||||
}
|
||||
|
||||
/* Render an array to text */
|
||||
static char *print_array(cJSON *item,int depth,int fmt)
|
||||
{
|
||||
char **entries;
|
||||
char *out=0,*ptr,*ret;int len=5;
|
||||
cJSON *child=item->child;
|
||||
int numentries=0,i=0,fail=0;
|
||||
|
||||
/* How many entries in the array? */
|
||||
while (child) numentries++,child=child->next;
|
||||
/* Explicitly handle numentries==0 */
|
||||
if (!numentries)
|
||||
{
|
||||
out=(char*)cJSON_malloc(3);
|
||||
if (out) strcpy(out,"[]");
|
||||
return out;
|
||||
}
|
||||
/* Allocate an array to hold the values for each */
|
||||
entries=(char**)cJSON_malloc(numentries*sizeof(char*));
|
||||
if (!entries) return 0;
|
||||
memset(entries,0,numentries*sizeof(char*));
|
||||
/* Retrieve all the results: */
|
||||
child=item->child;
|
||||
while (child && !fail)
|
||||
{
|
||||
ret=print_value(child,depth+1,fmt);
|
||||
entries[i++]=ret;
|
||||
if (ret) len+=strlen(ret)+2+(fmt?1:0); else fail=1;
|
||||
child=child->next;
|
||||
}
|
||||
|
||||
/* If we didn't fail, try to malloc the output string */
|
||||
if (!fail) out=(char*)cJSON_malloc(len);
|
||||
/* If that fails, we fail. */
|
||||
if (!out) fail=1;
|
||||
|
||||
/* Handle failure. */
|
||||
if (fail)
|
||||
{
|
||||
for (i=0;i<numentries;i++) if (entries[i]) cJSON_free(entries[i]);
|
||||
cJSON_free(entries);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Compose the output array. */
|
||||
*out='[';
|
||||
ptr=out+1;*ptr=0;
|
||||
for (i=0;i<numentries;i++)
|
||||
{
|
||||
strcpy(ptr,entries[i]);ptr+=strlen(entries[i]);
|
||||
if (i!=numentries-1) {*ptr++=',';if(fmt)*ptr++=' ';*ptr=0;}
|
||||
cJSON_free(entries[i]);
|
||||
}
|
||||
cJSON_free(entries);
|
||||
*ptr++=']';*ptr++=0;
|
||||
return out;
|
||||
}
|
||||
|
||||
/* Build an object from the text. */
|
||||
static const char *parse_object(cJSON *item,const char *value)
|
||||
{
|
||||
cJSON *child;
|
||||
if (*value!='{') {ep=value;return 0;} /* not an object! */
|
||||
|
||||
item->type=cJSON_Object;
|
||||
value=skip(value+1);
|
||||
if (*value=='}') return value+1; /* empty array. */
|
||||
|
||||
item->child=child=cJSON_New_Item();
|
||||
if (!item->child) return 0;
|
||||
value=skip(parse_string(child,skip(value)));
|
||||
if (!value) return 0;
|
||||
child->string=child->valuestring;child->valuestring=0;
|
||||
if (*value!=':') {ep=value;return 0;} /* fail! */
|
||||
value=skip(parse_value(child,skip(value+1))); /* skip any spacing, get the value. */
|
||||
if (!value) return 0;
|
||||
|
||||
while (*value==',')
|
||||
{
|
||||
cJSON *new_item;
|
||||
if (!(new_item=cJSON_New_Item())) return 0; /* memory fail */
|
||||
child->next=new_item;new_item->prev=child;child=new_item;
|
||||
value=skip(parse_string(child,skip(value+1)));
|
||||
if (!value) return 0;
|
||||
child->string=child->valuestring;child->valuestring=0;
|
||||
if (*value!=':') {ep=value;return 0;} /* fail! */
|
||||
value=skip(parse_value(child,skip(value+1))); /* skip any spacing, get the value. */
|
||||
if (!value) return 0;
|
||||
}
|
||||
|
||||
if (*value=='}') return value+1; /* end of array */
|
||||
ep=value;return 0; /* malformed. */
|
||||
}
|
||||
|
||||
/* Render an object to text. */
|
||||
static char *print_object(cJSON *item,int depth,int fmt)
|
||||
{
|
||||
char **entries=0,**names=0;
|
||||
char *out=0,*ptr,*ret,*str;int len=7,i=0,j;
|
||||
cJSON *child=item->child;
|
||||
int numentries=0,fail=0;
|
||||
/* Count the number of entries. */
|
||||
while (child) numentries++,child=child->next;
|
||||
/* Explicitly handle empty object case */
|
||||
if (!numentries)
|
||||
{
|
||||
out=(char*)cJSON_malloc(fmt?depth+4:3);
|
||||
if (!out) return 0;
|
||||
ptr=out;*ptr++='{';
|
||||
if (fmt) {*ptr++='\n';for (i=0;i<depth-1;i++) *ptr++='\t';}
|
||||
*ptr++='}';*ptr++=0;
|
||||
return out;
|
||||
}
|
||||
/* Allocate space for the names and the objects */
|
||||
entries=(char**)cJSON_malloc(numentries*sizeof(char*));
|
||||
if (!entries) return 0;
|
||||
names=(char**)cJSON_malloc(numentries*sizeof(char*));
|
||||
if (!names) {cJSON_free(entries);return 0;}
|
||||
memset(entries,0,sizeof(char*)*numentries);
|
||||
memset(names,0,sizeof(char*)*numentries);
|
||||
|
||||
/* Collect all the results into our arrays: */
|
||||
child=item->child;depth++;if (fmt) len+=depth;
|
||||
while (child)
|
||||
{
|
||||
names[i]=str=print_string_ptr(child->string);
|
||||
entries[i++]=ret=print_value(child,depth,fmt);
|
||||
if (str && ret) len+=strlen(ret)+strlen(str)+2+(fmt?2+depth:0); else fail=1;
|
||||
child=child->next;
|
||||
}
|
||||
|
||||
/* Try to allocate the output string */
|
||||
if (!fail) out=(char*)cJSON_malloc(len);
|
||||
if (!out) fail=1;
|
||||
|
||||
/* Handle failure */
|
||||
if (fail)
|
||||
{
|
||||
for (i=0;i<numentries;i++) {if (names[i]) cJSON_free(names[i]);if (entries[i]) cJSON_free(entries[i]);}
|
||||
cJSON_free(names);cJSON_free(entries);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Compose the output: */
|
||||
*out='{';ptr=out+1;if (fmt)*ptr++='\n';*ptr=0;
|
||||
for (i=0;i<numentries;i++)
|
||||
{
|
||||
if (fmt) for (j=0;j<depth;j++) *ptr++='\t';
|
||||
strcpy(ptr,names[i]);ptr+=strlen(names[i]);
|
||||
*ptr++=':';if (fmt) *ptr++='\t';
|
||||
strcpy(ptr,entries[i]);ptr+=strlen(entries[i]);
|
||||
if (i!=numentries-1) *ptr++=',';
|
||||
if (fmt) *ptr++='\n';
|
||||
*ptr=0;
|
||||
cJSON_free(names[i]);
|
||||
cJSON_free(entries[i]);
|
||||
}
|
||||
|
||||
cJSON_free(names);cJSON_free(entries);
|
||||
if (fmt) for (i=0;i<depth-1;i++) *ptr++='\t';
|
||||
*ptr++='}';*ptr++=0;
|
||||
return out;
|
||||
}
|
||||
|
||||
/* Get Array size/item / object item. */
|
||||
int cJSON_GetArraySize(cJSON *array) {cJSON *c=array->child;int i=0;while(c)i++,c=c->next;return i;}
|
||||
cJSON *cJSON_GetArrayItem(cJSON *array,int item) {cJSON *c=array->child; while (c && item>0) item--,c=c->next; return c;}
|
||||
cJSON *cJSON_GetObjectItem(cJSON *object,const char *string) {cJSON *c=object->child; while (c && cJSON_strcasecmp(c->string,string)) c=c->next; return c;}
|
||||
|
||||
/* Utility for array list handling. */
|
||||
static void suffix_object(cJSON *prev,cJSON *item) {prev->next=item;item->prev=prev;}
|
||||
/* Utility for handling references. */
|
||||
static cJSON *create_reference(cJSON *item) {cJSON *ref=cJSON_New_Item();if (!ref) return 0;memcpy(ref,item,sizeof(cJSON));ref->string=0;ref->type|=cJSON_IsReference;ref->next=ref->prev=0;return ref;}
|
||||
|
||||
/* Add item to array/object. */
|
||||
void cJSON_AddItemToArray(cJSON *array, cJSON *item) {cJSON *c=array->child;if (!item) return; if (!c) {array->child=item;} else {while (c && c->next) c=c->next; suffix_object(c,item);}}
|
||||
void cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item) {if (!item) return; if (item->string) cJSON_free(item->string);item->string=cJSON_strdup(string);cJSON_AddItemToArray(object,item);}
|
||||
void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) {cJSON_AddItemToArray(array,create_reference(item));}
|
||||
void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item) {cJSON_AddItemToObject(object,string,create_reference(item));}
|
||||
|
||||
cJSON *cJSON_DetachItemFromArray(cJSON *array,int which) {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) return 0;
|
||||
if (c->prev) c->prev->next=c->next;
|
||||
if (c->next) c->next->prev=c->prev;
|
||||
if (c==array->child) array->child=c->next;
|
||||
c->prev=c->next=0;
|
||||
return c;}
|
||||
void cJSON_DeleteItemFromArray(cJSON *array,int which) {cJSON_Delete(cJSON_DetachItemFromArray(array,which));}
|
||||
cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string) {int i=0;cJSON *c=object->child;while (c && cJSON_strcasecmp(c->string,string)) i++,c=c->next;if (c) return cJSON_DetachItemFromArray(object,i);return 0;}
|
||||
void cJSON_DeleteItemFromObject(cJSON *object,const char *string) {cJSON_Delete(cJSON_DetachItemFromObject(object,string));}
|
||||
|
||||
/* Replace array/object items with new ones. */
|
||||
void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem) {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) return;
|
||||
newitem->next=c->next;newitem->prev=c->prev;if (newitem->next) newitem->next->prev=newitem;
|
||||
if (c==array->child) array->child=newitem; else newitem->prev->next=newitem;c->next=c->prev=0;cJSON_Delete(c);}
|
||||
void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem){int i=0;cJSON *c=object->child;while(c && cJSON_strcasecmp(c->string,string))i++,c=c->next;if(c){newitem->string=cJSON_strdup(string);cJSON_ReplaceItemInArray(object,i,newitem);}}
|
||||
|
||||
/* Create basic types: */
|
||||
cJSON *cJSON_CreateNull(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_NULL;return item;}
|
||||
cJSON *cJSON_CreateTrue(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_True;return item;}
|
||||
cJSON *cJSON_CreateFalse(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_False;return item;}
|
||||
cJSON *cJSON_CreateBool(int b) {cJSON *item=cJSON_New_Item();if(item)item->type=b?cJSON_True:cJSON_False;return item;}
|
||||
cJSON *cJSON_CreateNumber(double num) {cJSON *item=cJSON_New_Item();if(item){item->type=cJSON_Number;item->valuedouble=num;item->valueint=(int)num;}return item;}
|
||||
cJSON *cJSON_CreateString(const char *string) {cJSON *item=cJSON_New_Item();if(item){item->type=cJSON_String;item->valuestring=cJSON_strdup(string);}return item;}
|
||||
cJSON *cJSON_CreateArray(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_Array;return item;}
|
||||
cJSON *cJSON_CreateObject(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_Object;return item;}
|
||||
|
||||
/* Create Arrays: */
|
||||
cJSON *cJSON_CreateIntArray(const int *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
|
||||
cJSON *cJSON_CreateFloatArray(const float *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
|
||||
cJSON *cJSON_CreateDoubleArray(const double *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
|
||||
cJSON *cJSON_CreateStringArray(const char **strings,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateString(strings[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
|
||||
|
||||
/* Duplication */
|
||||
cJSON *cJSON_Duplicate(cJSON *item,int recurse)
|
||||
{
|
||||
cJSON *newitem,*cptr,*nptr=0,*newchild;
|
||||
/* Bail on bad ptr */
|
||||
if (!item) return 0;
|
||||
/* Create new item */
|
||||
newitem=cJSON_New_Item();
|
||||
if (!newitem) return 0;
|
||||
/* Copy over all vars */
|
||||
newitem->type=item->type&(~cJSON_IsReference),newitem->valueint=item->valueint,newitem->valuedouble=item->valuedouble;
|
||||
if (item->valuestring) {newitem->valuestring=cJSON_strdup(item->valuestring); if (!newitem->valuestring) {cJSON_Delete(newitem);return 0;}}
|
||||
if (item->string) {newitem->string=cJSON_strdup(item->string); if (!newitem->string) {cJSON_Delete(newitem);return 0;}}
|
||||
/* If non-recursive, then we're done! */
|
||||
if (!recurse) return newitem;
|
||||
/* Walk the ->next chain for the child. */
|
||||
cptr=item->child;
|
||||
while (cptr)
|
||||
{
|
||||
newchild=cJSON_Duplicate(cptr,1); /* Duplicate (with recurse) each item in the ->next chain */
|
||||
if (!newchild) {cJSON_Delete(newitem);return 0;}
|
||||
if (nptr) {nptr->next=newchild,newchild->prev=nptr;nptr=newchild;} /* If newitem->child already set, then crosswire ->prev and ->next and move on */
|
||||
else {newitem->child=newchild;nptr=newchild;} /* Set newitem->child and move to it */
|
||||
cptr=cptr->next;
|
||||
}
|
||||
return newitem;
|
||||
}
|
||||
|
||||
void cJSON_Minify(char *json)
|
||||
{
|
||||
char *into=json;
|
||||
while (*json)
|
||||
{
|
||||
if (*json==' ') json++;
|
||||
else if (*json=='\t') json++; // Whitespace characters.
|
||||
else if (*json=='\r') json++;
|
||||
else if (*json=='\n') json++;
|
||||
else if (*json=='/' && json[1]=='/') while (*json && *json!='\n') json++; // double-slash comments, to end of line.
|
||||
else if (*json=='/' && json[1]=='*') {while (*json && !(*json=='*' && json[1]=='/')) json++;json+=2;} // multiline comments.
|
||||
else if (*json=='\"'){*into++=*json++;while (*json && *json!='\"'){if (*json=='\\') *into++=*json++;*into++=*json++;}*into++=*json++;} // string literals, which are \" sensitive.
|
||||
else *into++=*json++; // All other characters.
|
||||
}
|
||||
*into=0; // and null-terminate.
|
||||
}
|
||||
143
3rdparty/cjson/cJSON.h
vendored
Normal file
143
3rdparty/cjson/cJSON.h
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
Copyright (c) 2009 Dave Gamble
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef cJSON__h
|
||||
#define cJSON__h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* cJSON Types: */
|
||||
#define cJSON_False 0
|
||||
#define cJSON_True 1
|
||||
#define cJSON_NULL 2
|
||||
#define cJSON_Number 3
|
||||
#define cJSON_String 4
|
||||
#define cJSON_Array 5
|
||||
#define cJSON_Object 6
|
||||
|
||||
#define cJSON_IsReference 256
|
||||
|
||||
/* The cJSON structure: */
|
||||
typedef struct cJSON {
|
||||
struct cJSON *next,*prev; /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
|
||||
struct cJSON *child; /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
|
||||
|
||||
int type; /* The type of the item, as above. */
|
||||
|
||||
char *valuestring; /* The item's string, if type==cJSON_String */
|
||||
int valueint; /* The item's number, if type==cJSON_Number */
|
||||
double valuedouble; /* The item's number, if type==cJSON_Number */
|
||||
|
||||
char *string; /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
|
||||
} cJSON;
|
||||
|
||||
typedef struct cJSON_Hooks {
|
||||
void *(*malloc_fn)(size_t sz);
|
||||
void (*free_fn)(void *ptr);
|
||||
} cJSON_Hooks;
|
||||
|
||||
/* Supply malloc, realloc and free functions to cJSON */
|
||||
extern void cJSON_InitHooks(cJSON_Hooks* hooks);
|
||||
|
||||
|
||||
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. Call cJSON_Delete when finished. */
|
||||
extern cJSON *cJSON_Parse(const char *value);
|
||||
/* Render a cJSON entity to text for transfer/storage. Free the char* when finished. */
|
||||
extern char *cJSON_Print(cJSON *item);
|
||||
/* Render a cJSON entity to text for transfer/storage without any formatting. Free the char* when finished. */
|
||||
extern char *cJSON_PrintUnformatted(cJSON *item);
|
||||
/* Delete a cJSON entity and all subentities. */
|
||||
extern void cJSON_Delete(cJSON *c);
|
||||
|
||||
/* Returns the number of items in an array (or object). */
|
||||
extern int cJSON_GetArraySize(cJSON *array);
|
||||
/* Retrieve item number "item" from array "array". Returns NULL if unsuccessful. */
|
||||
extern cJSON *cJSON_GetArrayItem(cJSON *array,int item);
|
||||
/* Get item "string" from object. Case insensitive. */
|
||||
extern cJSON *cJSON_GetObjectItem(cJSON *object,const char *string);
|
||||
|
||||
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
|
||||
extern const char *cJSON_GetErrorPtr(void);
|
||||
|
||||
/* These calls create a cJSON item of the appropriate type. */
|
||||
extern cJSON *cJSON_CreateNull(void);
|
||||
extern cJSON *cJSON_CreateTrue(void);
|
||||
extern cJSON *cJSON_CreateFalse(void);
|
||||
extern cJSON *cJSON_CreateBool(int b);
|
||||
extern cJSON *cJSON_CreateNumber(double num);
|
||||
extern cJSON *cJSON_CreateString(const char *string);
|
||||
extern cJSON *cJSON_CreateArray(void);
|
||||
extern cJSON *cJSON_CreateObject(void);
|
||||
|
||||
/* These utilities create an Array of count items. */
|
||||
extern cJSON *cJSON_CreateIntArray(const int *numbers,int count);
|
||||
extern cJSON *cJSON_CreateFloatArray(const float *numbers,int count);
|
||||
extern cJSON *cJSON_CreateDoubleArray(const double *numbers,int count);
|
||||
extern cJSON *cJSON_CreateStringArray(const char **strings,int count);
|
||||
|
||||
/* Append item to the specified array/object. */
|
||||
extern void cJSON_AddItemToArray(cJSON *array, cJSON *item);
|
||||
extern void cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item);
|
||||
/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
|
||||
extern void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
|
||||
extern void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item);
|
||||
|
||||
/* Remove/Detatch items from Arrays/Objects. */
|
||||
extern cJSON *cJSON_DetachItemFromArray(cJSON *array,int which);
|
||||
extern void cJSON_DeleteItemFromArray(cJSON *array,int which);
|
||||
extern cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string);
|
||||
extern void cJSON_DeleteItemFromObject(cJSON *object,const char *string);
|
||||
|
||||
/* Update array items. */
|
||||
extern void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem);
|
||||
extern void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
|
||||
|
||||
/* Duplicate a cJSON item */
|
||||
extern cJSON *cJSON_Duplicate(cJSON *item,int recurse);
|
||||
/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
|
||||
need to be released. With recurse!=0, it will duplicate any children connected to the item.
|
||||
The item->next and ->prev pointers are always zero on return from Duplicate. */
|
||||
|
||||
/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
|
||||
extern cJSON *cJSON_ParseWithOpts(const char *value,const char **return_parse_end,int require_null_terminated);
|
||||
|
||||
extern void cJSON_Minify(char *json);
|
||||
|
||||
/* Macros for creating things quickly. */
|
||||
#define cJSON_AddNullToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateNull())
|
||||
#define cJSON_AddTrueToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateTrue())
|
||||
#define cJSON_AddFalseToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateFalse())
|
||||
#define cJSON_AddBoolToObject(object,name,b) cJSON_AddItemToObject(object, name, cJSON_CreateBool(b))
|
||||
#define cJSON_AddNumberToObject(object,name,n) cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n))
|
||||
#define cJSON_AddStringToObject(object,name,s) cJSON_AddItemToObject(object, name, cJSON_CreateString(s))
|
||||
|
||||
/* When assigning an integer value, it needs to be propagated to valuedouble too. */
|
||||
#define cJSON_SetIntValue(object,val) ((object)?(object)->valueint=(object)->valuedouble=(val):(val))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
156
3rdparty/cjson/test.c
vendored
Normal file
156
3rdparty/cjson/test.c
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
Copyright (c) 2009 Dave Gamble
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "cJSON.h"
|
||||
|
||||
/* Parse text to JSON, then render back to text, and print! */
|
||||
void doit(char *text)
|
||||
{
|
||||
char *out;cJSON *json;
|
||||
|
||||
json=cJSON_Parse(text);
|
||||
if (!json) {printf("Error before: [%s]\n",cJSON_GetErrorPtr());}
|
||||
else
|
||||
{
|
||||
out=cJSON_Print(json);
|
||||
cJSON_Delete(json);
|
||||
printf("%s\n",out);
|
||||
free(out);
|
||||
}
|
||||
}
|
||||
|
||||
/* Read a file, parse, render back, etc. */
|
||||
void dofile(char *filename)
|
||||
{
|
||||
FILE *f=fopen(filename,"rb");fseek(f,0,SEEK_END);long len=ftell(f);fseek(f,0,SEEK_SET);
|
||||
char *data=(char*)malloc(len+1);fread(data,1,len,f);fclose(f);
|
||||
doit(data);
|
||||
free(data);
|
||||
}
|
||||
|
||||
/* Used by some code below as an example datatype. */
|
||||
struct record {const char *precision;double lat,lon;const char *address,*city,*state,*zip,*country; };
|
||||
|
||||
/* Create a bunch of objects as demonstration. */
|
||||
void create_objects()
|
||||
{
|
||||
cJSON *root,*fmt,*img,*thm,*fld;char *out;int i; /* declare a few. */
|
||||
|
||||
/* Here we construct some JSON standards, from the JSON site. */
|
||||
|
||||
/* Our "Video" datatype: */
|
||||
root=cJSON_CreateObject();
|
||||
cJSON_AddItemToObject(root, "name", cJSON_CreateString("Jack (\"Bee\") Nimble"));
|
||||
cJSON_AddItemToObject(root, "format", fmt=cJSON_CreateObject());
|
||||
cJSON_AddStringToObject(fmt,"type", "rect");
|
||||
cJSON_AddNumberToObject(fmt,"width", 1920);
|
||||
cJSON_AddNumberToObject(fmt,"height", 1080);
|
||||
cJSON_AddFalseToObject (fmt,"interlace");
|
||||
cJSON_AddNumberToObject(fmt,"frame rate", 24);
|
||||
|
||||
out=cJSON_Print(root); cJSON_Delete(root); printf("%s\n",out); free(out); /* Print to text, Delete the cJSON, print it, release the string. */
|
||||
|
||||
/* Our "days of the week" array: */
|
||||
const char *strings[7]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
|
||||
root=cJSON_CreateStringArray(strings,7);
|
||||
|
||||
out=cJSON_Print(root); cJSON_Delete(root); printf("%s\n",out); free(out);
|
||||
|
||||
/* Our matrix: */
|
||||
int numbers[3][3]={{0,-1,0},{1,0,0},{0,0,1}};
|
||||
root=cJSON_CreateArray();
|
||||
for (i=0;i<3;i++) cJSON_AddItemToArray(root,cJSON_CreateIntArray(numbers[i],3));
|
||||
|
||||
/* cJSON_ReplaceItemInArray(root,1,cJSON_CreateString("Replacement")); */
|
||||
|
||||
out=cJSON_Print(root); cJSON_Delete(root); printf("%s\n",out); free(out);
|
||||
|
||||
|
||||
/* Our "gallery" item: */
|
||||
int ids[4]={116,943,234,38793};
|
||||
root=cJSON_CreateObject();
|
||||
cJSON_AddItemToObject(root, "Image", img=cJSON_CreateObject());
|
||||
cJSON_AddNumberToObject(img,"Width",800);
|
||||
cJSON_AddNumberToObject(img,"Height",600);
|
||||
cJSON_AddStringToObject(img,"Title","View from 15th Floor");
|
||||
cJSON_AddItemToObject(img, "Thumbnail", thm=cJSON_CreateObject());
|
||||
cJSON_AddStringToObject(thm, "Url", "http:/*www.example.com/image/481989943");
|
||||
cJSON_AddNumberToObject(thm,"Height",125);
|
||||
cJSON_AddStringToObject(thm,"Width","100");
|
||||
cJSON_AddItemToObject(img,"IDs", cJSON_CreateIntArray(ids,4));
|
||||
|
||||
out=cJSON_Print(root); cJSON_Delete(root); printf("%s\n",out); free(out);
|
||||
|
||||
/* Our array of "records": */
|
||||
struct record fields[2]={
|
||||
{"zip",37.7668,-1.223959e+2,"","SAN FRANCISCO","CA","94107","US"},
|
||||
{"zip",37.371991,-1.22026e+2,"","SUNNYVALE","CA","94085","US"}};
|
||||
|
||||
root=cJSON_CreateArray();
|
||||
for (i=0;i<2;i++)
|
||||
{
|
||||
cJSON_AddItemToArray(root,fld=cJSON_CreateObject());
|
||||
cJSON_AddStringToObject(fld, "precision", fields[i].precision);
|
||||
cJSON_AddNumberToObject(fld, "Latitude", fields[i].lat);
|
||||
cJSON_AddNumberToObject(fld, "Longitude", fields[i].lon);
|
||||
cJSON_AddStringToObject(fld, "Address", fields[i].address);
|
||||
cJSON_AddStringToObject(fld, "City", fields[i].city);
|
||||
cJSON_AddStringToObject(fld, "State", fields[i].state);
|
||||
cJSON_AddStringToObject(fld, "Zip", fields[i].zip);
|
||||
cJSON_AddStringToObject(fld, "Country", fields[i].country);
|
||||
}
|
||||
|
||||
/* cJSON_ReplaceItemInObject(cJSON_GetArrayItem(root,1),"City",cJSON_CreateIntArray(ids,4)); */
|
||||
|
||||
out=cJSON_Print(root); cJSON_Delete(root); printf("%s\n",out); free(out);
|
||||
|
||||
}
|
||||
|
||||
int main (int argc, const char * argv[]) {
|
||||
/* a bunch of json: */
|
||||
char text1[]="{\n\"name\": \"Jack (\\\"Bee\\\") Nimble\", \n\"format\": {\"type\": \"rect\", \n\"width\": 1920, \n\"height\": 1080, \n\"interlace\": false,\"frame rate\": 24\n}\n}";
|
||||
char text2[]="[\"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\"]";
|
||||
char text3[]="[\n [0, -1, 0],\n [1, 0, 0],\n [0, 0, 1]\n ]\n";
|
||||
char text4[]="{\n \"Image\": {\n \"Width\": 800,\n \"Height\": 600,\n \"Title\": \"View from 15th Floor\",\n \"Thumbnail\": {\n \"Url\": \"http:/*www.example.com/image/481989943\",\n \"Height\": 125,\n \"Width\": \"100\"\n },\n \"IDs\": [116, 943, 234, 38793]\n }\n }";
|
||||
char text5[]="[\n {\n \"precision\": \"zip\",\n \"Latitude\": 37.7668,\n \"Longitude\": -122.3959,\n \"Address\": \"\",\n \"City\": \"SAN FRANCISCO\",\n \"State\": \"CA\",\n \"Zip\": \"94107\",\n \"Country\": \"US\"\n },\n {\n \"precision\": \"zip\",\n \"Latitude\": 37.371991,\n \"Longitude\": -122.026020,\n \"Address\": \"\",\n \"City\": \"SUNNYVALE\",\n \"State\": \"CA\",\n \"Zip\": \"94085\",\n \"Country\": \"US\"\n }\n ]";
|
||||
|
||||
/* Process each json textblock by parsing, then rebuilding: */
|
||||
doit(text1);
|
||||
doit(text2);
|
||||
doit(text3);
|
||||
doit(text4);
|
||||
doit(text5);
|
||||
|
||||
/* Parse standard testfiles: */
|
||||
/* dofile("../../tests/test1"); */
|
||||
/* dofile("../../tests/test2"); */
|
||||
/* dofile("../../tests/test3"); */
|
||||
/* dofile("../../tests/test4"); */
|
||||
/* dofile("../../tests/test5"); */
|
||||
|
||||
/* Now some samplecode for building objects concisely: */
|
||||
create_objects();
|
||||
|
||||
return 0;
|
||||
}
|
||||
22
3rdparty/cjson/tests/test1
vendored
Normal file
22
3rdparty/cjson/tests/test1
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"glossary": {
|
||||
"title": "example glossary",
|
||||
"GlossDiv": {
|
||||
"title": "S",
|
||||
"GlossList": {
|
||||
"GlossEntry": {
|
||||
"ID": "SGML",
|
||||
"SortAs": "SGML",
|
||||
"GlossTerm": "Standard Generalized Markup Language",
|
||||
"Acronym": "SGML",
|
||||
"Abbrev": "ISO 8879:1986",
|
||||
"GlossDef": {
|
||||
"para": "A meta-markup language, used to create markup languages such as DocBook.",
|
||||
"GlossSeeAlso": ["GML", "XML"]
|
||||
},
|
||||
"GlossSee": "markup"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
3rdparty/cjson/tests/test2
vendored
Normal file
11
3rdparty/cjson/tests/test2
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
{"menu": {
|
||||
"id": "file",
|
||||
"value": "File",
|
||||
"popup": {
|
||||
"menuitem": [
|
||||
{"value": "New", "onclick": "CreateNewDoc()"},
|
||||
{"value": "Open", "onclick": "OpenDoc()"},
|
||||
{"value": "Close", "onclick": "CloseDoc()"}
|
||||
]
|
||||
}
|
||||
}}
|
||||
26
3rdparty/cjson/tests/test3
vendored
Normal file
26
3rdparty/cjson/tests/test3
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
{"widget": {
|
||||
"debug": "on",
|
||||
"window": {
|
||||
"title": "Sample Konfabulator Widget",
|
||||
"name": "main_window",
|
||||
"width": 500,
|
||||
"height": 500
|
||||
},
|
||||
"image": {
|
||||
"src": "Images/Sun.png",
|
||||
"name": "sun1",
|
||||
"hOffset": 250,
|
||||
"vOffset": 250,
|
||||
"alignment": "center"
|
||||
},
|
||||
"text": {
|
||||
"data": "Click Here",
|
||||
"size": 36,
|
||||
"style": "bold",
|
||||
"name": "text1",
|
||||
"hOffset": 250,
|
||||
"vOffset": 100,
|
||||
"alignment": "center",
|
||||
"onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;"
|
||||
}
|
||||
}}
|
||||
88
3rdparty/cjson/tests/test4
vendored
Normal file
88
3rdparty/cjson/tests/test4
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
{"web-app": {
|
||||
"servlet": [
|
||||
{
|
||||
"servlet-name": "cofaxCDS",
|
||||
"servlet-class": "org.cofax.cds.CDSServlet",
|
||||
"init-param": {
|
||||
"configGlossary:installationAt": "Philadelphia, PA",
|
||||
"configGlossary:adminEmail": "ksm@pobox.com",
|
||||
"configGlossary:poweredBy": "Cofax",
|
||||
"configGlossary:poweredByIcon": "/images/cofax.gif",
|
||||
"configGlossary:staticPath": "/content/static",
|
||||
"templateProcessorClass": "org.cofax.WysiwygTemplate",
|
||||
"templateLoaderClass": "org.cofax.FilesTemplateLoader",
|
||||
"templatePath": "templates",
|
||||
"templateOverridePath": "",
|
||||
"defaultListTemplate": "listTemplate.htm",
|
||||
"defaultFileTemplate": "articleTemplate.htm",
|
||||
"useJSP": false,
|
||||
"jspListTemplate": "listTemplate.jsp",
|
||||
"jspFileTemplate": "articleTemplate.jsp",
|
||||
"cachePackageTagsTrack": 200,
|
||||
"cachePackageTagsStore": 200,
|
||||
"cachePackageTagsRefresh": 60,
|
||||
"cacheTemplatesTrack": 100,
|
||||
"cacheTemplatesStore": 50,
|
||||
"cacheTemplatesRefresh": 15,
|
||||
"cachePagesTrack": 200,
|
||||
"cachePagesStore": 100,
|
||||
"cachePagesRefresh": 10,
|
||||
"cachePagesDirtyRead": 10,
|
||||
"searchEngineListTemplate": "forSearchEnginesList.htm",
|
||||
"searchEngineFileTemplate": "forSearchEngines.htm",
|
||||
"searchEngineRobotsDb": "WEB-INF/robots.db",
|
||||
"useDataStore": true,
|
||||
"dataStoreClass": "org.cofax.SqlDataStore",
|
||||
"redirectionClass": "org.cofax.SqlRedirection",
|
||||
"dataStoreName": "cofax",
|
||||
"dataStoreDriver": "com.microsoft.jdbc.sqlserver.SQLServerDriver",
|
||||
"dataStoreUrl": "jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon",
|
||||
"dataStoreUser": "sa",
|
||||
"dataStorePassword": "dataStoreTestQuery",
|
||||
"dataStoreTestQuery": "SET NOCOUNT ON;select test='test';",
|
||||
"dataStoreLogFile": "/usr/local/tomcat/logs/datastore.log",
|
||||
"dataStoreInitConns": 10,
|
||||
"dataStoreMaxConns": 100,
|
||||
"dataStoreConnUsageLimit": 100,
|
||||
"dataStoreLogLevel": "debug",
|
||||
"maxUrlLength": 500}},
|
||||
{
|
||||
"servlet-name": "cofaxEmail",
|
||||
"servlet-class": "org.cofax.cds.EmailServlet",
|
||||
"init-param": {
|
||||
"mailHost": "mail1",
|
||||
"mailHostOverride": "mail2"}},
|
||||
{
|
||||
"servlet-name": "cofaxAdmin",
|
||||
"servlet-class": "org.cofax.cds.AdminServlet"},
|
||||
|
||||
{
|
||||
"servlet-name": "fileServlet",
|
||||
"servlet-class": "org.cofax.cds.FileServlet"},
|
||||
{
|
||||
"servlet-name": "cofaxTools",
|
||||
"servlet-class": "org.cofax.cms.CofaxToolsServlet",
|
||||
"init-param": {
|
||||
"templatePath": "toolstemplates/",
|
||||
"log": 1,
|
||||
"logLocation": "/usr/local/tomcat/logs/CofaxTools.log",
|
||||
"logMaxSize": "",
|
||||
"dataLog": 1,
|
||||
"dataLogLocation": "/usr/local/tomcat/logs/dataLog.log",
|
||||
"dataLogMaxSize": "",
|
||||
"removePageCache": "/content/admin/remove?cache=pages&id=",
|
||||
"removeTemplateCache": "/content/admin/remove?cache=templates&id=",
|
||||
"fileTransferFolder": "/usr/local/tomcat/webapps/content/fileTransferFolder",
|
||||
"lookInContext": 1,
|
||||
"adminGroupID": 4,
|
||||
"betaServer": true}}],
|
||||
"servlet-mapping": {
|
||||
"cofaxCDS": "/",
|
||||
"cofaxEmail": "/cofaxutil/aemail/*",
|
||||
"cofaxAdmin": "/admin/*",
|
||||
"fileServlet": "/static/*",
|
||||
"cofaxTools": "/tools/*"},
|
||||
|
||||
"taglib": {
|
||||
"taglib-uri": "cofax.tld",
|
||||
"taglib-location": "/WEB-INF/tlds/cofax.tld"}}}
|
||||
27
3rdparty/cjson/tests/test5
vendored
Normal file
27
3rdparty/cjson/tests/test5
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
{"menu": {
|
||||
"header": "SVG Viewer",
|
||||
"items": [
|
||||
{"id": "Open"},
|
||||
{"id": "OpenNew", "label": "Open New"},
|
||||
null,
|
||||
{"id": "ZoomIn", "label": "Zoom In"},
|
||||
{"id": "ZoomOut", "label": "Zoom Out"},
|
||||
{"id": "OriginalView", "label": "Original View"},
|
||||
null,
|
||||
{"id": "Quality"},
|
||||
{"id": "Pause"},
|
||||
{"id": "Mute"},
|
||||
null,
|
||||
{"id": "Find", "label": "Find..."},
|
||||
{"id": "FindAgain", "label": "Find Again"},
|
||||
{"id": "Copy"},
|
||||
{"id": "CopyAgain", "label": "Copy Again"},
|
||||
{"id": "CopySVG", "label": "Copy SVG"},
|
||||
{"id": "ViewSVG", "label": "View SVG"},
|
||||
{"id": "ViewSource", "label": "View Source"},
|
||||
{"id": "SaveAs", "label": "Save As"},
|
||||
null,
|
||||
{"id": "Help"},
|
||||
{"id": "About", "label": "About Adobe CVG Viewer..."}
|
||||
]
|
||||
}}
|
||||
6
3rdparty/cppunit/AUTHORS
vendored
Normal file
6
3rdparty/cppunit/AUTHORS
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
Michael Feathers <mfeathers@objectmentor.com>
|
||||
Jerome Lacoste <lacostej@altern.org>
|
||||
E. Sommerlade <eric@sommerla.de>
|
||||
Baptiste Lepilleur <gaiacrtn@free.fr> <blep@sourceforge.net>
|
||||
Bastiaan Bakker <bastiaan.bakker@lifeline.nl>
|
||||
Steve Robbins <smr99@sourceforge.net>
|
||||
18
3rdparty/cppunit/CMakeLists.txt
vendored
Normal file
18
3rdparty/cppunit/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
set(CPPUNIT_SOURCES
|
||||
${CPPUNIT_SOURCES}
|
||||
)
|
||||
set(CPPUNIT_HEADERS
|
||||
${CPPUNIT_HEADERS}
|
||||
)
|
||||
|
||||
# Add the src and header directories.
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(include)
|
||||
|
||||
foreach(s ${CPPUNIT_SOURCES})
|
||||
set_property(GLOBAL APPEND PROPERTY CPPUNIT_SOURCES "${s}")
|
||||
endforeach()
|
||||
|
||||
foreach(h ${CPPUNIT_HEADERS})
|
||||
set_property(GLOBAL APPEND PROPERTY CPPUNIT_HEADERS "${h}")
|
||||
endforeach()
|
||||
504
3rdparty/cppunit/COPYING
vendored
Normal file
504
3rdparty/cppunit/COPYING
vendored
Normal file
@@ -0,0 +1,504 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
|
||||
|
||||
1247
3rdparty/cppunit/NEWS
vendored
Normal file
1247
3rdparty/cppunit/NEWS
vendored
Normal file
File diff suppressed because it is too large
Load Diff
17
3rdparty/cppunit/README
vendored
Normal file
17
3rdparty/cppunit/README
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
CppUnit --- The C++ Unit Test Library
|
||||
-------------------------------------
|
||||
http://www.freedesktop.org/wiki/Software/cppunit
|
||||
|
||||
CppUnit is the C++ port of the famous JUnit framework for unit
|
||||
testing.
|
||||
|
||||
For MSWindows installation notes, see INSTALL-WIN32.txt.
|
||||
For other systems -- including cygwin -- see INSTALL and INSTALL-unix.
|
||||
|
||||
|
||||
Bug reports are welcome. Please open bug reports for Cppunit at
|
||||
bugs.documentfoundation.org under the component cppunit.
|
||||
|
||||
Email to the current maintainers may be sent to
|
||||
<libreoffice@lists.freedesktop.org>
|
||||
|
||||
6
3rdparty/cppunit/include/CMakeLists.txt
vendored
Normal file
6
3rdparty/cppunit/include/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
add_subdirectory(cppunit)
|
||||
|
||||
set(CPPUNIT_HEADERS
|
||||
${CPPUNIT_HEADERS}
|
||||
PARENT_SCOPE
|
||||
)
|
||||
76
3rdparty/cppunit/include/cppunit/AdditionalMessage.h
vendored
Normal file
76
3rdparty/cppunit/include/cppunit/AdditionalMessage.h
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
#ifndef CPPUNIT_ADDITIONALMESSAGE_H
|
||||
#define CPPUNIT_ADDITIONALMESSAGE_H
|
||||
|
||||
#include <cppunit/Message.h>
|
||||
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
/*! \brief An additional Message for assertions.
|
||||
* \ingroup CreatingNewAssertions
|
||||
*
|
||||
* Provides a implicit constructor that takes a single string. This allow this
|
||||
* class to be used as the message arguments in macros.
|
||||
*
|
||||
* The constructed object is either a Message with a single detail string if
|
||||
* a string was passed to the macro, or a copy of the Message passed to the macro.
|
||||
*
|
||||
* Here is an example of usage:
|
||||
* \code
|
||||
*
|
||||
* void checkStringEquals( const std::string &expected,
|
||||
* const std::string &actual,
|
||||
* const CppUnit::SourceLine &sourceLine,
|
||||
* const CppUnit::AdditionalMessage &message );
|
||||
*
|
||||
* #define XTLUT_ASSERT_STRING_EQUAL_MESSAGE( expected, actual, message ) \
|
||||
* ::XtlUt::Impl::checkStringEquals( ::Xtl::toString(expected), \
|
||||
* ::Xtl::toString(actual), \
|
||||
* CPPUNIT_SOURCELINE(), \
|
||||
* message )
|
||||
* \endcode
|
||||
*
|
||||
* In the previous example, the user can specify a simple string for \a message,
|
||||
* or a complex Message object.
|
||||
*
|
||||
* \see Message
|
||||
*/
|
||||
class CPPUNIT_API AdditionalMessage : public Message
|
||||
{
|
||||
public:
|
||||
typedef Message SuperClass;
|
||||
|
||||
/// Constructs an empty Message.
|
||||
AdditionalMessage();
|
||||
|
||||
/*! \brief Constructs a Message with the specified detail string.
|
||||
* \param detail1 Detail string of the message. If empty, then it is not added.
|
||||
*/
|
||||
AdditionalMessage( const std::string &detail1 );
|
||||
|
||||
/*! \brief Constructs a Message with the specified detail string.
|
||||
* \param detail1 Detail string of the message. If empty, then it is not added.
|
||||
*/
|
||||
AdditionalMessage( const char *detail1 );
|
||||
|
||||
/*! \brief Constructs a copy of the specified message.
|
||||
* \param other Message to copy.
|
||||
*/
|
||||
AdditionalMessage( const Message &other );
|
||||
|
||||
/*! \brief Assignment operator.
|
||||
* \param other Message to copy.
|
||||
* \return Reference on this object.
|
||||
*/
|
||||
AdditionalMessage &operator =( const Message &other );
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
|
||||
|
||||
#endif // CPPUNIT_ADDITIONALMESSAGE_H
|
||||
252
3rdparty/cppunit/include/cppunit/Asserter.h
vendored
Normal file
252
3rdparty/cppunit/include/cppunit/Asserter.h
vendored
Normal file
@@ -0,0 +1,252 @@
|
||||
#ifndef CPPUNIT_ASSERTER_H
|
||||
#define CPPUNIT_ASSERTER_H
|
||||
|
||||
#include <cppunit/AdditionalMessage.h>
|
||||
#include <cppunit/SourceLine.h>
|
||||
#include <string>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
class Message;
|
||||
|
||||
|
||||
/*! \brief A set of functions to help writing assertion macros.
|
||||
* \ingroup CreatingNewAssertions
|
||||
*
|
||||
* Here is an example of assertion, a simplified version of the
|
||||
* actual assertion implemented in examples/cppunittest/XmlUniformiser.h:
|
||||
* \code
|
||||
* #include <cppunit/SourceLine.h>
|
||||
* #include <cppunit/TestAssert.h>
|
||||
*
|
||||
* void
|
||||
* checkXmlEqual( std::string expectedXml,
|
||||
* std::string actualXml,
|
||||
* CppUnit::SourceLine sourceLine )
|
||||
* {
|
||||
* std::string expected = XmlUniformiser( expectedXml ).stripped();
|
||||
* std::string actual = XmlUniformiser( actualXml ).stripped();
|
||||
*
|
||||
* if ( expected == actual )
|
||||
* return;
|
||||
*
|
||||
* ::CppUnit::Asserter::failNotEqual( expected,
|
||||
* actual,
|
||||
* sourceLine );
|
||||
* }
|
||||
*
|
||||
* /// Asserts that two XML strings are equivalent.
|
||||
* #define CPPUNITTEST_ASSERT_XML_EQUAL( expected, actual ) \
|
||||
* checkXmlEqual( expected, actual, \
|
||||
* CPPUNIT_SOURCELINE() )
|
||||
* \endcode
|
||||
*/
|
||||
|
||||
#if defined __GNUC__
|
||||
# define NORETURN __attribute__((noreturn))
|
||||
#else
|
||||
# define NORETURN
|
||||
#endif
|
||||
|
||||
struct Asserter
|
||||
{
|
||||
/*! \brief Throws a Exception with the specified message and location.
|
||||
*/
|
||||
NORETURN static void CPPUNIT_API fail( const Message &message,
|
||||
const SourceLine &sourceLine = SourceLine() );
|
||||
|
||||
/*! \brief Throws a Exception with the specified message and location.
|
||||
* \deprecated Use fail( Message, SourceLine ) instead.
|
||||
*/
|
||||
NORETURN static void CPPUNIT_API fail( std::string message,
|
||||
const SourceLine &sourceLine = SourceLine() );
|
||||
|
||||
/*! \brief Throws a Exception with the specified message and location.
|
||||
* \param shouldFail if \c true then the exception is thrown. Otherwise
|
||||
* nothing happen.
|
||||
* \param message Message explaining the assertion failiure.
|
||||
* \param sourceLine Location of the assertion.
|
||||
*/
|
||||
static void CPPUNIT_API failIf( bool shouldFail,
|
||||
const Message &message,
|
||||
const SourceLine &sourceLine = SourceLine() );
|
||||
|
||||
/*! \brief Throws a Exception with the specified message and location.
|
||||
* \deprecated Use failIf( bool, Message, SourceLine ) instead.
|
||||
* \param shouldFail if \c true then the exception is thrown. Otherwise
|
||||
* nothing happen.
|
||||
* \param message Message explaining the assertion failiure.
|
||||
* \param sourceLine Location of the assertion.
|
||||
*/
|
||||
static void CPPUNIT_API failIf( bool shouldFail,
|
||||
std::string message,
|
||||
const SourceLine &sourceLine = SourceLine() );
|
||||
|
||||
/*! \brief Returns a expected value string for a message, case equal than
|
||||
* Typically used to create 'not equal' message, or to check that a message
|
||||
* contains the expected content when writing unit tests for your custom
|
||||
* assertions.
|
||||
*
|
||||
* \param expectedValue String that represents the expected value.
|
||||
* \return \a expectedValue prefixed with "Expected: ".
|
||||
* \deprecated Use makeExpectedEqual instead
|
||||
* \see makeActual().
|
||||
*/
|
||||
static std::string CPPUNIT_API makeExpected( const std::string &expectedValue );
|
||||
/*! \brief Returns a expected value string for a message, case equal than
|
||||
* Typically used to create 'not equal' message, or to check that a message
|
||||
* contains the expected content when writing unit tests for your custom
|
||||
* assertions.
|
||||
*
|
||||
* \param expectedValue String that represents the expected value.
|
||||
* \return \a expectedValue prefixed with "Expected: ".
|
||||
* \see makeActual().
|
||||
*/
|
||||
static std::string CPPUNIT_API makeExpectedEqual( const std::string &expectedValue );
|
||||
/*! \brief Returns a expected value string for a message, case less than.
|
||||
*
|
||||
* \param expectedValue String that represents the expected value.
|
||||
* \return \a expectedValue prefixed with "Expected less than: ".
|
||||
* \see makeExpectedEqual().
|
||||
*/
|
||||
static std::string CPPUNIT_API makeExpectedLess( const std::string &expectedValue );
|
||||
/*! \brief Returns a expected value string for a message, case less or equal than.
|
||||
*
|
||||
* \param expectedValue String that represents the expected value.
|
||||
* \return \a expectedValue prefixed with "Expected: ".
|
||||
* \see makeExpectedEqual().
|
||||
*/
|
||||
static std::string CPPUNIT_API makeExpectedLessEqual( const std::string &expectedValue );
|
||||
/*! \brief Returns a expected value string for a message, case greater than.
|
||||
*
|
||||
* \param expectedValue String that represents the expected value.
|
||||
* \return \a expectedValue prefixed with "Expected: ".
|
||||
* \see makeExpectedEqual().
|
||||
*/
|
||||
static std::string CPPUNIT_API makeExpectedGreater( const std::string &expectedValue );
|
||||
/*! \brief Returns a expected value string for a message, greater or equal than.
|
||||
*
|
||||
* \param expectedValue String that represents the expected value.
|
||||
* \return \a expectedValue prefixed with "Expected: ".
|
||||
* \see makeExpectedEqual().
|
||||
*/
|
||||
static std::string CPPUNIT_API makeExpectedGreaterEqual( const std::string &expectedValue );
|
||||
|
||||
/*! \brief Returns an actual value string for a message.
|
||||
* Typically used to create 'not equal' message, or to check that a message
|
||||
* contains the expected content when writing unit tests for your custom
|
||||
* assertions.
|
||||
*
|
||||
* \param actualValue String that represents the actual value.
|
||||
* \return \a actualValue prefixed with "Actual : ".
|
||||
* \see makeExpected().
|
||||
*/
|
||||
static std::string CPPUNIT_API makeActual( const std::string &actualValue );
|
||||
|
||||
/*!
|
||||
* \deprecated Use makeMessage instead
|
||||
*/
|
||||
static Message CPPUNIT_API makeNotEqualMessage( const std::string &expectedValue,
|
||||
const std::string &actualValue,
|
||||
const AdditionalMessage &additionalMessage = AdditionalMessage(),
|
||||
const std::string &shortDescription = "equality assertion failed");
|
||||
|
||||
static Message CPPUNIT_API makeMessage( const std::string &expectedValue,
|
||||
const std::string &actualValue,
|
||||
const std::string &shortDescription,
|
||||
const AdditionalMessage &additionalMessage = AdditionalMessage());
|
||||
|
||||
/*! \brief Throws an Exception with the specified message and location.
|
||||
* \param expected Text describing the expected value.
|
||||
* \param actual Text describing the actual value.
|
||||
* \param sourceLine Location of the assertion.
|
||||
* \param additionalMessage Additional message. Usually used to report
|
||||
* what are the differences between the expected and actual value.
|
||||
* \param shortDescription Short description for the failure message.
|
||||
*/
|
||||
NORETURN static void CPPUNIT_API failNotEqual( std::string expected,
|
||||
std::string actual,
|
||||
const SourceLine &sourceLine,
|
||||
const AdditionalMessage &additionalMessage = AdditionalMessage(),
|
||||
std::string shortDescription = "equality assertion failed" );
|
||||
|
||||
/*! \brief Throws an Exception with the specified message and location.
|
||||
* \param expected Text describing the expected value.
|
||||
* \param actual Text describing the actual value.
|
||||
* \param sourceLine Location of the assertion.
|
||||
* \param additionalMessage Additional message. Usually used to report
|
||||
* what are the differences between the expected and actual value.
|
||||
* \param shortDescription Short description for the failure message.
|
||||
*/
|
||||
static void CPPUNIT_API failNotLess( std::string expected,
|
||||
std::string actual,
|
||||
const SourceLine &sourceLine,
|
||||
const AdditionalMessage &additionalMessage = AdditionalMessage(),
|
||||
std::string shortDescription = "less assertion failed" );
|
||||
|
||||
/*! \brief Throws an Exception with the specified message and location.
|
||||
* \param expected Text describing the expected value.
|
||||
* \param actual Text describing the actual value.
|
||||
* \param sourceLine Location of the assertion.
|
||||
* \param additionalMessage Additional message. Usually used to report
|
||||
* what are the differences between the expected and actual value.
|
||||
* \param shortDescription Short description for the failure message.
|
||||
*/
|
||||
static void CPPUNIT_API failNotGreater( std::string expected,
|
||||
std::string actual,
|
||||
const SourceLine &sourceLine,
|
||||
const AdditionalMessage &additionalMessage = AdditionalMessage(),
|
||||
std::string shortDescription = "greater assertion failed" );
|
||||
|
||||
/*! \brief Throws an Exception with the specified message and location.
|
||||
* \param expected Text describing the expected value.
|
||||
* \param actual Text describing the actual value.
|
||||
* \param sourceLine Location of the assertion.
|
||||
* \param additionalMessage Additional message. Usually used to report
|
||||
* what are the differences between the expected and actual value.
|
||||
* \param shortDescription Short description for the failure message.
|
||||
*/
|
||||
static void CPPUNIT_API failNotLessEqual( std::string expected,
|
||||
std::string actual,
|
||||
const SourceLine &sourceLine,
|
||||
const AdditionalMessage &additionalMessage = AdditionalMessage(),
|
||||
std::string shortDescription = "less equal assertion failed" );
|
||||
|
||||
/*! \brief Throws an Exception with the specified message and location.
|
||||
* \param expected Text describing the expected value.
|
||||
* \param actual Text describing the actual value.
|
||||
* \param sourceLine Location of the assertion.
|
||||
* \param additionalMessage Additional message. Usually used to report
|
||||
* what are the differences between the expected and actual value.
|
||||
* \param shortDescription Short description for the failure message.
|
||||
*/
|
||||
static void CPPUNIT_API failNotGreaterEqual( std::string expected,
|
||||
std::string actual,
|
||||
const SourceLine &sourceLine,
|
||||
const AdditionalMessage &additionalMessage = AdditionalMessage(),
|
||||
std::string shortDescription = "greater equal assertion failed" ); /*! \brief Throws an Exception with the specified message and location.
|
||||
|
||||
* \param shouldFail if \c true then the exception is thrown. Otherwise
|
||||
* nothing happen.
|
||||
* \param expected Text describing the expected value.
|
||||
* \param actual Text describing the actual value.
|
||||
* \param sourceLine Location of the assertion.
|
||||
* \param additionalMessage Additional message. Usually used to report
|
||||
* where the "difference" is located.
|
||||
* \param shortDescription Short description for the failure message.
|
||||
*/
|
||||
static void CPPUNIT_API failNotEqualIf( bool shouldFail,
|
||||
std::string expected,
|
||||
std::string actual,
|
||||
const SourceLine &sourceLine,
|
||||
const AdditionalMessage &additionalMessage = AdditionalMessage(),
|
||||
std::string shortDescription = "equality assertion failed" );
|
||||
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
|
||||
#endif // CPPUNIT_ASSERTER_H
|
||||
43
3rdparty/cppunit/include/cppunit/BriefTestProgressListener.h
vendored
Normal file
43
3rdparty/cppunit/include/cppunit/BriefTestProgressListener.h
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef CPPUNIT_BRIEFTESTPROGRESSLISTENER_H
|
||||
#define CPPUNIT_BRIEFTESTPROGRESSLISTENER_H
|
||||
|
||||
#include <cppunit/TestListener.h>
|
||||
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
/*! \brief TestListener that prints the name of each test before running it.
|
||||
* \ingroup TrackingTestExecution
|
||||
*/
|
||||
class CPPUNIT_API BriefTestProgressListener : public TestListener
|
||||
{
|
||||
public:
|
||||
/*! Constructs a BriefTestProgressListener object.
|
||||
*/
|
||||
BriefTestProgressListener();
|
||||
|
||||
/// Destructor.
|
||||
virtual ~BriefTestProgressListener();
|
||||
|
||||
void startTest( Test *test );
|
||||
|
||||
void addFailure( const TestFailure &failure );
|
||||
|
||||
void endTest( Test *test );
|
||||
|
||||
private:
|
||||
/// Prevents the use of the copy constructor.
|
||||
BriefTestProgressListener( const BriefTestProgressListener © );
|
||||
|
||||
/// Prevents the use of the copy operator.
|
||||
void operator =( const BriefTestProgressListener © );
|
||||
|
||||
private:
|
||||
bool m_lastTestFailed;
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // CPPUNIT_BRIEFTESTPROGRESSLISTENER_H
|
||||
36
3rdparty/cppunit/include/cppunit/CMakeLists.txt
vendored
Normal file
36
3rdparty/cppunit/include/cppunit/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
set(CPPUNIT_HEADERS
|
||||
${CPPUNIT_HEADERS}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/AdditionalMessage.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Asserter.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/BriefTestProgressListener.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CompilerOutputter.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Exception.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Message.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Outputter.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Portability.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Protector.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/SourceLine.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/SynchronizedObject.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Test.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestAssert.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestCase.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestCaller.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestComposite.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestFailure.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestFixture.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestLeaf.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestPath.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestResult.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestResultCollector.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestRunner.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestSuccessListener.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestSuite.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TextOutputter.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TextTestProgressListener.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TextTestResult.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TextTestRunner.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestListener.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/XmlOutputter.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/XmlOutputterHook.h
|
||||
PARENT_SCOPE
|
||||
)
|
||||
146
3rdparty/cppunit/include/cppunit/CompilerOutputter.h
vendored
Normal file
146
3rdparty/cppunit/include/cppunit/CompilerOutputter.h
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
#ifndef CPPUNIT_COMPILERTESTRESULTOUTPUTTER_H
|
||||
#define CPPUNIT_COMPILERTESTRESULTOUTPUTTER_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
#include <cppunit/Outputter.h>
|
||||
#include <cppunit/portability/Stream.h>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
class Exception;
|
||||
class SourceLine;
|
||||
class Test;
|
||||
class TestFailure;
|
||||
class TestResultCollector;
|
||||
|
||||
/*!
|
||||
* \brief Outputs a TestResultCollector in a compiler compatible format.
|
||||
* \ingroup WritingTestResult
|
||||
*
|
||||
* Printing the test results in a compiler compatible format (assertion
|
||||
* location has the same format as compiler error), allow you to use your
|
||||
* IDE to jump to the assertion failure. Location format can be customized (see
|
||||
* setLocationFormat() ).
|
||||
*
|
||||
* For example, when running the test in a post-build with VC++, if an assertion
|
||||
* fails, you can jump to the assertion by pressing F4 (jump to next error).
|
||||
*
|
||||
* Heres is an example of usage (from examples/cppunittest/CppUnitTestMain.cpp):
|
||||
* \code
|
||||
* int main( int argc, char* argv[] ) {
|
||||
* // if command line contains "-selftest" then this is the post build check
|
||||
* // => the output must be in the compiler error format.
|
||||
* bool selfTest = (argc > 1) &&
|
||||
* (std::string("-selftest") == argv[1]);
|
||||
*
|
||||
* CppUnit::TextUi::TestRunner runner;
|
||||
* runner.addTest( CppUnitTest::suite() ); // Add the top suite to the test runner
|
||||
*
|
||||
* if ( selfTest )
|
||||
* { // Change the default outputter to a compiler error format outputter
|
||||
* // The test runner owns the new outputter.
|
||||
* runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
|
||||
* std::cerr ) );
|
||||
* }
|
||||
*
|
||||
* // Run the test and don't wait a key if post build check.
|
||||
* bool wasSuccessful = runner.run( "", !selfTest );
|
||||
*
|
||||
* // Return error code 1 if the one of test failed.
|
||||
* return wasSuccessful ? 0 : 1;
|
||||
* }
|
||||
* \endcode
|
||||
*/
|
||||
class CPPUNIT_API CompilerOutputter : public Outputter
|
||||
{
|
||||
public:
|
||||
/*! \brief Constructs a CompilerOutputter object.
|
||||
* \param result Result of the test run.
|
||||
* \param stream Stream used to output test result.
|
||||
* \param locationFormat Error location format used by your compiler. Default
|
||||
* to \c CPPUNIT_COMPILER_LOCATION_FORMAT which is defined
|
||||
* in the configuration file. See setLocationFormat() for detail.
|
||||
* \see setLocationFormat().
|
||||
*/
|
||||
CompilerOutputter( TestResultCollector *result,
|
||||
OStream &stream,
|
||||
const std::string &locationFormat = CPPUNIT_COMPILER_LOCATION_FORMAT );
|
||||
|
||||
/// Destructor.
|
||||
virtual ~CompilerOutputter();
|
||||
|
||||
/*! \brief Sets the error location format.
|
||||
*
|
||||
* Indicates the format used to report location of failed assertion. This format should
|
||||
* match the one used by your compiler.
|
||||
*
|
||||
* The location format is a string in which the occurence of the following character
|
||||
* sequence are replaced:
|
||||
*
|
||||
* - "%l" => replaced by the line number
|
||||
* - "%p" => replaced by the full path name of the file ("G:\prg\vc\cppunit\MyTest.cpp")
|
||||
* - "%f" => replaced by the base name of the file ("MyTest.cpp")
|
||||
*
|
||||
* Some examples:
|
||||
*
|
||||
* - VC++ error location format: "%p(%l):" => produce "G:\prg\MyTest.cpp(43):"
|
||||
* - GCC error location format: "%f:%l:" => produce "MyTest.cpp:43:"
|
||||
*
|
||||
* Thoses are the two compilers currently <em>supported</em> (gcc format is used if
|
||||
* VC++ is not detected). If you want your compiler to be automatically supported by
|
||||
* CppUnit, send a mail to the mailing list (preferred), or submit a feature request
|
||||
* that indicates how to detect your compiler with the preprocessor (\#ifdef...) and
|
||||
* your compiler location format.
|
||||
*/
|
||||
void setLocationFormat( const std::string &locationFormat );
|
||||
|
||||
/*! \brief Creates an instance of an outputter that matches your current compiler.
|
||||
* \deprecated This class is specialized through parameterization instead of subclassing...
|
||||
* Use CompilerOutputter::CompilerOutputter instead.
|
||||
*/
|
||||
static CompilerOutputter *defaultOutputter( TestResultCollector *result,
|
||||
OStream &stream );
|
||||
|
||||
void write();
|
||||
|
||||
void setNoWrap();
|
||||
|
||||
void setWrapColumn( int wrapColumn );
|
||||
|
||||
int wrapColumn() const;
|
||||
|
||||
virtual void printSuccess();
|
||||
virtual void printFailureReport();
|
||||
virtual void printFailuresList();
|
||||
virtual void printStatistics();
|
||||
virtual void printFailureDetail( TestFailure *failure );
|
||||
virtual void printFailureLocation( SourceLine sourceLine );
|
||||
virtual void printFailureType( TestFailure *failure );
|
||||
virtual void printFailedTestName( TestFailure *failure );
|
||||
virtual void printFailureMessage( TestFailure *failure );
|
||||
|
||||
private:
|
||||
/// Prevents the use of the copy constructor.
|
||||
CompilerOutputter( const CompilerOutputter © );
|
||||
|
||||
/// Prevents the use of the copy operator.
|
||||
void operator =( const CompilerOutputter © );
|
||||
|
||||
virtual bool processLocationFormatCommand( char command,
|
||||
const SourceLine &sourceLine );
|
||||
|
||||
virtual std::string extractBaseName( const std::string &fileName ) const;
|
||||
|
||||
private:
|
||||
TestResultCollector *m_result;
|
||||
OStream &m_stream;
|
||||
std::string m_locationFormat;
|
||||
int m_wrapColumn;
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
|
||||
#endif // CPPUNIT_COMPILERTESTRESULTOUTPUTTER_H
|
||||
90
3rdparty/cppunit/include/cppunit/Exception.h
vendored
Normal file
90
3rdparty/cppunit/include/cppunit/Exception.h
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
#ifndef CPPUNIT_EXCEPTION_H
|
||||
#define CPPUNIT_EXCEPTION_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
#include <cppunit/Message.h>
|
||||
#include <cppunit/SourceLine.h>
|
||||
#include <exception>
|
||||
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
/*! \brief Exceptions thrown by failed assertions.
|
||||
* \ingroup BrowsingCollectedTestResult
|
||||
*
|
||||
* Exception is an exception that serves
|
||||
* descriptive strings through its what() method
|
||||
*/
|
||||
class CPPUNIT_API Exception : public std::exception
|
||||
{
|
||||
public:
|
||||
/*! \brief Constructs the exception with the specified message and source location.
|
||||
* \param message Message associated to the exception.
|
||||
* \param sourceLine Source location related to the exception.
|
||||
*/
|
||||
Exception( const Message &message = Message(),
|
||||
const SourceLine &sourceLine = SourceLine() );
|
||||
|
||||
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
|
||||
/*!
|
||||
* \deprecated Use other constructor instead.
|
||||
*/
|
||||
Exception( std::string message,
|
||||
long lineNumber,
|
||||
std::string fileName );
|
||||
#endif
|
||||
|
||||
/*! \brief Constructs a copy of an exception.
|
||||
* \param other Exception to copy.
|
||||
*/
|
||||
Exception( const Exception &other );
|
||||
|
||||
/// Destructs the exception
|
||||
virtual ~Exception() throw();
|
||||
|
||||
/// Performs an assignment
|
||||
Exception &operator =( const Exception &other );
|
||||
|
||||
/// Returns descriptive message
|
||||
const char *what() const throw();
|
||||
|
||||
/// Location where the error occured
|
||||
SourceLine sourceLine() const;
|
||||
|
||||
/// Message related to the exception.
|
||||
Message message() const;
|
||||
|
||||
/// Set the message.
|
||||
void setMessage( const Message &message );
|
||||
|
||||
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
|
||||
/// The line on which the error occurred
|
||||
long lineNumber() const;
|
||||
|
||||
/// The file in which the error occurred
|
||||
std::string fileName() const;
|
||||
|
||||
static const std::string UNKNOWNFILENAME;
|
||||
static const long UNKNOWNLINENUMBER;
|
||||
#endif
|
||||
|
||||
/// Clones the exception.
|
||||
virtual Exception *clone() const;
|
||||
|
||||
protected:
|
||||
// VC++ does not recognize call to parent class when prefixed
|
||||
// with a namespace. This is a workaround.
|
||||
typedef std::exception SuperClass;
|
||||
|
||||
Message m_message;
|
||||
SourceLine m_sourceLine;
|
||||
std::string m_whatMessage;
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
|
||||
#endif // CPPUNIT_EXCEPTION_H
|
||||
|
||||
154
3rdparty/cppunit/include/cppunit/Message.h
vendored
Normal file
154
3rdparty/cppunit/include/cppunit/Message.h
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
#ifndef CPPUNIT_MESSAGE_H
|
||||
#define CPPUNIT_MESSAGE_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
|
||||
#if CPPUNIT_NEED_DLL_DECL
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z
|
||||
#endif
|
||||
|
||||
#include <deque>
|
||||
#include <string>
|
||||
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
/*! \brief Message associated to an Exception.
|
||||
* \ingroup CreatingNewAssertions
|
||||
* A message is composed of two items:
|
||||
* - a short description (~20/30 characters)
|
||||
* - a list of detail strings
|
||||
*
|
||||
* The short description is used to indicate how the detail strings should be
|
||||
* interpreted. It usually indicates the failure types, such as
|
||||
* "assertion failed", "forced failure", "unexpected exception caught",
|
||||
* "equality assertion failed"... It should not contains new line character (\n).
|
||||
*
|
||||
* Detail strings are used to provide more information about the failure. It
|
||||
* can contains the asserted expression, the expected and actual values in an
|
||||
* equality assertion, some addional messages... Detail strings can contains
|
||||
* new line characters (\n).
|
||||
*/
|
||||
class CPPUNIT_API Message
|
||||
{
|
||||
public:
|
||||
Message() {};
|
||||
|
||||
// Ensure thread-safe copy by detaching the string.
|
||||
Message( const Message &other );
|
||||
|
||||
explicit Message( const std::string &shortDescription );
|
||||
|
||||
Message( const std::string &shortDescription,
|
||||
const std::string &detail1 );
|
||||
|
||||
Message( const std::string &shortDescription,
|
||||
const std::string &detail1,
|
||||
const std::string &detail2 );
|
||||
|
||||
Message( const std::string &shortDescription,
|
||||
const std::string &detail1,
|
||||
const std::string &detail2,
|
||||
const std::string &detail3 );
|
||||
|
||||
virtual ~Message();
|
||||
|
||||
Message &operator =( const Message &other );
|
||||
|
||||
/*! \brief Returns the short description.
|
||||
* \return Short description.
|
||||
*/
|
||||
const std::string &shortDescription() const;
|
||||
|
||||
/*! \brief Returns the number of detail string.
|
||||
* \return Number of detail string.
|
||||
*/
|
||||
int detailCount() const;
|
||||
|
||||
/*! \brief Returns the detail at the specified index.
|
||||
* \param index Zero based index of the detail string to return.
|
||||
* \returns Detail string at the specified index.
|
||||
* \exception std::invalid_argument if \a index < 0 or index >= detailCount().
|
||||
*/
|
||||
std::string detailAt( int index ) const;
|
||||
|
||||
/*! \brief Returns a string that represents a list of the detail strings.
|
||||
*
|
||||
* Example:
|
||||
* \code
|
||||
* Message message( "not equal", "Expected: 3", "Actual: 7" );
|
||||
* std::string details = message.details();
|
||||
* // details contains:
|
||||
* // "- Expected: 3\n- Actual: 7\n" \endcode
|
||||
*
|
||||
* \return A string that is a concatenation of all the detail strings. Each detail
|
||||
* string is prefixed with '- ' and suffixed with '\n' before being
|
||||
* concatenated to the other.
|
||||
*/
|
||||
std::string details() const;
|
||||
|
||||
/*! \brief Removes all detail strings.
|
||||
*/
|
||||
void clearDetails();
|
||||
|
||||
/*! \brief Adds a single detail string.
|
||||
* \param detail Detail string to add.
|
||||
*/
|
||||
void addDetail( const std::string &detail );
|
||||
|
||||
/*! \brief Adds two detail strings.
|
||||
* \param detail1 Detail string to add.
|
||||
* \param detail2 Detail string to add.
|
||||
*/
|
||||
void addDetail( const std::string &detail1,
|
||||
const std::string &detail2 );
|
||||
|
||||
/*! \brief Adds three detail strings.
|
||||
* \param detail1 Detail string to add.
|
||||
* \param detail2 Detail string to add.
|
||||
* \param detail3 Detail string to add.
|
||||
*/
|
||||
void addDetail( const std::string &detail1,
|
||||
const std::string &detail2,
|
||||
const std::string &detail3 );
|
||||
|
||||
/*! \brief Adds the detail strings of the specified message.
|
||||
* \param message All the detail strings of this message are added to this one.
|
||||
*/
|
||||
void addDetail( const Message &message );
|
||||
|
||||
/*! \brief Sets the short description.
|
||||
* \param shortDescription New short description.
|
||||
*/
|
||||
void setShortDescription( const std::string &shortDescription );
|
||||
|
||||
/*! \brief Tests if a message is identical to another one.
|
||||
* \param other Message this message is compared to.
|
||||
* \return \c true if the two message are identical, \c false otherwise.
|
||||
*/
|
||||
bool operator ==( const Message &other ) const;
|
||||
|
||||
/*! \brief Tests if a message is different from another one.
|
||||
* \param other Message this message is compared to.
|
||||
* \return \c true if the two message are not identical, \c false otherwise.
|
||||
*/
|
||||
bool operator !=( const Message &other ) const;
|
||||
|
||||
private:
|
||||
std::string m_shortDescription;
|
||||
|
||||
typedef std::deque<std::string> Details;
|
||||
Details m_details;
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#if CPPUNIT_NEED_DLL_DECL
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
|
||||
|
||||
#endif // CPPUNIT_MESSAGE_H
|
||||
26
3rdparty/cppunit/include/cppunit/Outputter.h
vendored
Normal file
26
3rdparty/cppunit/include/cppunit/Outputter.h
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef CPPUNIT_OUTPUTTER_H
|
||||
#define CPPUNIT_OUTPUTTER_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
/*! \brief Abstract outputter to print test result summary.
|
||||
* \ingroup WritingTestResult
|
||||
*/
|
||||
class CPPUNIT_API Outputter
|
||||
{
|
||||
public:
|
||||
/// Destructor.
|
||||
virtual ~Outputter() {}
|
||||
|
||||
virtual void write() =0;
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
|
||||
#endif // CPPUNIT_OUTPUTTER_H
|
||||
169
3rdparty/cppunit/include/cppunit/Portability.h
vendored
Normal file
169
3rdparty/cppunit/include/cppunit/Portability.h
vendored
Normal file
@@ -0,0 +1,169 @@
|
||||
#ifndef CPPUNIT_PORTABILITY_H
|
||||
#define CPPUNIT_PORTABILITY_H
|
||||
|
||||
#if defined(_WIN32) && !defined(WIN32)
|
||||
# define WIN32 1
|
||||
#endif
|
||||
|
||||
/* include platform specific config */
|
||||
#if defined(__BORLANDC__)
|
||||
# include <cppunit/config/config-bcb5.h>
|
||||
#elif defined (_MSC_VER)
|
||||
# if _MSC_VER == 1200 && defined(_WIN32_WCE) //evc4
|
||||
# include <cppunit/config/config-evc4.h>
|
||||
# else
|
||||
# include <cppunit/config/config-msvc6.h>
|
||||
# endif
|
||||
#else
|
||||
# include <cppunit/config-auto.h>
|
||||
#endif
|
||||
|
||||
// Version number of package
|
||||
#ifndef CPPUNIT_VERSION
|
||||
#define CPPUNIT_VERSION "1.14.0"
|
||||
#endif
|
||||
|
||||
#include <cppunit/config/CppUnitApi.h> // define CPPUNIT_API & CPPUNIT_NEED_DLL_DECL
|
||||
#include <cppunit/config/SelectDllLoader.h>
|
||||
|
||||
|
||||
/* Options that the library user may switch on or off.
|
||||
* If the user has not done so, we chose default values.
|
||||
*/
|
||||
|
||||
|
||||
/* Define to 1 if you wish to have the old-style macros
|
||||
assert(), assertEqual(), assertDoublesEqual(), and assertLongsEqual() */
|
||||
#if !defined(CPPUNIT_ENABLE_NAKED_ASSERT)
|
||||
# define CPPUNIT_ENABLE_NAKED_ASSERT 0
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you wish to have the old-style CU_TEST family
|
||||
of macros. */
|
||||
#if !defined(CPPUNIT_ENABLE_CU_TEST_MACROS)
|
||||
# define CPPUNIT_ENABLE_CU_TEST_MACROS 0
|
||||
#endif
|
||||
|
||||
/* Define to 1 if the preprocessor expands (#foo) to "foo" (quotes incl.)
|
||||
I don't think there is any C preprocess that does NOT support this! */
|
||||
#if !defined(CPPUNIT_HAVE_CPP_SOURCE_ANNOTATION)
|
||||
# define CPPUNIT_HAVE_CPP_SOURCE_ANNOTATION 1
|
||||
#endif
|
||||
|
||||
/* Assumes that STL and CppUnit are in global space if the compiler does not
|
||||
support namespace. */
|
||||
#if !defined(CPPUNIT_HAVE_NAMESPACES)
|
||||
# if !defined(CPPUNIT_NO_NAMESPACE)
|
||||
# define CPPUNIT_NO_NAMESPACE 1
|
||||
# endif // !defined(CPPUNIT_NO_NAMESPACE)
|
||||
# if !defined(CPPUNIT_NO_STD_NAMESPACE)
|
||||
# define CPPUNIT_NO_STD_NAMESPACE 1
|
||||
# endif // !defined(CPPUNIT_NO_STD_NAMESPACE)
|
||||
#endif // !defined(CPPUNIT_HAVE_NAMESPACES)
|
||||
|
||||
// Compiler error location format for CompilerOutputter
|
||||
// If not define, assumes that it's gcc
|
||||
// See class CompilerOutputter for format.
|
||||
#if !defined(CPPUNIT_COMPILER_LOCATION_FORMAT)
|
||||
#if defined(__GNUC__) && ( defined(__APPLE_CPP__) || defined(__APPLE_CC__) )
|
||||
// gcc/Xcode integration on Mac OS X
|
||||
# define CPPUNIT_COMPILER_LOCATION_FORMAT "%p:%l: "
|
||||
#else
|
||||
# define CPPUNIT_COMPILER_LOCATION_FORMAT "%f:%l:"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// If CPPUNIT_HAVE_CPP_CAST is defined, then c++ style cast will be used,
|
||||
// otherwise, C style cast are used.
|
||||
#if defined( CPPUNIT_HAVE_CPP_CAST )
|
||||
# define CPPUNIT_CONST_CAST( TargetType, pointer ) \
|
||||
const_cast<TargetType>( pointer )
|
||||
|
||||
# define CPPUNIT_STATIC_CAST( TargetType, pointer ) \
|
||||
static_cast<TargetType>( pointer )
|
||||
#else // defined( CPPUNIT_HAVE_CPP_CAST )
|
||||
# define CPPUNIT_CONST_CAST( TargetType, pointer ) \
|
||||
((TargetType)( pointer ))
|
||||
# define CPPUNIT_STATIC_CAST( TargetType, pointer ) \
|
||||
((TargetType)( pointer ))
|
||||
#endif // defined( CPPUNIT_HAVE_CPP_CAST )
|
||||
|
||||
// If CPPUNIT_NO_STD_NAMESPACE is defined then STL are in the global space.
|
||||
// => Define macro 'std' to nothing
|
||||
#if defined(CPPUNIT_NO_STD_NAMESPACE)
|
||||
# undef std
|
||||
# define std
|
||||
#endif // defined(CPPUNIT_NO_STD_NAMESPACE)
|
||||
|
||||
// If CPPUNIT_NO_NAMESPACE is defined, then put CppUnit classes in the
|
||||
// global namespace: the compiler does not support namespace.
|
||||
#if defined(CPPUNIT_NO_NAMESPACE)
|
||||
# define CPPUNIT_NS_BEGIN
|
||||
# define CPPUNIT_NS_END
|
||||
# define CPPUNIT_NS
|
||||
#else // defined(CPPUNIT_NO_NAMESPACE)
|
||||
# define CPPUNIT_NS_BEGIN namespace CppUnit {
|
||||
# define CPPUNIT_NS_END }
|
||||
# define CPPUNIT_NS CppUnit
|
||||
#endif // defined(CPPUNIT_NO_NAMESPACE)
|
||||
|
||||
/*! Stringize a symbol.
|
||||
*
|
||||
* Use this macro to convert a preprocessor symbol to a string.
|
||||
*
|
||||
* Example of usage:
|
||||
* \code
|
||||
* #define CPPUNIT_PLUGIN_EXPORTED_NAME cppunitTestPlugIn
|
||||
* const char *name = CPPUNIT_STRINGIZE( CPPUNIT_PLUGIN_EXPORTED_NAME );
|
||||
* \endcode
|
||||
*/
|
||||
#define CPPUNIT_STRINGIZE( symbol ) _CPPUNIT_DO_STRINGIZE( symbol )
|
||||
|
||||
/// \internal
|
||||
#define _CPPUNIT_DO_STRINGIZE( symbol ) #symbol
|
||||
|
||||
/*! Joins to symbol after expanding them into string.
|
||||
*
|
||||
* Use this macro to join two symbols. Example of usage:
|
||||
*
|
||||
* \code
|
||||
* #define MAKE_UNIQUE_NAME(prefix) CPPUNIT_JOIN( prefix, __LINE__ )
|
||||
* \endcode
|
||||
*
|
||||
* The macro defined in the example concatenate a given prefix with the line number
|
||||
* to obtain a 'unique' identifier.
|
||||
*
|
||||
* \internal From boost documentation:
|
||||
* The following piece of macro magic joins the two
|
||||
* arguments together, even when one of the arguments is
|
||||
* itself a macro (see 16.3.1 in C++ standard). The key
|
||||
* is that macro expansion of macro arguments does not
|
||||
* occur in CPPUNIT_JOIN2 but does in CPPUNIT_JOIN.
|
||||
*/
|
||||
#define CPPUNIT_JOIN( symbol1, symbol2 ) _CPPUNIT_DO_JOIN( symbol1, symbol2 )
|
||||
|
||||
/// \internal
|
||||
#define _CPPUNIT_DO_JOIN( symbol1, symbol2 ) _CPPUNIT_DO_JOIN2( symbol1, symbol2 )
|
||||
|
||||
/// \internal
|
||||
#define _CPPUNIT_DO_JOIN2( symbol1, symbol2 ) symbol1##symbol2
|
||||
|
||||
/// \internal Unique suffix for variable name. Can be overridden in platform specific
|
||||
/// config-*.h. Default to line number.
|
||||
#ifndef CPPUNIT_UNIQUE_COUNTER
|
||||
# define CPPUNIT_UNIQUE_COUNTER __LINE__
|
||||
#endif
|
||||
|
||||
/*! Adds the line number to the specified string to create a unique identifier.
|
||||
* \param prefix Prefix added to the line number to create a unique identifier.
|
||||
* \see CPPUNIT_TEST_SUITE_REGISTRATION for an example of usage.
|
||||
*/
|
||||
#define CPPUNIT_MAKE_UNIQUE_NAME( prefix ) CPPUNIT_JOIN( prefix, CPPUNIT_UNIQUE_COUNTER )
|
||||
|
||||
/*! Defines wrap colunm for %CppUnit. Used by CompilerOuputter.
|
||||
*/
|
||||
#if !defined(CPPUNIT_WRAP_COLUMN)
|
||||
# define CPPUNIT_WRAP_COLUMN 79
|
||||
#endif
|
||||
|
||||
#endif // CPPUNIT_PORTABILITY_H
|
||||
96
3rdparty/cppunit/include/cppunit/Protector.h
vendored
Normal file
96
3rdparty/cppunit/include/cppunit/Protector.h
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
#ifndef CPPUNIT_PROTECTOR_H
|
||||
#define CPPUNIT_PROTECTOR_H
|
||||
|
||||
#include <cppunit/SourceLine.h>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
class Exception;
|
||||
class Message;
|
||||
class ProtectorContext;
|
||||
class TestResult;
|
||||
|
||||
|
||||
class CPPUNIT_API Functor
|
||||
{
|
||||
public:
|
||||
virtual ~Functor();
|
||||
|
||||
virtual bool operator()() const =0;
|
||||
};
|
||||
|
||||
|
||||
/*! \brief Protects one or more test case run.
|
||||
*
|
||||
* Protector are used to globably 'decorate' a test case. The most common
|
||||
* usage of Protector is to catch exception that do not subclass std::exception,
|
||||
* such as MFC CException class or Rogue Wave RWXMsg class, and capture the
|
||||
* message associated to the exception. In fact, CppUnit capture message from
|
||||
* Exception and std::exception using a Protector.
|
||||
*
|
||||
* Protector are chained. When you add a Protector using
|
||||
* TestResult::pushProtector(), your protector is in fact passed as a Functor
|
||||
* to the first protector of the chain.
|
||||
*
|
||||
* TestCase protects call to setUp(), runTest() and tearDown() by calling
|
||||
* TestResult::protect().
|
||||
*
|
||||
* Because the protector chain is handled by TestResult, a protector can be
|
||||
* active for a single test, or a complete test run.
|
||||
*
|
||||
* Here are some possible usages:
|
||||
* - run all test case in a separate thread and assumes the test failed if it
|
||||
* did not finish in a given time (infinite loop work around)
|
||||
* - performance tracing : time only the runTest() time.
|
||||
* \sa TestResult, TestCase, TestListener.
|
||||
*/
|
||||
class CPPUNIT_API Protector
|
||||
{
|
||||
public:
|
||||
virtual ~Protector();
|
||||
|
||||
virtual bool protect( const Functor &functor,
|
||||
const ProtectorContext &context ) =0;
|
||||
|
||||
protected:
|
||||
void reportError( const ProtectorContext &context,
|
||||
const Exception &error ) const;
|
||||
|
||||
void reportError( const ProtectorContext &context,
|
||||
const Message &message,
|
||||
const SourceLine &sourceLine = SourceLine() ) const;
|
||||
|
||||
void reportFailure( const ProtectorContext &context,
|
||||
const Exception &failure ) const;
|
||||
|
||||
Message actualMessage( const Message &message,
|
||||
const ProtectorContext &context ) const;
|
||||
};
|
||||
|
||||
|
||||
/*! \brief Scoped protector push to TestResult.
|
||||
*
|
||||
* Adds the specified Protector to the specified TestResult for the object
|
||||
* life-time.
|
||||
*/
|
||||
class CPPUNIT_API ProtectorGuard
|
||||
{
|
||||
public:
|
||||
/// Pushes the specified protector.
|
||||
ProtectorGuard( TestResult *result,
|
||||
Protector *protector );
|
||||
|
||||
/// Pops the protector.
|
||||
~ProtectorGuard();
|
||||
|
||||
private:
|
||||
ProtectorGuard( const ProtectorGuard& ); /* not copyable */
|
||||
ProtectorGuard& operator=( const ProtectorGuard& ); /* not assignable */
|
||||
TestResult *m_result;
|
||||
};
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
|
||||
#endif // CPPUNIT_PROTECTOR_H
|
||||
|
||||
63
3rdparty/cppunit/include/cppunit/SourceLine.h
vendored
Normal file
63
3rdparty/cppunit/include/cppunit/SourceLine.h
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
#ifndef CPPUNIT_SOURCELINE_H
|
||||
#define CPPUNIT_SOURCELINE_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
#include <string>
|
||||
|
||||
/*! \brief Constructs a SourceLine object initialized with the location where the macro is expanded.
|
||||
* \ingroup CreatingNewAssertions
|
||||
* \relates CppUnit::SourceLine
|
||||
* Used to write your own assertion macros.
|
||||
* \see Asserter for example of usage.
|
||||
*/
|
||||
#define CPPUNIT_SOURCELINE() CPPUNIT_NS::SourceLine( __FILE__, __LINE__ )
|
||||
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
/*! \brief Represents a source line location.
|
||||
* \ingroup CreatingNewAssertions
|
||||
* \ingroup BrowsingCollectedTestResult
|
||||
*
|
||||
* Used to capture the failure location in assertion.
|
||||
*
|
||||
* Use the CPPUNIT_SOURCELINE() macro to construct that object. Typically used when
|
||||
* writing an assertion macro in association with Asserter.
|
||||
*
|
||||
* \see Asserter.
|
||||
*/
|
||||
class CPPUNIT_API SourceLine
|
||||
{
|
||||
public:
|
||||
SourceLine();
|
||||
|
||||
// Ensure thread-safe copy by detaching the string buffer.
|
||||
SourceLine( const SourceLine &other );
|
||||
|
||||
SourceLine( const std::string &fileName,
|
||||
int lineNumber );
|
||||
|
||||
SourceLine &operator =( const SourceLine &other );
|
||||
|
||||
/// Destructor.
|
||||
virtual ~SourceLine();
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
int lineNumber() const;
|
||||
|
||||
std::string fileName() const;
|
||||
|
||||
bool operator ==( const SourceLine &other ) const;
|
||||
bool operator !=( const SourceLine &other ) const;
|
||||
|
||||
private:
|
||||
std::string m_fileName;
|
||||
int m_lineNumber;
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // CPPUNIT_SOURCELINE_H
|
||||
86
3rdparty/cppunit/include/cppunit/SynchronizedObject.h
vendored
Normal file
86
3rdparty/cppunit/include/cppunit/SynchronizedObject.h
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
#ifndef CPPUNIT_SYNCHRONIZEDOBJECT_H
|
||||
#define CPPUNIT_SYNCHRONIZEDOBJECT_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
/*! \brief Base class for synchronized object.
|
||||
*
|
||||
* Synchronized object are object which members are used concurrently by mutiple
|
||||
* threads.
|
||||
*
|
||||
* This class define the class SynchronizationObject which must be subclassed
|
||||
* to implement an actual lock.
|
||||
*
|
||||
* Each instance of this class holds a pointer on a lock object.
|
||||
*
|
||||
* See src/msvc6/MfcSynchronizedObject.h for an example.
|
||||
*/
|
||||
class CPPUNIT_API SynchronizedObject
|
||||
{
|
||||
public:
|
||||
/*! \brief Abstract synchronization object (mutex)
|
||||
*/
|
||||
class SynchronizationObject
|
||||
{
|
||||
public:
|
||||
SynchronizationObject() {}
|
||||
virtual ~SynchronizationObject() {}
|
||||
|
||||
virtual void lock() {}
|
||||
virtual void unlock() {}
|
||||
};
|
||||
|
||||
/*! Constructs a SynchronizedObject object.
|
||||
*/
|
||||
SynchronizedObject( SynchronizationObject *syncObject =0 );
|
||||
|
||||
/// Destructor.
|
||||
virtual ~SynchronizedObject();
|
||||
|
||||
protected:
|
||||
/*! \brief Locks a synchronization object in the current scope.
|
||||
*/
|
||||
class ExclusiveZone
|
||||
{
|
||||
SynchronizationObject *m_syncObject;
|
||||
|
||||
public:
|
||||
ExclusiveZone( SynchronizationObject *syncObject )
|
||||
: m_syncObject( syncObject )
|
||||
{
|
||||
m_syncObject->lock();
|
||||
}
|
||||
|
||||
~ExclusiveZone()
|
||||
{
|
||||
m_syncObject->unlock ();
|
||||
}
|
||||
private:
|
||||
/// Prevents the use of the copy constructor.
|
||||
ExclusiveZone( const ExclusiveZone& );
|
||||
|
||||
/// Prevents the use of the copy operator.
|
||||
ExclusiveZone& operator=( const ExclusiveZone& );
|
||||
};
|
||||
|
||||
virtual void setSynchronizationObject( SynchronizationObject *syncObject );
|
||||
|
||||
protected:
|
||||
SynchronizationObject *m_syncObject;
|
||||
|
||||
private:
|
||||
/// Prevents the use of the copy constructor.
|
||||
SynchronizedObject( const SynchronizedObject © );
|
||||
|
||||
/// Prevents the use of the copy operator.
|
||||
void operator =( const SynchronizedObject © );
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // CPPUNIT_SYNCHRONIZEDOBJECT_H
|
||||
117
3rdparty/cppunit/include/cppunit/Test.h
vendored
Normal file
117
3rdparty/cppunit/include/cppunit/Test.h
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
#ifndef CPPUNIT_TEST_H
|
||||
#define CPPUNIT_TEST_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
#include <string>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
class TestResult;
|
||||
class TestPath;
|
||||
|
||||
/*! \brief Base class for all test objects.
|
||||
* \ingroup BrowsingCollectedTestResult
|
||||
*
|
||||
* All test objects should be a subclass of Test. Some test objects,
|
||||
* TestCase for example, represent one individual test. Other test
|
||||
* objects, such as TestSuite, are comprised of several tests.
|
||||
*
|
||||
* When a Test is run, the result is collected by a TestResult object.
|
||||
*
|
||||
* \see TestCase
|
||||
* \see TestSuite
|
||||
*/
|
||||
class CPPUNIT_API Test
|
||||
{
|
||||
public:
|
||||
virtual ~Test() {};
|
||||
|
||||
/*! \brief Run the test, collecting results.
|
||||
*/
|
||||
virtual void run( TestResult *result ) =0;
|
||||
|
||||
/*! \brief Return the number of test cases invoked by run().
|
||||
*
|
||||
* The base unit of testing is the class TestCase. This
|
||||
* method returns the number of TestCase objects invoked by
|
||||
* the run() method.
|
||||
*/
|
||||
virtual int countTestCases () const =0;
|
||||
|
||||
/*! \brief Returns the number of direct child of the test.
|
||||
*/
|
||||
virtual int getChildTestCount() const =0;
|
||||
|
||||
/*! \brief Returns the child test of the specified index.
|
||||
*
|
||||
* This method test if the index is valid, then call doGetChildTestAt() if
|
||||
* the index is valid. Otherwise std::out_of_range exception is thrown.
|
||||
*
|
||||
* You should override doGetChildTestAt() method.
|
||||
*
|
||||
* \param index Zero based index of the child test to return.
|
||||
* \return Pointer on the test. Never \c NULL.
|
||||
* \exception std::out_of_range is \a index is < 0 or >= getChildTestCount().
|
||||
*/
|
||||
virtual Test *getChildTestAt( int index ) const;
|
||||
|
||||
/*! \brief Returns the test name.
|
||||
*
|
||||
* Each test has a name. This name may be used to find the
|
||||
* test in a suite or registry of tests.
|
||||
*/
|
||||
virtual std::string getName () const =0;
|
||||
|
||||
/*! \brief Finds the test with the specified name and its parents test.
|
||||
* \param testName Name of the test to find.
|
||||
* \param testPath If the test is found, then all the tests traversed to access
|
||||
* \a test are added to \a testPath, including \c this and \a test.
|
||||
* \return \c true if a test with the specified name is found, \c false otherwise.
|
||||
*/
|
||||
virtual bool findTestPath( const std::string &testName,
|
||||
TestPath &testPath ) const;
|
||||
|
||||
/*! \brief Finds the specified test and its parents test.
|
||||
* \param test Test to find.
|
||||
* \param testPath If the test is found, then all the tests traversed to access
|
||||
* \a test are added to \a testPath, including \c this and \a test.
|
||||
* \return \c true if the specified test is found, \c false otherwise.
|
||||
*/
|
||||
virtual bool findTestPath( const Test *test,
|
||||
TestPath &testPath ) const;
|
||||
|
||||
/*! \brief Finds the test with the specified name in the hierarchy.
|
||||
* \param testName Name of the test to find.
|
||||
* \return Pointer on the first test found that is named \a testName. Never \c NULL.
|
||||
* \exception std::invalid_argument if no test named \a testName is found.
|
||||
*/
|
||||
virtual Test *findTest( const std::string &testName ) const;
|
||||
|
||||
/*! \brief Resolved the specified test path with this test acting as 'root'.
|
||||
* \param testPath Test path string to resolve.
|
||||
* \return Resolved TestPath.
|
||||
* \exception std::invalid_argument if \a testPath could not be resolved.
|
||||
* \see TestPath.
|
||||
*/
|
||||
virtual TestPath resolveTestPath( const std::string &testPath ) const;
|
||||
|
||||
protected:
|
||||
/*! Throws an exception if the specified index is invalid.
|
||||
* \param index Zero base index of a child test.
|
||||
* \exception std::out_of_range is \a index is < 0 or >= getChildTestCount().
|
||||
*/
|
||||
virtual void checkIsValidIndex( int index ) const;
|
||||
|
||||
/*! \brief Returns the child test of the specified valid index.
|
||||
* \param index Zero based valid index of the child test to return.
|
||||
* \return Pointer on the test. Never \c NULL.
|
||||
*/
|
||||
virtual Test *doGetChildTestAt( int index ) const =0;
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // CPPUNIT_TEST_H
|
||||
|
||||
641
3rdparty/cppunit/include/cppunit/TestAssert.h
vendored
Normal file
641
3rdparty/cppunit/include/cppunit/TestAssert.h
vendored
Normal file
@@ -0,0 +1,641 @@
|
||||
#ifndef CPPUNIT_TESTASSERT_H
|
||||
#define CPPUNIT_TESTASSERT_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
#include <cppunit/Exception.h>
|
||||
#include <cppunit/Asserter.h>
|
||||
#include <cppunit/portability/Stream.h>
|
||||
#include <cppunit/tools/StringHelper.h>
|
||||
#include <stdio.h>
|
||||
#include <float.h> // For struct assertion_traits<double>
|
||||
|
||||
// Work around "passing 'T' chooses 'int' over 'unsigned int'" warnings when T
|
||||
// is an enum type:
|
||||
#if defined __GNUC__ && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6))
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
using namespace std::string_literals;
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
/*! \brief Traits used by CPPUNIT_ASSERT* macros.
|
||||
*
|
||||
* Here is an example of specialising these traits:
|
||||
*
|
||||
* \code
|
||||
* template<>
|
||||
* struct assertion_traits<std::string> // specialization for the std::string type
|
||||
* {
|
||||
* static bool equal( const std::string& x, const std::string& y )
|
||||
* {
|
||||
* return x == y;
|
||||
* }
|
||||
*
|
||||
* static bool less( const std::string& x, const std::string& y )
|
||||
* {
|
||||
* return x < y;
|
||||
* }
|
||||
*
|
||||
* static bool lessEqual( const std::string& x, const std::string& y )
|
||||
* {
|
||||
* return x <= y;
|
||||
* }
|
||||
*
|
||||
* static std::string toString( const std::string& x )
|
||||
* {
|
||||
* std::string text = '"' + x + '"'; // adds quote around the string to see whitespace
|
||||
* OStringStream ost;
|
||||
* ost << text;
|
||||
* return ost.str();
|
||||
* }
|
||||
* };
|
||||
* \endcode
|
||||
*/
|
||||
template <class T>
|
||||
struct assertion_traits
|
||||
{
|
||||
static bool equal( const T& x, const T& y )
|
||||
{
|
||||
return x == y;
|
||||
}
|
||||
|
||||
static bool less( const T& x, const T& y )
|
||||
{
|
||||
return x < y;
|
||||
}
|
||||
|
||||
static bool lessEqual( const T& x, const T& y )
|
||||
{
|
||||
return x <= y;
|
||||
}
|
||||
|
||||
static std::string toString( const T& x )
|
||||
{
|
||||
return CPPUNIT_NS::StringHelper::toString(x);
|
||||
}
|
||||
};
|
||||
|
||||
/*! \brief Traits used by CPPUNIT_ASSERT_DOUBLES_EQUAL().
|
||||
*
|
||||
* This specialisation from @c struct @c assertion_traits<> ensures that
|
||||
* doubles are converted in full, instead of being rounded to the default
|
||||
* 6 digits of precision. Use the system defined ISO C99 macro DBL_DIG
|
||||
* within float.h is available to define the maximum precision, otherwise
|
||||
* use the hard-coded maximum precision of 15.
|
||||
*/
|
||||
template <>
|
||||
struct assertion_traits<double>
|
||||
{
|
||||
static bool equal( double x, double y )
|
||||
{
|
||||
return x == y;
|
||||
}
|
||||
|
||||
static bool less( double x, double y )
|
||||
{
|
||||
return x < y;
|
||||
}
|
||||
|
||||
static bool lessEqual( double x, double y )
|
||||
{
|
||||
return x <= y;
|
||||
}
|
||||
|
||||
static std::string toString( double x )
|
||||
{
|
||||
#ifdef DBL_DIG
|
||||
const int precision = DBL_DIG;
|
||||
#else
|
||||
const int precision = 15;
|
||||
#endif // #ifdef DBL_DIG
|
||||
char buffer[128];
|
||||
#ifdef __STDC_SECURE_LIB__ // Use secure version with visual studio 2005 to avoid warning.
|
||||
sprintf_s(buffer, sizeof(buffer), "%.*g", precision, x);
|
||||
#else
|
||||
sprintf(buffer, "%.*g", precision, x);
|
||||
#endif
|
||||
return buffer;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*! \brief (Implementation) Asserts that two objects of the same type are equals.
|
||||
* Use CPPUNIT_ASSERT_EQUAL instead of this function.
|
||||
* \sa assertion_traits, Asserter::failNotEqual().
|
||||
*/
|
||||
template <class T>
|
||||
void assertEquals( const T& expected,
|
||||
const T& actual,
|
||||
SourceLine sourceLine,
|
||||
const std::string &message )
|
||||
{
|
||||
if ( !assertion_traits<T>::equal(expected,actual) ) // lazy toString conversion...
|
||||
{
|
||||
Asserter::failNotEqual( assertion_traits<T>::toString(expected),
|
||||
assertion_traits<T>::toString(actual),
|
||||
sourceLine,
|
||||
message );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*! \brief (Implementation) Asserts that two double are equals given a tolerance.
|
||||
* Use CPPUNIT_ASSERT_DOUBLES_EQUAL instead of this function.
|
||||
* \sa Asserter::failNotEqual().
|
||||
* \sa CPPUNIT_ASSERT_DOUBLES_EQUAL for detailed semantic of the assertion.
|
||||
*/
|
||||
void CPPUNIT_API assertDoubleEquals( double expected,
|
||||
double actual,
|
||||
double delta,
|
||||
SourceLine sourceLine,
|
||||
const std::string &message );
|
||||
|
||||
|
||||
/*! \brief (Implementation) Asserts that an object is less than another one of the same type
|
||||
* Use CPPUNIT_ASSERT_LESS, CPPUNIT_ASSERT_GREATER instead of this function.
|
||||
* \sa assertion_traits, Asserter::failNotLess().
|
||||
*/
|
||||
template <class T>
|
||||
void assertLess( const T& expected,
|
||||
const T& actual,
|
||||
SourceLine sourceLine,
|
||||
const std::string& message )
|
||||
{
|
||||
if ( !assertion_traits<T>::less(actual,expected) )
|
||||
{
|
||||
Asserter::failNotLess( assertion_traits<T>::toString(expected),
|
||||
assertion_traits<T>::toString(actual),
|
||||
sourceLine,
|
||||
message );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*! \brief (Implementation) Asserts that an object is less than another one of the same type
|
||||
* Use CPPUNIT_ASSERT_LESS, CPPUNIT_ASSERT_GREATER instead of this function.
|
||||
* \sa assertion_traits, Asserter::failNotLess().
|
||||
*/
|
||||
template <class T>
|
||||
void assertGreater( const T& expected,
|
||||
const T& actual,
|
||||
SourceLine sourceLine,
|
||||
const std::string& message )
|
||||
{
|
||||
if ( !assertion_traits<T>::less(expected,actual) )
|
||||
{
|
||||
Asserter::failNotGreater( assertion_traits<T>::toString(expected),
|
||||
assertion_traits<T>::toString(actual),
|
||||
sourceLine,
|
||||
message );
|
||||
}
|
||||
}
|
||||
|
||||
/*! \brief (Implementation) Asserts that two objects of the same type are equals.
|
||||
* Use CPPUNIT_ASSERT_LESSEQUAL, CPPUNIT_ASSERT_GREATEREQUAL instead of this function.
|
||||
* \sa assertion_traits, Asserter::failNotLessEqual().
|
||||
*/
|
||||
template <class T>
|
||||
void assertLessEqual( const T& expected,
|
||||
const T& actual,
|
||||
SourceLine sourceLine,
|
||||
const std::string& message )
|
||||
{
|
||||
if ( !assertion_traits<T>::lessEqual(actual,expected) )
|
||||
{
|
||||
Asserter::failNotLessEqual( assertion_traits<T>::toString(expected),
|
||||
assertion_traits<T>::toString(actual),
|
||||
sourceLine,
|
||||
message );
|
||||
}
|
||||
}
|
||||
|
||||
/*! \brief (Implementation) Asserts that two objects of the same type are equals.
|
||||
* Use CPPUNIT_ASSERT_LESSEQUAL, CPPUNIT_ASSERT_GREATEREQUAL instead of this function.
|
||||
* \sa assertion_traits, Asserter::failNotLessEqual().
|
||||
*/
|
||||
template <class T>
|
||||
void assertGreaterEqual( const T& expected,
|
||||
const T& actual,
|
||||
SourceLine sourceLine,
|
||||
const std::string& message )
|
||||
{
|
||||
if ( !assertion_traits<T>::lessEqual(expected,actual) )
|
||||
{
|
||||
Asserter::failNotGreaterEqual( assertion_traits<T>::toString(expected),
|
||||
assertion_traits<T>::toString(actual),
|
||||
sourceLine,
|
||||
message );
|
||||
}
|
||||
}
|
||||
/* A set of macros which allow us to get the line number
|
||||
* and file name at the point of an error.
|
||||
* Just goes to show that preprocessors do have some
|
||||
* redeeming qualities.
|
||||
*/
|
||||
#if CPPUNIT_HAVE_CPP_SOURCE_ANNOTATION
|
||||
/** Assertions that a condition is \c true.
|
||||
* \ingroup Assertions
|
||||
*/
|
||||
#define CPPUNIT_ASSERT(condition) \
|
||||
( CPPUNIT_NS::Asserter::failIf( !(condition), \
|
||||
CPPUNIT_NS::Message( "assertion failed", \
|
||||
"Expression: " #condition), \
|
||||
CPPUNIT_SOURCELINE() ) )
|
||||
#else
|
||||
#define CPPUNIT_ASSERT(condition) \
|
||||
( CPPUNIT_NS::Asserter::failIf( !(condition), \
|
||||
CPPUNIT_NS::Message( "assertion failed" ), \
|
||||
CPPUNIT_SOURCELINE() ) )
|
||||
#endif
|
||||
|
||||
/** Assertion with a user specified message.
|
||||
* \ingroup Assertions
|
||||
* \param message Message reported in diagnostic if \a condition evaluates
|
||||
* to \c false.
|
||||
* \param condition If this condition evaluates to \c false then the
|
||||
* test failed.
|
||||
*/
|
||||
#define CPPUNIT_ASSERT_MESSAGE(message,condition) \
|
||||
( CPPUNIT_NS::Asserter::failIf( !(condition), \
|
||||
CPPUNIT_NS::Message( "assertion failed", \
|
||||
"Expression: " \
|
||||
#condition, \
|
||||
message ), \
|
||||
CPPUNIT_SOURCELINE() ) )
|
||||
|
||||
/** Fails with the specified message.
|
||||
* \ingroup Assertions
|
||||
* \param message Message reported in diagnostic.
|
||||
*/
|
||||
#define CPPUNIT_FAIL( message ) \
|
||||
( CPPUNIT_NS::Asserter::fail( CPPUNIT_NS::Message( "forced failure", \
|
||||
message ), \
|
||||
CPPUNIT_SOURCELINE() ) )
|
||||
|
||||
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
|
||||
/// Generalized macro for primitive value comparisons
|
||||
#define CPPUNIT_ASSERT_EQUAL(expected,actual) \
|
||||
( CPPUNIT_NS::assertEquals( (expected), \
|
||||
(actual), \
|
||||
__LINE__, __FILE__ ) )
|
||||
#else
|
||||
/** Asserts that two values are equals.
|
||||
* \ingroup Assertions
|
||||
*
|
||||
* Equality and string representation can be defined with
|
||||
* an appropriate CppUnit::assertion_traits class.
|
||||
*
|
||||
* A diagnostic is printed if actual and expected values disagree.
|
||||
*
|
||||
* Requirement for \a expected and \a actual parameters:
|
||||
* - They are exactly of the same type
|
||||
* - They are serializable into a std::strstream using operator <<.
|
||||
* - They can be compared using operator ==.
|
||||
*
|
||||
* The last two requirements (serialization and comparison) can be
|
||||
* removed by specializing the CppUnit::assertion_traits.
|
||||
*/
|
||||
#define CPPUNIT_ASSERT_EQUAL(expected,actual) \
|
||||
( CPPUNIT_NS::assertEquals( (expected), \
|
||||
(actual), \
|
||||
CPPUNIT_SOURCELINE(), \
|
||||
"" ) )
|
||||
|
||||
/** Asserts that two values are equals, provides additional message on failure.
|
||||
* \ingroup Assertions
|
||||
*
|
||||
* Equality and string representation can be defined with
|
||||
* an appropriate assertion_traits class.
|
||||
*
|
||||
* A diagnostic is printed if actual and expected values disagree.
|
||||
* The message is printed in addition to the expected and actual value
|
||||
* to provide additional information.
|
||||
*
|
||||
* Requirement for \a expected and \a actual parameters:
|
||||
* - They are exactly of the same type
|
||||
* - They are serializable into a std::strstream using operator <<.
|
||||
* - They can be compared using operator ==.
|
||||
*
|
||||
* The last two requirements (serialization and comparison) can be
|
||||
* removed by specializing the CppUnit::assertion_traits.
|
||||
*/
|
||||
#define CPPUNIT_ASSERT_EQUAL_MESSAGE(message,expected,actual) \
|
||||
( CPPUNIT_NS::assertEquals( (expected), \
|
||||
(actual), \
|
||||
CPPUNIT_SOURCELINE(), \
|
||||
(message) ) )
|
||||
#endif
|
||||
|
||||
/** Asserts that actual is less than expected, provides additional message on failure.
|
||||
* \ingroup Assertions
|
||||
*
|
||||
* Less and string representation can be defined with
|
||||
* an appropriate assertion_traits class.
|
||||
*
|
||||
* A diagnostic is printed if actual is less than expected.
|
||||
* The message is printed in addition to the expected and actual value
|
||||
* to provide additional information.
|
||||
*
|
||||
* Requirement for \a expected and \a actual parameters:
|
||||
* - They are exactly of the same type
|
||||
* - They are serializable into a std::strstream using operator <<.
|
||||
* - They can be compared using operator <.
|
||||
*
|
||||
* The last two requirements (serialization and comparison) can be
|
||||
* removed by specializing the CppUnit::assertion_traits.
|
||||
*
|
||||
* \sa CPPUNIT_ASSERT_GREATER
|
||||
*/
|
||||
#define CPPUNIT_ASSERT_LESS(expected, actual) \
|
||||
( CPPUNIT_NS::assertLess( (expected), \
|
||||
(actual), \
|
||||
CPPUNIT_SOURCELINE(), \
|
||||
"" ) )
|
||||
|
||||
/** Asserts that actual is greater than expected, provides additional message on failure.
|
||||
* \ingroup Assertions
|
||||
*
|
||||
* String representation can be defined with
|
||||
* an appropriate assertion_traits class. For comparison assertLess is used.
|
||||
*
|
||||
* A diagnostic is printed if actual is less than expected.
|
||||
* The message is printed in addition to the expected and actual value
|
||||
* to provide additional information.
|
||||
*
|
||||
* Requirement for \a expected and \a actual parameters:
|
||||
* - They are exactly of the same type
|
||||
* - They are serializable into a std::strstream using operator <<.
|
||||
* - They can be compared using operator<.
|
||||
*
|
||||
* The last two requirements (serialization and comparison) can be
|
||||
* removed by specializing the CppUnit::assertion_traits.
|
||||
*
|
||||
* \sa CPPUNIT_ASSERT_LESS
|
||||
*/
|
||||
#define CPPUNIT_ASSERT_GREATER(expected, actual) \
|
||||
( CPPUNIT_NS::assertGreater( (expected), \
|
||||
(actual), \
|
||||
CPPUNIT_SOURCELINE(), \
|
||||
"" ) )
|
||||
|
||||
/** Asserts that actual is less or equal than expected, provides additional message on failure.
|
||||
* \ingroup Assertions
|
||||
*
|
||||
* LessEqual and string representation can be defined with
|
||||
* an appropriate assertion_traits class.
|
||||
*
|
||||
* A diagnostic is printed if actual is greater than expected.
|
||||
* The message is printed in addition to the expected and actual value
|
||||
* to provide additional information.
|
||||
*
|
||||
* Requirement for \a expected and \a actual parameters:
|
||||
* - They are exactly of the same type
|
||||
* - They are serializable into a std::strstream using operator <<.
|
||||
* - They can be compared using operator <=.
|
||||
*
|
||||
* The last two requirements (serialization and comparison) can be
|
||||
* removed by specializing the CppUnit::assertion_traits.
|
||||
*
|
||||
* \sa CPPUNIT_ASSERT_GREATEREQUAL
|
||||
*/
|
||||
#define CPPUNIT_ASSERT_LESSEQUAL(expected, actual) \
|
||||
( CPPUNIT_NS::assertLessEqual( (expected), \
|
||||
(actual), \
|
||||
CPPUNIT_SOURCELINE(), \
|
||||
"" ) )
|
||||
|
||||
/** Asserts that actual is greater than expected, provides additional message on failure.
|
||||
* \ingroup Assertions
|
||||
*
|
||||
* String representation can be defined with
|
||||
* an appropriate assertion_traits class. For comparison assertLess is used.
|
||||
*
|
||||
* A diagnostic is printed if actual is less than expected.
|
||||
* The message is printed in addition to the expected and actual value
|
||||
* to provide additional information.
|
||||
*
|
||||
* Requirement for \a expected and \a actual parameters:
|
||||
* - They are exactly of the same type
|
||||
* - They are serializable into a std::strstream using operator <<.
|
||||
* - They can be compared using operator<=.
|
||||
*
|
||||
* The last two requirements (serialization and comparison) can be
|
||||
* removed by specializing the CppUnit::assertion_traits.
|
||||
*
|
||||
* \sa CPPUNIT_ASSERT_LESSEQUAL
|
||||
*/
|
||||
#define CPPUNIT_ASSERT_GREATEREQUAL(expected, actual) \
|
||||
( CPPUNIT_NS::assertGreaterEqual( (expected), \
|
||||
(actual), \
|
||||
CPPUNIT_SOURCELINE(), \
|
||||
"" ) )
|
||||
/*! \brief Macro for primitive double value comparisons.
|
||||
* \ingroup Assertions
|
||||
*
|
||||
* The assertion pass if both expected and actual are finite and
|
||||
* \c fabs( \c expected - \c actual ) <= \c delta.
|
||||
* If either \c expected or actual are infinite (+/- inf), the
|
||||
* assertion pass if \c expected == \c actual.
|
||||
* If either \c expected or \c actual is a NaN (not a number), then
|
||||
* the assertion fails.
|
||||
*/
|
||||
#define CPPUNIT_ASSERT_DOUBLES_EQUAL(expected,actual,delta) \
|
||||
( CPPUNIT_NS::assertDoubleEquals( (expected), \
|
||||
(actual), \
|
||||
(delta), \
|
||||
CPPUNIT_SOURCELINE(), \
|
||||
"" ) )
|
||||
|
||||
|
||||
/*! \brief Macro for primitive double value comparisons, setting a
|
||||
* user-supplied message in case of failure.
|
||||
* \ingroup Assertions
|
||||
* \sa CPPUNIT_ASSERT_DOUBLES_EQUAL for detailed semantic of the assertion.
|
||||
*/
|
||||
#define CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(message,expected,actual,delta) \
|
||||
( CPPUNIT_NS::assertDoubleEquals( (expected), \
|
||||
(actual), \
|
||||
(delta), \
|
||||
CPPUNIT_SOURCELINE(), \
|
||||
(message) ) )
|
||||
|
||||
|
||||
/** Asserts that the given expression throws an exception of the specified type.
|
||||
* \ingroup Assertions
|
||||
* Example of usage:
|
||||
* \code
|
||||
* std::vector<int> v;
|
||||
* CPPUNIT_ASSERT_THROW( v.at( 50 ), std::out_of_range );
|
||||
* \endcode
|
||||
*/
|
||||
# define CPPUNIT_ASSERT_THROW( expression, ExceptionType ) \
|
||||
CPPUNIT_ASSERT_THROW_MESSAGE( CPPUNIT_NS::AdditionalMessage(), \
|
||||
expression, \
|
||||
ExceptionType )
|
||||
|
||||
|
||||
// implementation detail
|
||||
#if defined(CPPUNIT_USE_TYPEINFO_NAME)
|
||||
#define CPPUNIT_EXTRACT_EXCEPTION_TYPE_( exception, no_rtti_message ) \
|
||||
CPPUNIT_NS::TypeInfoHelper::getClassName( typeid(exception) )
|
||||
#else
|
||||
#define CPPUNIT_EXTRACT_EXCEPTION_TYPE_( exception, no_rtti_message ) \
|
||||
std::string( no_rtti_message )
|
||||
#endif // CPPUNIT_USE_TYPEINFO_NAME
|
||||
|
||||
// implementation detail
|
||||
#define CPPUNIT_GET_PARAMETER_STRING( parameter ) #parameter
|
||||
|
||||
/** Asserts that the given expression throws an exception of the specified type,
|
||||
* setting a user supplied message in case of failure.
|
||||
* \ingroup Assertions
|
||||
* Example of usage:
|
||||
* \code
|
||||
* std::vector<int> v;
|
||||
* CPPUNIT_ASSERT_THROW_MESSAGE( "- std::vector<int> v;", v.at( 50 ), std::out_of_range );
|
||||
* \endcode
|
||||
*/
|
||||
# define CPPUNIT_ASSERT_THROW_MESSAGE( message, expression, ExceptionType ) \
|
||||
do { \
|
||||
bool cpputCorrectExceptionThrown_ = false; \
|
||||
CPPUNIT_NS::Message cpputMsg_( "expected exception not thrown" ); \
|
||||
cpputMsg_.addDetail( message ); \
|
||||
cpputMsg_.addDetail( "Expected: " \
|
||||
CPPUNIT_GET_PARAMETER_STRING( ExceptionType ) ); \
|
||||
\
|
||||
try { \
|
||||
expression; \
|
||||
} catch ( const ExceptionType & ) { \
|
||||
cpputCorrectExceptionThrown_ = true; \
|
||||
} catch ( const std::exception &e) { \
|
||||
cpputMsg_.addDetail( "Actual : " + \
|
||||
CPPUNIT_EXTRACT_EXCEPTION_TYPE_( e, \
|
||||
"std::exception or derived") ); \
|
||||
cpputMsg_.addDetail( "What() : "s + e.what() ); \
|
||||
} catch ( ... ) { \
|
||||
cpputMsg_.addDetail( "Actual : unknown."); \
|
||||
} \
|
||||
\
|
||||
if ( cpputCorrectExceptionThrown_ ) \
|
||||
break; \
|
||||
\
|
||||
CPPUNIT_NS::Asserter::fail( cpputMsg_, \
|
||||
CPPUNIT_SOURCELINE() ); \
|
||||
} while ( false )
|
||||
|
||||
|
||||
/** Asserts that the given expression does not throw any exceptions.
|
||||
* \ingroup Assertions
|
||||
* Example of usage:
|
||||
* \code
|
||||
* std::vector<int> v;
|
||||
* v.push_back( 10 );
|
||||
* CPPUNIT_ASSERT_NO_THROW( v.at( 0 ) );
|
||||
* \endcode
|
||||
*/
|
||||
# define CPPUNIT_ASSERT_NO_THROW( expression ) \
|
||||
CPPUNIT_ASSERT_NO_THROW_MESSAGE( CPPUNIT_NS::AdditionalMessage(), \
|
||||
expression )
|
||||
|
||||
|
||||
/** Asserts that the given expression does not throw any exceptions,
|
||||
* setting a user supplied message in case of failure.
|
||||
* \ingroup Assertions
|
||||
* Example of usage:
|
||||
* \code
|
||||
* std::vector<int> v;
|
||||
* v.push_back( 10 );
|
||||
* CPPUNIT_ASSERT_NO_THROW( "std::vector<int> v;", v.at( 0 ) );
|
||||
* \endcode
|
||||
*/
|
||||
# define CPPUNIT_ASSERT_NO_THROW_MESSAGE( message, expression ) \
|
||||
do { \
|
||||
CPPUNIT_NS::Message cpputMsg_( "unexpected exception caught" ); \
|
||||
cpputMsg_.addDetail( message ); \
|
||||
\
|
||||
try { \
|
||||
expression; \
|
||||
} catch ( const std::exception &e ) { \
|
||||
cpputMsg_.addDetail( "Caught: " + \
|
||||
CPPUNIT_EXTRACT_EXCEPTION_TYPE_( e, \
|
||||
"std::exception or derived" ) ); \
|
||||
cpputMsg_.addDetail( "What(): "s + e.what() ); \
|
||||
CPPUNIT_NS::Asserter::fail( cpputMsg_, \
|
||||
CPPUNIT_SOURCELINE() ); \
|
||||
} catch ( ... ) { \
|
||||
cpputMsg_.addDetail( "Caught: unknown." ); \
|
||||
CPPUNIT_NS::Asserter::fail( cpputMsg_, \
|
||||
CPPUNIT_SOURCELINE() ); \
|
||||
} \
|
||||
} while ( false )
|
||||
|
||||
|
||||
/** Asserts that an assertion fail.
|
||||
* \ingroup Assertions
|
||||
* Use to test assertions.
|
||||
* Example of usage:
|
||||
* \code
|
||||
* CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT( 1 == 2 ) );
|
||||
* \endcode
|
||||
*/
|
||||
# define CPPUNIT_ASSERT_ASSERTION_FAIL( assertion ) \
|
||||
CPPUNIT_ASSERT_THROW( assertion, CPPUNIT_NS::Exception )
|
||||
|
||||
|
||||
/** Asserts that an assertion fail, with a user-supplied message in
|
||||
* case of error.
|
||||
* \ingroup Assertions
|
||||
* Use to test assertions.
|
||||
* Example of usage:
|
||||
* \code
|
||||
* CPPUNIT_ASSERT_ASSERTION_FAIL_MESSAGE( "1 == 2", CPPUNIT_ASSERT( 1 == 2 ) );
|
||||
* \endcode
|
||||
*/
|
||||
# define CPPUNIT_ASSERT_ASSERTION_FAIL_MESSAGE( message, assertion ) \
|
||||
CPPUNIT_ASSERT_THROW_MESSAGE( message, assertion, CPPUNIT_NS::Exception )
|
||||
|
||||
|
||||
/** Asserts that an assertion pass.
|
||||
* \ingroup Assertions
|
||||
* Use to test assertions.
|
||||
* Example of usage:
|
||||
* \code
|
||||
* CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT( 1 == 1 ) );
|
||||
* \endcode
|
||||
*/
|
||||
# define CPPUNIT_ASSERT_ASSERTION_PASS( assertion ) \
|
||||
CPPUNIT_ASSERT_NO_THROW( assertion )
|
||||
|
||||
|
||||
/** Asserts that an assertion pass, with a user-supplied message in
|
||||
* case of failure.
|
||||
* \ingroup Assertions
|
||||
* Use to test assertions.
|
||||
* Example of usage:
|
||||
* \code
|
||||
* CPPUNIT_ASSERT_ASSERTION_PASS_MESSAGE( "1 != 1", CPPUNIT_ASSERT( 1 == 1 ) );
|
||||
* \endcode
|
||||
*/
|
||||
# define CPPUNIT_ASSERT_ASSERTION_PASS_MESSAGE( message, assertion ) \
|
||||
CPPUNIT_ASSERT_NO_THROW_MESSAGE( message, assertion )
|
||||
|
||||
|
||||
|
||||
|
||||
// Backwards compatibility
|
||||
|
||||
#if CPPUNIT_ENABLE_NAKED_ASSERT
|
||||
|
||||
#undef assert
|
||||
#define assert(c) CPPUNIT_ASSERT(c)
|
||||
#define assertEqual(e,a) CPPUNIT_ASSERT_EQUAL(e,a)
|
||||
#define assertDoublesEqual(e,a,d) CPPUNIT_ASSERT_DOUBLES_EQUAL(e,a,d)
|
||||
#define assertLongsEqual(e,a) CPPUNIT_ASSERT_EQUAL(e,a)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // CPPUNIT_TESTASSERT_H
|
||||
207
3rdparty/cppunit/include/cppunit/TestCaller.h
vendored
Normal file
207
3rdparty/cppunit/include/cppunit/TestCaller.h
vendored
Normal file
@@ -0,0 +1,207 @@
|
||||
#ifndef CPPUNIT_TESTCALLER_H // -*- C++ -*-
|
||||
#define CPPUNIT_TESTCALLER_H
|
||||
|
||||
#include <cppunit/Exception.h>
|
||||
#include <cppunit/TestCase.h>
|
||||
|
||||
#include <functional>
|
||||
|
||||
|
||||
#if defined(CPPUNIT_USE_TYPEINFO_NAME)
|
||||
# include <cppunit/extensions/TypeInfoHelper.h>
|
||||
#endif
|
||||
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
#if 0
|
||||
/*! \brief Marker class indicating that no exception is expected by TestCaller.
|
||||
* This class is an implementation detail. You should never use this class directly.
|
||||
*/
|
||||
class CPPUNIT_API NoExceptionExpected
|
||||
{
|
||||
private:
|
||||
//! Prevent class instantiation.
|
||||
NoExceptionExpected();
|
||||
};
|
||||
|
||||
|
||||
/*! \brief (Implementation) Traits used by TestCaller to expect an exception.
|
||||
*
|
||||
* This class is an implementation detail. You should never use this class directly.
|
||||
*/
|
||||
template<class ExceptionType>
|
||||
struct ExpectedExceptionTraits
|
||||
{
|
||||
static void expectedException()
|
||||
{
|
||||
#if defined(CPPUNIT_USE_TYPEINFO_NAME)
|
||||
throw Exception( Message(
|
||||
"expected exception not thrown",
|
||||
"Expected exception type: " +
|
||||
TypeInfoHelper::getClassName( typeid( ExceptionType ) ) ) );
|
||||
#else
|
||||
throw Exception( "expected exception not thrown" );
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*! \brief (Implementation) Traits specialization used by TestCaller to
|
||||
* expect no exception.
|
||||
*
|
||||
* This class is an implementation detail. You should never use this class directly.
|
||||
*/
|
||||
template<>
|
||||
struct ExpectedExceptionTraits<NoExceptionExpected>
|
||||
{
|
||||
static void expectedException()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
//*** FIXME: rework this when class Fixture is implemented. ***//
|
||||
|
||||
|
||||
/*! \brief Generate a test case from a fixture method.
|
||||
* \ingroup WritingTestFixture
|
||||
*
|
||||
* A test caller provides access to a test case method
|
||||
* on a test fixture class. Test callers are useful when
|
||||
* you want to run an individual test or add it to a
|
||||
* suite.
|
||||
* Test Callers invoke only one Test (i.e. test method) on one
|
||||
* Fixture of a TestFixture.
|
||||
*
|
||||
* Here is an example:
|
||||
* \code
|
||||
* class MathTest : public CppUnit::TestFixture {
|
||||
* ...
|
||||
* public:
|
||||
* void setUp();
|
||||
* void tearDown();
|
||||
*
|
||||
* void testAdd();
|
||||
* void testSubtract();
|
||||
* };
|
||||
*
|
||||
* CppUnit::Test *MathTest::suite() {
|
||||
* CppUnit::TestSuite *suite = new CppUnit::TestSuite;
|
||||
*
|
||||
* suite->addTest( new CppUnit::TestCaller<MathTest>( "testAdd", testAdd ) );
|
||||
* return suite;
|
||||
* }
|
||||
* \endcode
|
||||
*
|
||||
* You can use a TestCaller to bind any test method on a TestFixture
|
||||
* class, as long as it accepts void and returns void.
|
||||
*
|
||||
* \see TestCase
|
||||
*/
|
||||
|
||||
template <class Fixture>
|
||||
class TestCaller : public TestCase
|
||||
{
|
||||
typedef void (Fixture::*TestMethod)();
|
||||
|
||||
public:
|
||||
/*!
|
||||
* Constructor for TestCaller. This constructor builds a new Fixture
|
||||
* instance owned by the TestCaller.
|
||||
* \param name name of this TestCaller
|
||||
* \param test the method this TestCaller calls in runTest()
|
||||
*/
|
||||
TestCaller( std::string name, TestMethod test ) :
|
||||
TestCase( name ),
|
||||
m_ownFixture( true ),
|
||||
m_fixture( new Fixture() ),
|
||||
m_test_function( std::bind(test, m_fixture) )
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
* Constructor for TestCaller.
|
||||
* This constructor does not create a new Fixture instance but accepts
|
||||
* an existing one as parameter. The TestCaller will not own the
|
||||
* Fixture object.
|
||||
* \param name name of this TestCaller
|
||||
* \param test the method this TestCaller calls in runTest()
|
||||
* \param fixture the Fixture to invoke the test method on.
|
||||
*/
|
||||
TestCaller(std::string name, TestMethod test, Fixture& fixture) :
|
||||
TestCase( name ),
|
||||
m_ownFixture( false ),
|
||||
m_fixture( &fixture ),
|
||||
m_test_function( std::bind(test, &fixture) )
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
* Constructor for TestCaller.
|
||||
* This constructor does not create a new Fixture instance but accepts
|
||||
* an existing one as parameter. The TestCaller will own the
|
||||
* Fixture object and delete it in its destructor.
|
||||
* \param name name of this TestCaller
|
||||
* \param test the method this TestCaller calls in runTest()
|
||||
* \param fixture the Fixture to invoke the test method on.
|
||||
*/
|
||||
TestCaller(std::string name, TestMethod test, Fixture* fixture) :
|
||||
TestCase( name ),
|
||||
m_ownFixture( true ),
|
||||
m_fixture( fixture ),
|
||||
m_test_function( std::bind(test, fixture) )
|
||||
{
|
||||
}
|
||||
|
||||
TestCaller(std::string name, std::function<void()> test_function, Fixture* fixture):
|
||||
TestCase(name),
|
||||
m_ownFixture(true),
|
||||
m_fixture(fixture),
|
||||
m_test_function(test_function)
|
||||
{
|
||||
}
|
||||
|
||||
~TestCaller()
|
||||
{
|
||||
if (m_ownFixture)
|
||||
delete m_fixture;
|
||||
}
|
||||
|
||||
void runTest()
|
||||
{
|
||||
m_test_function();
|
||||
}
|
||||
|
||||
void setUp()
|
||||
{
|
||||
m_fixture->setUp ();
|
||||
}
|
||||
|
||||
void tearDown()
|
||||
{
|
||||
m_fixture->tearDown ();
|
||||
}
|
||||
|
||||
std::string toString() const
|
||||
{
|
||||
return "TestCaller " + getName();
|
||||
}
|
||||
|
||||
private:
|
||||
TestCaller( const TestCaller &other );
|
||||
TestCaller &operator =( const TestCaller &other );
|
||||
|
||||
private:
|
||||
bool m_ownFixture;
|
||||
Fixture *m_fixture;
|
||||
std::function<void()> m_test_function;
|
||||
};
|
||||
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // CPPUNIT_TESTCALLER_H
|
||||
55
3rdparty/cppunit/include/cppunit/TestCase.h
vendored
Normal file
55
3rdparty/cppunit/include/cppunit/TestCase.h
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
#ifndef CPPUNIT_TESTCASE_H
|
||||
#define CPPUNIT_TESTCASE_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
#include <cppunit/TestLeaf.h>
|
||||
#include <cppunit/TestAssert.h>
|
||||
#include <cppunit/TestFixture.h>
|
||||
#include <string>
|
||||
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
class TestResult;
|
||||
|
||||
|
||||
/*! \brief A single test object.
|
||||
*
|
||||
* This class is used to implement a simple test case: define a subclass
|
||||
* that overrides the runTest method.
|
||||
*
|
||||
* You don't usually need to use that class, but TestFixture and TestCaller instead.
|
||||
*
|
||||
* You are expected to subclass TestCase is you need to write a class similiar
|
||||
* to TestCaller.
|
||||
*/
|
||||
class CPPUNIT_API TestCase : public TestLeaf,
|
||||
public TestFixture
|
||||
{
|
||||
public:
|
||||
|
||||
TestCase( const std::string &name );
|
||||
|
||||
TestCase();
|
||||
|
||||
~TestCase();
|
||||
|
||||
virtual void run(TestResult *result);
|
||||
|
||||
std::string getName() const;
|
||||
|
||||
//! FIXME: this should probably be pure virtual.
|
||||
virtual void runTest();
|
||||
|
||||
private:
|
||||
TestCase( const TestCase &other );
|
||||
TestCase &operator=( const TestCase &other );
|
||||
|
||||
private:
|
||||
const std::string m_name;
|
||||
};
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // CPPUNIT_TESTCASE_H
|
||||
45
3rdparty/cppunit/include/cppunit/TestComposite.h
vendored
Normal file
45
3rdparty/cppunit/include/cppunit/TestComposite.h
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
#ifndef CPPUNIT_TESTCOMPSITE_H // -*- C++ -*-
|
||||
#define CPPUNIT_TESTCOMPSITE_H
|
||||
|
||||
#include <cppunit/Test.h>
|
||||
#include <string>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
/*! \brief A Composite of Tests.
|
||||
*
|
||||
* Base class for all test composites. Subclass this class if you need to implement
|
||||
* a custom TestSuite.
|
||||
*
|
||||
* \see Test, TestSuite.
|
||||
*/
|
||||
class CPPUNIT_API TestComposite : public Test
|
||||
{
|
||||
public:
|
||||
TestComposite( const std::string &name = "" );
|
||||
|
||||
~TestComposite();
|
||||
|
||||
void run( TestResult *result );
|
||||
|
||||
int countTestCases() const;
|
||||
|
||||
std::string getName() const;
|
||||
|
||||
private:
|
||||
TestComposite( const TestComposite &other );
|
||||
TestComposite &operator =( const TestComposite &other );
|
||||
|
||||
virtual void doStartSuite( TestResult *controller );
|
||||
virtual void doRunChildTests( TestResult *controller );
|
||||
virtual void doEndSuite( TestResult *controller );
|
||||
|
||||
private:
|
||||
const std::string m_name;
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // CPPUNIT_TESTCOMPSITE_H
|
||||
58
3rdparty/cppunit/include/cppunit/TestFailure.h
vendored
Normal file
58
3rdparty/cppunit/include/cppunit/TestFailure.h
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
#ifndef CPPUNIT_TESTFAILURE_H // -*- C++ -*-
|
||||
#define CPPUNIT_TESTFAILURE_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
#include <string>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
class Exception;
|
||||
class SourceLine;
|
||||
class Test;
|
||||
|
||||
|
||||
/*! \brief Record of a failed Test execution.
|
||||
* \ingroup BrowsingCollectedTestResult
|
||||
*
|
||||
* A TestFailure collects a failed test together with
|
||||
* the caught exception.
|
||||
*
|
||||
* TestFailure assumes lifetime control for any exception
|
||||
* passed to it.
|
||||
*/
|
||||
class CPPUNIT_API TestFailure
|
||||
{
|
||||
public:
|
||||
TestFailure( Test *failedTest,
|
||||
Exception *thrownException,
|
||||
bool isError );
|
||||
|
||||
virtual ~TestFailure ();
|
||||
|
||||
virtual Test *failedTest() const;
|
||||
|
||||
virtual Exception *thrownException() const;
|
||||
|
||||
virtual SourceLine sourceLine() const;
|
||||
|
||||
virtual bool isError() const;
|
||||
|
||||
virtual std::string failedTestName() const;
|
||||
|
||||
virtual TestFailure *clone() const;
|
||||
|
||||
protected:
|
||||
Test *m_failedTest;
|
||||
Exception *m_thrownException;
|
||||
bool m_isError;
|
||||
|
||||
private:
|
||||
TestFailure( const TestFailure &other );
|
||||
TestFailure &operator =( const TestFailure& other );
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // CPPUNIT_TESTFAILURE_H
|
||||
99
3rdparty/cppunit/include/cppunit/TestFixture.h
vendored
Normal file
99
3rdparty/cppunit/include/cppunit/TestFixture.h
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
#ifndef CPPUNIT_TESTFIXTURE_H // -*- C++ -*-
|
||||
#define CPPUNIT_TESTFIXTURE_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
/*! \brief Wraps a test case with setUp and tearDown methods.
|
||||
* \ingroup WritingTestFixture
|
||||
*
|
||||
* A TestFixture is used to provide a common environment for a set
|
||||
* of test cases.
|
||||
*
|
||||
* To define a test fixture, do the following:
|
||||
* - implement a subclass of TestCase
|
||||
* - the fixture is defined by instance variables
|
||||
* - initialize the fixture state by overriding setUp
|
||||
* (i.e. construct the instance variables of the fixture)
|
||||
* - clean-up after a test by overriding tearDown.
|
||||
*
|
||||
* Each test runs in its own fixture so there
|
||||
* can be no side effects among test runs.
|
||||
* Here is an example:
|
||||
*
|
||||
* \code
|
||||
* class MathTest : public CppUnit::TestFixture {
|
||||
* protected:
|
||||
* int m_value1, m_value2;
|
||||
*
|
||||
* public:
|
||||
* MathTest() {}
|
||||
*
|
||||
* void setUp () {
|
||||
* m_value1 = 2;
|
||||
* m_value2 = 3;
|
||||
* }
|
||||
* }
|
||||
* \endcode
|
||||
*
|
||||
* For each test implement a method which interacts
|
||||
* with the fixture. Verify the expected results with assertions specified
|
||||
* by calling CPPUNIT_ASSERT on the expression you want to test:
|
||||
*
|
||||
* \code
|
||||
* public:
|
||||
* void testAdd () {
|
||||
* int result = m_value1 + m_value2;
|
||||
* CPPUNIT_ASSERT( result == 5 );
|
||||
* }
|
||||
* \endcode
|
||||
*
|
||||
* Once the methods are defined you can run them. To do this, use
|
||||
* a TestCaller.
|
||||
*
|
||||
* \code
|
||||
* CppUnit::Test *test = new CppUnit::TestCaller<MathTest>( "testAdd",
|
||||
* &MathTest::testAdd );
|
||||
* test->run();
|
||||
* \endcode
|
||||
*
|
||||
*
|
||||
* The tests to be run can be collected into a TestSuite.
|
||||
*
|
||||
* \code
|
||||
* public:
|
||||
* static CppUnit::TestSuite *MathTest::suite () {
|
||||
* CppUnit::TestSuite *suiteOfTests = new CppUnit::TestSuite;
|
||||
* suiteOfTests->addTest(new CppUnit::TestCaller<MathTest>(
|
||||
* "testAdd", &MathTest::testAdd));
|
||||
* suiteOfTests->addTest(new CppUnit::TestCaller<MathTest>(
|
||||
* "testDivideByZero", &MathTest::testDivideByZero));
|
||||
* return suiteOfTests;
|
||||
* }
|
||||
* \endcode
|
||||
*
|
||||
* A set of macros have been created for convenience. They are located in HelperMacros.h.
|
||||
*
|
||||
* \see TestResult, TestSuite, TestCaller,
|
||||
* \see CPPUNIT_TEST_SUB_SUITE, CPPUNIT_TEST, CPPUNIT_TEST_SUITE_END,
|
||||
* \see CPPUNIT_TEST_SUITE_REGISTRATION, CPPUNIT_TEST_EXCEPTION, CPPUNIT_TEST_FAIL.
|
||||
*/
|
||||
class CPPUNIT_API TestFixture
|
||||
{
|
||||
public:
|
||||
virtual ~TestFixture() {};
|
||||
|
||||
//! \brief Set up context before running a test.
|
||||
virtual void setUp() {};
|
||||
|
||||
//! Clean up after the test run.
|
||||
virtual void tearDown() {};
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
|
||||
#endif
|
||||
44
3rdparty/cppunit/include/cppunit/TestLeaf.h
vendored
Normal file
44
3rdparty/cppunit/include/cppunit/TestLeaf.h
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifndef CPPUNIT_TESTLEAF_H
|
||||
#define CPPUNIT_TESTLEAF_H
|
||||
|
||||
#include <cppunit/Test.h>
|
||||
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
/*! \brief A single test object.
|
||||
*
|
||||
* Base class for single test case: a test that doesn't have any children.
|
||||
*
|
||||
*/
|
||||
class CPPUNIT_API TestLeaf: public Test
|
||||
{
|
||||
public:
|
||||
/*! Returns 1 as the default number of test cases invoked by run().
|
||||
*
|
||||
* You may override this method when many test cases are invoked (RepeatedTest
|
||||
* for example).
|
||||
*
|
||||
* \return 1.
|
||||
* \see Test::countTestCases().
|
||||
*/
|
||||
int countTestCases() const;
|
||||
|
||||
/*! Returns the number of child of this test case: 0.
|
||||
*
|
||||
* You should never override this method: a TestLeaf as no children by definition.
|
||||
*
|
||||
* \return 0.
|
||||
*/
|
||||
int getChildTestCount() const;
|
||||
|
||||
/*! Always throws std::out_of_range.
|
||||
* \see Test::doGetChildTestAt().
|
||||
*/
|
||||
Test *doGetChildTestAt( int index ) const;
|
||||
};
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // CPPUNIT_TESTLEAF_H
|
||||
148
3rdparty/cppunit/include/cppunit/TestListener.h
vendored
Normal file
148
3rdparty/cppunit/include/cppunit/TestListener.h
vendored
Normal file
@@ -0,0 +1,148 @@
|
||||
#ifndef CPPUNIT_TESTLISTENER_H // -*- C++ -*-
|
||||
#define CPPUNIT_TESTLISTENER_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
class Exception;
|
||||
class Test;
|
||||
class TestFailure;
|
||||
class TestResult;
|
||||
|
||||
|
||||
/*! \brief Listener for test progress and result.
|
||||
* \ingroup TrackingTestExecution
|
||||
*
|
||||
* Implementing the Observer pattern a TestListener may be registered
|
||||
* to a TestResult to obtain information on the testing progress. Use
|
||||
* specialized sub classes of TestListener for text output
|
||||
* (TextTestProgressListener). Do not use the Listener for the test
|
||||
* result output, use a subclass of Outputter instead.
|
||||
*
|
||||
* The test framework distinguishes between failures and errors.
|
||||
* A failure is anticipated and checked for with assertions. Errors are
|
||||
* unanticipated problems signified by exceptions that are not generated
|
||||
* by the framework.
|
||||
*
|
||||
* Here is an example to track test time:
|
||||
*
|
||||
*
|
||||
* \code
|
||||
* #include <cppunit/TestListener.h>
|
||||
* #include <cppunit/Test.h>
|
||||
* #include <time.h> // for clock()
|
||||
*
|
||||
* class TimingListener : public CppUnit::TestListener
|
||||
* {
|
||||
* public:
|
||||
* void startTest( CppUnit::Test *test )
|
||||
* {
|
||||
* _chronometer.start();
|
||||
* }
|
||||
*
|
||||
* void endTest( CppUnit::Test *test )
|
||||
* {
|
||||
* _chronometer.end();
|
||||
* addTest( test, _chronometer.elapsedTime() );
|
||||
* }
|
||||
*
|
||||
* // ... (interface to add/read test timing result)
|
||||
*
|
||||
* private:
|
||||
* Clock _chronometer;
|
||||
* };
|
||||
* \endcode
|
||||
*
|
||||
* And another example that track failure/success at test suite level and captures
|
||||
* the TestPath of each suite:
|
||||
* \code
|
||||
* class SuiteTracker : public CppUnit::TestListener
|
||||
* {
|
||||
* public:
|
||||
* void startSuite( CppUnit::Test *suite )
|
||||
* {
|
||||
* m_currentPath.add( suite );
|
||||
* }
|
||||
*
|
||||
* void addFailure( const TestFailure &failure )
|
||||
* {
|
||||
* m_suiteFailure.top() = false;
|
||||
* }
|
||||
*
|
||||
* void endSuite( CppUnit::Test *suite )
|
||||
* {
|
||||
* m_suiteStatus.insert( std::make_pair( suite, m_suiteFailure.top() ) );
|
||||
* m_suitePaths.insert( std::make_pair( suite, m_currentPath ) );
|
||||
*
|
||||
* m_currentPath.up();
|
||||
* m_suiteFailure.pop();
|
||||
* }
|
||||
*
|
||||
* private:
|
||||
* std::stack<bool> m_suiteFailure;
|
||||
* CppUnit::TestPath m_currentPath;
|
||||
* std::map<CppUnit::Test *, bool> m_suiteStatus;
|
||||
* std::map<CppUnit::Test *, CppUnit::TestPath> m_suitePaths;
|
||||
* };
|
||||
* \endcode
|
||||
*
|
||||
* \see TestResult
|
||||
*/
|
||||
class CPPUNIT_API TestListener
|
||||
{
|
||||
public:
|
||||
virtual ~TestListener() {}
|
||||
|
||||
/// Called when just before a TestCase is run.
|
||||
virtual void startTest( Test * /*test*/ ) {}
|
||||
|
||||
/*! \brief Called when a failure occurs while running a test.
|
||||
* \see TestFailure.
|
||||
* \warning \a failure is a temporary object that is destroyed after the
|
||||
* method call. Use TestFailure::clone() to create a duplicate.
|
||||
*/
|
||||
virtual void addFailure( const TestFailure & /*failure*/ ) {}
|
||||
|
||||
/// Called just after a TestCase was run (even if a failure occured).
|
||||
virtual void endTest( Test * /*test*/ ) {}
|
||||
|
||||
/*! \brief Called by a TestComposite just before running its child tests.
|
||||
*/
|
||||
virtual void startSuite( Test * /*suite*/ ) {}
|
||||
|
||||
/*! \brief Called by a TestComposite after running its child tests.
|
||||
*/
|
||||
virtual void endSuite( Test * /*suite*/ ) {}
|
||||
|
||||
/*! \brief Called by a TestRunner before running the test.
|
||||
*
|
||||
* You can use this to do some global initialisation. A listener
|
||||
* could also use to output a 'prolog' to the test run.
|
||||
*
|
||||
* \param test Test that is going to be run.
|
||||
* \param eventManager Event manager used for the test run.
|
||||
*/
|
||||
virtual void startTestRun( Test * /*test*/,
|
||||
TestResult * /*eventManager*/ ) {}
|
||||
|
||||
/*! \brief Called by a TestRunner after running the test.
|
||||
*
|
||||
* TextTestProgressListener use this to emit a line break. You can also use this
|
||||
* to do some global uninitialisation.
|
||||
*
|
||||
* \param test Test that was run.
|
||||
* \param eventManager Event manager used for the test run.
|
||||
*/
|
||||
virtual void endTestRun( Test * /*test*/,
|
||||
TestResult * /*eventManager*/ ) {}
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // CPPUNIT_TESTLISTENER_H
|
||||
|
||||
|
||||
206
3rdparty/cppunit/include/cppunit/TestPath.h
vendored
Normal file
206
3rdparty/cppunit/include/cppunit/TestPath.h
vendored
Normal file
@@ -0,0 +1,206 @@
|
||||
#ifndef CPPUNIT_TESTPATH_H
|
||||
#define CPPUNIT_TESTPATH_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
|
||||
#if CPPUNIT_NEED_DLL_DECL
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z
|
||||
#endif
|
||||
|
||||
#include <deque>
|
||||
#include <string>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
class Test;
|
||||
|
||||
/*! \brief A List of Test representing a path to access a Test.
|
||||
* \ingroup ExecutingTest
|
||||
*
|
||||
* The path can be converted to a string and resolved from a string with toString()
|
||||
* and TestPath( Test *root, const std::string &pathAsString ).
|
||||
*
|
||||
* Pointed tests are not owned by the class.
|
||||
*
|
||||
* \see Test::resolvedTestPath()
|
||||
*/
|
||||
class CPPUNIT_API TestPath
|
||||
{
|
||||
public:
|
||||
/*! \brief Constructs an invalid path.
|
||||
*
|
||||
* The path is invalid until a test is added with add().
|
||||
*/
|
||||
TestPath();
|
||||
|
||||
/*! \brief Constructs a valid path.
|
||||
*
|
||||
* \param root Test to add.
|
||||
*/
|
||||
TestPath( Test *root );
|
||||
|
||||
/*! \brief Constructs a path using a slice of another path.
|
||||
* \param otherPath Path the test are copied from.
|
||||
* \param indexFirst Zero based index of the first test to copy. Adjusted to be in valid
|
||||
* range. \a count is adjusted with \a indexFirst.
|
||||
* \param count Number of tests to copy. If < 0 then all test starting from index
|
||||
* \a indexFirst are copied.
|
||||
*/
|
||||
TestPath( const TestPath &otherPath,
|
||||
int indexFirst,
|
||||
int count = -1 );
|
||||
|
||||
/*! \brief Resolves a path from a string returned by toString().
|
||||
*
|
||||
* If \a pathAsString is an absolute path (begins with '/'), then the first test name
|
||||
* of the path must be the name of \a searchRoot. Otherwise, \a pathAsString is a
|
||||
* relative path, and the first test found using Test::findTest() matching the first
|
||||
* test name is used as root. An empty string resolve to a path containing
|
||||
* \a searchRoot.
|
||||
*
|
||||
* The resolved path is always valid.
|
||||
*
|
||||
* \param searchRoot Test used to resolve the path.
|
||||
* \param pathAsString String that contains the path as a string created by toString().
|
||||
* \exception std::invalid_argument if one of the test names can not be resolved.
|
||||
* \see toString().
|
||||
*/
|
||||
TestPath( Test *searchRoot,
|
||||
const std::string &pathAsString );
|
||||
|
||||
/*! \brief Copy constructor.
|
||||
* \param other Object to copy.
|
||||
*/
|
||||
TestPath( const TestPath &other );
|
||||
|
||||
virtual ~TestPath();
|
||||
|
||||
/*! \brief Tests if the path contains at least one test.
|
||||
* \return \c true if the path contains at least one test, otherwise returns \c false.
|
||||
*/
|
||||
virtual bool isValid() const;
|
||||
|
||||
/*! \brief Adds a test to the path.
|
||||
* \param test Pointer on the test to add. Must not be \c NULL.
|
||||
*/
|
||||
virtual void add( Test *test );
|
||||
|
||||
/*! \brief Adds all the tests of the specified path.
|
||||
* \param path Path that contains the test to add.
|
||||
*/
|
||||
virtual void add( const TestPath &path );
|
||||
|
||||
/*! \brief Inserts a test at the specified index.
|
||||
* \param test Pointer on the test to insert. Must not be \c NULL.
|
||||
* \param index Zero based index indicating where the test is inserted.
|
||||
* \exception std::out_of_range is \a index < 0 or \a index > getTestCount().
|
||||
*/
|
||||
virtual void insert( Test *test, int index );
|
||||
|
||||
/*! \brief Inserts all the tests at the specified path at a given index.
|
||||
* \param path Path that contains the test to insert.
|
||||
* \param index Zero based index indicating where the tests are inserted.
|
||||
* \exception std::out_of_range is \a index < 0 or \a index > getTestCount(), and
|
||||
* \a path is valid.
|
||||
*/
|
||||
virtual void insert( const TestPath &path, int index );
|
||||
|
||||
/*! \brief Removes all the test from the path.
|
||||
*
|
||||
* The path becomes invalid after this call.
|
||||
*/
|
||||
virtual void removeTests();
|
||||
|
||||
/*! \brief Removes the test at the specified index of the path.
|
||||
* \param index Zero based index of the test to remove.
|
||||
* \exception std::out_of_range is \a index < 0 or \a index >= getTestCount().
|
||||
*/
|
||||
virtual void removeTest( int index );
|
||||
|
||||
/*! \brief Removes the last test.
|
||||
* \exception std::out_of_range is the path is invalid.
|
||||
* \see isValid().
|
||||
*/
|
||||
virtual void up();
|
||||
|
||||
/*! \brief Returns the number of tests in the path.
|
||||
* \return Number of tests in the path.
|
||||
*/
|
||||
virtual int getTestCount() const;
|
||||
|
||||
/*! \brief Returns the test of the specified index.
|
||||
* \param index Zero based index of the test to return.
|
||||
* \return Pointer on the test at index \a index. Never \c NULL.
|
||||
* \exception std::out_of_range is \a index < 0 or \a index >= getTestCount().
|
||||
*/
|
||||
virtual Test *getTestAt( int index ) const;
|
||||
|
||||
/*! \brief Get the last test of the path.
|
||||
* \return Pointer on the last test (test at the bottom of the hierarchy). Never \c NULL.
|
||||
* \exception std::out_of_range if the path is not valid ( isValid() returns \c false ).
|
||||
*/
|
||||
virtual Test *getChildTest() const;
|
||||
|
||||
/*! \brief Returns the path as a string.
|
||||
*
|
||||
* For example, if a path is composed of three tests named "All Tests", "Math" and
|
||||
* "Math::testAdd", toString() will return:
|
||||
*
|
||||
* "All Tests/Math/Math::testAdd".
|
||||
*
|
||||
* \return A string composed of the test names separated with a '/'. It is a relative
|
||||
* path.
|
||||
*/
|
||||
virtual std::string toString() const;
|
||||
|
||||
/*! \brief Assignment operator.
|
||||
* \param other Object to copy.
|
||||
* \return This object.
|
||||
*/
|
||||
TestPath &operator =( const TestPath &other );
|
||||
|
||||
protected:
|
||||
/*! \brief Checks that the specified test index is within valid range.
|
||||
* \param index Zero based index to check.
|
||||
* \exception std::out_of_range is \a index < 0 or \a index >= getTestCount().
|
||||
*/
|
||||
void checkIndexValid( int index ) const;
|
||||
|
||||
/// A list of test names.
|
||||
typedef std::deque<std::string> PathTestNames;
|
||||
|
||||
/*! \brief Splits a path string into its test name components.
|
||||
* \param pathAsString Path string created with toString().
|
||||
* \param testNames Test name components are added to that container.
|
||||
* \return \c true if the path is relative (does not begin with '/'), \c false
|
||||
* if it is absolute (begin with '/').
|
||||
*/
|
||||
bool splitPathString( const std::string &pathAsString,
|
||||
PathTestNames &testNames );
|
||||
|
||||
/*! \brief Finds the actual root of a path string and get the path string name components.
|
||||
* \param searchRoot Test used as root if the path string is absolute, or to search
|
||||
* the root test if the path string is relative.
|
||||
* \param pathAsString Path string. May be absolute or relative.
|
||||
* \param testNames Test name components are added to that container.
|
||||
* \return Pointer on the resolved root test. Never \c NULL.
|
||||
* \exception std::invalid_argument if either the root name can not be resolved or if
|
||||
* pathAsString contains no name components.
|
||||
*/
|
||||
Test *findActualRoot( Test *searchRoot,
|
||||
const std::string &pathAsString,
|
||||
PathTestNames &testNames );
|
||||
|
||||
protected:
|
||||
typedef std::deque<Test *> Tests;
|
||||
Tests m_tests;
|
||||
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // CPPUNIT_TESTPATH_H
|
||||
|
||||
152
3rdparty/cppunit/include/cppunit/TestResult.h
vendored
Normal file
152
3rdparty/cppunit/include/cppunit/TestResult.h
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
#ifndef CPPUNIT_TESTRESULT_H
|
||||
#define CPPUNIT_TESTRESULT_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
|
||||
#if CPPUNIT_NEED_DLL_DECL
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z
|
||||
#endif
|
||||
|
||||
#include <cppunit/SynchronizedObject.h>
|
||||
#include <deque>
|
||||
#include <string>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
class Exception;
|
||||
class Functor;
|
||||
class Protector;
|
||||
class ProtectorChain;
|
||||
class Test;
|
||||
class TestFailure;
|
||||
class TestListener;
|
||||
|
||||
|
||||
/*! \brief Manages TestListener.
|
||||
* \ingroup TrackingTestExecution
|
||||
*
|
||||
* A single instance of this class is used when running the test. It is usually
|
||||
* created by the test runner (TestRunner).
|
||||
*
|
||||
* This class shouldn't have to be inherited from. Use a TestListener
|
||||
* or one of its subclasses to be informed of the ongoing tests.
|
||||
* Use a Outputter to receive a test summary once it has finished
|
||||
*
|
||||
* TestResult supplies a template method 'setSynchronizationObject()'
|
||||
* so that subclasses can provide mutual exclusion in the face of multiple
|
||||
* threads. This can be useful when tests execute in one thread and
|
||||
* they fill a subclass of TestResult which effects change in another
|
||||
* thread. To have mutual exclusion, override setSynchronizationObject()
|
||||
* and make sure that you create an instance of ExclusiveZone at the
|
||||
* beginning of each method.
|
||||
*
|
||||
* \see Test, TestListener, TestResultCollector, Outputter.
|
||||
*/
|
||||
class CPPUNIT_API TestResult : protected SynchronizedObject
|
||||
{
|
||||
public:
|
||||
/// Construct a TestResult
|
||||
TestResult( SynchronizationObject *syncObject = 0 );
|
||||
|
||||
/// Destroys a test result
|
||||
virtual ~TestResult();
|
||||
|
||||
virtual void addListener( TestListener *listener );
|
||||
|
||||
virtual void removeListener( TestListener *listener );
|
||||
|
||||
/// Resets the stop flag.
|
||||
virtual void reset();
|
||||
|
||||
/// Stop testing
|
||||
virtual void stop();
|
||||
|
||||
/// Returns whether testing should be stopped
|
||||
virtual bool shouldStop() const;
|
||||
|
||||
/// Informs TestListener that a test will be started.
|
||||
virtual void startTest( Test *test );
|
||||
|
||||
/*! \brief Adds an error to the list of errors.
|
||||
* The passed in exception
|
||||
* caused the error
|
||||
*/
|
||||
virtual void addError( Test *test, Exception *e );
|
||||
|
||||
/*! \brief Adds a failure to the list of failures. The passed in exception
|
||||
* caused the failure.
|
||||
*/
|
||||
virtual void addFailure( Test *test, Exception *e );
|
||||
|
||||
/// Informs TestListener that a test was completed.
|
||||
virtual void endTest( Test *test );
|
||||
|
||||
/// Informs TestListener that a test suite will be started.
|
||||
virtual void startSuite( Test *test );
|
||||
|
||||
/// Informs TestListener that a test suite was completed.
|
||||
virtual void endSuite( Test *test );
|
||||
|
||||
/*! \brief Run the specified test.
|
||||
*
|
||||
* Calls startTestRun(), test->run(this), and finally endTestRun().
|
||||
*/
|
||||
virtual void runTest( Test *test );
|
||||
|
||||
/*! \brief Protects a call to the specified functor.
|
||||
*
|
||||
* See Protector to understand how protector works. A default protector is
|
||||
* always present. It captures CppUnit::Exception, std::exception and
|
||||
* any other exceptions, retrieving as much as possible information about
|
||||
* the exception as possible.
|
||||
*
|
||||
* Additional Protector can be added to the chain to support other exception
|
||||
* types using pushProtector() and popProtector().
|
||||
*
|
||||
* \param functor Functor to call (typically a call to setUp(), runTest() or
|
||||
* tearDown().
|
||||
* \param test Test the functor is associated to (used for failure reporting).
|
||||
* \param shortDescription Short description override for the failure message.
|
||||
*/
|
||||
virtual bool protect( const Functor &functor,
|
||||
Test *test,
|
||||
const std::string &shortDescription = std::string("") );
|
||||
|
||||
/// Adds the specified protector to the protector chain.
|
||||
virtual void pushProtector( Protector *protector );
|
||||
|
||||
/// Removes the last protector from the protector chain.
|
||||
virtual void popProtector();
|
||||
|
||||
protected:
|
||||
/*! \brief Called to add a failure to the list of failures.
|
||||
*/
|
||||
void addFailure( const TestFailure &failure );
|
||||
|
||||
virtual void startTestRun( Test *test );
|
||||
virtual void endTestRun( Test *test );
|
||||
|
||||
protected:
|
||||
typedef std::deque<TestListener *> TestListeners;
|
||||
TestListeners m_listeners;
|
||||
ProtectorChain *m_protectorChain;
|
||||
bool m_stop;
|
||||
|
||||
private:
|
||||
TestResult( const TestResult &other );
|
||||
TestResult &operator =( const TestResult &other );
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
|
||||
#if CPPUNIT_NEED_DLL_DECL
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
|
||||
#endif // CPPUNIT_TESTRESULT_H
|
||||
|
||||
|
||||
82
3rdparty/cppunit/include/cppunit/TestResultCollector.h
vendored
Normal file
82
3rdparty/cppunit/include/cppunit/TestResultCollector.h
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
#ifndef CPPUNIT_TESTRESULTCOLLECTOR_H
|
||||
#define CPPUNIT_TESTRESULTCOLLECTOR_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
|
||||
#if CPPUNIT_NEED_DLL_DECL
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable: 4251 4660 ) // X needs to have dll-interface to be used by clients of class Z
|
||||
#endif
|
||||
|
||||
#include <cppunit/TestSuccessListener.h>
|
||||
#include <deque>
|
||||
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
/*! \brief Collects test result.
|
||||
* \ingroup WritingTestResult
|
||||
* \ingroup BrowsingCollectedTestResult
|
||||
*
|
||||
* A TestResultCollector is a TestListener which collects the results of executing
|
||||
* a test case. It is an instance of the Collecting Parameter pattern.
|
||||
*
|
||||
* The test framework distinguishes between failures and errors.
|
||||
* A failure is anticipated and checked for with assertions. Errors are
|
||||
* unanticipated problems signified by exceptions that are not generated
|
||||
* by the framework.
|
||||
* \see TestListener, TestFailure.
|
||||
*/
|
||||
class CPPUNIT_API TestResultCollector : public TestSuccessListener
|
||||
{
|
||||
public:
|
||||
typedef std::deque<TestFailure *> TestFailures;
|
||||
typedef std::deque<Test *> Tests;
|
||||
|
||||
|
||||
/*! Constructs a TestResultCollector object.
|
||||
*/
|
||||
TestResultCollector( SynchronizationObject *syncObject = 0 );
|
||||
|
||||
/// Destructor.
|
||||
virtual ~TestResultCollector();
|
||||
|
||||
void startTest( Test *test );
|
||||
void addFailure( const TestFailure &failure );
|
||||
|
||||
virtual void reset();
|
||||
|
||||
virtual int runTests() const;
|
||||
virtual int testErrors() const;
|
||||
virtual int testFailures() const;
|
||||
virtual int testFailuresTotal() const;
|
||||
|
||||
virtual const TestFailures& failures() const;
|
||||
virtual const Tests &tests() const;
|
||||
|
||||
protected:
|
||||
void freeFailures();
|
||||
|
||||
Tests m_tests;
|
||||
TestFailures m_failures;
|
||||
int m_testErrors;
|
||||
|
||||
private:
|
||||
/// Prevents the use of the copy constructor.
|
||||
TestResultCollector( const TestResultCollector © );
|
||||
|
||||
/// Prevents the use of the copy operator.
|
||||
void operator =( const TestResultCollector © );
|
||||
};
|
||||
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#if CPPUNIT_NEED_DLL_DECL
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
|
||||
|
||||
#endif // CPPUNIT_TESTRESULTCOLLECTOR_H
|
||||
135
3rdparty/cppunit/include/cppunit/TestRunner.h
vendored
Normal file
135
3rdparty/cppunit/include/cppunit/TestRunner.h
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
#ifndef CPPUNIT_TESTRUNNER_H
|
||||
#define CPPUNIT_TESTRUNNER_H
|
||||
|
||||
#include <cppunit/TestSuite.h>
|
||||
#include <string>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
class Test;
|
||||
class TestResult;
|
||||
|
||||
|
||||
/*! \brief Generic test runner.
|
||||
* \ingroup ExecutingTest
|
||||
*
|
||||
* The TestRunner assumes ownership of all added tests: you can not add test
|
||||
* or suite that are local variable since they can't be deleted.
|
||||
*
|
||||
* Example of usage:
|
||||
* \code
|
||||
* #include <cppunit/extensions/TestFactoryRegistry.h>
|
||||
* #include <cppunit/CompilerOutputter.h>
|
||||
* #include <cppunit/TestResult.h>
|
||||
* #include <cppunit/TestResultCollector.h>
|
||||
* #include <cppunit/TestRunner.h>
|
||||
* #include <cppunit/TextTestProgressListener.h>
|
||||
*
|
||||
*
|
||||
* int
|
||||
* main( int argc, char* argv[] )
|
||||
* {
|
||||
* std::string testPath = (argc > 1) ? std::string(argv[1]) : "";
|
||||
*
|
||||
* // Create the event manager and test controller
|
||||
* CppUnit::TestResult controller;
|
||||
*
|
||||
* // Add a listener that colllects test result
|
||||
* CppUnit::TestResultCollector result;
|
||||
* controller.addListener( &result );
|
||||
*
|
||||
* // Add a listener that print dots as test run.
|
||||
* CppUnit::TextTestProgressListener progress;
|
||||
* controller.addListener( &progress );
|
||||
*
|
||||
* // Add the top suite to the test runner
|
||||
* CppUnit::TestRunner runner;
|
||||
* runner.addTest( CppUnit::TestFactoryRegistry::getRegistry().makeTest() );
|
||||
* try
|
||||
* {
|
||||
* std::cout << "Running " << testPath;
|
||||
* runner.run( controller, testPath );
|
||||
*
|
||||
* std::cerr << std::endl;
|
||||
*
|
||||
* // Print test in a compiler compatible format.
|
||||
* CppUnit::CompilerOutputter outputter( &result, std::cerr );
|
||||
* outputter.write();
|
||||
* }
|
||||
* catch ( std::invalid_argument &e ) // Test path not resolved
|
||||
* {
|
||||
* std::cerr << std::endl
|
||||
* << "ERROR: " << e.what()
|
||||
* << std::endl;
|
||||
* return 0;
|
||||
* }
|
||||
*
|
||||
* return result.wasSuccessful() ? 0 : 1;
|
||||
* }
|
||||
* \endcode
|
||||
*/
|
||||
class CPPUNIT_API TestRunner
|
||||
{
|
||||
public:
|
||||
/*! \brief Constructs a TestRunner object.
|
||||
*/
|
||||
TestRunner( );
|
||||
|
||||
/// Destructor.
|
||||
virtual ~TestRunner();
|
||||
|
||||
/*! \brief Adds the specified test.
|
||||
* \param test Test to add. The TestRunner takes ownership of the test.
|
||||
*/
|
||||
virtual void addTest( Test *test );
|
||||
|
||||
/*! \brief Runs a test using the specified controller.
|
||||
* \param controller Event manager and controller used for testing
|
||||
* \param testPath Test path string. See Test::resolveTestPath() for detail.
|
||||
* \exception std::invalid_argument if no test matching \a testPath is found.
|
||||
* see TestPath::TestPath( Test*, const std::string &)
|
||||
* for detail.
|
||||
*/
|
||||
virtual void run( TestResult &controller,
|
||||
const std::string &testPath = "" );
|
||||
|
||||
protected:
|
||||
/*! \brief (INTERNAL) Mutating test suite.
|
||||
*/
|
||||
class CPPUNIT_API WrappingSuite : public TestSuite
|
||||
{
|
||||
public:
|
||||
WrappingSuite( const std::string &name = "All Tests" );
|
||||
|
||||
int getChildTestCount() const;
|
||||
|
||||
std::string getName() const;
|
||||
|
||||
void run( TestResult *result );
|
||||
|
||||
protected:
|
||||
Test *doGetChildTestAt( int index ) const;
|
||||
|
||||
bool hasOnlyOneTest() const;
|
||||
|
||||
Test *getUniqueChildTest() const;
|
||||
};
|
||||
|
||||
protected:
|
||||
WrappingSuite *m_suite;
|
||||
|
||||
private:
|
||||
/// Prevents the use of the copy constructor.
|
||||
TestRunner( const TestRunner © );
|
||||
|
||||
/// Prevents the use of the copy operator.
|
||||
void operator =( const TestRunner © );
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // CPPUNIT_TESTRUNNER_H
|
||||
39
3rdparty/cppunit/include/cppunit/TestSuccessListener.h
vendored
Normal file
39
3rdparty/cppunit/include/cppunit/TestSuccessListener.h
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifndef CPPUNIT_TESTSUCCESSLISTENER_H
|
||||
#define CPPUNIT_TESTSUCCESSLISTENER_H
|
||||
|
||||
#include <cppunit/SynchronizedObject.h>
|
||||
#include <cppunit/TestListener.h>
|
||||
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
/*! \brief TestListener that checks if any test case failed.
|
||||
* \ingroup TrackingTestExecution
|
||||
*/
|
||||
class CPPUNIT_API TestSuccessListener : public TestListener,
|
||||
public SynchronizedObject
|
||||
{
|
||||
public:
|
||||
/*! Constructs a TestSuccessListener object.
|
||||
*/
|
||||
TestSuccessListener( SynchronizationObject *syncObject = 0 );
|
||||
|
||||
/// Destructor.
|
||||
virtual ~TestSuccessListener();
|
||||
|
||||
virtual void reset();
|
||||
|
||||
void addFailure( const TestFailure &failure );
|
||||
|
||||
/// Returns whether the entire test was successful or not.
|
||||
virtual bool wasSuccessful() const;
|
||||
|
||||
private:
|
||||
bool m_success;
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // CPPUNIT_TESTSUCCESSLISTENER_H
|
||||
80
3rdparty/cppunit/include/cppunit/TestSuite.h
vendored
Normal file
80
3rdparty/cppunit/include/cppunit/TestSuite.h
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
#ifndef CPPUNIT_TESTSUITE_H // -*- C++ -*-
|
||||
#define CPPUNIT_TESTSUITE_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
|
||||
#if CPPUNIT_NEED_DLL_DECL
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z
|
||||
#endif
|
||||
|
||||
#include <cppunit/TestComposite.h>
|
||||
#include <vector>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
#if CPPUNIT_NEED_DLL_DECL
|
||||
// template class CPPUNIT_API std::vector<Test *>;
|
||||
#endif
|
||||
|
||||
|
||||
/*! \brief A Composite of Tests.
|
||||
* \ingroup CreatingTestSuite
|
||||
*
|
||||
* It runs a collection of test cases. Here is an example.
|
||||
* \code
|
||||
* CppUnit::TestSuite *suite= new CppUnit::TestSuite();
|
||||
* suite->addTest(new CppUnit::TestCaller<MathTest> (
|
||||
* "testAdd", testAdd));
|
||||
* suite->addTest(new CppUnit::TestCaller<MathTest> (
|
||||
* "testDivideByZero", testDivideByZero));
|
||||
* \endcode
|
||||
* Note that \link TestSuite TestSuites \endlink assume lifetime
|
||||
* control for any tests added to them.
|
||||
*
|
||||
* TestSuites do not register themselves in the TestRegistry.
|
||||
* \see Test
|
||||
* \see TestCaller
|
||||
*/
|
||||
class CPPUNIT_API TestSuite : public TestComposite
|
||||
{
|
||||
public:
|
||||
/*! Constructs a test suite with the specified name.
|
||||
*/
|
||||
TestSuite( std::string name = "" );
|
||||
|
||||
~TestSuite();
|
||||
|
||||
/*! Adds the specified test to the suite.
|
||||
* \param test Test to add. Must not be \c NULL.
|
||||
*/
|
||||
void addTest( Test *test );
|
||||
|
||||
/*! Returns the list of the tests (DEPRECATED).
|
||||
* \deprecated Use getChildTestCount() & getChildTestAt() of the
|
||||
* TestComposite interface instead.
|
||||
* \return Reference on a vector that contains the tests of the suite.
|
||||
*/
|
||||
const std::vector<Test *> &getTests() const;
|
||||
|
||||
/*! Destroys all the tests of the suite.
|
||||
*/
|
||||
virtual void deleteContents();
|
||||
|
||||
int getChildTestCount() const;
|
||||
|
||||
Test *doGetChildTestAt( int index ) const;
|
||||
|
||||
private:
|
||||
std::vector<Test *> m_tests;
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#if CPPUNIT_NEED_DLL_DECL
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
|
||||
#endif // CPPUNIT_TESTSUITE_H
|
||||
59
3rdparty/cppunit/include/cppunit/TextOutputter.h
vendored
Normal file
59
3rdparty/cppunit/include/cppunit/TextOutputter.h
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
#ifndef CPPUNIT_TEXTOUTPUTTER_H
|
||||
#define CPPUNIT_TEXTOUTPUTTER_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
#include <cppunit/Outputter.h>
|
||||
#include <cppunit/portability/Stream.h>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
class Exception;
|
||||
class SourceLine;
|
||||
class TestResultCollector;
|
||||
class TestFailure;
|
||||
|
||||
|
||||
/*! \brief Prints a TestResultCollector to a text stream.
|
||||
* \ingroup WritingTestResult
|
||||
*/
|
||||
class CPPUNIT_API TextOutputter : public Outputter
|
||||
{
|
||||
public:
|
||||
TextOutputter( TestResultCollector *result,
|
||||
OStream &stream );
|
||||
|
||||
/// Destructor.
|
||||
virtual ~TextOutputter();
|
||||
|
||||
void write();
|
||||
virtual void printFailures();
|
||||
virtual void printHeader();
|
||||
|
||||
virtual void printFailure( TestFailure *failure,
|
||||
int failureNumber );
|
||||
virtual void printFailureListMark( int failureNumber );
|
||||
virtual void printFailureTestName( TestFailure *failure );
|
||||
virtual void printFailureType( TestFailure *failure );
|
||||
virtual void printFailureLocation( SourceLine sourceLine );
|
||||
virtual void printFailureDetail( Exception *thrownException );
|
||||
virtual void printFailureWarning();
|
||||
virtual void printStatistics();
|
||||
|
||||
protected:
|
||||
TestResultCollector *m_result;
|
||||
OStream &m_stream;
|
||||
|
||||
private:
|
||||
/// Prevents the use of the copy constructor.
|
||||
TextOutputter( const TextOutputter © );
|
||||
|
||||
/// Prevents the use of the copy operator.
|
||||
void operator =( const TextOutputter © );
|
||||
};
|
||||
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // CPPUNIT_TEXTOUTPUTTER_H
|
||||
44
3rdparty/cppunit/include/cppunit/TextTestProgressListener.h
vendored
Normal file
44
3rdparty/cppunit/include/cppunit/TextTestProgressListener.h
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifndef CPPUNIT_TEXTTESTPROGRESSLISTENER_H
|
||||
#define CPPUNIT_TEXTTESTPROGRESSLISTENER_H
|
||||
|
||||
#include <cppunit/TestListener.h>
|
||||
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
/*!
|
||||
* \brief TestListener that show the status of each TestCase test result.
|
||||
* \ingroup TrackingTestExecution
|
||||
*/
|
||||
class CPPUNIT_API TextTestProgressListener : public TestListener
|
||||
{
|
||||
public:
|
||||
/*! Constructs a TextTestProgressListener object.
|
||||
*/
|
||||
TextTestProgressListener();
|
||||
|
||||
/// Destructor.
|
||||
virtual ~TextTestProgressListener();
|
||||
|
||||
void startTest( Test *test );
|
||||
|
||||
void addFailure( const TestFailure &failure );
|
||||
|
||||
void endTestRun( Test *test,
|
||||
TestResult *eventManager );
|
||||
|
||||
private:
|
||||
/// Prevents the use of the copy constructor.
|
||||
TextTestProgressListener( const TextTestProgressListener © );
|
||||
|
||||
/// Prevents the use of the copy operator.
|
||||
void operator =( const TextTestProgressListener © );
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // CPPUNIT_TEXTTESTPROGRESSLISTENER_H
|
||||
41
3rdparty/cppunit/include/cppunit/TextTestResult.h
vendored
Normal file
41
3rdparty/cppunit/include/cppunit/TextTestResult.h
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
#ifndef CPPUNIT_TEXTTESTRESULT_H
|
||||
#define CPPUNIT_TEXTTESTRESULT_H
|
||||
|
||||
#include <cppunit/TestResult.h>
|
||||
#include <cppunit/TestResultCollector.h>
|
||||
#include <cppunit/portability/Stream.h>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
class SourceLine;
|
||||
class Exception;
|
||||
class Test;
|
||||
|
||||
/*! \brief Holds printable test result (DEPRECATED).
|
||||
* \ingroup TrackingTestExecution
|
||||
*
|
||||
* deprecated Use class TextTestProgressListener and TextOutputter instead.
|
||||
*/
|
||||
class CPPUNIT_API TextTestResult : public TestResult,
|
||||
public TestResultCollector
|
||||
{
|
||||
public:
|
||||
TextTestResult();
|
||||
|
||||
virtual void addFailure( const TestFailure &failure );
|
||||
virtual void startTest( Test *test );
|
||||
virtual void print( OStream &stream );
|
||||
|
||||
using TestResult::addFailure;
|
||||
};
|
||||
|
||||
/** insertion operator for easy output */
|
||||
CPPUNIT_API OStream &operator <<( OStream &stream,
|
||||
TextTestResult &result );
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // CPPUNIT_TEXTTESTRESULT_H
|
||||
|
||||
|
||||
6
3rdparty/cppunit/include/cppunit/TextTestRunner.h
vendored
Normal file
6
3rdparty/cppunit/include/cppunit/TextTestRunner.h
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef CPPUNIT_TEXTTESTRUNNER_H
|
||||
#define CPPUNIT_TEXTTESTRUNNER_H
|
||||
|
||||
#include <cppunit/ui/text/TextTestRunner.h>
|
||||
|
||||
#endif // CPPUNIT_TEXTTESTRUNNER_H
|
||||
167
3rdparty/cppunit/include/cppunit/XmlOutputter.h
vendored
Normal file
167
3rdparty/cppunit/include/cppunit/XmlOutputter.h
vendored
Normal file
@@ -0,0 +1,167 @@
|
||||
#ifndef CPPUNIT_XMLTESTRESULTOUTPUTTER_H
|
||||
#define CPPUNIT_XMLTESTRESULTOUTPUTTER_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
|
||||
#if CPPUNIT_NEED_DLL_DECL
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z
|
||||
#endif
|
||||
|
||||
#include <cppunit/Outputter.h>
|
||||
#include <deque>
|
||||
#include <map>
|
||||
#include <cppunit/portability/Stream.h>
|
||||
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
class Test;
|
||||
class TestFailure;
|
||||
class TestResultCollector;
|
||||
class XmlDocument;
|
||||
class XmlElement;
|
||||
class XmlOutputterHook;
|
||||
|
||||
|
||||
/*! \brief Outputs a TestResultCollector in XML format.
|
||||
* \ingroup WritingTestResult
|
||||
*
|
||||
* Save the test result as a XML stream.
|
||||
*
|
||||
* Additional datas can be added to the XML document using XmlOutputterHook.
|
||||
* Hook are not owned by the XmlOutputter. They should be valid until
|
||||
* destruction of the XmlOutputter. They can be removed with removeHook().
|
||||
*
|
||||
* \see XmlDocument, XmlElement, XmlOutputterHook.
|
||||
*/
|
||||
class CPPUNIT_API XmlOutputter : public Outputter
|
||||
{
|
||||
public:
|
||||
/*! \brief Constructs a XmlOutputter object.
|
||||
* \param result Result of the test run.
|
||||
* \param stream Stream used to output the XML output.
|
||||
* \param encoding Encoding used in the XML file (default is Latin-1).
|
||||
*/
|
||||
XmlOutputter( TestResultCollector *result,
|
||||
OStream &stream,
|
||||
const std::string& encoding = std::string("ISO-8859-1") );
|
||||
|
||||
/// Destructor.
|
||||
virtual ~XmlOutputter();
|
||||
|
||||
/*! \brief Adds the specified hook to the outputter.
|
||||
* \param hook Hook to add. Must not be \c NULL.
|
||||
*/
|
||||
virtual void addHook( XmlOutputterHook *hook );
|
||||
|
||||
/*! \brief Removes the specified hook from the outputter.
|
||||
* \param hook Hook to remove.
|
||||
*/
|
||||
virtual void removeHook( XmlOutputterHook *hook );
|
||||
|
||||
/*! \brief Writes the specified result as an XML document to the stream.
|
||||
*
|
||||
* Refer to examples/cppunittest/XmlOutputterTest.cpp for example
|
||||
* of use and XML document structure.
|
||||
*/
|
||||
virtual void write();
|
||||
|
||||
/*! \brief Sets the XSL style sheet used.
|
||||
*
|
||||
* \param styleSheet Name of the style sheet used. If empty, then no style sheet
|
||||
* is used (default).
|
||||
*/
|
||||
virtual void setStyleSheet( const std::string &styleSheet );
|
||||
|
||||
/*! \brief set the output document as standalone or not.
|
||||
*
|
||||
* For the output document, specify wether it's a standalone XML
|
||||
* document, or not.
|
||||
*
|
||||
* \param standalone if true, the output will be specified as standalone.
|
||||
* if false, it will be not.
|
||||
*/
|
||||
virtual void setStandalone( bool standalone );
|
||||
|
||||
typedef std::map<Test *,TestFailure*, std::less<Test*> > FailedTests;
|
||||
|
||||
/*! \brief Sets the root element and adds its children.
|
||||
*
|
||||
* Set the root element of the XML Document and add its child elements.
|
||||
*
|
||||
* For all hooks, call beginDocument() just after creating the root element (it
|
||||
* is empty at this time), and endDocument() once all the datas have been added
|
||||
* to the root element.
|
||||
*/
|
||||
virtual void setRootNode();
|
||||
|
||||
virtual void addFailedTests( FailedTests &failedTests,
|
||||
XmlElement *rootNode );
|
||||
|
||||
virtual void addSuccessfulTests( FailedTests &failedTests,
|
||||
XmlElement *rootNode );
|
||||
|
||||
/*! \brief Adds the statics element to the root node.
|
||||
*
|
||||
* Creates a new element containing statistics data and adds it to the root element.
|
||||
* Then, for all hooks, call statisticsAdded().
|
||||
* \param rootNode Root element.
|
||||
*/
|
||||
virtual void addStatistics( XmlElement *rootNode );
|
||||
|
||||
/*! \brief Adds a failed test to the failed tests node.
|
||||
* Creates a new element containing datas about the failed test, and adds it to
|
||||
* the failed tests element.
|
||||
* Then, for all hooks, call failTestAdded().
|
||||
*/
|
||||
virtual void addFailedTest( Test *test,
|
||||
TestFailure *failure,
|
||||
int testNumber,
|
||||
XmlElement *testsNode );
|
||||
|
||||
virtual void addFailureLocation( TestFailure *failure,
|
||||
XmlElement *testElement );
|
||||
|
||||
|
||||
/*! \brief Adds a successful test to the successful tests node.
|
||||
* Creates a new element containing datas about the successful test, and adds it to
|
||||
* the successful tests element.
|
||||
* Then, for all hooks, call successfulTestAdded().
|
||||
*/
|
||||
virtual void addSuccessfulTest( Test *test,
|
||||
int testNumber,
|
||||
XmlElement *testsNode );
|
||||
protected:
|
||||
virtual void fillFailedTestsMap( FailedTests &failedTests );
|
||||
|
||||
protected:
|
||||
typedef std::deque<XmlOutputterHook *> Hooks;
|
||||
|
||||
TestResultCollector *m_result;
|
||||
OStream &m_stream;
|
||||
std::string m_encoding;
|
||||
std::string m_styleSheet;
|
||||
XmlDocument *m_xml;
|
||||
Hooks m_hooks;
|
||||
|
||||
private:
|
||||
/// Prevents the use of the copy constructor.
|
||||
XmlOutputter( const XmlOutputter © );
|
||||
|
||||
/// Prevents the use of the copy operator.
|
||||
void operator =( const XmlOutputter © );
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#if CPPUNIT_NEED_DLL_DECL
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
|
||||
|
||||
#endif // CPPUNIT_XMLTESTRESULTOUTPUTTER_H
|
||||
163
3rdparty/cppunit/include/cppunit/XmlOutputterHook.h
vendored
Normal file
163
3rdparty/cppunit/include/cppunit/XmlOutputterHook.h
vendored
Normal file
@@ -0,0 +1,163 @@
|
||||
#ifndef CPPUNIT_XMLOUTPUTTERHOOK_H
|
||||
#define CPPUNIT_XMLOUTPUTTERHOOK_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
class Test;
|
||||
class TestFailure;
|
||||
class XmlDocument;
|
||||
class XmlElement;
|
||||
|
||||
|
||||
|
||||
/*! \brief Hook to customize Xml output.
|
||||
*
|
||||
* XmlOutputterHook can be passed to XmlOutputter to customize the XmlDocument.
|
||||
*
|
||||
* Common customizations are:
|
||||
* - adding some datas to successfull or failed test with
|
||||
* failTestAdded() and successfulTestAdded(),
|
||||
* - adding some statistics with statisticsAdded(),
|
||||
* - adding other datas with beginDocument() or endDocument().
|
||||
*
|
||||
* See examples/ClockerPlugIn which makes use of most the hook.
|
||||
*
|
||||
* Another simple example of an outputter hook is shown below. It may be
|
||||
* used to add some meta information to your result files. In the example,
|
||||
* the author name as well as the project name and test creation date is
|
||||
* added to the head of the xml file.
|
||||
*
|
||||
* In order to make this information stored within the xml file, the virtual
|
||||
* member function beginDocument() is overriden where a new
|
||||
* XmlElement object is created.
|
||||
*
|
||||
* This element is simply added to the root node of the document which
|
||||
* makes the information automatically being stored when the xml file
|
||||
* is written.
|
||||
*
|
||||
* \code
|
||||
* #include <cppunit/XmlOutputterHook.h>
|
||||
* #include <cppunit/XmlElement.h>
|
||||
* #include <cppunit/tools/StringTools.h>
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* class MyXmlOutputterHook : public CppUnit::XmlOutputterHook
|
||||
* {
|
||||
* public:
|
||||
* MyXmlOutputterHook(const std::string projectName,
|
||||
* const std::string author)
|
||||
* {
|
||||
* m_projectName = projectName;
|
||||
* m_author = author;
|
||||
* };
|
||||
*
|
||||
* virtual ~MyXmlOutputterHook()
|
||||
* {
|
||||
* };
|
||||
*
|
||||
* void beginDocument(CppUnit::XmlDocument* document)
|
||||
* {
|
||||
* if (!document)
|
||||
* return;
|
||||
*
|
||||
* // dump current time
|
||||
* std::string szDate = CppUnit::StringTools::toString( (int)time(0) );
|
||||
* CppUnit::XmlElement* metaEl = new CppUnit::XmlElement("SuiteInfo",
|
||||
* "");
|
||||
*
|
||||
* metaEl->addElement( new CppUnit::XmlElement("Author", m_author) );
|
||||
* metaEl->addElement( new CppUnit::XmlElement("Project", m_projectName) );
|
||||
* metaEl->addElement( new CppUnit::XmlElement("Date", szDate ) );
|
||||
*
|
||||
* document->rootElement().addElement(metaEl);
|
||||
* };
|
||||
* private:
|
||||
* std::string m_projectName;
|
||||
* std::string m_author;
|
||||
* };
|
||||
* \endcode
|
||||
*
|
||||
* Within your application's main code, you need to snap the hook
|
||||
* object into your xml outputter object like shown below:
|
||||
*
|
||||
* \code
|
||||
* CppUnit::TextUi::TestRunner runner;
|
||||
* std::ofstream outputFile("testResults.xml");
|
||||
*
|
||||
* CppUnit::XmlOutputter* outputter = new CppUnit::XmlOutputter( &runner.result(),
|
||||
* outputFile );
|
||||
* MyXmlOutputterHook hook("myProject", "meAuthor");
|
||||
* outputter->addHook(&hook);
|
||||
* runner.setOutputter(outputter);
|
||||
* runner.addTest( VectorFixture::suite() );
|
||||
* runner.run();
|
||||
* outputFile.close();
|
||||
* \endcode
|
||||
*
|
||||
* This results into the following output:
|
||||
*
|
||||
* \code
|
||||
* <TestRun>
|
||||
* <suiteInfo>
|
||||
* <author>meAuthor</author>
|
||||
* <project>myProject</project>
|
||||
* <date>1028143912</date>
|
||||
* </suiteInfo>
|
||||
* <FailedTests>
|
||||
* ...
|
||||
* \endcode
|
||||
*
|
||||
* \see XmlOutputter, CppUnitTestPlugIn.
|
||||
*/
|
||||
class CPPUNIT_API XmlOutputterHook
|
||||
{
|
||||
public:
|
||||
/*! Called before any elements is added to the root element.
|
||||
* \param document XML Document being created.
|
||||
*/
|
||||
virtual void beginDocument( XmlDocument *document );
|
||||
|
||||
/*! Called after adding all elements to the root element.
|
||||
* \param document XML Document being created.
|
||||
*/
|
||||
virtual void endDocument( XmlDocument *document );
|
||||
|
||||
/*! Called after adding a fail test element.
|
||||
* \param document XML Document being created.
|
||||
* \param testElement \<FailedTest\> element.
|
||||
* \param test Test that failed.
|
||||
* \param failure Test failure data.
|
||||
*/
|
||||
virtual void failTestAdded( XmlDocument *document,
|
||||
XmlElement *testElement,
|
||||
Test *test,
|
||||
TestFailure *failure );
|
||||
|
||||
/*! Called after adding a successful test element.
|
||||
* \param document XML Document being created.
|
||||
* \param testElement \<Test\> element.
|
||||
* \param test Test that was successful.
|
||||
*/
|
||||
virtual void successfulTestAdded( XmlDocument *document,
|
||||
XmlElement *testElement,
|
||||
Test *test );
|
||||
|
||||
/*! Called after adding the statistic element.
|
||||
* \param document XML Document being created.
|
||||
* \param statisticsElement \<Statistics\> element.
|
||||
*/
|
||||
virtual void statisticsAdded( XmlDocument *document,
|
||||
XmlElement *statisticsElement );
|
||||
|
||||
virtual ~XmlOutputterHook() {}
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // CPPUNIT_XMLOUTPUTTERHOOK_H
|
||||
176
3rdparty/cppunit/include/cppunit/config-auto.h
vendored
Normal file
176
3rdparty/cppunit/include/cppunit/config-auto.h
vendored
Normal file
@@ -0,0 +1,176 @@
|
||||
#ifndef _INCLUDE_CPPUNIT_CONFIG_AUTO_H
|
||||
#define _INCLUDE_CPPUNIT_CONFIG_AUTO_H 1
|
||||
|
||||
/* include/cppunit/config-auto.h. Generated automatically at end of configure. */
|
||||
/* config.h. Generated from config.h.in by configure. */
|
||||
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* define if library uses std::string::compare(string,pos,n) */
|
||||
/* #undef FUNC_STRING_COMPARE_STRING_FIRST */
|
||||
|
||||
/* define if the library defines strstream */
|
||||
#ifndef CPPUNIT_HAVE_CLASS_STRSTREAM
|
||||
#define CPPUNIT_HAVE_CLASS_STRSTREAM 1
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the <cmath> header file. */
|
||||
#ifndef CPPUNIT_HAVE_CMATH
|
||||
#define CPPUNIT_HAVE_CMATH 1
|
||||
#endif
|
||||
|
||||
/* define if the compiler supports basic C++11 syntax */
|
||||
#ifndef CPPUNIT_HAVE_CXX11
|
||||
#define CPPUNIT_HAVE_CXX11 1
|
||||
#endif
|
||||
|
||||
/* Define if you have the GNU dld library. */
|
||||
/* #undef HAVE_DLD */
|
||||
|
||||
/* Define to 1 if you have the `dlerror' function. */
|
||||
#ifndef CPPUNIT_HAVE_DLERROR
|
||||
#define CPPUNIT_HAVE_DLERROR 1
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#ifndef CPPUNIT_HAVE_DLFCN_H
|
||||
#define CPPUNIT_HAVE_DLFCN_H 1
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the `finite' function. */
|
||||
#ifndef CPPUNIT_HAVE_FINITE
|
||||
#define CPPUNIT_HAVE_FINITE 1
|
||||
#endif
|
||||
|
||||
/* define if the compiler supports GCC C++ ABI name demangling */
|
||||
#ifndef CPPUNIT_HAVE_GCC_ABI_DEMANGLE
|
||||
#define CPPUNIT_HAVE_GCC_ABI_DEMANGLE 1
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#ifndef CPPUNIT_HAVE_INTTYPES_H
|
||||
#define CPPUNIT_HAVE_INTTYPES_H 1
|
||||
#endif
|
||||
|
||||
/* define if compiler has isfinite */
|
||||
#ifndef CPPUNIT_HAVE_ISFINITE
|
||||
#define CPPUNIT_HAVE_ISFINITE 1
|
||||
#endif
|
||||
|
||||
/* Define if you have the libdl library or equivalent. */
|
||||
#ifndef CPPUNIT_HAVE_LIBDL
|
||||
#define CPPUNIT_HAVE_LIBDL 1
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#ifndef CPPUNIT_HAVE_MEMORY_H
|
||||
#define CPPUNIT_HAVE_MEMORY_H 1
|
||||
#endif
|
||||
|
||||
/* define if the compiler implements namespaces */
|
||||
#ifndef CPPUNIT_HAVE_NAMESPACES
|
||||
#define CPPUNIT_HAVE_NAMESPACES 1
|
||||
#endif
|
||||
|
||||
/* Define if you have the shl_load function. */
|
||||
/* #undef HAVE_SHL_LOAD */
|
||||
|
||||
/* define if the compiler has stringstream */
|
||||
#ifndef CPPUNIT_HAVE_SSTREAM
|
||||
#define CPPUNIT_HAVE_SSTREAM 1
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#ifndef CPPUNIT_HAVE_STDINT_H
|
||||
#define CPPUNIT_HAVE_STDINT_H 1
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#ifndef CPPUNIT_HAVE_STDLIB_H
|
||||
#define CPPUNIT_HAVE_STDLIB_H 1
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#ifndef CPPUNIT_HAVE_STRINGS_H
|
||||
#define CPPUNIT_HAVE_STRINGS_H 1
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#ifndef CPPUNIT_HAVE_STRING_H
|
||||
#define CPPUNIT_HAVE_STRING_H 1
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the <strstream> header file. */
|
||||
#ifndef CPPUNIT_HAVE_STRSTREAM
|
||||
#define CPPUNIT_HAVE_STRSTREAM 1
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#ifndef CPPUNIT_HAVE_SYS_STAT_H
|
||||
#define CPPUNIT_HAVE_SYS_STAT_H 1
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#ifndef CPPUNIT_HAVE_SYS_TYPES_H
|
||||
#define CPPUNIT_HAVE_SYS_TYPES_H 1
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#ifndef CPPUNIT_HAVE_UNISTD_H
|
||||
#define CPPUNIT_HAVE_UNISTD_H 1
|
||||
#endif
|
||||
|
||||
/* Define to the sub-directory where libtool stores uninstalled libraries. */
|
||||
#ifndef CPPUNIT_LT_OBJDIR
|
||||
#define CPPUNIT_LT_OBJDIR ".libs/"
|
||||
#endif
|
||||
|
||||
/* Disable debugging information */
|
||||
#ifndef CPPUNIT_NDEBUG
|
||||
#define CPPUNIT_NDEBUG /**/
|
||||
#endif
|
||||
|
||||
/* Name of package */
|
||||
#ifndef CPPUNIT_PACKAGE
|
||||
#define CPPUNIT_PACKAGE "cppunit"
|
||||
#endif
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#ifndef CPPUNIT_PACKAGE_BUGREPORT
|
||||
#define CPPUNIT_PACKAGE_BUGREPORT ""
|
||||
#endif
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#ifndef CPPUNIT_PACKAGE_NAME
|
||||
#define CPPUNIT_PACKAGE_NAME "cppunit"
|
||||
#endif
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#ifndef CPPUNIT_PACKAGE_STRING
|
||||
#define CPPUNIT_PACKAGE_STRING "cppunit 1.14.0"
|
||||
#endif
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#ifndef CPPUNIT_PACKAGE_TARNAME
|
||||
#define CPPUNIT_PACKAGE_TARNAME "cppunit"
|
||||
#endif
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#ifndef CPPUNIT_PACKAGE_URL
|
||||
#define CPPUNIT_PACKAGE_URL ""
|
||||
#endif
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#ifndef CPPUNIT_PACKAGE_VERSION
|
||||
#define CPPUNIT_PACKAGE_VERSION "1.14.0"
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
/* #undef STDC_HEADERS */
|
||||
|
||||
/* Version number of package */
|
||||
#ifndef CPPUNIT_VERSION
|
||||
#define CPPUNIT_VERSION "1.14.0"
|
||||
#endif
|
||||
|
||||
/* once: _INCLUDE_CPPUNIT_CONFIG_AUTO_H */
|
||||
#endif
|
||||
33
3rdparty/cppunit/include/cppunit/config/CppUnitApi.h
vendored
Normal file
33
3rdparty/cppunit/include/cppunit/config/CppUnitApi.h
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef CPPUNIT_CONFIG_CPPUNITAPI
|
||||
#define CPPUNIT_CONFIG_CPPUNITAPI
|
||||
|
||||
#undef CPPUNIT_API
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
// define CPPUNIT_DLL_BUILD when building CppUnit dll.
|
||||
#ifdef CPPUNIT_BUILD_DLL
|
||||
#define CPPUNIT_API __declspec(dllexport)
|
||||
#endif
|
||||
|
||||
// define CPPUNIT_DLL when linking to CppUnit dll.
|
||||
#ifdef CPPUNIT_DLL
|
||||
#define CPPUNIT_API __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#ifdef CPPUNIT_API
|
||||
#undef CPPUNIT_NEED_DLL_DECL
|
||||
#define CPPUNIT_NEED_DLL_DECL 1
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef CPPUNIT_API
|
||||
#define CPPUNIT_API
|
||||
#undef CPPUNIT_NEED_DLL_DECL
|
||||
#define CPPUNIT_NEED_DLL_DECL 0
|
||||
#endif
|
||||
|
||||
|
||||
#endif // CPPUNIT_CONFIG_CPPUNITAPI
|
||||
69
3rdparty/cppunit/include/cppunit/config/SelectDllLoader.h
vendored
Normal file
69
3rdparty/cppunit/include/cppunit/config/SelectDllLoader.h
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
#ifndef CPPUNIT_CONFIG_SELECTDLLLOADER_H
|
||||
#define CPPUNIT_CONFIG_SELECTDLLLOADER_H
|
||||
|
||||
/*! \file
|
||||
* Selects DynamicLibraryManager implementation.
|
||||
*
|
||||
* Don't include this file directly. Include Portability.h instead.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \def CPPUNIT_NO_TESTPLUGIN
|
||||
* \brief If defined, then plug-in related classes and functions will not be compiled.
|
||||
*
|
||||
* \internal
|
||||
* CPPUNIT_HAVE_WIN32_DLL_LOADER
|
||||
* If defined, Win32 implementation of DynamicLibraryManager will be used.
|
||||
*
|
||||
* CPPUNIT_HAVE_UNIX_DLL_LOADER
|
||||
* If defined, Unix implementation (dlfcn.h) of DynamicLibraryManager will be used.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \def CPPUNIT_PLUGIN_EXPORT
|
||||
* \ingroup WritingTestPlugIn
|
||||
* \brief A macro to export a function from a dynamic library
|
||||
*
|
||||
* This macro export the C function following it from a dynamic library.
|
||||
* Exporting the function makes it accessible to the DynamicLibraryManager.
|
||||
*
|
||||
* Example of usage:
|
||||
* \code
|
||||
* #include <cppunit/include/plugin/TestPlugIn.h>
|
||||
*
|
||||
* CPPUNIT_PLUGIN_EXPORT CppUnitTestPlugIn *CPPUNIT_PLUGIN_EXPORTED_NAME(void)
|
||||
* {
|
||||
* ...
|
||||
* return &myPlugInInterface;
|
||||
* }
|
||||
* \endcode
|
||||
*/
|
||||
|
||||
#if !defined(CPPUNIT_NO_TESTPLUGIN)
|
||||
|
||||
// Is WIN32 platform ?
|
||||
#if defined(WIN32)
|
||||
#define CPPUNIT_HAVE_WIN32_DLL_LOADER 1
|
||||
#undef CPPUNIT_PLUGIN_EXPORT
|
||||
#define CPPUNIT_PLUGIN_EXPORT extern "C" __declspec(dllexport)
|
||||
|
||||
// Is Unix platform and have shl_load() (hp-ux)
|
||||
#elif defined(CPPUNIT_HAVE_SHL_LOAD)
|
||||
#define CPPUNIT_HAVE_UNIX_SHL_LOADER 1
|
||||
|
||||
// Is Unix platform and have include <dlfcn.h>
|
||||
#elif defined(CPPUNIT_HAVE_LIBDL)
|
||||
#define CPPUNIT_HAVE_UNIX_DLL_LOADER 1
|
||||
|
||||
// Otherwise, disable support for DllLoader
|
||||
#else
|
||||
#define CPPUNIT_NO_TESTPLUGIN 1
|
||||
#endif
|
||||
|
||||
#if !defined(CPPUNIT_PLUGIN_EXPORT)
|
||||
#define CPPUNIT_PLUGIN_EXPORT extern "C"
|
||||
#endif // !defined(CPPUNIT_PLUGIN_EXPORT)
|
||||
|
||||
#endif // !defined(CPPUNIT_NO_TESTPLUGIN)
|
||||
|
||||
#endif // CPPUNIT_CONFIG_SELECTDLLLOADER_H
|
||||
14
3rdparty/cppunit/include/cppunit/config/SourcePrefix.h
vendored
Normal file
14
3rdparty/cppunit/include/cppunit/config/SourcePrefix.h
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef CPPUNIT_CONFIG_H_INCLUDED
|
||||
#define CPPUNIT_CONFIG_H_INCLUDED
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4018 4284 4146)
|
||||
#if _MSC_VER >= 1400
|
||||
#pragma warning(disable: 4996) // sprintf is deprecated
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#endif // CPPUNIT_CONFIG_H_INCLUDED
|
||||
37
3rdparty/cppunit/include/cppunit/config/config-bcb5.h
vendored
Normal file
37
3rdparty/cppunit/include/cppunit/config/config-bcb5.h
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef _INCLUDE_CPPUNIT_CONFIG_BCB5_H
|
||||
#define _INCLUDE_CPPUNIT_CONFIG_BCB5_H 1
|
||||
|
||||
#define HAVE_CMATH 1
|
||||
|
||||
/* include/cppunit/config-bcb5.h. Manually adapted from
|
||||
include/cppunit/config-auto.h */
|
||||
|
||||
/* define to 1 if the compiler implements namespaces */
|
||||
#ifndef CPPUNIT_HAVE_NAMESPACES
|
||||
#define CPPUNIT_HAVE_NAMESPACES 1
|
||||
#endif
|
||||
|
||||
/* define if library uses std::string::compare(string,pos,n) */
|
||||
#ifndef CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST
|
||||
#define CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST 0
|
||||
#endif
|
||||
|
||||
/* Define if you have the <dlfcn.h> header file. */
|
||||
#ifdef CPPUNIT_HAVE_DLFCN_H
|
||||
#undef CPPUNIT_HAVE_DLFCN_H
|
||||
#endif
|
||||
|
||||
/* define to 1 if the compiler implements namespaces */
|
||||
#ifndef CPPUNIT_HAVE_NAMESPACES
|
||||
#define CPPUNIT_HAVE_NAMESPACES 1
|
||||
#endif
|
||||
|
||||
#define CPPUNIT_HAVE_SSTREAM 1
|
||||
|
||||
/* Name of package */
|
||||
#ifndef CPPUNIT_PACKAGE
|
||||
#define CPPUNIT_PACKAGE "cppunit"
|
||||
#endif
|
||||
|
||||
/* _INCLUDE_CPPUNIT_CONFIG_BCB5_H */
|
||||
#endif
|
||||
66
3rdparty/cppunit/include/cppunit/config/config-evc4.h
vendored
Normal file
66
3rdparty/cppunit/include/cppunit/config/config-evc4.h
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
#ifndef _INCLUDE_CPPUNIT_CONFIG_EVC4_H
|
||||
#define _INCLUDE_CPPUNIT_CONFIG_EVC4_H 1
|
||||
|
||||
#if _MSC_VER > 1000 // VC++
|
||||
#pragma warning( disable : 4786 ) // disable warning debug symbol > 255...
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#define HAVE_CMATH 1
|
||||
|
||||
/* include/cppunit/config-msvc6.h. Manually adapted from
|
||||
include/cppunit/config-auto.h */
|
||||
|
||||
/* define to 1 if the compiler implements namespaces */
|
||||
#ifndef CPPUNIT_HAVE_NAMESPACES
|
||||
#define CPPUNIT_HAVE_NAMESPACES 1
|
||||
#endif
|
||||
|
||||
/* define if library uses std::string::compare(string,pos,n) */
|
||||
#ifdef CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST
|
||||
#undef CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST
|
||||
#endif
|
||||
|
||||
/* Define if you have the <dlfcn.h> header file. */
|
||||
#ifdef CPPUNIT_HAVE_DLFCN_H
|
||||
#undef CPPUNIT_HAVE_DLFCN_H
|
||||
#endif
|
||||
|
||||
/* define to 1 if the compiler implements namespaces */
|
||||
#ifndef CPPUNIT_HAVE_NAMESPACES
|
||||
#define CPPUNIT_HAVE_NAMESPACES 1
|
||||
#endif
|
||||
|
||||
#define CPPUNIT_NO_STREAM 1
|
||||
#define CPPUNIT_NO_ASSERT 1
|
||||
|
||||
#define CPPUNIT_HAVE_SSTREAM 0
|
||||
|
||||
/* Name of package */
|
||||
#ifndef CPPUNIT_PACKAGE
|
||||
#define CPPUNIT_PACKAGE "cppunit"
|
||||
#endif
|
||||
|
||||
|
||||
// Compiler error location format for CompilerOutputter
|
||||
// See class CompilerOutputter for format.
|
||||
#undef CPPUNIT_COMPILER_LOCATION_FORMAT
|
||||
#if _MSC_VER >= 1300 // VS 7.0
|
||||
# define CPPUNIT_COMPILER_LOCATION_FORMAT "%p(%l) : error : "
|
||||
#else
|
||||
# define CPPUNIT_COMPILER_LOCATION_FORMAT "%p(%l):"
|
||||
#endif
|
||||
|
||||
/* define to 1 if the compiler has _finite() */
|
||||
#ifndef CPPUNIT_HAVE__FINITE
|
||||
#define CPPUNIT_HAVE__FINITE 1
|
||||
#endif
|
||||
|
||||
// Uncomment to turn on STL wrapping => use this to test compilation.
|
||||
// This will make CppUnit subclass std::vector & co to provide default
|
||||
// parameter.
|
||||
/* #define CPPUNIT_NO_NAMESPACE 1
|
||||
*/
|
||||
|
||||
|
||||
/* _INCLUDE_CPPUNIT_CONFIG_EVC4_H */
|
||||
#endif
|
||||
48
3rdparty/cppunit/include/cppunit/config/config-mac.h
vendored
Normal file
48
3rdparty/cppunit/include/cppunit/config/config-mac.h
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef _INCLUDE_CPPUNIT_CONFIG_MAC_H
|
||||
#define _INCLUDE_CPPUNIT_CONFIG_MAC_H 1
|
||||
|
||||
/* MacOS X should be installed using the configure script.
|
||||
This file is for other macs.
|
||||
|
||||
It is not integrated into <cppunit/Portability.h> because we don't
|
||||
know a suitable preprocessor symbol that will distinguish MacOS X
|
||||
from other MacOS versions. Email us if you know the answer.
|
||||
*/
|
||||
|
||||
/* define if library uses std::string::compare(string,pos,n) */
|
||||
#ifdef CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST
|
||||
#undef CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST
|
||||
#endif
|
||||
|
||||
/* define if the library defines strstream */
|
||||
#ifndef CPPUNIT_HAVE_CLASS_STRSTREAM
|
||||
#define CPPUNIT_HAVE_CLASS_STRSTREAM 1
|
||||
#endif
|
||||
|
||||
/* Define if you have the <cmath> header file. */
|
||||
#ifdef CPPUNIT_HAVE_CMATH
|
||||
#undef CPPUNIT_HAVE_CMATH
|
||||
#endif
|
||||
|
||||
/* Define if you have the <dlfcn.h> header file. */
|
||||
#ifdef CPPUNIT_HAVE_DLFCN_H
|
||||
#undef CPPUNIT_HAVE_DLFCN_H
|
||||
#endif
|
||||
|
||||
/* define to 1 if the compiler implements namespaces */
|
||||
#ifndef CPPUNIT_HAVE_NAMESPACES
|
||||
#define CPPUNIT_HAVE_NAMESPACES 1
|
||||
#endif
|
||||
|
||||
/* define if the compiler has stringstream */
|
||||
#ifndef CPPUNIT_HAVE_SSTREAM
|
||||
#define CPPUNIT_HAVE_SSTREAM 1
|
||||
#endif
|
||||
|
||||
/* Define if you have the <strstream> header file. */
|
||||
#ifndef CPPUNIT_HAVE_STRSTREAM
|
||||
#define CPPUNIT_HAVE_STRSTREAM 1
|
||||
#endif
|
||||
|
||||
/* _INCLUDE_CPPUNIT_CONFIG_MAC_H */
|
||||
#endif
|
||||
70
3rdparty/cppunit/include/cppunit/config/config-msvc6.h
vendored
Normal file
70
3rdparty/cppunit/include/cppunit/config/config-msvc6.h
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
#ifndef _INCLUDE_CPPUNIT_CONFIG_MSVC6_H
|
||||
#define _INCLUDE_CPPUNIT_CONFIG_MSVC6_H 1
|
||||
|
||||
#if _MSC_VER > 1000 // VC++
|
||||
#pragma warning( disable : 4786 ) // disable warning debug symbol > 255...
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#define HAVE_CMATH 1
|
||||
|
||||
/* include/cppunit/config-msvc6.h. Manually adapted from
|
||||
include/cppunit/config-auto.h */
|
||||
|
||||
/* define to 1 if the compiler implements namespaces */
|
||||
#ifndef CPPUNIT_HAVE_NAMESPACES
|
||||
#define CPPUNIT_HAVE_NAMESPACES 1
|
||||
#endif
|
||||
|
||||
/* define if library uses std::string::compare(string,pos,n) */
|
||||
#ifdef CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST
|
||||
#undef CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST
|
||||
#endif
|
||||
|
||||
/* Define if you have the <dlfcn.h> header file. */
|
||||
#ifdef CPPUNIT_HAVE_DLFCN_H
|
||||
#undef CPPUNIT_HAVE_DLFCN_H
|
||||
#endif
|
||||
|
||||
/* define to 1 if the compiler implements namespaces */
|
||||
#ifndef CPPUNIT_HAVE_NAMESPACES
|
||||
#define CPPUNIT_HAVE_NAMESPACES 1
|
||||
#endif
|
||||
|
||||
#define CPPUNIT_HAVE_SSTREAM 1
|
||||
|
||||
/* Name of package */
|
||||
#ifndef CPPUNIT_PACKAGE
|
||||
#define CPPUNIT_PACKAGE "cppunit"
|
||||
#endif
|
||||
|
||||
|
||||
// Compiler error location format for CompilerOutputter
|
||||
// See class CompilerOutputter for format.
|
||||
#undef CPPUNIT_COMPILER_LOCATION_FORMAT
|
||||
#if _MSC_VER >= 1300 // VS 7.0
|
||||
# define CPPUNIT_COMPILER_LOCATION_FORMAT "%p(%l) : error : "
|
||||
#else
|
||||
# define CPPUNIT_COMPILER_LOCATION_FORMAT "%p(%l):"
|
||||
#endif
|
||||
|
||||
// Define to 1 if the compiler support C++ style cast.
|
||||
#define CPPUNIT_HAVE_CPP_CAST 1
|
||||
|
||||
/* define to 1 if the compiler has _finite() */
|
||||
#ifndef CPPUNIT_HAVE__FINITE
|
||||
#define CPPUNIT_HAVE__FINITE 1
|
||||
#endif
|
||||
|
||||
|
||||
// Uncomment to turn on STL wrapping => use this to test compilation.
|
||||
// This will make CppUnit subclass std::vector & co to provide default
|
||||
// parameter.
|
||||
/*#define CPPUNIT_NO_NAMESPACE 1
|
||||
*/
|
||||
|
||||
#if _MSC_VER >= 1300 // VS 7.0
|
||||
#define CPPUNIT_UNIQUE_COUNTER __COUNTER__
|
||||
#endif // if _MSC_VER >= 1300 // VS 7.0
|
||||
|
||||
/* _INCLUDE_CPPUNIT_CONFIG_MSVC6_H */
|
||||
#endif
|
||||
83
3rdparty/cppunit/include/cppunit/extensions/AutoRegisterSuite.h
vendored
Normal file
83
3rdparty/cppunit/include/cppunit/extensions/AutoRegisterSuite.h
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
#ifndef CPPUNIT_EXTENSIONS_AUTOREGISTERSUITE_H
|
||||
#define CPPUNIT_EXTENSIONS_AUTOREGISTERSUITE_H
|
||||
|
||||
#include <cppunit/extensions/TestSuiteFactory.h>
|
||||
#include <cppunit/extensions/TestFactoryRegistry.h>
|
||||
#include <string>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
/*! \brief (Implementation) Automatically register the test suite of the specified type.
|
||||
*
|
||||
* You should not use this class directly. Instead, use the following macros:
|
||||
* - CPPUNIT_TEST_SUITE_REGISTRATION()
|
||||
* - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION()
|
||||
*
|
||||
* This object will register the test returned by TestCaseType::suite()
|
||||
* when constructed to the test registry.
|
||||
*
|
||||
* This object is intented to be used as a static variable.
|
||||
*
|
||||
*
|
||||
* \param TestCaseType Type of the test case which suite is registered.
|
||||
* \see CPPUNIT_TEST_SUITE_REGISTRATION, CPPUNIT_TEST_SUITE_NAMED_REGISTRATION
|
||||
* \see CppUnit::TestFactoryRegistry.
|
||||
*/
|
||||
template<class TestCaseType>
|
||||
class AutoRegisterSuite
|
||||
{
|
||||
public:
|
||||
/** Auto-register the suite factory in the global registry.
|
||||
*/
|
||||
AutoRegisterSuite()
|
||||
: m_registry( &TestFactoryRegistry::getRegistry() )
|
||||
{
|
||||
m_registry->registerFactory( &m_factory );
|
||||
}
|
||||
|
||||
/** Auto-register the suite factory in the specified registry.
|
||||
* \param name Name of the registry.
|
||||
*/
|
||||
AutoRegisterSuite( const std::string &name )
|
||||
: m_registry( &TestFactoryRegistry::getRegistry( name ) )
|
||||
{
|
||||
m_registry->registerFactory( &m_factory );
|
||||
}
|
||||
|
||||
~AutoRegisterSuite()
|
||||
{
|
||||
if ( TestFactoryRegistry::isValid() )
|
||||
m_registry->unregisterFactory( &m_factory );
|
||||
}
|
||||
|
||||
private:
|
||||
TestFactoryRegistry *m_registry;
|
||||
TestSuiteFactory<TestCaseType> m_factory;
|
||||
};
|
||||
|
||||
|
||||
/*! \brief (Implementation) Automatically adds a registry into another registry.
|
||||
*
|
||||
* Don't use this class. Use the macros CPPUNIT_REGISTRY_ADD() and
|
||||
* CPPUNIT_REGISTRY_ADD_TO_DEFAULT() instead.
|
||||
*/
|
||||
class AutoRegisterRegistry
|
||||
{
|
||||
public:
|
||||
AutoRegisterRegistry( const std::string &which,
|
||||
const std::string &to )
|
||||
{
|
||||
TestFactoryRegistry::getRegistry( to ).addRegistry( which );
|
||||
}
|
||||
|
||||
AutoRegisterRegistry( const std::string &which )
|
||||
{
|
||||
TestFactoryRegistry::getRegistry().addRegistry( which );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // CPPUNIT_EXTENSIONS_AUTOREGISTERSUITE_H
|
||||
104
3rdparty/cppunit/include/cppunit/extensions/ExceptionTestCaseDecorator.h
vendored
Normal file
104
3rdparty/cppunit/include/cppunit/extensions/ExceptionTestCaseDecorator.h
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
#ifndef CPPUNIT_EXTENSIONS_EXCEPTIONTESTCASEDECORATOR_H
|
||||
#define CPPUNIT_EXTENSIONS_EXCEPTIONTESTCASEDECORATOR_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
#include <cppunit/Exception.h>
|
||||
#include <cppunit/extensions/TestCaseDecorator.h>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
/*! \brief Expected exception test case decorator.
|
||||
*
|
||||
* A decorator used to assert that a specific test case should throw an
|
||||
* exception of a given type.
|
||||
*
|
||||
* You should use this class only if you need to check the exception object
|
||||
* state (that a specific cause is set for example). If you don't need to
|
||||
* do that, you might consider using CPPUNIT_TEST_EXCEPTION() instead.
|
||||
*
|
||||
* Intended use is to subclass and override checkException(). Example:
|
||||
*
|
||||
* \code
|
||||
*
|
||||
* class NetworkErrorTestCaseDecorator :
|
||||
* public ExceptionTestCaseDecorator<NetworkError>
|
||||
* {
|
||||
* public:
|
||||
* NetworkErrorTestCaseDecorator( NetworkError::Cause expectedCause )
|
||||
* : m_expectedCause( expectedCause )
|
||||
* {
|
||||
* }
|
||||
* private:
|
||||
* void checkException( ExpectedExceptionType &e )
|
||||
* {
|
||||
* CPPUNIT_ASSERT_EQUAL( m_expectedCause, e.getCause() );
|
||||
* }
|
||||
*
|
||||
* NetworkError::Cause m_expectedCause;
|
||||
* };
|
||||
* \endcode
|
||||
*
|
||||
*/
|
||||
template<class ExpectedException>
|
||||
class ExceptionTestCaseDecorator : public TestCaseDecorator
|
||||
{
|
||||
public:
|
||||
typedef ExpectedException ExpectedExceptionType;
|
||||
|
||||
/*! \brief Decorates the specified test.
|
||||
* \param test TestCase to decorate. Assumes ownership of the test.
|
||||
*/
|
||||
ExceptionTestCaseDecorator( TestCase *test )
|
||||
: TestCaseDecorator( test )
|
||||
{
|
||||
}
|
||||
|
||||
/*! \brief Checks that the expected exception is thrown by the decorated test.
|
||||
* is thrown.
|
||||
*
|
||||
* Calls the decorated test runTest() and checks that an exception of
|
||||
* type ExpectedException is thrown. Call checkException() passing the
|
||||
* exception that was caught so that some assertions can be made if
|
||||
* needed.
|
||||
*/
|
||||
void runTest()
|
||||
{
|
||||
try
|
||||
{
|
||||
TestCaseDecorator::runTest();
|
||||
}
|
||||
catch ( ExpectedExceptionType &e )
|
||||
{
|
||||
checkException( e );
|
||||
return;
|
||||
}
|
||||
|
||||
// Moved outside the try{} statement to handle the case where the
|
||||
// expected exception type is Exception (expecting assertion failure).
|
||||
#if defined(CPPUNIT_USE_TYPEINFO_NAME)
|
||||
throw Exception( Message(
|
||||
"expected exception not thrown",
|
||||
"Expected exception type: " +
|
||||
TypeInfoHelper::getClassName(
|
||||
typeid( ExpectedExceptionType ) ) ) );
|
||||
#else
|
||||
throw Exception( Message("expected exception not thrown") );
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
/*! \brief Called when the exception is caught.
|
||||
*
|
||||
* Should be overriden to check the exception.
|
||||
*/
|
||||
virtual void checkException( ExpectedExceptionType & )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // CPPUNIT_EXTENSIONS_EXCEPTIONTESTCASEDECORATOR_H
|
||||
|
||||
553
3rdparty/cppunit/include/cppunit/extensions/HelperMacros.h
vendored
Normal file
553
3rdparty/cppunit/include/cppunit/extensions/HelperMacros.h
vendored
Normal file
@@ -0,0 +1,553 @@
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
// Header file HelperMacros.h
|
||||
// (c)Copyright 2000, Baptiste Lepilleur.
|
||||
// Created: 2001/04/15
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
#ifndef CPPUNIT_EXTENSIONS_HELPERMACROS_H
|
||||
#define CPPUNIT_EXTENSIONS_HELPERMACROS_H
|
||||
|
||||
#include <cppunit/TestCaller.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
#include <cppunit/extensions/AutoRegisterSuite.h>
|
||||
#include <cppunit/extensions/ExceptionTestCaseDecorator.h>
|
||||
#include <cppunit/extensions/TestFixtureFactory.h>
|
||||
#include <cppunit/extensions/TestNamer.h>
|
||||
#include <cppunit/extensions/TestSuiteBuilderContext.h>
|
||||
#include <memory>
|
||||
|
||||
|
||||
/*! \addtogroup WritingTestFixture Writing test fixture
|
||||
*/
|
||||
/** @{
|
||||
*/
|
||||
|
||||
|
||||
/** \file
|
||||
* Macros intended to ease the definition of test suites.
|
||||
*
|
||||
* The macros
|
||||
* CPPUNIT_TEST_SUITE(), CPPUNIT_TEST(), and CPPUNIT_TEST_SUITE_END()
|
||||
* are designed to facilitate easy creation of a test suite.
|
||||
* For example,
|
||||
*
|
||||
* \code
|
||||
* #include <cppunit/extensions/HelperMacros.h>
|
||||
* class MyTest : public CppUnit::TestFixture {
|
||||
* CPPUNIT_TEST_SUITE( MyTest );
|
||||
* CPPUNIT_TEST( testEquality );
|
||||
* CPPUNIT_TEST( testSetName );
|
||||
* CPPUNIT_TEST_SUITE_END();
|
||||
* public:
|
||||
* void testEquality();
|
||||
* void testSetName();
|
||||
* };
|
||||
* \endcode
|
||||
*
|
||||
* The effect of these macros is to define two methods in the
|
||||
* class MyTest. The first method is an auxiliary function
|
||||
* named registerTests that you will not need to call directly.
|
||||
* The second function
|
||||
* \code static CppUnit::TestSuite *suite()\endcode
|
||||
* returns a pointer to the suite of tests defined by the CPPUNIT_TEST()
|
||||
* macros.
|
||||
*
|
||||
* Rather than invoking suite() directly,
|
||||
* the macro CPPUNIT_TEST_SUITE_REGISTRATION() is
|
||||
* used to create a static variable that automatically
|
||||
* registers its test suite in a global registry.
|
||||
* The registry yields a Test instance containing all the
|
||||
* registered suites.
|
||||
* \code
|
||||
* CPPUNIT_TEST_SUITE_REGISTRATION( MyTest );
|
||||
* CppUnit::Test* tp =
|
||||
* CppUnit::TestFactoryRegistry::getRegistry().makeTest();
|
||||
* \endcode
|
||||
*
|
||||
* The test suite macros can even be used with templated test classes.
|
||||
* For example:
|
||||
*
|
||||
* \code
|
||||
* template<typename CharType>
|
||||
* class StringTest : public CppUnit::TestFixture {
|
||||
* CPPUNIT_TEST_SUITE( StringTest );
|
||||
* CPPUNIT_TEST( testAppend );
|
||||
* CPPUNIT_TEST_SUITE_END();
|
||||
* public:
|
||||
* ...
|
||||
* };
|
||||
* \endcode
|
||||
*
|
||||
* You need to add in an implementation file:
|
||||
*
|
||||
* \code
|
||||
* CPPUNIT_TEST_SUITE_REGISTRATION( StringTest<char> );
|
||||
* CPPUNIT_TEST_SUITE_REGISTRATION( StringTest<wchar_t> );
|
||||
* \endcode
|
||||
*/
|
||||
|
||||
|
||||
/*! \brief Begin test suite
|
||||
*
|
||||
* This macro starts the declaration of a new test suite.
|
||||
* Use CPPUNIT_TEST_SUB_SUITE() instead, if you wish to include the
|
||||
* test suite of the parent class.
|
||||
*
|
||||
* \param ATestFixtureType Type of the test case class. This type \b MUST
|
||||
* be derived from TestFixture.
|
||||
* \see CPPUNIT_TEST_SUB_SUITE, CPPUNIT_TEST, CPPUNIT_TEST_SUITE_END,
|
||||
* \see CPPUNIT_TEST_SUITE_REGISTRATION, CPPUNIT_TEST_EXCEPTION, CPPUNIT_TEST_FAIL.
|
||||
*/
|
||||
#define CPPUNIT_TEST_SUITE( ATestFixtureType ) \
|
||||
public: \
|
||||
typedef ATestFixtureType TestFixtureType; \
|
||||
\
|
||||
private: \
|
||||
static const CPPUNIT_NS::TestNamer &getTestNamer__() \
|
||||
{ \
|
||||
static CPPUNIT_TESTNAMER_DECL( testNamer, ATestFixtureType ); \
|
||||
return testNamer; \
|
||||
} \
|
||||
\
|
||||
public: \
|
||||
typedef CPPUNIT_NS::TestSuiteBuilderContext<TestFixtureType> \
|
||||
TestSuiteBuilderContextType; \
|
||||
\
|
||||
static void \
|
||||
addTestsToSuite( CPPUNIT_NS::TestSuiteBuilderContextBase &baseContext ) \
|
||||
{ \
|
||||
TestSuiteBuilderContextType context( baseContext )
|
||||
|
||||
|
||||
/*! \brief Begin test suite (includes parent suite)
|
||||
*
|
||||
* This macro may only be used in a class whose parent class
|
||||
* defines a test suite using CPPUNIT_TEST_SUITE() or CPPUNIT_TEST_SUB_SUITE().
|
||||
*
|
||||
* This macro begins the declaration of a test suite, in the same
|
||||
* manner as CPPUNIT_TEST_SUITE(). In addition, the test suite of the
|
||||
* parent is automatically inserted in the test suite being
|
||||
* defined.
|
||||
*
|
||||
* Here is an example:
|
||||
*
|
||||
* \code
|
||||
* #include <cppunit/extensions/HelperMacros.h>
|
||||
* class MySubTest : public MyTest {
|
||||
* CPPUNIT_TEST_SUB_SUITE( MySubTest, MyTest );
|
||||
* CPPUNIT_TEST( testAdd );
|
||||
* CPPUNIT_TEST( testSub );
|
||||
* CPPUNIT_TEST_SUITE_END();
|
||||
* public:
|
||||
* void testAdd();
|
||||
* void testSub();
|
||||
* };
|
||||
* \endcode
|
||||
*
|
||||
* \param ATestFixtureType Type of the test case class. This type \b MUST
|
||||
* be derived from TestFixture.
|
||||
* \param ASuperClass Type of the parent class.
|
||||
* \see CPPUNIT_TEST_SUITE.
|
||||
*/
|
||||
#define CPPUNIT_TEST_SUB_SUITE( ATestFixtureType, ASuperClass ) \
|
||||
public: \
|
||||
typedef ASuperClass ParentTestFixtureType; \
|
||||
private: \
|
||||
CPPUNIT_TEST_SUITE( ATestFixtureType ); \
|
||||
ParentTestFixtureType::addTestsToSuite( baseContext )
|
||||
|
||||
|
||||
/*! \brief End declaration of the test suite.
|
||||
*
|
||||
* After this macro, member access is set to "private".
|
||||
*
|
||||
* \see CPPUNIT_TEST_SUITE.
|
||||
* \see CPPUNIT_TEST_SUITE_REGISTRATION.
|
||||
*/
|
||||
#define CPPUNIT_TEST_SUITE_END() \
|
||||
} \
|
||||
\
|
||||
public: \
|
||||
static CPPUNIT_NS::TestSuite *suite() \
|
||||
{ \
|
||||
const CPPUNIT_NS::TestNamer &namer = getTestNamer__(); \
|
||||
std::unique_ptr<CPPUNIT_NS::TestSuite> guard( \
|
||||
new CPPUNIT_NS::TestSuite( namer.getFixtureName() )); \
|
||||
CPPUNIT_NS::ConcretTestFixtureFactory<TestFixtureType> factory; \
|
||||
CPPUNIT_NS::TestSuiteBuilderContextBase context( *guard.get(), \
|
||||
namer, \
|
||||
factory ); \
|
||||
TestFixtureType::addTestsToSuite( context ); \
|
||||
return guard.release(); \
|
||||
} \
|
||||
private: /* dummy typedef so that the macro can still end with ';'*/ \
|
||||
typedef int CppUnitDummyTypedefForSemiColonEnding__
|
||||
|
||||
/*! \brief End declaration of an abstract test suite.
|
||||
*
|
||||
* Use this macro to indicate that the %TestFixture is abstract. No
|
||||
* static suite() method will be declared.
|
||||
*
|
||||
* After this macro, member access is set to "private".
|
||||
*
|
||||
* Here is an example of usage:
|
||||
*
|
||||
* The abstract test fixture:
|
||||
* \code
|
||||
* #include <cppunit/extensions/HelperMacros.h>
|
||||
* class AbstractDocument;
|
||||
* class AbstractDocumentTest : public CppUnit::TestFixture {
|
||||
* CPPUNIT_TEST_SUITE( AbstractDocumentTest );
|
||||
* CPPUNIT_TEST( testInsertText );
|
||||
* CPPUNIT_TEST_SUITE_END_ABSTRACT();
|
||||
* public:
|
||||
* void testInsertText();
|
||||
*
|
||||
* void setUp()
|
||||
* {
|
||||
* m_document = makeDocument();
|
||||
* }
|
||||
*
|
||||
* void tearDown()
|
||||
* {
|
||||
* delete m_document;
|
||||
* }
|
||||
* protected:
|
||||
* virtual AbstractDocument *makeDocument() =0;
|
||||
*
|
||||
* AbstractDocument *m_document;
|
||||
* };\endcode
|
||||
*
|
||||
* The concret test fixture:
|
||||
* \code
|
||||
* class RichTextDocumentTest : public AbstractDocumentTest {
|
||||
* CPPUNIT_TEST_SUB_SUITE( RichTextDocumentTest, AbstractDocumentTest );
|
||||
* CPPUNIT_TEST( testInsertFormatedText );
|
||||
* CPPUNIT_TEST_SUITE_END();
|
||||
* public:
|
||||
* void testInsertFormatedText();
|
||||
* protected:
|
||||
* AbstractDocument *makeDocument()
|
||||
* {
|
||||
* return new RichTextDocument();
|
||||
* }
|
||||
* };\endcode
|
||||
*
|
||||
* \see CPPUNIT_TEST_SUB_SUITE.
|
||||
* \see CPPUNIT_TEST_SUITE_REGISTRATION.
|
||||
*/
|
||||
#define CPPUNIT_TEST_SUITE_END_ABSTRACT() \
|
||||
} \
|
||||
private: /* dummy typedef so that the macro can still end with ';'*/ \
|
||||
typedef int CppUnitDummyTypedefForSemiColonEnding__
|
||||
|
||||
|
||||
/*! \brief Add a test to the suite (for custom test macro).
|
||||
*
|
||||
* The specified test will be added to the test suite being declared. This macro
|
||||
* is intended for \e advanced usage, to extend %CppUnit by creating new macro such
|
||||
* as CPPUNIT_TEST_EXCEPTION()...
|
||||
*
|
||||
* Between macro CPPUNIT_TEST_SUITE() and CPPUNIT_TEST_SUITE_END(), you can assume
|
||||
* that the following variables can be used:
|
||||
* \code
|
||||
* typedef TestSuiteBuilder<TestFixtureType> TestSuiteBuilderType;
|
||||
* TestSuiteBuilderType &context;
|
||||
* \endcode
|
||||
*
|
||||
* \c context can be used to name test case, create new test fixture instance,
|
||||
* or add test case to the test fixture suite.
|
||||
*
|
||||
* Below is an example that show how to use this macro to create new macro to add
|
||||
* test to the fixture suite. The macro below show how you would add a new type
|
||||
* of test case which fails if the execution last more than a given time limit.
|
||||
* It relies on an imaginary TimeOutTestCaller class which has an interface similar
|
||||
* to TestCaller.
|
||||
*
|
||||
* \code
|
||||
* #define CPPUNITEX_TEST_TIMELIMIT( testMethod, timeLimit ) \
|
||||
* CPPUNIT_TEST_SUITE_ADD_TEST( (new TimeOutTestCaller<TestFixtureType>( \
|
||||
* namer.getTestNameFor( #testMethod ), \
|
||||
* &TestFixtureType::testMethod, \
|
||||
* factory.makeFixture(), \
|
||||
* timeLimit ) ) )
|
||||
*
|
||||
* class PerformanceTest : CppUnit::TestFixture
|
||||
* {
|
||||
* public:
|
||||
* CPPUNIT_TEST_SUITE( PerformanceTest );
|
||||
* CPPUNITEX_TEST_TIMELIMIT( testSortReverseOrder, 5.0 );
|
||||
* CPPUNIT_TEST_SUITE_END();
|
||||
*
|
||||
* void testSortReverseOrder();
|
||||
* };
|
||||
* \endcode
|
||||
*
|
||||
* \param test Test to add to the suite. Must be a subclass of Test. The test name
|
||||
* should have been obtained using TestNamer::getTestNameFor().
|
||||
*/
|
||||
#define CPPUNIT_TEST_SUITE_ADD_TEST( test ) \
|
||||
context.addTest( test )
|
||||
|
||||
/*! \brief Add a method to the suite.
|
||||
* \param testMethod Name of the method of the test case to add to the
|
||||
* suite. The signature of the method must be of
|
||||
* type: void testMethod();
|
||||
* \see CPPUNIT_TEST_SUITE.
|
||||
*/
|
||||
#define CPPUNIT_TEST( testMethod ) \
|
||||
CPPUNIT_TEST_SUITE_ADD_TEST( \
|
||||
( new CPPUNIT_NS::TestCaller<TestFixtureType>( \
|
||||
context.getTestNameFor( #testMethod), \
|
||||
&TestFixtureType::testMethod, \
|
||||
context.makeFixture() ) ) )
|
||||
|
||||
#define CPPUNIT_TEST_PARAMETERIZED( testMethod, ... ) \
|
||||
for (auto& i : __VA_ARGS__) \
|
||||
{ \
|
||||
TestFixtureType* fixture = context.makeFixture(); \
|
||||
CPPUNIT_TEST_SUITE_ADD_TEST( \
|
||||
( new CPPUNIT_NS::TestCaller<TestFixtureType>( \
|
||||
context.getTestNameFor(#testMethod, i), \
|
||||
std::bind(&TestFixtureType::testMethod, fixture, i), \
|
||||
fixture))); \
|
||||
}
|
||||
|
||||
/*! \brief Add a test which fail if the specified exception is not caught.
|
||||
*
|
||||
* Example:
|
||||
* \code
|
||||
* #include <cppunit/extensions/HelperMacros.h>
|
||||
* #include <vector>
|
||||
* class MyTest : public CppUnit::TestFixture {
|
||||
* CPPUNIT_TEST_SUITE( MyTest );
|
||||
* CPPUNIT_TEST_EXCEPTION( testVectorAtThrow, std::out_of_range );
|
||||
* CPPUNIT_TEST_SUITE_END();
|
||||
* public:
|
||||
* void testVectorAtThrow()
|
||||
* {
|
||||
* std::vector<int> v;
|
||||
* v.at( 1 ); // must throw exception std::out_of_range
|
||||
* }
|
||||
* };
|
||||
* \endcode
|
||||
*
|
||||
* \param testMethod Name of the method of the test case to add to the suite.
|
||||
* \param ExceptionType Type of the exception that must be thrown by the test
|
||||
* method.
|
||||
* \deprecated Use the assertion macro CPPUNIT_ASSERT_THROW instead.
|
||||
*/
|
||||
#define CPPUNIT_TEST_EXCEPTION( testMethod, ExceptionType ) \
|
||||
CPPUNIT_TEST_SUITE_ADD_TEST( \
|
||||
(new CPPUNIT_NS::ExceptionTestCaseDecorator< ExceptionType >( \
|
||||
new CPPUNIT_NS::TestCaller< TestFixtureType >( \
|
||||
context.getTestNameFor( #testMethod ), \
|
||||
&TestFixtureType::testMethod, \
|
||||
context.makeFixture() ) ) ) )
|
||||
|
||||
/*! \brief Adds a test case which is excepted to fail.
|
||||
*
|
||||
* The added test case expect an assertion to fail. You usually used that type
|
||||
* of test case when testing custom assertion macros.
|
||||
*
|
||||
* \code
|
||||
* CPPUNIT_TEST_FAIL( testAssertFalseFail );
|
||||
*
|
||||
* void testAssertFalseFail()
|
||||
* {
|
||||
* CPPUNIT_ASSERT( false );
|
||||
* }
|
||||
* \endcode
|
||||
* \see CreatingNewAssertions.
|
||||
* \deprecated Use the assertion macro CPPUNIT_ASSERT_ASSERTION_FAIL instead.
|
||||
*/
|
||||
#define CPPUNIT_TEST_FAIL( testMethod ) \
|
||||
CPPUNIT_TEST_EXCEPTION( testMethod, CPPUNIT_NS::Exception )
|
||||
|
||||
/*! \brief Adds some custom test cases.
|
||||
*
|
||||
* Use this to add one or more test cases to the fixture suite. The specified
|
||||
* method is called with a context parameter that can be used to name,
|
||||
* instantiate fixture, and add instantiated test case to the fixture suite.
|
||||
* The specified method must have the following signature:
|
||||
* \code
|
||||
* static void aMethodName( TestSuiteBuilderContextType &context );
|
||||
* \endcode
|
||||
*
|
||||
* \c TestSuiteBuilderContextType is typedef to
|
||||
* TestSuiteBuilderContext<TestFixtureType> declared by CPPUNIT_TEST_SUITE().
|
||||
*
|
||||
* Here is an example that add two custom tests:
|
||||
*
|
||||
* \code
|
||||
* #include <cppunit/extensions/HelperMacros.h>
|
||||
*
|
||||
* class MyTest : public CppUnit::TestFixture {
|
||||
* CPPUNIT_TEST_SUITE( MyTest );
|
||||
* CPPUNIT_TEST_SUITE_ADD_CUSTOM_TESTS( addTimeOutTests );
|
||||
* CPPUNIT_TEST_SUITE_END();
|
||||
* public:
|
||||
* static void addTimeOutTests( TestSuiteBuilderContextType &context )
|
||||
* {
|
||||
* context.addTest( new TimeOutTestCaller( context.getTestNameFor( "test1" ) ),
|
||||
* &MyTest::test1,
|
||||
* context.makeFixture(),
|
||||
* 5.0 );
|
||||
* context.addTest( new TimeOutTestCaller( context.getTestNameFor( "test2" ) ),
|
||||
* &MyTest::test2,
|
||||
* context.makeFixture(),
|
||||
* 5.0 );
|
||||
* }
|
||||
*
|
||||
* void test1()
|
||||
* {
|
||||
* // Do some test that may never end...
|
||||
* }
|
||||
*
|
||||
* void test2()
|
||||
* {
|
||||
* // Do some test that may never end...
|
||||
* }
|
||||
* };
|
||||
* \endcode
|
||||
* @param testAdderMethod Name of the method called to add the test cases.
|
||||
*/
|
||||
#define CPPUNIT_TEST_SUITE_ADD_CUSTOM_TESTS( testAdderMethod ) \
|
||||
testAdderMethod( context )
|
||||
|
||||
/*! \brief Adds a property to the test suite builder context.
|
||||
* \param APropertyKey Key of the property to add.
|
||||
* \param APropertyValue Value for the added property.
|
||||
* Example:
|
||||
* \code
|
||||
* CPPUNIT_TEST_SUITE_PROPERTY("XmlFileName", "paraTest.xml"); \endcode
|
||||
*/
|
||||
#define CPPUNIT_TEST_SUITE_PROPERTY( APropertyKey, APropertyValue ) \
|
||||
context.addProperty( std::string(APropertyKey), \
|
||||
std::string(APropertyValue) )
|
||||
|
||||
/** @}
|
||||
*/
|
||||
|
||||
|
||||
/*! Adds the specified fixture suite to the unnamed registry.
|
||||
* \ingroup CreatingTestSuite
|
||||
*
|
||||
* This macro declares a static variable whose construction
|
||||
* causes a test suite factory to be inserted in a global registry
|
||||
* of such factories. The registry is available by calling
|
||||
* the static function CppUnit::TestFactoryRegistry::getRegistry().
|
||||
*
|
||||
* \param ATestFixtureType Type of the test case class.
|
||||
* \warning This macro should be used only once per line of code (the line
|
||||
* number is used to name a hidden static variable).
|
||||
* \see CPPUNIT_TEST_SUITE_NAMED_REGISTRATION
|
||||
* \see CPPUNIT_REGISTRY_ADD_TO_DEFAULT
|
||||
* \see CPPUNIT_REGISTRY_ADD
|
||||
* \see CPPUNIT_TEST_SUITE, CppUnit::AutoRegisterSuite,
|
||||
* CppUnit::TestFactoryRegistry.
|
||||
*/
|
||||
#define CPPUNIT_TEST_SUITE_REGISTRATION( ATestFixtureType ) \
|
||||
static CPPUNIT_NS::AutoRegisterSuite< ATestFixtureType > \
|
||||
CPPUNIT_MAKE_UNIQUE_NAME(autoRegisterRegistry__ )
|
||||
|
||||
|
||||
/** Adds the specified fixture suite to the specified registry suite.
|
||||
* \ingroup CreatingTestSuite
|
||||
*
|
||||
* This macro declares a static variable whose construction
|
||||
* causes a test suite factory to be inserted in the global registry
|
||||
* suite of the specified name. The registry is available by calling
|
||||
* the static function CppUnit::TestFactoryRegistry::getRegistry().
|
||||
*
|
||||
* For the suite name, use a string returned by a static function rather
|
||||
* than a hardcoded string. That way, you can know what are the name of
|
||||
* named registry and you don't risk mistyping the registry name.
|
||||
*
|
||||
* \code
|
||||
* // MySuites.h
|
||||
* namespace MySuites {
|
||||
* std::string math() {
|
||||
* return "Math";
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* // ComplexNumberTest.cpp
|
||||
* #include "MySuites.h"
|
||||
*
|
||||
* CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ComplexNumberTest, MySuites::math() );
|
||||
* \endcode
|
||||
*
|
||||
* \param ATestFixtureType Type of the test case class.
|
||||
* \param suiteName Name of the global registry suite the test suite is
|
||||
* registered into.
|
||||
* \warning This macro should be used only once per line of code (the line
|
||||
* number is used to name a hidden static variable).
|
||||
* \see CPPUNIT_TEST_SUITE_REGISTRATION
|
||||
* \see CPPUNIT_REGISTRY_ADD_TO_DEFAULT
|
||||
* \see CPPUNIT_REGISTRY_ADD
|
||||
* \see CPPUNIT_TEST_SUITE, CppUnit::AutoRegisterSuite,
|
||||
* CppUnit::TestFactoryRegistry..
|
||||
*/
|
||||
#define CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ATestFixtureType, suiteName ) \
|
||||
static CPPUNIT_NS::AutoRegisterSuite< ATestFixtureType > \
|
||||
CPPUNIT_MAKE_UNIQUE_NAME(autoRegisterRegistry__ )(suiteName)
|
||||
|
||||
/*! Adds that the specified registry suite to another registry suite.
|
||||
* \ingroup CreatingTestSuite
|
||||
*
|
||||
* Use this macros to automatically create test registry suite hierarchy. For example,
|
||||
* if you want to create the following hierarchy:
|
||||
* - Math
|
||||
* - IntegerMath
|
||||
* - FloatMath
|
||||
* - FastFloat
|
||||
* - StandardFloat
|
||||
*
|
||||
* You can do this automatically with:
|
||||
* \code
|
||||
* CPPUNIT_REGISTRY_ADD( "FastFloat", "FloatMath" );
|
||||
* CPPUNIT_REGISTRY_ADD( "IntegerMath", "Math" );
|
||||
* CPPUNIT_REGISTRY_ADD( "FloatMath", "Math" );
|
||||
* CPPUNIT_REGISTRY_ADD( "StandardFloat", "FloatMath" );
|
||||
* \endcode
|
||||
*
|
||||
* There is no specific order of declaration. Think of it as declaring links.
|
||||
*
|
||||
* You register the test in each suite using CPPUNIT_TEST_SUITE_NAMED_REGISTRATION.
|
||||
*
|
||||
* \param which Name of the registry suite to add to the registry suite named \a to.
|
||||
* \param to Name of the registry suite \a which is added to.
|
||||
* \see CPPUNIT_REGISTRY_ADD_TO_DEFAULT, CPPUNIT_TEST_SUITE_NAMED_REGISTRATION.
|
||||
*/
|
||||
#define CPPUNIT_REGISTRY_ADD( which, to ) \
|
||||
static CPPUNIT_NS::AutoRegisterRegistry \
|
||||
CPPUNIT_MAKE_UNIQUE_NAME( autoRegisterRegistry__ )( which, to )
|
||||
|
||||
/*! Adds that the specified registry suite to the default registry suite.
|
||||
* \ingroup CreatingTestSuite
|
||||
*
|
||||
* This macro is just like CPPUNIT_REGISTRY_ADD except the specified registry
|
||||
* suite is added to the default suite (root suite).
|
||||
*
|
||||
* \param which Name of the registry suite to add to the default registry suite.
|
||||
* \see CPPUNIT_REGISTRY_ADD.
|
||||
*/
|
||||
#define CPPUNIT_REGISTRY_ADD_TO_DEFAULT( which ) \
|
||||
static CPPUNIT_NS::AutoRegisterRegistry \
|
||||
CPPUNIT_MAKE_UNIQUE_NAME( autoRegisterRegistry__ )( which )
|
||||
|
||||
// Backwards compatibility
|
||||
// (Not tested!)
|
||||
|
||||
#if CPPUNIT_ENABLE_CU_TEST_MACROS
|
||||
|
||||
#define CU_TEST_SUITE(tc) CPPUNIT_TEST_SUITE(tc)
|
||||
#define CU_TEST_SUB_SUITE(tc,sc) CPPUNIT_TEST_SUB_SUITE(tc,sc)
|
||||
#define CU_TEST(tm) CPPUNIT_TEST(tm)
|
||||
#define CU_TEST_SUITE_END() CPPUNIT_TEST_SUITE_END()
|
||||
#define CU_TEST_SUITE_REGISTRATION(tc) CPPUNIT_TEST_SUITE_REGISTRATION(tc)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif // CPPUNIT_EXTENSIONS_HELPERMACROS_H
|
||||
95
3rdparty/cppunit/include/cppunit/extensions/Orthodox.h
vendored
Normal file
95
3rdparty/cppunit/include/cppunit/extensions/Orthodox.h
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
#ifndef CPPUNIT_EXTENSIONS_ORTHODOX_H
|
||||
#define CPPUNIT_EXTENSIONS_ORTHODOX_H
|
||||
|
||||
#include <cppunit/TestCase.h>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
/*
|
||||
* Orthodox performs a simple set of tests on an arbitary
|
||||
* class to make sure that it supports at least the
|
||||
* following operations:
|
||||
*
|
||||
* default construction - constructor
|
||||
* equality/inequality - operator== && operator!=
|
||||
* assignment - operator=
|
||||
* negation - operator!
|
||||
* safe passage - copy construction
|
||||
*
|
||||
* If operations for each of these are not declared
|
||||
* the template will not instantiate. If it does
|
||||
* instantiate, tests are performed to make sure
|
||||
* that the operations have correct semantics.
|
||||
*
|
||||
* Adding an orthodox test to a suite is very
|
||||
* easy:
|
||||
*
|
||||
* public: Test *suite () {
|
||||
* TestSuite *suiteOfTests = new TestSuite;
|
||||
* suiteOfTests->addTest (new ComplexNumberTest ("testAdd");
|
||||
* suiteOfTests->addTest (new TestCaller<Orthodox<Complex> > ());
|
||||
* return suiteOfTests;
|
||||
* }
|
||||
*
|
||||
* Templated test cases be very useful when you are want to
|
||||
* make sure that a group of classes have the same form.
|
||||
*
|
||||
* see TestSuite
|
||||
*/
|
||||
|
||||
|
||||
template <class ClassUnderTest> class Orthodox : public TestCase
|
||||
{
|
||||
public:
|
||||
Orthodox () : TestCase ("Orthodox") {}
|
||||
|
||||
protected:
|
||||
ClassUnderTest call (ClassUnderTest object);
|
||||
void runTest ();
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
// Run an orthodoxy test
|
||||
template <class ClassUnderTest> void Orthodox<ClassUnderTest>::runTest ()
|
||||
{
|
||||
// make sure we have a default constructor
|
||||
ClassUnderTest a, b, c;
|
||||
|
||||
// make sure we have an equality operator
|
||||
CPPUNIT_ASSERT (a == b);
|
||||
|
||||
// check the inverse
|
||||
b.operator= (a.operator! ());
|
||||
CPPUNIT_ASSERT (a != b);
|
||||
|
||||
// double inversion
|
||||
b = !!a;
|
||||
CPPUNIT_ASSERT (a == b);
|
||||
|
||||
// invert again
|
||||
b = !a;
|
||||
|
||||
// check calls
|
||||
c = a;
|
||||
CPPUNIT_ASSERT (c == call (a));
|
||||
|
||||
c = b;
|
||||
CPPUNIT_ASSERT (c == call (b));
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Exercise a call
|
||||
template <class ClassUnderTest>
|
||||
ClassUnderTest Orthodox<ClassUnderTest>::call (ClassUnderTest object)
|
||||
{
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif
|
||||
43
3rdparty/cppunit/include/cppunit/extensions/RepeatedTest.h
vendored
Normal file
43
3rdparty/cppunit/include/cppunit/extensions/RepeatedTest.h
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef CPPUNIT_EXTENSIONS_REPEATEDTEST_H
|
||||
#define CPPUNIT_EXTENSIONS_REPEATEDTEST_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
#include <cppunit/extensions/TestDecorator.h>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
class Test;
|
||||
class TestResult;
|
||||
|
||||
|
||||
/*! \brief Decorator that runs a test repeatedly.
|
||||
*
|
||||
* Does not assume ownership of the test it decorates
|
||||
*/
|
||||
class CPPUNIT_API RepeatedTest : public TestDecorator
|
||||
{
|
||||
public:
|
||||
RepeatedTest( Test *test,
|
||||
int timesRepeat ) :
|
||||
TestDecorator( test ),
|
||||
m_timesRepeat(timesRepeat)
|
||||
{
|
||||
}
|
||||
|
||||
void run( TestResult *result );
|
||||
|
||||
int countTestCases() const;
|
||||
|
||||
private:
|
||||
RepeatedTest( const RepeatedTest & );
|
||||
void operator=( const RepeatedTest & );
|
||||
|
||||
const int m_timesRepeat;
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
|
||||
#endif // CPPUNIT_EXTENSIONS_REPEATEDTEST_H
|
||||
47
3rdparty/cppunit/include/cppunit/extensions/TestCaseDecorator.h
vendored
Normal file
47
3rdparty/cppunit/include/cppunit/extensions/TestCaseDecorator.h
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef CPPUNIT_EXTENSIONS_TESTCASEDECORATOR_H
|
||||
#define CPPUNIT_EXTENSIONS_TESTCASEDECORATOR_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
#include <cppunit/TestCase.h>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
/*! \brief Decorator for Test cases.
|
||||
*
|
||||
* TestCaseDecorator provides an alternate means to extend functionality
|
||||
* of a test class without subclassing the test. Instead, one can
|
||||
* subclass the decorater and use it to wrap the test class.
|
||||
*
|
||||
* Assumes ownership of the test it decorates
|
||||
*/
|
||||
class CPPUNIT_API TestCaseDecorator : public TestCase
|
||||
{
|
||||
public:
|
||||
TestCaseDecorator( TestCase *test );
|
||||
~TestCaseDecorator();
|
||||
|
||||
std::string getName() const;
|
||||
|
||||
void setUp();
|
||||
|
||||
void tearDown();
|
||||
|
||||
void runTest();
|
||||
|
||||
protected:
|
||||
TestCase *m_test;
|
||||
|
||||
private:
|
||||
|
||||
//prevent the creation of copy c'tor and operator=
|
||||
TestCaseDecorator( const TestCaseDecorator& );
|
||||
TestCaseDecorator& operator=( const TestCaseDecorator& );
|
||||
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif
|
||||
|
||||
49
3rdparty/cppunit/include/cppunit/extensions/TestDecorator.h
vendored
Normal file
49
3rdparty/cppunit/include/cppunit/extensions/TestDecorator.h
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
#ifndef CPPUNIT_EXTENSIONS_TESTDECORATOR_H
|
||||
#define CPPUNIT_EXTENSIONS_TESTDECORATOR_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
#include <cppunit/Test.h>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
class TestResult;
|
||||
|
||||
|
||||
/*! \brief Decorator for Tests.
|
||||
*
|
||||
* TestDecorator provides an alternate means to extend functionality
|
||||
* of a test class without subclassing the test. Instead, one can
|
||||
* subclass the decorater and use it to wrap the test class.
|
||||
*
|
||||
* Assumes ownership of the test it decorates
|
||||
*/
|
||||
class CPPUNIT_API TestDecorator : public Test
|
||||
{
|
||||
public:
|
||||
TestDecorator( Test *test );
|
||||
~TestDecorator();
|
||||
|
||||
int countTestCases() const;
|
||||
|
||||
std::string getName() const;
|
||||
|
||||
void run( TestResult *result );
|
||||
|
||||
int getChildTestCount() const;
|
||||
|
||||
protected:
|
||||
Test *doGetChildTestAt( int index ) const;
|
||||
|
||||
Test *m_test;
|
||||
|
||||
private:
|
||||
TestDecorator( const TestDecorator &);
|
||||
void operator =( const TestDecorator & );
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif
|
||||
|
||||
27
3rdparty/cppunit/include/cppunit/extensions/TestFactory.h
vendored
Normal file
27
3rdparty/cppunit/include/cppunit/extensions/TestFactory.h
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef CPPUNIT_EXTENSIONS_TESTFACTORY_H
|
||||
#define CPPUNIT_EXTENSIONS_TESTFACTORY_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
class Test;
|
||||
|
||||
/*! \brief Abstract Test factory.
|
||||
*/
|
||||
class CPPUNIT_API TestFactory
|
||||
{
|
||||
public:
|
||||
virtual ~TestFactory() {}
|
||||
|
||||
/*! Makes a new test.
|
||||
* \return A new Test.
|
||||
*/
|
||||
virtual Test* makeTest() = 0;
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // CPPUNIT_EXTENSIONS_TESTFACTORY_H
|
||||
177
3rdparty/cppunit/include/cppunit/extensions/TestFactoryRegistry.h
vendored
Normal file
177
3rdparty/cppunit/include/cppunit/extensions/TestFactoryRegistry.h
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
#ifndef CPPUNIT_EXTENSIONS_TESTFACTORYREGISTRY_H
|
||||
#define CPPUNIT_EXTENSIONS_TESTFACTORYREGISTRY_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
|
||||
#if CPPUNIT_NEED_DLL_DECL
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable: 4251) // X needs to have dll-interface to be used by clients of class Z
|
||||
#endif
|
||||
|
||||
#include <set>
|
||||
#include <cppunit/extensions/TestFactory.h>
|
||||
#include <string>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
class TestSuite;
|
||||
|
||||
/*! \brief Registry for TestFactory.
|
||||
* \ingroup CreatingTestSuite
|
||||
*
|
||||
* Notes that the registry \b DON'T assumes lifetime control for any registered tests
|
||||
* anymore.
|
||||
*
|
||||
* The <em>default</em> registry is the registry returned by getRegistry() with the
|
||||
* default name parameter value.
|
||||
*
|
||||
* To register tests, use the macros:
|
||||
* - CPPUNIT_TEST_SUITE_REGISTRATION(): to add tests in the default registry.
|
||||
* - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(): to add tests in a named registry.
|
||||
*
|
||||
* Example 1: retreiving a suite that contains all the test registered with
|
||||
* CPPUNIT_TEST_SUITE_REGISTRATION().
|
||||
* \code
|
||||
* CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry();
|
||||
* CppUnit::TestSuite *suite = registry.makeTest();
|
||||
* \endcode
|
||||
*
|
||||
* Example 2: retreiving a suite that contains all the test registered with
|
||||
* \link CPPUNIT_TEST_SUITE_NAMED_REGISTRATION() CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ..., "Math" )\endlink.
|
||||
* \code
|
||||
* CppUnit::TestFactoryRegistry &mathRegistry = CppUnit::TestFactoryRegistry::getRegistry( "Math" );
|
||||
* CppUnit::TestSuite *mathSuite = mathRegistry.makeTest();
|
||||
* \endcode
|
||||
*
|
||||
* Example 3: creating a test suite hierarchy composed of unnamed registration and
|
||||
* named registration:
|
||||
* - All Tests
|
||||
* - tests registered with CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ..., "Graph" )
|
||||
* - tests registered with CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ..., "Math" )
|
||||
* - tests registered with CPPUNIT_TEST_SUITE_REGISTRATION
|
||||
*
|
||||
* \code
|
||||
* CppUnit::TestSuite *rootSuite = new CppUnit::TestSuite( "All tests" );
|
||||
* rootSuite->addTest( CppUnit::TestFactoryRegistry::getRegistry( "Graph" ).makeTest() );
|
||||
* rootSuite->addTest( CppUnit::TestFactoryRegistry::getRegistry( "Math" ).makeTest() );
|
||||
* CppUnit::TestFactoryRegistry::getRegistry().addTestToSuite( rootSuite );
|
||||
* \endcode
|
||||
*
|
||||
* The same result can be obtained with:
|
||||
* \code
|
||||
* CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry();
|
||||
* registry.addRegistry( "Graph" );
|
||||
* registry.addRegistry( "Math" );
|
||||
* CppUnit::TestSuite *suite = registry.makeTest();
|
||||
* \endcode
|
||||
*
|
||||
* Since a TestFactoryRegistry is a TestFactory, the named registries can be
|
||||
* registered in the unnamed registry, creating the hierarchy links.
|
||||
*
|
||||
* \see TestSuiteFactory, AutoRegisterSuite
|
||||
* \see CPPUNIT_TEST_SUITE_REGISTRATION, CPPUNIT_TEST_SUITE_NAMED_REGISTRATION
|
||||
*/
|
||||
class CPPUNIT_API TestFactoryRegistry : public TestFactory
|
||||
{
|
||||
public:
|
||||
/** Constructs the registry with the specified name.
|
||||
* \param name Name of the registry. It is the name of TestSuite returned by
|
||||
* makeTest().
|
||||
*/
|
||||
TestFactoryRegistry( std::string name );
|
||||
|
||||
/// Destructor.
|
||||
virtual ~TestFactoryRegistry();
|
||||
|
||||
/** Returns a new TestSuite that contains the registered test.
|
||||
* \return A new TestSuite which contains all the test added using
|
||||
* registerFactory(TestFactory *).
|
||||
*/
|
||||
virtual Test *makeTest();
|
||||
|
||||
/** Returns a named registry.
|
||||
*
|
||||
* If the \a name is left to its default value, then the registry that is returned is
|
||||
* the one used by CPPUNIT_TEST_SUITE_REGISTRATION(): the 'top' level registry.
|
||||
*
|
||||
* \param name Name of the registry to return.
|
||||
* \return Registry. If the registry does not exist, it is created with the
|
||||
* specified name.
|
||||
*/
|
||||
static TestFactoryRegistry &getRegistry( const std::string &name = "All Tests" );
|
||||
|
||||
/** Adds the registered tests to the specified suite.
|
||||
* \param suite Suite the tests are added to.
|
||||
*/
|
||||
void addTestToSuite( TestSuite *suite );
|
||||
|
||||
/** Adds the specified TestFactory to the registry.
|
||||
*
|
||||
* \param factory Factory to register.
|
||||
*/
|
||||
void registerFactory( TestFactory *factory );
|
||||
|
||||
/*! Removes the specified TestFactory from the registry.
|
||||
*
|
||||
* The specified factory is not destroyed.
|
||||
* \param factory Factory to remove from the registry.
|
||||
* \todo Address case when trying to remove a TestRegistryFactory.
|
||||
*/
|
||||
void unregisterFactory( TestFactory *factory );
|
||||
|
||||
/*! Adds a registry to the registry.
|
||||
*
|
||||
* Convenience method to help create test hierarchy. See TestFactoryRegistry detail
|
||||
* for examples of use. Calling this method is equivalent to:
|
||||
* \code
|
||||
* this->registerFactory( TestFactoryRegistry::getRegistry( name ) );
|
||||
* \endcode
|
||||
*
|
||||
* \param name Name of the registry to add.
|
||||
*/
|
||||
void addRegistry( const std::string &name );
|
||||
|
||||
/*! Tests if the registry is valid.
|
||||
*
|
||||
* This method should be used when unregistering test factory on static variable
|
||||
* destruction to ensure that the registry has not been already destroyed (in
|
||||
* that case there is no need to unregister the test factory).
|
||||
*
|
||||
* You should not concern yourself with this method unless you are writing a class
|
||||
* like AutoRegisterSuite.
|
||||
*
|
||||
* \return \c true if the specified registry has not been destroyed,
|
||||
* otherwise returns \c false.
|
||||
* \see AutoRegisterSuite.
|
||||
*/
|
||||
static bool isValid();
|
||||
|
||||
/** Adds the specified TestFactory with a specific name (DEPRECATED).
|
||||
* \param name Name associated to the factory.
|
||||
* \param factory Factory to register.
|
||||
* \deprecated Use registerFactory( TestFactory *) instead.
|
||||
*/
|
||||
void registerFactory( const std::string &name,
|
||||
TestFactory *factory );
|
||||
|
||||
private:
|
||||
TestFactoryRegistry( const TestFactoryRegistry © );
|
||||
void operator =( const TestFactoryRegistry © );
|
||||
|
||||
private:
|
||||
typedef std::set<TestFactory *, std::less<TestFactory*> > Factories;
|
||||
Factories m_factories;
|
||||
|
||||
std::string m_name;
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#if CPPUNIT_NEED_DLL_DECL
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
|
||||
|
||||
#endif // CPPUNIT_EXTENSIONS_TESTFACTORYREGISTRY_H
|
||||
50
3rdparty/cppunit/include/cppunit/extensions/TestFixtureFactory.h
vendored
Normal file
50
3rdparty/cppunit/include/cppunit/extensions/TestFixtureFactory.h
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
#ifndef CPPUNIT_EXTENSIONS_TESTFIXTUREFACTORY_H
|
||||
#define CPPUNIT_EXTENSIONS_TESTFIXTUREFACTORY_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
class TestFixture;
|
||||
|
||||
/*! \brief Abstract TestFixture factory (Implementation).
|
||||
*
|
||||
* Implementation detail. Use by HelperMacros to handle TestFixture hierarchy.
|
||||
*/
|
||||
class TestFixtureFactory
|
||||
{
|
||||
public:
|
||||
//! Creates a new TestFixture instance.
|
||||
virtual TestFixture *makeFixture() =0;
|
||||
|
||||
virtual ~TestFixtureFactory() {}
|
||||
};
|
||||
|
||||
|
||||
/*! \brief Concret TestFixture factory (Implementation).
|
||||
*
|
||||
* Implementation detail. Use by HelperMacros to handle TestFixture hierarchy.
|
||||
*/
|
||||
template<class TestFixtureType>
|
||||
class ConcretTestFixtureFactory : public CPPUNIT_NS::TestFixtureFactory
|
||||
{
|
||||
/*! \brief Returns a new TestFixture instance.
|
||||
* \return A new fixture instance. The fixture instance is returned by
|
||||
* the TestFixtureFactory passed on construction. The actual type
|
||||
* is that of the fixture on which the static method suite()
|
||||
* was called.
|
||||
*/
|
||||
TestFixture *makeFixture()
|
||||
{
|
||||
return new TestFixtureType();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
|
||||
#endif // CPPUNIT_EXTENSIONS_TESTFIXTUREFACTORY_H
|
||||
|
||||
80
3rdparty/cppunit/include/cppunit/extensions/TestNamer.h
vendored
Normal file
80
3rdparty/cppunit/include/cppunit/extensions/TestNamer.h
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
#ifndef CPPUNIT_EXTENSIONS_TESTNAMER_H
|
||||
#define CPPUNIT_EXTENSIONS_TESTNAMER_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
#include <string>
|
||||
#include <cppunit/tools/StringHelper.h>
|
||||
|
||||
#include <typeinfo>
|
||||
|
||||
|
||||
|
||||
/*! \def CPPUNIT_TESTNAMER_DECL( variableName, FixtureType )
|
||||
* \brief Declares a TestNamer.
|
||||
*
|
||||
* Declares a TestNamer for the specified type
|
||||
*
|
||||
* \code
|
||||
* void someMethod()
|
||||
* {
|
||||
* CPPUNIT_TESTNAMER_DECL( namer, AFixtureType );
|
||||
* std::string fixtureName = namer.getFixtureName();
|
||||
* ...
|
||||
* \endcode
|
||||
*
|
||||
* \relates TestNamer
|
||||
* \see TestNamer
|
||||
*/
|
||||
# define CPPUNIT_TESTNAMER_DECL( variableName, FixtureType ) \
|
||||
CPPUNIT_NS::TestNamer variableName( typeid(FixtureType) )
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
/*! \brief Names a test or a fixture suite.
|
||||
*
|
||||
* TestNamer is usually instantiated using CPPUNIT_TESTNAMER_DECL.
|
||||
*
|
||||
*/
|
||||
class CPPUNIT_API TestNamer
|
||||
{
|
||||
public:
|
||||
/*! \brief Constructs a namer using the fixture's type-info.
|
||||
* \param typeInfo Type-info of the fixture type. Use to name the fixture suite.
|
||||
*/
|
||||
TestNamer( const std::type_info &typeInfo );
|
||||
|
||||
/*! \brief Constructs a namer using the specified fixture name.
|
||||
* \param fixtureName Name of the fixture suite. Usually extracted using a macro.
|
||||
*/
|
||||
TestNamer( const std::string &fixtureName );
|
||||
|
||||
virtual ~TestNamer();
|
||||
|
||||
/*! \brief Returns the name of the fixture.
|
||||
* \return Name of the fixture.
|
||||
*/
|
||||
virtual std::string getFixtureName() const;
|
||||
|
||||
/*! \brief Returns the name of the test for the specified method.
|
||||
* \param testMethodName Name of the method that implements a test.
|
||||
* \return A string that is the concatenation of the test fixture name
|
||||
* (returned by getFixtureName()) and\a testMethodName,
|
||||
* separated using '::'. This provides a fairly unique name for a given
|
||||
* test.
|
||||
*/
|
||||
virtual std::string getTestNameFor( const std::string &testMethodName ) const;
|
||||
|
||||
template<typename E>
|
||||
std::string getTestNameFor( const std::string& testMethodName, const E& val) const
|
||||
{
|
||||
return getTestNameFor(testMethodName) + " with parameter: " + CPPUNIT_NS::StringHelper::toString(val);
|
||||
}
|
||||
|
||||
protected:
|
||||
std::string m_fixtureName;
|
||||
};
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // CPPUNIT_EXTENSIONS_TESTNAMER_H
|
||||
|
||||
34
3rdparty/cppunit/include/cppunit/extensions/TestSetUp.h
vendored
Normal file
34
3rdparty/cppunit/include/cppunit/extensions/TestSetUp.h
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef CPPUNIT_EXTENSIONS_TESTSETUP_H
|
||||
#define CPPUNIT_EXTENSIONS_TESTSETUP_H
|
||||
|
||||
#include <cppunit/extensions/TestDecorator.h>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
class Test;
|
||||
class TestResult;
|
||||
|
||||
/*! \brief Decorates a test by providing a specific setUp() and tearDown().
|
||||
*/
|
||||
class CPPUNIT_API TestSetUp : public TestDecorator
|
||||
{
|
||||
public:
|
||||
TestSetUp( Test *test );
|
||||
|
||||
void run( TestResult *result );
|
||||
|
||||
protected:
|
||||
virtual void setUp();
|
||||
virtual void tearDown();
|
||||
|
||||
private:
|
||||
TestSetUp( const TestSetUp & );
|
||||
void operator =( const TestSetUp & );
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // CPPUNIT_EXTENSIONS_TESTSETUP_H
|
||||
|
||||
146
3rdparty/cppunit/include/cppunit/extensions/TestSuiteBuilderContext.h
vendored
Normal file
146
3rdparty/cppunit/include/cppunit/extensions/TestSuiteBuilderContext.h
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
#ifndef CPPUNIT_HELPER_TESTSUITEBUILDERCONTEXT_H
|
||||
#define CPPUNIT_HELPER_TESTSUITEBUILDERCONTEXT_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#if CPPUNIT_NEED_DLL_DECL
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z
|
||||
#endif
|
||||
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
class TestSuite;
|
||||
class TestFixture;
|
||||
class TestFixtureFactory;
|
||||
class TestNamer;
|
||||
|
||||
/*! \brief Context used when creating test suite in HelperMacros.
|
||||
*
|
||||
* Base class for all context used when creating test suite. The
|
||||
* actual context type during test suite creation is TestSuiteBuilderContext.
|
||||
*
|
||||
* \sa CPPUNIT_TEST_SUITE, CPPUNIT_TEST_SUITE_ADD_TEST,
|
||||
* CPPUNIT_TEST_SUITE_ADD_CUSTOM_TESTS.
|
||||
*/
|
||||
class CPPUNIT_API TestSuiteBuilderContextBase
|
||||
{
|
||||
public:
|
||||
/*! \brief Constructs a new context.
|
||||
*
|
||||
* You should not use this. The context is created in
|
||||
* CPPUNIT_TEST_SUITE().
|
||||
*/
|
||||
TestSuiteBuilderContextBase( TestSuite &suite,
|
||||
const TestNamer &namer,
|
||||
TestFixtureFactory &factory );
|
||||
|
||||
virtual ~TestSuiteBuilderContextBase();
|
||||
|
||||
/*! \brief Adds a test to the fixture suite.
|
||||
*
|
||||
* \param test Test to add to the fixture suite. Must not be \c NULL.
|
||||
*/
|
||||
void addTest( Test *test );
|
||||
|
||||
/*! \brief Returns the fixture name.
|
||||
* \return Fixture name. It is the name used to name the fixture
|
||||
* suite.
|
||||
*/
|
||||
std::string getFixtureName() const;
|
||||
|
||||
/*! \brief Returns the name of the test for the specified method.
|
||||
*
|
||||
* \param testMethodName Name of the method that implements a test.
|
||||
* \return A string that is the concatenation of the test fixture name
|
||||
* (returned by getFixtureName()) and\a testMethodName,
|
||||
* separated using '::'. This provides a fairly unique name for a given
|
||||
* test.
|
||||
*/
|
||||
std::string getTestNameFor( const std::string &testMethodName ) const;
|
||||
|
||||
/*! \brief Returns the name of the test for the specified method with the corresponding parameter.
|
||||
*
|
||||
* \param testMethodName Name (including a parameter) of the method that implements a test.
|
||||
* \return A string that is the concatenation of the test fixture name
|
||||
* (returned by getFixtureName()), \a testMethodName,
|
||||
* separated using '::' and the parameter. This provides a fairly unique name for a given
|
||||
* test. The parameter must be convertable to std::string through operator<<
|
||||
* or a specialization of CPPUNIT_NS::StringHelper::toString needs to exist.
|
||||
*/
|
||||
template<typename T>
|
||||
std::string getTestNameFor( const std::string &testMethodName, const T& value ) const
|
||||
{
|
||||
return m_namer.getTestNameFor(testMethodName, value);
|
||||
}
|
||||
|
||||
/*! \brief Adds property pair.
|
||||
* \param key PropertyKey string to add.
|
||||
* \param value PropertyValue string to add.
|
||||
*/
|
||||
void addProperty( const std::string &key,
|
||||
const std::string &value );
|
||||
|
||||
/*! \brief Returns property value assigned to param key.
|
||||
* \param key PropertyKey string.
|
||||
*/
|
||||
const std::string getStringProperty( const std::string &key ) const;
|
||||
|
||||
protected:
|
||||
TestFixture *makeTestFixture() const;
|
||||
|
||||
// Notes: we use a vector here instead of a map to work-around the
|
||||
// shared std::map in dll bug in VC6.
|
||||
// See http://www.dinkumware.com/vc_fixes.html for detail.
|
||||
typedef std::pair<std::string,std::string> Property;
|
||||
typedef std::vector<Property> Properties;
|
||||
|
||||
TestSuite &m_suite;
|
||||
const TestNamer &m_namer;
|
||||
TestFixtureFactory &m_factory;
|
||||
|
||||
private:
|
||||
Properties m_properties;
|
||||
};
|
||||
|
||||
|
||||
/*! \brief Type-sage context used when creating test suite in HelperMacros.
|
||||
*
|
||||
* \sa TestSuiteBuilderContextBase.
|
||||
*/
|
||||
template<class Fixture>
|
||||
class TestSuiteBuilderContext : public TestSuiteBuilderContextBase
|
||||
{
|
||||
public:
|
||||
typedef Fixture FixtureType;
|
||||
|
||||
TestSuiteBuilderContext( TestSuiteBuilderContextBase &contextBase )
|
||||
: TestSuiteBuilderContextBase( contextBase )
|
||||
{
|
||||
}
|
||||
|
||||
/*! \brief Returns a new TestFixture instance.
|
||||
* \return A new fixture instance. The fixture instance is returned by
|
||||
* the TestFixtureFactory passed on construction. The actual type
|
||||
* is that of the fixture on which the static method suite()
|
||||
* was called.
|
||||
*/
|
||||
FixtureType *makeFixture() const
|
||||
{
|
||||
return CPPUNIT_STATIC_CAST( FixtureType *,
|
||||
TestSuiteBuilderContextBase::makeTestFixture() );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#if CPPUNIT_NEED_DLL_DECL
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
|
||||
#endif // CPPUNIT_HELPER_TESTSUITEBUILDERCONTEXT_H
|
||||
|
||||
27
3rdparty/cppunit/include/cppunit/extensions/TestSuiteFactory.h
vendored
Normal file
27
3rdparty/cppunit/include/cppunit/extensions/TestSuiteFactory.h
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef CPPUNIT_EXTENSIONS_TESTSUITEFACTORY_H
|
||||
#define CPPUNIT_EXTENSIONS_TESTSUITEFACTORY_H
|
||||
|
||||
#include <cppunit/extensions/TestFactory.h>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
class Test;
|
||||
|
||||
/*! \brief TestFactory for TestFixture that implements a static suite() method.
|
||||
* \see AutoRegisterSuite.
|
||||
*/
|
||||
template<class TestCaseType>
|
||||
class TestSuiteFactory : public TestFactory
|
||||
{
|
||||
public:
|
||||
virtual Test *makeTest()
|
||||
{
|
||||
return TestCaseType::suite();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // CPPUNIT_EXTENSIONS_TESTSUITEFACTORY_H
|
||||
27
3rdparty/cppunit/include/cppunit/extensions/TypeInfoHelper.h
vendored
Normal file
27
3rdparty/cppunit/include/cppunit/extensions/TypeInfoHelper.h
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef CPPUNIT_TYPEINFOHELPER_H
|
||||
#define CPPUNIT_TYPEINFOHELPER_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
|
||||
#include <typeinfo>
|
||||
#include <string>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
/**! \brief Helper to use type_info.
|
||||
*/
|
||||
class CPPUNIT_API TypeInfoHelper
|
||||
{
|
||||
public:
|
||||
/*! \brief Get the class name of the specified type_info.
|
||||
* \param info Info which the class name is extracted from.
|
||||
* \return The string returned by type_info::name() without
|
||||
* the "class" prefix. If the name is not prefixed
|
||||
* by "class", it is returned as this.
|
||||
*/
|
||||
static std::string getClassName( const std::type_info &info );
|
||||
};
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // CPPUNIT_TYPEINFOHELPER_H
|
||||
121
3rdparty/cppunit/include/cppunit/plugin/DynamicLibraryManager.h
vendored
Normal file
121
3rdparty/cppunit/include/cppunit/plugin/DynamicLibraryManager.h
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
#ifndef CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGER_H
|
||||
#define CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGER_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
#include <string>
|
||||
|
||||
#if !defined(CPPUNIT_NO_TESTPLUGIN)
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
/*! \brief Manages dynamic libraries.
|
||||
*
|
||||
* The Dynamic Library Manager provides a platform independent way to work with
|
||||
* dynamic library. It load a specific dynamic library, and can returns specific
|
||||
* symbol exported by the dynamic library.
|
||||
*
|
||||
* If an error occurs, a DynamicLibraryManagerException is thrown.
|
||||
*
|
||||
* \internal Implementation of the OS independent methods is in
|
||||
* DynamicLibraryManager.cpp.
|
||||
*
|
||||
* \internal Porting to a new platform:
|
||||
* - Adds platform detection in config/SelectDllLoader.h. Should define a specific
|
||||
* macro for that platform of the form: CPPUNIT_HAVE_XYZ_DLL_LOADER, where
|
||||
* XYZ is the platform.
|
||||
* - Makes a copy of UnixDynamicLibraryManager.cpp and named it after the platform.
|
||||
* - Updated the 'guard' in your file (CPPUNIT_HAVE_XYZ_DLL_LOADER) so that it is
|
||||
* only processed if the matching platform has been detected.
|
||||
* - Change the implementation of methods doLoadLibrary(), doReleaseLibrary(),
|
||||
* doFindSymbol() in your copy. Those methods usually maps directly to OS calls.
|
||||
* - Adds the file to the project.
|
||||
*/
|
||||
class DynamicLibraryManager
|
||||
{
|
||||
public:
|
||||
typedef void *Symbol;
|
||||
typedef void *LibraryHandle;
|
||||
|
||||
/*! \brief Loads the specified library.
|
||||
* \param libraryFileName Name of the library to load.
|
||||
* \exception DynamicLibraryManagerException if a failure occurs while loading
|
||||
* the library (fail to found or load the library).
|
||||
*/
|
||||
DynamicLibraryManager( const std::string &libraryFileName );
|
||||
|
||||
/// Releases the loaded library..
|
||||
~DynamicLibraryManager();
|
||||
|
||||
/*! \brief Returns a pointer on the specified symbol exported by the library.
|
||||
* \param symbol Name of the symbol exported by the library.
|
||||
* \return Pointer on the symbol. Should be casted to the actual type. Never \c NULL.
|
||||
* \exception DynamicLibraryManagerException if the symbol is not found.
|
||||
*/
|
||||
Symbol findSymbol( const std::string &symbol );
|
||||
|
||||
private:
|
||||
/*! Loads the specified library.
|
||||
* \param libraryName Name of the library to load.
|
||||
* \exception DynamicLibraryManagerException if a failure occurs while loading
|
||||
* the library (fail to found or load the library).
|
||||
*/
|
||||
void loadLibrary( const std::string &libraryName );
|
||||
|
||||
/*! Releases the loaded library.
|
||||
*
|
||||
* \warning Must NOT throw any exceptions (called from destructor).
|
||||
*/
|
||||
void releaseLibrary();
|
||||
|
||||
/*! Loads the specified library.
|
||||
*
|
||||
* May throw any exceptions (indicates failure).
|
||||
* \param libraryName Name of the library to load.
|
||||
* \return Handle of the loaded library. \c NULL indicates failure.
|
||||
*/
|
||||
LibraryHandle doLoadLibrary( const std::string &libraryName );
|
||||
|
||||
/*! Releases the loaded library.
|
||||
*
|
||||
* The handle of the library to free is in \c m_libraryHandle. It is never
|
||||
* \c NULL.
|
||||
* \warning Must NOT throw any exceptions (called from destructor).
|
||||
*/
|
||||
void doReleaseLibrary();
|
||||
|
||||
/*! Returns a pointer on the specified symbol exported by the library.
|
||||
*
|
||||
* May throw any exceptions (indicates failure).
|
||||
* \param symbol Name of the symbol exported by the library.
|
||||
* \return Pointer on the symbol. \c NULL indicates failure.
|
||||
*/
|
||||
Symbol doFindSymbol( const std::string &symbol );
|
||||
|
||||
/*! Returns detailed information about doLoadLibrary() failure.
|
||||
*
|
||||
* Called just after a failed call to doLoadLibrary() to get extra
|
||||
* error information.
|
||||
*
|
||||
* \return Detailed information about the failure of the call to
|
||||
* doLoadLibrary() that just failed.
|
||||
*/
|
||||
std::string getLastErrorDetail() const;
|
||||
|
||||
/// Prevents the use of the copy constructor.
|
||||
DynamicLibraryManager( const DynamicLibraryManager © );
|
||||
|
||||
/// Prevents the use of the copy operator.
|
||||
void operator =( const DynamicLibraryManager © );
|
||||
|
||||
private:
|
||||
LibraryHandle m_libraryHandle;
|
||||
std::string m_libraryName;
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // !defined(CPPUNIT_NO_TESTPLUGIN)
|
||||
|
||||
#endif // CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGER_H
|
||||
53
3rdparty/cppunit/include/cppunit/plugin/DynamicLibraryManagerException.h
vendored
Normal file
53
3rdparty/cppunit/include/cppunit/plugin/DynamicLibraryManagerException.h
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
#ifndef CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGEREXCEPTION_H
|
||||
#define CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGEREXCEPTION_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
|
||||
#if !defined(CPPUNIT_NO_TESTPLUGIN)
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
/*! \brief Exception thrown by DynamicLibraryManager when a failure occurs.
|
||||
*
|
||||
* Use getCause() to know what function caused the failure.
|
||||
*
|
||||
*/
|
||||
class DynamicLibraryManagerException : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
enum Cause
|
||||
{
|
||||
/// Failed to load the dynamic library
|
||||
loadingFailed =0,
|
||||
/// Symbol not found in the dynamic library
|
||||
symbolNotFound
|
||||
};
|
||||
|
||||
/// Failed to load the dynamic library or Symbol not found in the dynamic library.
|
||||
DynamicLibraryManagerException( const std::string &libraryName,
|
||||
const std::string &errorDetail,
|
||||
Cause cause );
|
||||
|
||||
~DynamicLibraryManagerException() throw()
|
||||
{
|
||||
}
|
||||
|
||||
Cause getCause() const;
|
||||
|
||||
const char *what() const throw();
|
||||
|
||||
private:
|
||||
std::string m_message;
|
||||
Cause m_cause;
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // !defined(CPPUNIT_NO_TESTPLUGIN)
|
||||
|
||||
#endif // CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGEREXCEPTION_H
|
||||
113
3rdparty/cppunit/include/cppunit/plugin/PlugInManager.h
vendored
Normal file
113
3rdparty/cppunit/include/cppunit/plugin/PlugInManager.h
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
#ifndef CPPUNIT_PLUGIN_PLUGINMANAGER_H
|
||||
#define CPPUNIT_PLUGIN_PLUGINMANAGER_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
|
||||
#if !defined(CPPUNIT_NO_TESTPLUGIN)
|
||||
|
||||
#if CPPUNIT_NEED_DLL_DECL
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z
|
||||
#endif
|
||||
|
||||
#include <cppunit/plugin/PlugInParameters.h>
|
||||
struct CppUnitTestPlugIn;
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
class DynamicLibraryManager;
|
||||
class TestResult;
|
||||
class XmlOutputter;
|
||||
|
||||
|
||||
/*! \brief Manges TestPlugIn.
|
||||
*/
|
||||
class CPPUNIT_API PlugInManager
|
||||
{
|
||||
public:
|
||||
/*! Constructs a PlugInManager object.
|
||||
*/
|
||||
PlugInManager();
|
||||
|
||||
/// Destructor.
|
||||
virtual ~PlugInManager();
|
||||
|
||||
/*! \brief Loads the specified plug-in.
|
||||
*
|
||||
* After being loaded, the CppUnitTestPlugIn::initialize() is called.
|
||||
*
|
||||
* \param libraryFileName Name of the file that contains the TestPlugIn.
|
||||
* \param parameters List of string passed to the plug-in.
|
||||
* \return Pointer on the DynamicLibraryManager associated to the library.
|
||||
* Valid until the library is unloaded. Never \c NULL.
|
||||
* \exception DynamicLibraryManagerException is thrown if an error occurs during loading.
|
||||
*/
|
||||
void load( const std::string &libraryFileName,
|
||||
const PlugInParameters ¶meters = PlugInParameters() );
|
||||
|
||||
/*! \brief Unloads the specified plug-in.
|
||||
* \param libraryFileName Name of the file that contains the TestPlugIn passed
|
||||
* to a previous call to load().
|
||||
*/
|
||||
void unload( const std::string &libraryFileName );
|
||||
|
||||
/*! \brief Gives a chance to each loaded plug-in to register TestListener.
|
||||
*
|
||||
* For each plug-in, call CppUnitTestPlugIn::addListener().
|
||||
*/
|
||||
void addListener( TestResult *eventManager );
|
||||
|
||||
/*! \brief Gives a chance to each loaded plug-in to unregister TestListener.
|
||||
* For each plug-in, call CppUnitTestPlugIn::removeListener().
|
||||
*/
|
||||
void removeListener( TestResult *eventManager );
|
||||
|
||||
/*! \brief Provides a way for the plug-in to register some XmlOutputterHook.
|
||||
*/
|
||||
void addXmlOutputterHooks( XmlOutputter *outputter );
|
||||
|
||||
/*! \brief Called when the XmlOutputter is destroyed.
|
||||
*
|
||||
* Can be used to free some resources allocated by addXmlOutputterHooks().
|
||||
*/
|
||||
void removeXmlOutputterHooks();
|
||||
|
||||
protected:
|
||||
/*! \brief (INTERNAL) Information about a specific plug-in.
|
||||
*/
|
||||
struct PlugInInfo
|
||||
{
|
||||
std::string m_fileName;
|
||||
DynamicLibraryManager *m_manager;
|
||||
CppUnitTestPlugIn *m_interface;
|
||||
};
|
||||
|
||||
/*! Unloads the specified plug-in.
|
||||
* \param plugIn Information about the plug-in.
|
||||
*/
|
||||
void unload( PlugInInfo &plugIn );
|
||||
|
||||
private:
|
||||
/// Prevents the use of the copy constructor.
|
||||
PlugInManager( const PlugInManager © );
|
||||
|
||||
/// Prevents the use of the copy operator.
|
||||
void operator =( const PlugInManager © );
|
||||
|
||||
private:
|
||||
typedef std::deque<PlugInInfo> PlugIns;
|
||||
PlugIns m_plugIns;
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#if CPPUNIT_NEED_DLL_DECL
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
|
||||
#endif // !defined(CPPUNIT_NO_TESTPLUGIN)
|
||||
|
||||
|
||||
#endif // CPPUNIT_PLUGIN_PLUGINMANAGER_H
|
||||
36
3rdparty/cppunit/include/cppunit/plugin/PlugInParameters.h
vendored
Normal file
36
3rdparty/cppunit/include/cppunit/plugin/PlugInParameters.h
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef CPPUNIT_PLUGIN_PARAMETERS
|
||||
#define CPPUNIT_PLUGIN_PARAMETERS
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
|
||||
#if !defined(CPPUNIT_NO_TESTPLUGIN)
|
||||
|
||||
#include <deque>
|
||||
#include <string>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
/*! \brief Test plug-ins parameters.
|
||||
*/
|
||||
class CPPUNIT_API PlugInParameters
|
||||
{
|
||||
public:
|
||||
/// Constructs plug-in parameters from the specified command-line.
|
||||
PlugInParameters( const std::string &commandLine = "" );
|
||||
|
||||
virtual ~PlugInParameters();
|
||||
|
||||
/// Returns the command line that was passed on construction.
|
||||
std::string getCommandLine() const;
|
||||
|
||||
private:
|
||||
std::string m_commandLine;
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // !defined(CPPUNIT_NO_TESTPLUGIN)
|
||||
|
||||
|
||||
#endif // CPPUNIT_PLUGIN_PARAMETERS
|
||||
198
3rdparty/cppunit/include/cppunit/plugin/TestPlugIn.h
vendored
Normal file
198
3rdparty/cppunit/include/cppunit/plugin/TestPlugIn.h
vendored
Normal file
@@ -0,0 +1,198 @@
|
||||
#ifndef CPPUNIT_PLUGIN_TESTPLUGIN
|
||||
#define CPPUNIT_PLUGIN_TESTPLUGIN
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
|
||||
#if !defined(CPPUNIT_NO_TESTPLUGIN)
|
||||
|
||||
#include <cppunit/plugin/PlugInParameters.h>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
class Test;
|
||||
class TestFactoryRegistry;
|
||||
class TestResult;
|
||||
class XmlOutputter;
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
/*! \file
|
||||
*/
|
||||
|
||||
|
||||
/*! \brief Test plug-in interface.
|
||||
* \ingroup WritingTestPlugIn
|
||||
*
|
||||
* This class define the interface implemented by test plug-in. A pointer to that
|
||||
* interface is returned by the function exported by the test plug-in.
|
||||
*
|
||||
* Plug-in are loaded/unloaded by PlugInManager. When a plug-in is loaded,
|
||||
* initialize() is called. Before unloading the plug-in, the PlugInManager
|
||||
* call uninitialize().
|
||||
*
|
||||
* addListener() and removeListener() are called respectively before and after
|
||||
* the test run.
|
||||
*
|
||||
* addXmlOutputterHooks() and removeXmlOutputterHooks() are called respectively
|
||||
* before and after writing the XML output using a XmlOutputter.
|
||||
*
|
||||
* \see CPPUNIT_PLUGIN_IMPLEMENT, CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL
|
||||
* \see CppUnit::TestPlugInDefaultImpl, CppUnit::XmlOutputter.
|
||||
*/
|
||||
struct CPPUNIT_API CppUnitTestPlugIn
|
||||
{
|
||||
/*! \brief Called just after loading the dynamic library.
|
||||
*
|
||||
* Override this method to add additional suite to the registry, though this
|
||||
* is preferably done using the macros (CPPUNIT_TEST_SUITE_REGISTRATION...).
|
||||
* If you are creating a custom listener to extends the plug-in runner,
|
||||
* you can use this to configure the listener using the \a parameters.
|
||||
*
|
||||
* You could also use the parameters to specify some global parameter, such
|
||||
* as test datas location, database name...
|
||||
*
|
||||
* N.B.: Parameters interface is not define yet, and the plug-in runner does
|
||||
* not yet support plug-in parameter.
|
||||
*/
|
||||
virtual void initialize( CPPUNIT_NS::TestFactoryRegistry *registry,
|
||||
const CPPUNIT_NS::PlugInParameters ¶meters ) =0;
|
||||
|
||||
/*! \brief Gives a chance to the plug-in to register TestListener.
|
||||
*
|
||||
* Override this method to add a TestListener for the test run. This is useful
|
||||
* if you are writing a custom TestListener, but also if you need to
|
||||
* setUp some global resource: listen to TestListener::startTestRun(),
|
||||
* and TestListener::endTestRun().
|
||||
*/
|
||||
virtual void addListener( CPPUNIT_NS::TestResult *eventManager ) =0;
|
||||
|
||||
/*! \brief Gives a chance to the plug-in to remove its registered TestListener.
|
||||
*
|
||||
* Override this method to remove a TestListener that has been added.
|
||||
*/
|
||||
virtual void removeListener( CPPUNIT_NS::TestResult *eventManager ) =0;
|
||||
|
||||
/*! \brief Provides a way for the plug-in to register some XmlOutputterHook.
|
||||
*/
|
||||
virtual void addXmlOutputterHooks( CPPUNIT_NS::XmlOutputter *outputter ) =0;
|
||||
|
||||
/*! \brief Called when the XmlOutputter is destroyed.
|
||||
*
|
||||
* Can be used to free some resources allocated by addXmlOutputterHooks().
|
||||
*/
|
||||
virtual void removeXmlOutputterHooks() = 0;
|
||||
|
||||
/*! \brief Called just before unloading the dynamic library.
|
||||
*
|
||||
* Override this method to unregister test factory added in initialize().
|
||||
* This is necessary to keep the TestFactoryRegistry 'clean'. When
|
||||
* the plug-in is unloaded from memory, the TestFactoryRegistry will hold
|
||||
* reference on test that are no longer available if they are not
|
||||
* unregistered.
|
||||
*/
|
||||
virtual void uninitialize( CPPUNIT_NS::TestFactoryRegistry *registry ) =0;
|
||||
|
||||
virtual ~CppUnitTestPlugIn() {}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*! \brief Name of the function exported by a test plug-in.
|
||||
* \ingroup WritingTestPlugIn
|
||||
*
|
||||
* The signature of the exported function is:
|
||||
* \code
|
||||
* CppUnitTestPlugIn *CPPUNIT_PLUGIN_EXPORTED_NAME(void);
|
||||
* \endcode
|
||||
*/
|
||||
#define CPPUNIT_PLUGIN_EXPORTED_NAME cppunitTestPlugIn
|
||||
|
||||
/*! \brief Type of the function exported by a plug-in.
|
||||
* \ingroup WritingTestPlugIn
|
||||
*/
|
||||
typedef CppUnitTestPlugIn *(*TestPlugInSignature)();
|
||||
|
||||
|
||||
/*! \brief Implements the function exported by the test plug-in
|
||||
* \ingroup WritingTestPlugIn
|
||||
*/
|
||||
#define CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL( TestPlugInInterfaceType ) \
|
||||
CPPUNIT_PLUGIN_EXPORT CppUnitTestPlugIn *CPPUNIT_PLUGIN_EXPORTED_NAME(void) \
|
||||
{ \
|
||||
static TestPlugInInterfaceType plugIn; \
|
||||
return &plugIn; \
|
||||
} \
|
||||
typedef char __CppUnitPlugInExportFunctionDummyTypeDef // dummy typedef so it can end with ';'
|
||||
|
||||
|
||||
// Note: This include should remain after definition of CppUnitTestPlugIn
|
||||
#include <cppunit/plugin/TestPlugInDefaultImpl.h>
|
||||
|
||||
|
||||
/*! \def CPPUNIT_PLUGIN_IMPLEMENT_MAIN()
|
||||
* \brief Implements the 'main' function for the plug-in.
|
||||
*
|
||||
* This macros implements the main() function for dynamic library.
|
||||
* For example, WIN32 requires a DllMain function, while some Unix
|
||||
* requires a main() function. This macros takes care of the implementation.
|
||||
*/
|
||||
|
||||
// Win32
|
||||
#if defined(CPPUNIT_HAVE_WIN32_DLL_LOADER)
|
||||
#if !defined(APIENTRY)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOGDI
|
||||
#define NOUSER
|
||||
#define NOKERNEL
|
||||
#define NOSOUND
|
||||
#define NOMINMAX
|
||||
#define BLENDFUNCTION void // for mingw & gcc
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#define CPPUNIT_PLUGIN_IMPLEMENT_MAIN() \
|
||||
BOOL APIENTRY DllMain( HANDLE, DWORD, LPVOID ) \
|
||||
{ \
|
||||
return TRUE; \
|
||||
} \
|
||||
typedef char __CppUnitPlugInImplementMainDummyTypeDef
|
||||
|
||||
// Unix
|
||||
#elif defined(CPPUNIT_HAVE_UNIX_DLL_LOADER) || defined(CPPUNIT_HAVE_UNIX_SHL_LOADER)
|
||||
#define CPPUNIT_PLUGIN_IMPLEMENT_MAIN() \
|
||||
int main() \
|
||||
{ \
|
||||
return 0; \
|
||||
} \
|
||||
typedef char __CppUnitPlugInImplementMainDummyTypeDef
|
||||
|
||||
|
||||
// Other
|
||||
#else // other platforms don't require anything specifics
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*! \brief Implements and exports the test plug-in interface.
|
||||
* \ingroup WritingTestPlugIn
|
||||
*
|
||||
* This macro exports the test plug-in function using the subclass,
|
||||
* and implements the 'main' function for the plug-in using
|
||||
* CPPUNIT_PLUGIN_IMPLEMENT_MAIN().
|
||||
*
|
||||
* When using this macro, CppUnit must be linked as a DLL (shared library).
|
||||
* Otherwise, tests registered to the TestFactoryRegistry in the DLL will
|
||||
* not be visible to the DllPlugInTester.
|
||||
*
|
||||
* \see CppUnitTestPlugIn
|
||||
* \see CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL(), CPPUNIT_PLUGIN_IMPLEMENT_MAIN().
|
||||
*/
|
||||
#define CPPUNIT_PLUGIN_IMPLEMENT() \
|
||||
CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL( CPPUNIT_NS::TestPlugInDefaultImpl ); \
|
||||
CPPUNIT_PLUGIN_IMPLEMENT_MAIN()
|
||||
|
||||
|
||||
#endif // !defined(CPPUNIT_NO_TESTPLUGIN)
|
||||
|
||||
|
||||
#endif // CPPUNIT_PLUGIN_TESTPLUGIN
|
||||
61
3rdparty/cppunit/include/cppunit/plugin/TestPlugInDefaultImpl.h
vendored
Normal file
61
3rdparty/cppunit/include/cppunit/plugin/TestPlugInDefaultImpl.h
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
#ifndef CPPUNIT_PLUGIN_TESTPLUGINADAPTER
|
||||
#define CPPUNIT_PLUGIN_TESTPLUGINADAPTER
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
|
||||
#if !defined(CPPUNIT_NO_TESTPLUGIN)
|
||||
|
||||
#include <cppunit/plugin/TestPlugIn.h>
|
||||
|
||||
#if CPPUNIT_NEED_DLL_DECL
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable: 4251 4660 ) // X needs to have dll-interface to be used by clients of class Z
|
||||
#endif
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
class TestSuite;
|
||||
|
||||
|
||||
/*! \brief Default implementation of test plug-in interface.
|
||||
* \ingroup WritingTestPlugIn
|
||||
*
|
||||
* Override getSuiteName() to specify the suite name. Default is "All Tests".
|
||||
*
|
||||
* CppUnitTestPlugIn::getTestSuite() returns a suite that contains
|
||||
* all the test registered to the default test factory registry
|
||||
* ( TestFactoryRegistry::getRegistry() ).
|
||||
*
|
||||
*/
|
||||
class CPPUNIT_API TestPlugInDefaultImpl : public CppUnitTestPlugIn
|
||||
{
|
||||
public:
|
||||
TestPlugInDefaultImpl();
|
||||
|
||||
virtual ~TestPlugInDefaultImpl();
|
||||
|
||||
void initialize( TestFactoryRegistry *registry,
|
||||
const PlugInParameters ¶meters );
|
||||
|
||||
void addListener( TestResult *eventManager );
|
||||
|
||||
void removeListener( TestResult *eventManager );
|
||||
|
||||
void addXmlOutputterHooks( XmlOutputter *outputter );
|
||||
|
||||
void removeXmlOutputterHooks();
|
||||
|
||||
void uninitialize( TestFactoryRegistry *registry );
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#if CPPUNIT_NEED_DLL_DECL
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
|
||||
#endif // !defined(CPPUNIT_NO_TESTPLUGIN)
|
||||
|
||||
#endif // CPPUNIT_PLUGIN_TESTPLUGINADAPTER
|
||||
59
3rdparty/cppunit/include/cppunit/portability/FloatingPoint.h
vendored
Normal file
59
3rdparty/cppunit/include/cppunit/portability/FloatingPoint.h
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
#ifndef CPPUNIT_PORTABILITY_FLOATINGPOINT_H_INCLUDED
|
||||
#define CPPUNIT_PORTABILITY_FLOATINGPOINT_H_INCLUDED
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
#include <math.h>
|
||||
|
||||
#if defined(__sun) && !defined(CPPUNIT_HAVE_ISFINITE) && defined(CPPUNIT_HAVE_FINITE)
|
||||
#include <ieeefp.h>
|
||||
// <math.h> is still needed for usage of fabs in TestAssert.cpp
|
||||
#endif
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
/// \brief Tests if a floating-point is a NaN.
|
||||
// According to IEEE-754 floating point standard,
|
||||
// (see e.g. page 8 of
|
||||
// http://www.cs.berkeley.edu/~wkahan/ieee754status/ieee754.ps)
|
||||
// all comparisons with NaN are false except "x != x", which is true.
|
||||
//
|
||||
// At least Microsoft Visual Studio 6 is known not to implement this test correctly.
|
||||
// It emits the following code to test equality:
|
||||
// fcomp qword ptr [nan]
|
||||
// fnstsw ax // copie fp (floating-point) status register to ax
|
||||
// test ah,40h // test bit 14 of ax (0x4000) => C3 of fp status register
|
||||
// According to the following documentation on the x86 floating point status register,
|
||||
// the C2 bit should be tested to test for NaN value.
|
||||
// http://webster.cs.ucr.edu/AoA/Windows/HTML/RealArithmetic.html#1000117
|
||||
// In Microsoft Visual Studio 2003 & 2005, the test is implemented with:
|
||||
// test ah,44h // Visual Studio 2005 test both C2 & C3...
|
||||
//
|
||||
// To work around this, a NaN is assumed to be detected if no strict ordering is found.
|
||||
inline bool floatingPointIsUnordered( double x )
|
||||
{
|
||||
// x != x will detect a NaN on conformant platform
|
||||
// (2.0 < x && x < 1.0) will detect a NaN on non conformant platform:
|
||||
// => no ordering can be found for x.
|
||||
return (x != x) || (2.0 < x && x < 1.0);
|
||||
}
|
||||
|
||||
|
||||
/// \brief Tests if a floating-point is finite.
|
||||
/// @return \c true if x is neither a NaN, nor +inf, nor -inf, \c false otherwise.
|
||||
inline int floatingPointIsFinite( double x )
|
||||
{
|
||||
#if defined(CPPUNIT_HAVE_ISFINITE)
|
||||
return isfinite( x );
|
||||
#elif defined(CPPUNIT_HAVE_FINITE)
|
||||
return finite( x );
|
||||
#elif defined(CPPUNIT_HAVE__FINITE)
|
||||
return _finite(x);
|
||||
#else
|
||||
double testInf = x * 0.0; // Produce 0.0 if x is finite, a NaN otherwise.
|
||||
return testInf == 0.0 && !floatingPointIsUnordered(testInf);
|
||||
#endif
|
||||
}
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // CPPUNIT_PORTABILITY_FLOATINGPOINT_H_INCLUDED
|
||||
347
3rdparty/cppunit/include/cppunit/portability/Stream.h
vendored
Normal file
347
3rdparty/cppunit/include/cppunit/portability/Stream.h
vendored
Normal file
@@ -0,0 +1,347 @@
|
||||
#ifndef CPPUNIT_PORTABILITY_STREAM_H_INCLUDED
|
||||
#define CPPUNIT_PORTABILITY_STREAM_H_INCLUDED
|
||||
|
||||
// This module define:
|
||||
// Type CppUT::Stream (either std::stream or a custom type)
|
||||
// Type CppUT::OStringStream (eitjer std::ostringstream, older alternate or a custom type)
|
||||
// Functions stdCOut() & stdCErr() which returns a reference on cout & cerr stream (or our
|
||||
// custom stream).
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
|
||||
|
||||
#if defined( CPPUNIT_NO_STREAM )
|
||||
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
class StreamBuffer
|
||||
{
|
||||
public:
|
||||
virtual ~StreamBuffer() {}
|
||||
|
||||
virtual void write( const char *text, unsigned int length ) = 0;
|
||||
|
||||
virtual void flush() {}
|
||||
};
|
||||
|
||||
|
||||
class StringStreamBuffer : public StreamBuffer
|
||||
{
|
||||
public:
|
||||
std::string str() const
|
||||
{
|
||||
return str_;
|
||||
}
|
||||
|
||||
public: // overridden from StreamBuffer
|
||||
void write( const char *text, unsigned int length )
|
||||
{
|
||||
str_.append( text, length );
|
||||
}
|
||||
|
||||
private:
|
||||
std::string str_;
|
||||
};
|
||||
|
||||
|
||||
class FileStreamBuffer : public StreamBuffer
|
||||
{
|
||||
public:
|
||||
FileStreamBuffer( FILE *file )
|
||||
: file_( file )
|
||||
{
|
||||
}
|
||||
|
||||
FILE *file() const
|
||||
{
|
||||
return file_;
|
||||
}
|
||||
|
||||
public: // overridden from StreamBuffer
|
||||
void write( const char *text, unsigned int length )
|
||||
{
|
||||
if ( file_ )
|
||||
fwrite( text, sizeof(char), length, file_ );
|
||||
}
|
||||
|
||||
void flush()
|
||||
{
|
||||
if ( file_ )
|
||||
fflush( file_ );
|
||||
}
|
||||
|
||||
private:
|
||||
FILE *file_;
|
||||
};
|
||||
|
||||
|
||||
class OStream
|
||||
{
|
||||
public:
|
||||
OStream()
|
||||
: buffer_( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
OStream( StreamBuffer *buffer )
|
||||
: buffer_( buffer )
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~OStream()
|
||||
{
|
||||
flush();
|
||||
}
|
||||
|
||||
OStream &flush()
|
||||
{
|
||||
if ( buffer_ )
|
||||
buffer_->flush();
|
||||
return *this;
|
||||
}
|
||||
|
||||
void setBuffer( StreamBuffer *buffer )
|
||||
{
|
||||
buffer_ = buffer;
|
||||
}
|
||||
|
||||
OStream &write( const char *text, unsigned int length )
|
||||
{
|
||||
if ( buffer_ )
|
||||
buffer_->write( text, length );
|
||||
return *this;
|
||||
}
|
||||
|
||||
OStream &write( const char *text )
|
||||
{
|
||||
return write( text, strlen(text) );
|
||||
}
|
||||
|
||||
OStream &operator <<( bool v )
|
||||
{
|
||||
const char *out = v ? "true" : "false";
|
||||
return write( out );
|
||||
}
|
||||
|
||||
OStream &operator <<( short v )
|
||||
{
|
||||
char buffer[64];
|
||||
sprintf( buffer, "%hd", v );
|
||||
return write( buffer );
|
||||
}
|
||||
|
||||
OStream &operator <<( unsigned short v )
|
||||
{
|
||||
char buffer[64];
|
||||
sprintf( buffer, "%hu", v );
|
||||
return write( buffer );
|
||||
}
|
||||
|
||||
OStream &operator <<( int v )
|
||||
{
|
||||
char buffer[64];
|
||||
sprintf( buffer, "%d", v );
|
||||
return write( buffer );
|
||||
}
|
||||
|
||||
OStream &operator <<( unsigned int v )
|
||||
{
|
||||
char buffer[64];
|
||||
sprintf( buffer, "%u", v );
|
||||
return write( buffer );
|
||||
}
|
||||
|
||||
OStream &operator <<( long v )
|
||||
{
|
||||
char buffer[64];
|
||||
sprintf( buffer, "%ld", v );
|
||||
return write( buffer );
|
||||
}
|
||||
|
||||
OStream &operator <<( unsigned long v )
|
||||
{
|
||||
char buffer[64];
|
||||
sprintf( buffer, "%lu", v );
|
||||
return write( buffer );
|
||||
}
|
||||
|
||||
OStream &operator <<( float v )
|
||||
{
|
||||
char buffer[128];
|
||||
sprintf( buffer, "%.16g", double(v) );
|
||||
return write( buffer );
|
||||
}
|
||||
|
||||
OStream &operator <<( double v )
|
||||
{
|
||||
char buffer[128];
|
||||
sprintf( buffer, "%.16g", v );
|
||||
return write( buffer );
|
||||
}
|
||||
|
||||
OStream &operator <<( long double v )
|
||||
{
|
||||
char buffer[128];
|
||||
sprintf( buffer, "%.16g", double(v) );
|
||||
return write( buffer );
|
||||
}
|
||||
|
||||
OStream &operator <<( const void *v )
|
||||
{
|
||||
char buffer[64];
|
||||
sprintf( buffer, "%p", v );
|
||||
return write( buffer );
|
||||
}
|
||||
|
||||
OStream &operator <<( const char *v )
|
||||
{
|
||||
return write( v ? v : "NULL" );
|
||||
}
|
||||
|
||||
OStream &operator <<( char c )
|
||||
{
|
||||
char buffer[16];
|
||||
sprintf( buffer, "%c", c );
|
||||
return write( buffer );
|
||||
}
|
||||
|
||||
OStream &operator <<( const std::string &s )
|
||||
{
|
||||
return write( s.c_str(), s.length() );
|
||||
}
|
||||
|
||||
private:
|
||||
StreamBuffer *buffer_;
|
||||
};
|
||||
|
||||
|
||||
class OStringStream : public OStream
|
||||
{
|
||||
public:
|
||||
OStringStream()
|
||||
: OStream( &buffer_ )
|
||||
{
|
||||
}
|
||||
|
||||
std::string str() const
|
||||
{
|
||||
return buffer_.str();
|
||||
}
|
||||
|
||||
private:
|
||||
StringStreamBuffer buffer_;
|
||||
};
|
||||
|
||||
|
||||
class OFileStream : public OStream
|
||||
{
|
||||
public:
|
||||
OFileStream( FILE *file )
|
||||
: OStream( &buffer_ )
|
||||
, buffer_( file )
|
||||
, ownFile_( false )
|
||||
{
|
||||
}
|
||||
|
||||
OFileStream( const char *path )
|
||||
: OStream( &buffer_ )
|
||||
, buffer_( fopen( path, "wt" ) )
|
||||
, ownFile_( true )
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~OFileStream()
|
||||
{
|
||||
if ( ownFile_ && buffer_.file() )
|
||||
fclose( buffer_.file() );
|
||||
}
|
||||
|
||||
private:
|
||||
FileStreamBuffer buffer_;
|
||||
bool ownFile_;
|
||||
};
|
||||
|
||||
inline OStream &stdCOut()
|
||||
{
|
||||
static OFileStream stream( stdout );
|
||||
return stream;
|
||||
}
|
||||
|
||||
inline OStream &stdCErr()
|
||||
{
|
||||
static OFileStream stream( stderr );
|
||||
return stream;
|
||||
}
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#elif CPPUNIT_HAVE_SSTREAM // #if defined( CPPUNIT_NO_STREAM )
|
||||
# include <sstream>
|
||||
# include <fstream>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
typedef std::ostringstream OStringStream; // The standard C++ way
|
||||
typedef std::ofstream OFileStream;
|
||||
CPPUNIT_NS_END
|
||||
|
||||
|
||||
#elif CPPUNIT_HAVE_CLASS_STRSTREAM
|
||||
# include <string>
|
||||
# if CPPUNIT_HAVE_STRSTREAM
|
||||
# include <strstream>
|
||||
# else // CPPUNIT_HAVE_STRSTREAM
|
||||
# include <strstream.h>
|
||||
# endif // CPPUNIT_HAVE_CLASS_STRSTREAM
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
class OStringStream : public std::ostrstream
|
||||
{
|
||||
public:
|
||||
std::string str()
|
||||
{
|
||||
// (*this) << '\0';
|
||||
// std::string msg(std::ostrstream::str());
|
||||
// std::ostrstream::freeze(false);
|
||||
// return msg;
|
||||
// Alternative implementation that don't rely on freeze which is not
|
||||
// available on some platforms:
|
||||
return std::string( std::ostrstream::str(), pcount() );
|
||||
}
|
||||
};
|
||||
|
||||
CPPUNIT_NS_END
|
||||
#else // CPPUNIT_HAVE_CLASS_STRSTREAM
|
||||
# error Cannot define CppUnit::OStringStream.
|
||||
#endif // #if defined( CPPUNIT_NO_STREAM )
|
||||
|
||||
|
||||
|
||||
#if !defined( CPPUNIT_NO_STREAM )
|
||||
|
||||
#include <iostream>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
typedef std::ostream OStream;
|
||||
|
||||
inline OStream &stdCOut()
|
||||
{
|
||||
return std::cout;
|
||||
}
|
||||
|
||||
inline OStream &stdCErr()
|
||||
{
|
||||
return std::cerr;
|
||||
}
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // #if !defined( CPPUNIT_NO_STREAM )
|
||||
|
||||
#endif // CPPUNIT_PORTABILITY_STREAM_H_INCLUDED
|
||||
|
||||
23
3rdparty/cppunit/include/cppunit/tools/Algorithm.h
vendored
Normal file
23
3rdparty/cppunit/include/cppunit/tools/Algorithm.h
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef CPPUNIT_TOOLS_ALGORITHM_H_INCLUDED
|
||||
#define CPPUNIT_TOOLS_ALGORITHM_H_INCLUDED
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
template<class SequenceType, class ValueType>
|
||||
void
|
||||
removeFromSequence( SequenceType &sequence,
|
||||
const ValueType &valueToRemove )
|
||||
{
|
||||
for ( unsigned int index =0; index < sequence.size(); ++index )
|
||||
{
|
||||
if ( sequence[ index ] == valueToRemove )
|
||||
sequence.erase( sequence.begin() + index );
|
||||
}
|
||||
}
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
|
||||
#endif // CPPUNIT_TOOLS_ALGORITHM_H_INCLUDED
|
||||
45
3rdparty/cppunit/include/cppunit/tools/StringHelper.h
vendored
Normal file
45
3rdparty/cppunit/include/cppunit/tools/StringHelper.h
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
#ifndef CPPUNIT_TOOLS_STRINGHELPER_H
|
||||
#define CPPUNIT_TOOLS_STRINGHELPER_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
#include <cppunit/portability/Stream.h>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
/*! \brief Methods for converting values to strings. Replaces CPPUNIT_NS::StringTools::toString
|
||||
*/
|
||||
namespace StringHelper
|
||||
{
|
||||
|
||||
// work around to handle C++11 enum class correctly. We need an own conversion to std::string
|
||||
// as there is no implicit coversion to int for enum class.
|
||||
|
||||
template<typename T>
|
||||
typename std::enable_if<!std::is_enum<T>::value, std::string>::type toString(const T& x)
|
||||
{
|
||||
OStringStream ost;
|
||||
ost << x;
|
||||
|
||||
return ost.str();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename std::enable_if<std::is_enum<T>::value, std::string>::type toString(const T& x)
|
||||
{
|
||||
OStringStream ost;
|
||||
ost << static_cast<typename std::underlying_type<T>::type>(x);
|
||||
|
||||
return ost.str();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // CPPUNIT_TOOLS_STRINGHELPER_H
|
||||
|
||||
34
3rdparty/cppunit/include/cppunit/tools/StringTools.h
vendored
Normal file
34
3rdparty/cppunit/include/cppunit/tools/StringTools.h
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef CPPUNIT_TOOLS_STRINGTOOLS_H
|
||||
#define CPPUNIT_TOOLS_STRINGTOOLS_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
/*! \brief Tool functions to manipulate string.
|
||||
*/
|
||||
struct StringTools
|
||||
{
|
||||
|
||||
typedef std::vector<std::string> Strings;
|
||||
|
||||
static std::string CPPUNIT_API toString( int value );
|
||||
|
||||
static std::string CPPUNIT_API toString( double value );
|
||||
|
||||
static Strings CPPUNIT_API split( const std::string &text,
|
||||
char separator );
|
||||
|
||||
static std::string CPPUNIT_API wrap( const std::string &text,
|
||||
int wrapColumn = CPPUNIT_WRAP_COLUMN );
|
||||
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // CPPUNIT_TOOLS_STRINGTOOLS_H
|
||||
86
3rdparty/cppunit/include/cppunit/tools/XmlDocument.h
vendored
Normal file
86
3rdparty/cppunit/include/cppunit/tools/XmlDocument.h
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
#ifndef CPPUNIT_TOOLS_XMLDOCUMENT_H
|
||||
#define CPPUNIT_TOOLS_XMLDOCUMENT_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
|
||||
#if CPPUNIT_NEED_DLL_DECL
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
class XmlElement;
|
||||
|
||||
|
||||
/*! \brief A XML Document.
|
||||
*
|
||||
* A XmlDocument represents a XML file. It holds a pointer on the root XmlElement
|
||||
* of the document. It also holds the encoding and style sheet used.
|
||||
*
|
||||
* By default, the XML document is stand-alone and tagged with enconding "ISO-8859-1".
|
||||
*/
|
||||
class CPPUNIT_API XmlDocument
|
||||
{
|
||||
public:
|
||||
/*! \brief Constructs a XmlDocument object.
|
||||
* \param encoding Encoding used in the XML file (default is Latin-1, ISO-8859-1 ).
|
||||
* \param styleSheet Name of the XSL style sheet file used. If empty then no
|
||||
* style sheet will be specified in the output.
|
||||
*/
|
||||
XmlDocument( const std::string &encoding = "",
|
||||
const std::string &styleSheet = "" );
|
||||
|
||||
/// Destructor.
|
||||
virtual ~XmlDocument();
|
||||
|
||||
std::string encoding() const;
|
||||
void setEncoding( const std::string &encoding = "" );
|
||||
|
||||
std::string styleSheet() const;
|
||||
void setStyleSheet( const std::string &styleSheet = "" );
|
||||
|
||||
bool standalone() const;
|
||||
|
||||
/*! \brief set the output document as standalone or not.
|
||||
*
|
||||
* For the output document, specify wether it's a standalone XML
|
||||
* document, or not.
|
||||
*
|
||||
* \param standalone if true, the output will be specified as standalone.
|
||||
* if false, it will be not.
|
||||
*/
|
||||
void setStandalone( bool standalone );
|
||||
|
||||
void setRootElement( XmlElement *rootElement );
|
||||
XmlElement &rootElement() const;
|
||||
|
||||
std::string toString() const;
|
||||
|
||||
private:
|
||||
/// Prevents the use of the copy constructor.
|
||||
XmlDocument( const XmlDocument © );
|
||||
|
||||
/// Prevents the use of the copy operator.
|
||||
void operator =( const XmlDocument © );
|
||||
|
||||
protected:
|
||||
std::string m_encoding;
|
||||
std::string m_styleSheet;
|
||||
XmlElement *m_rootElement;
|
||||
bool m_standalone;
|
||||
};
|
||||
|
||||
|
||||
#if CPPUNIT_NEED_DLL_DECL
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // CPPUNIT_TOOLS_XMLDOCUMENT_H
|
||||
149
3rdparty/cppunit/include/cppunit/tools/XmlElement.h
vendored
Normal file
149
3rdparty/cppunit/include/cppunit/tools/XmlElement.h
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
#ifndef CPPUNIT_TOOLS_XMLELEMENT_H
|
||||
#define CPPUNIT_TOOLS_XMLELEMENT_H
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
|
||||
#if CPPUNIT_NEED_DLL_DECL
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z
|
||||
#endif
|
||||
|
||||
#include <deque>
|
||||
#include <string>
|
||||
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
class XmlElement;
|
||||
|
||||
#if CPPUNIT_NEED_DLL_DECL
|
||||
// template class CPPUNIT_API std::deque<XmlElement *>;
|
||||
#endif
|
||||
|
||||
|
||||
/*! \brief A XML Element.
|
||||
*
|
||||
* A XML element has:
|
||||
* - a name, specified on construction,
|
||||
* - a content, specified on construction (may be empty),
|
||||
* - zero or more attributes, added with addAttribute(),
|
||||
* - zero or more child elements, added with addElement().
|
||||
*/
|
||||
class CPPUNIT_API XmlElement
|
||||
{
|
||||
public:
|
||||
/*! \brief Constructs an element with the specified name and string content.
|
||||
* \param elementName Name of the element. Must not be empty.
|
||||
* \param content Content of the element.
|
||||
*/
|
||||
XmlElement( std::string elementName,
|
||||
std::string content ="" );
|
||||
|
||||
/*! \brief Constructs an element with the specified name and numeric content.
|
||||
* \param elementName Name of the element. Must not be empty.
|
||||
* \param numericContent Content of the element.
|
||||
*/
|
||||
XmlElement( std::string elementName,
|
||||
int numericContent );
|
||||
|
||||
/*! \brief Destructs the element and its child elements.
|
||||
*/
|
||||
virtual ~XmlElement();
|
||||
|
||||
/*! \brief Returns the name of the element.
|
||||
* \return Name of the element.
|
||||
*/
|
||||
std::string name() const;
|
||||
|
||||
/*! \brief Returns the content of the element.
|
||||
* \return Content of the element.
|
||||
*/
|
||||
std::string content() const;
|
||||
|
||||
/*! \brief Sets the name of the element.
|
||||
* \param name New name for the element.
|
||||
*/
|
||||
void setName( const std::string &name );
|
||||
|
||||
/*! \brief Sets the content of the element.
|
||||
* \param content New content for the element.
|
||||
*/
|
||||
void setContent( const std::string &content );
|
||||
|
||||
/*! \overload void setContent( const std::string &content )
|
||||
*/
|
||||
void setContent( int numericContent );
|
||||
|
||||
/*! \brief Adds an attribute with the specified string value.
|
||||
* \param attributeName Name of the attribute. Must not be an empty.
|
||||
* \param value Value of the attribute.
|
||||
*/
|
||||
void addAttribute( std::string attributeName,
|
||||
std::string value );
|
||||
|
||||
/*! \brief Adds an attribute with the specified numeric value.
|
||||
* \param attributeName Name of the attribute. Must not be empty.
|
||||
* \param numericValue Numeric value of the attribute.
|
||||
*/
|
||||
void addAttribute( std::string attributeName,
|
||||
int numericValue );
|
||||
|
||||
/*! \brief Adds a child element to the element.
|
||||
* \param element Child element to add. Must not be \c NULL.
|
||||
*/
|
||||
void addElement( XmlElement *element );
|
||||
|
||||
/*! \brief Returns the number of child elements.
|
||||
* \return Number of child elements (element added with addElement()).
|
||||
*/
|
||||
int elementCount() const;
|
||||
|
||||
/*! \brief Returns the child element at the specified index.
|
||||
* \param index Zero based index of the element to return.
|
||||
* \returns Element at the specified index. Never \c NULL.
|
||||
* \exception std::invalid_argument if \a index < 0 or index >= elementCount().
|
||||
*/
|
||||
XmlElement *elementAt( int index ) const;
|
||||
|
||||
/*! \brief Returns the first child element with the specified name.
|
||||
* \param name Name of the child element to return.
|
||||
* \return First child element found which is named \a name.
|
||||
* \exception std::invalid_argument if there is no child element with the specified
|
||||
* name.
|
||||
*/
|
||||
XmlElement *elementFor( const std::string &name ) const;
|
||||
|
||||
/*! \brief Returns a XML string that represents the element.
|
||||
* \param indent String of spaces representing the amount of 'indent'.
|
||||
* \return XML string that represents the element, its attributes and its
|
||||
* child elements.
|
||||
*/
|
||||
std::string toString( const std::string &indent = "" ) const;
|
||||
|
||||
private:
|
||||
typedef std::pair<std::string,std::string> Attribute;
|
||||
|
||||
std::string attributesAsString() const;
|
||||
std::string escape( std::string value ) const;
|
||||
|
||||
private:
|
||||
std::string m_name;
|
||||
std::string m_content;
|
||||
|
||||
typedef std::deque<Attribute> Attributes;
|
||||
Attributes m_attributes;
|
||||
|
||||
typedef std::deque<XmlElement *> Elements;
|
||||
Elements m_elements;
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#if CPPUNIT_NEED_DLL_DECL
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
|
||||
|
||||
#endif // CPPUNIT_TOOLS_XMLELEMENT_H
|
||||
24
3rdparty/cppunit/include/cppunit/ui/text/TestRunner.h
vendored
Normal file
24
3rdparty/cppunit/include/cppunit/ui/text/TestRunner.h
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef CPPUNIT_UI_TEXT_TESTRUNNER_H
|
||||
#define CPPUNIT_UI_TEXT_TESTRUNNER_H
|
||||
|
||||
#include <cppunit/ui/text/TextTestRunner.h>
|
||||
|
||||
|
||||
#if defined(CPPUNIT_HAVE_NAMESPACES)
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
namespace TextUi
|
||||
{
|
||||
|
||||
/*! Text TestRunner (DEPRECATED).
|
||||
* \deprecated Use TextTestRunner instead.
|
||||
*/
|
||||
typedef TextTestRunner TestRunner;
|
||||
|
||||
}
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // defined(CPPUNIT_HAVE_NAMESPACES)
|
||||
|
||||
|
||||
#endif // CPPUNIT_UI_TEXT_TESTRUNNER_H
|
||||
103
3rdparty/cppunit/include/cppunit/ui/text/TextTestRunner.h
vendored
Normal file
103
3rdparty/cppunit/include/cppunit/ui/text/TextTestRunner.h
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
#ifndef CPPUNIT_UI_TEXT_TEXTTESTRUNNER_H
|
||||
#define CPPUNIT_UI_TEXT_TEXTTESTRUNNER_H
|
||||
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
#include <string>
|
||||
#include <cppunit/TestRunner.h>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
class Outputter;
|
||||
class Test;
|
||||
class TestSuite;
|
||||
class TextOutputter;
|
||||
class TestResult;
|
||||
class TestResultCollector;
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* \brief A text mode test runner.
|
||||
* \ingroup WritingTestResult
|
||||
* \ingroup ExecutingTest
|
||||
*
|
||||
* The test runner manage the life cycle of the added tests.
|
||||
*
|
||||
* The test runner can run only one of the added tests or all the tests.
|
||||
*
|
||||
* TestRunner prints out a trace as the tests are executed followed by a
|
||||
* summary at the end. The trace and summary print are optional.
|
||||
*
|
||||
* Here is an example of use:
|
||||
*
|
||||
* \code
|
||||
* CppUnit::TextTestRunner runner;
|
||||
* runner.addTest( ExampleTestCase::suite() );
|
||||
* runner.run( "", true ); // Run all tests and wait
|
||||
* \endcode
|
||||
*
|
||||
* The trace is printed using a TextTestProgressListener. The summary is printed
|
||||
* using a TextOutputter.
|
||||
*
|
||||
* You can specify an alternate Outputter at construction
|
||||
* or later with setOutputter().
|
||||
*
|
||||
* After construction, you can register additional TestListener to eventManager(),
|
||||
* for a custom progress trace, for example.
|
||||
*
|
||||
* \code
|
||||
* CppUnit::TextTestRunner runner;
|
||||
* runner.addTest( ExampleTestCase::suite() );
|
||||
* runner.setOutputter( CppUnit::CompilerOutputter::defaultOutputter(
|
||||
* &runner.result(),
|
||||
* std::cerr ) );
|
||||
* MyCustomProgressTestListener progress;
|
||||
* runner.eventManager().addListener( &progress );
|
||||
* runner.run( "", true ); // Run all tests and wait
|
||||
* \endcode
|
||||
*
|
||||
* \see CompilerOutputter, XmlOutputter, TextOutputter.
|
||||
*/
|
||||
class CPPUNIT_API TextTestRunner : public CPPUNIT_NS::TestRunner
|
||||
{
|
||||
public:
|
||||
TextTestRunner( Outputter *outputter =NULL );
|
||||
|
||||
virtual ~TextTestRunner();
|
||||
|
||||
bool run( std::string testPath ="",
|
||||
bool doWait = false,
|
||||
bool doPrintResult = true,
|
||||
bool doPrintProgress = true );
|
||||
|
||||
void setOutputter( Outputter *outputter );
|
||||
|
||||
TestResultCollector &result() const;
|
||||
|
||||
TestResult &eventManager() const;
|
||||
|
||||
public: // overridden from TestRunner (to avoid hidden virtual function warning)
|
||||
virtual void run( TestResult &controller,
|
||||
const std::string &testPath = "" );
|
||||
|
||||
protected:
|
||||
virtual void wait( bool doWait );
|
||||
virtual void printResult( bool doPrintResult );
|
||||
|
||||
private:
|
||||
// prohibit copying
|
||||
TextTestRunner( const TextTestRunner& );
|
||||
// prohibit copying
|
||||
TextTestRunner& operator=( const TextTestRunner& );
|
||||
|
||||
TestResultCollector *m_result;
|
||||
TestResult *m_eventManager;
|
||||
Outputter *m_outputter;
|
||||
};
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // CPPUNIT_UI_TEXT_TEXTTESTRUNNER_H
|
||||
6
3rdparty/cppunit/src/CMakeLists.txt
vendored
Normal file
6
3rdparty/cppunit/src/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
add_subdirectory(cppunit)
|
||||
|
||||
set(CPPUNIT_SOURCES
|
||||
${CPPUNIT_SOURCES}
|
||||
PARENT_SCOPE
|
||||
)
|
||||
41
3rdparty/cppunit/src/cppunit/AdditionalMessage.cpp
vendored
Normal file
41
3rdparty/cppunit/src/cppunit/AdditionalMessage.cpp
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
#include <cppunit/AdditionalMessage.h>
|
||||
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
AdditionalMessage::AdditionalMessage()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
AdditionalMessage::AdditionalMessage( const std::string &detail1 )
|
||||
{
|
||||
if ( !detail1.empty() )
|
||||
addDetail( detail1 );
|
||||
}
|
||||
|
||||
|
||||
AdditionalMessage::AdditionalMessage( const char *detail1 )
|
||||
{
|
||||
if ( detail1 && !std::string( detail1 ).empty() )
|
||||
addDetail( std::string(detail1) );
|
||||
}
|
||||
|
||||
|
||||
AdditionalMessage::AdditionalMessage( const Message &other )
|
||||
: SuperClass( other )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
AdditionalMessage &
|
||||
AdditionalMessage::operator =( const Message &other )
|
||||
{
|
||||
SuperClass::operator =( other );
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
196
3rdparty/cppunit/src/cppunit/Asserter.cpp
vendored
Normal file
196
3rdparty/cppunit/src/cppunit/Asserter.cpp
vendored
Normal file
@@ -0,0 +1,196 @@
|
||||
#include <cppunit/Asserter.h>
|
||||
#include <cppunit/Exception.h>
|
||||
#include <cppunit/Message.h>
|
||||
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
// coverity[+kill]
|
||||
void
|
||||
Asserter::fail( std::string message,
|
||||
const SourceLine &sourceLine )
|
||||
{
|
||||
fail( Message( "assertion failed", message ), sourceLine );
|
||||
}
|
||||
|
||||
// coverity[+kill]
|
||||
void
|
||||
Asserter::fail( const Message &message,
|
||||
const SourceLine &sourceLine )
|
||||
{
|
||||
throw Exception( message, sourceLine );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Asserter::failIf( bool shouldFail,
|
||||
const Message &message,
|
||||
const SourceLine &sourceLine )
|
||||
{
|
||||
if ( shouldFail )
|
||||
fail( message, sourceLine );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Asserter::failIf( bool shouldFail,
|
||||
std::string message,
|
||||
const SourceLine &sourceLine )
|
||||
{
|
||||
failIf( shouldFail, Message( "assertion failed", message ), sourceLine );
|
||||
}
|
||||
|
||||
std::string
|
||||
Asserter::makeExpected( const std::string &expectedValue )
|
||||
{
|
||||
return "Expected: " + expectedValue;
|
||||
}
|
||||
|
||||
std::string
|
||||
Asserter::makeExpectedEqual( const std::string &expectedValue )
|
||||
{
|
||||
return "Expected: " + expectedValue;
|
||||
}
|
||||
|
||||
std::string
|
||||
Asserter::makeExpectedLess( const std::string& expectedValue )
|
||||
{
|
||||
return "Expected less than: " + expectedValue;
|
||||
}
|
||||
|
||||
std::string
|
||||
Asserter::makeExpectedLessEqual( const std::string& expectedValue )
|
||||
{
|
||||
return "Expected less or equal than: " + expectedValue;
|
||||
}
|
||||
|
||||
std::string
|
||||
Asserter::makeExpectedGreater( const std::string& expectedValue )
|
||||
{
|
||||
return "Expected greater than: " + expectedValue;
|
||||
}
|
||||
|
||||
std::string
|
||||
Asserter::makeExpectedGreaterEqual( const std::string& expectedValue )
|
||||
{
|
||||
return "Expected greater or equal than: " + expectedValue;
|
||||
}
|
||||
|
||||
std::string
|
||||
Asserter::makeActual( const std::string &actualValue )
|
||||
{
|
||||
return "Actual : " + actualValue;
|
||||
}
|
||||
|
||||
|
||||
Message
|
||||
Asserter::makeMessage( const std::string& expectedMessage,
|
||||
const std::string& actualMessage,
|
||||
const std::string& shortDescription,
|
||||
const AdditionalMessage& additionalMessage)
|
||||
{
|
||||
Message message( shortDescription,
|
||||
expectedMessage,
|
||||
actualMessage );
|
||||
message.addDetail( additionalMessage );
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
Message
|
||||
Asserter::makeNotEqualMessage( const std::string &expectedValue,
|
||||
const std::string &actualValue,
|
||||
const AdditionalMessage &additionalMessage,
|
||||
const std::string &shortDescription )
|
||||
{
|
||||
return makeMessage(makeExpectedEqual(expectedValue), makeActual(actualValue), shortDescription, additionalMessage);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Asserter::failNotEqual( std::string expected,
|
||||
std::string actual,
|
||||
const SourceLine &sourceLine,
|
||||
const AdditionalMessage &additionalMessage,
|
||||
std::string shortDescription )
|
||||
{
|
||||
fail( makeMessage( makeExpectedEqual(expected),
|
||||
makeActual(actual),
|
||||
shortDescription,
|
||||
additionalMessage ),
|
||||
sourceLine );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Asserter::failNotLess( std::string expected,
|
||||
std::string actual,
|
||||
const SourceLine &sourceLine,
|
||||
const AdditionalMessage &additionalMessage,
|
||||
std::string shortDescription )
|
||||
{
|
||||
fail( makeMessage( makeExpectedLess(expected),
|
||||
makeActual(actual),
|
||||
shortDescription,
|
||||
additionalMessage),
|
||||
sourceLine );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Asserter::failNotGreater( std::string expected,
|
||||
std::string actual,
|
||||
const SourceLine &sourceLine,
|
||||
const AdditionalMessage &additionalMessage,
|
||||
std::string shortDescription )
|
||||
{
|
||||
fail( makeMessage( makeExpectedGreater(expected),
|
||||
makeActual(actual),
|
||||
shortDescription,
|
||||
additionalMessage),
|
||||
sourceLine );
|
||||
}
|
||||
|
||||
void
|
||||
Asserter::failNotLessEqual( std::string expected,
|
||||
std::string actual,
|
||||
const SourceLine &sourceLine,
|
||||
const AdditionalMessage &additionalMessage,
|
||||
std::string shortDescription )
|
||||
{
|
||||
fail( makeMessage( makeExpectedLessEqual(expected),
|
||||
makeActual(actual),
|
||||
shortDescription,
|
||||
additionalMessage ),
|
||||
sourceLine );
|
||||
}
|
||||
|
||||
void
|
||||
Asserter::failNotGreaterEqual( std::string expected,
|
||||
std::string actual,
|
||||
const SourceLine &sourceLine,
|
||||
const AdditionalMessage &additionalMessage,
|
||||
std::string shortDescription )
|
||||
{
|
||||
fail( makeMessage( makeExpectedGreaterEqual(expected),
|
||||
makeActual(actual),
|
||||
shortDescription,
|
||||
additionalMessage ),
|
||||
sourceLine );
|
||||
}
|
||||
void
|
||||
Asserter::failNotEqualIf( bool shouldFail,
|
||||
std::string expected,
|
||||
std::string actual,
|
||||
const SourceLine &sourceLine,
|
||||
const AdditionalMessage &additionalMessage,
|
||||
std::string shortDescription )
|
||||
{
|
||||
if ( shouldFail )
|
||||
failNotEqual( expected, actual, sourceLine, additionalMessage, shortDescription );
|
||||
}
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
49
3rdparty/cppunit/src/cppunit/BriefTestProgressListener.cpp
vendored
Normal file
49
3rdparty/cppunit/src/cppunit/BriefTestProgressListener.cpp
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
#include <cppunit/BriefTestProgressListener.h>
|
||||
#include <cppunit/Test.h>
|
||||
#include <cppunit/TestFailure.h>
|
||||
#include <cppunit/portability/Stream.h>
|
||||
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
BriefTestProgressListener::BriefTestProgressListener()
|
||||
: m_lastTestFailed( false )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BriefTestProgressListener::~BriefTestProgressListener()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BriefTestProgressListener::startTest( Test *test )
|
||||
{
|
||||
stdCOut() << test->getName();
|
||||
stdCOut().flush();
|
||||
|
||||
m_lastTestFailed = false;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BriefTestProgressListener::addFailure( const TestFailure &failure )
|
||||
{
|
||||
stdCOut() << " : " << (failure.isError() ? "error" : "assertion");
|
||||
m_lastTestFailed = true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BriefTestProgressListener::endTest( Test * )
|
||||
{
|
||||
if ( !m_lastTestFailed )
|
||||
stdCOut() << " : OK";
|
||||
stdCOut() << "\n";
|
||||
}
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
55
3rdparty/cppunit/src/cppunit/CMakeLists.txt
vendored
Normal file
55
3rdparty/cppunit/src/cppunit/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
set(CPPUNIT_SOURCES
|
||||
${CPPUNIT_SOURCES}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/AdditionalMessage.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Asserter.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/BriefTestProgressListener.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CompilerOutputter.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/DefaultProtector.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/DefaultProtector.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/DynamicLibraryManager.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/DynamicLibraryManagerException.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Exception.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Message.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/RepeatedTest.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/PlugInManager.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/PlugInParameters.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Protector.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ProtectorChain.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ProtectorContext.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ProtectorChain.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/SourceLine.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/StringTools.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/SynchronizedObject.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Test.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestAssert.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestCase.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestCaseDecorator.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestComposite.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestDecorator.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestFactoryRegistry.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestFailure.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestLeaf.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestNamer.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestPath.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestPlugInDefaultImpl.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestResult.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestResultCollector.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestRunner.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestSetUp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestSuccessListener.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestSuite.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TestSuiteBuilderContext.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TextOutputter.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TextTestProgressListener.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TextTestResult.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TextTestRunner.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TypeInfoHelper.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/UnixDynamicLibraryManager.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ShlDynamicLibraryManager.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/XmlDocument.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/XmlElement.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/XmlOutputter.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/XmlOutputterHook.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Win32DynamicLibraryManager.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
216
3rdparty/cppunit/src/cppunit/CompilerOutputter.cpp
vendored
Normal file
216
3rdparty/cppunit/src/cppunit/CompilerOutputter.cpp
vendored
Normal file
@@ -0,0 +1,216 @@
|
||||
#include <cppunit/config/SourcePrefix.h>
|
||||
#include <cppunit/Exception.h>
|
||||
#include <cppunit/SourceLine.h>
|
||||
#include <cppunit/TestFailure.h>
|
||||
#include <cppunit/TestResultCollector.h>
|
||||
#include <cppunit/CompilerOutputter.h>
|
||||
#include <algorithm>
|
||||
#include <cppunit/tools/StringTools.h>
|
||||
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
CompilerOutputter::CompilerOutputter( TestResultCollector *result,
|
||||
OStream &stream,
|
||||
const std::string &locationFormat )
|
||||
: m_result( result )
|
||||
, m_stream( stream )
|
||||
, m_locationFormat( locationFormat )
|
||||
, m_wrapColumn( CPPUNIT_WRAP_COLUMN )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CompilerOutputter::~CompilerOutputter()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CompilerOutputter::setLocationFormat( const std::string &locationFormat )
|
||||
{
|
||||
m_locationFormat = locationFormat;
|
||||
}
|
||||
|
||||
|
||||
CompilerOutputter *
|
||||
CompilerOutputter::defaultOutputter( TestResultCollector *result,
|
||||
OStream &stream )
|
||||
{
|
||||
return new CompilerOutputter( result, stream );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CompilerOutputter::write()
|
||||
{
|
||||
if ( m_result->wasSuccessful() )
|
||||
printSuccess();
|
||||
else
|
||||
printFailureReport();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CompilerOutputter::printSuccess()
|
||||
{
|
||||
m_stream << "OK (" << m_result->runTests() << ")\n";
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CompilerOutputter::printFailureReport()
|
||||
{
|
||||
printFailuresList();
|
||||
printStatistics();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CompilerOutputter::printFailuresList()
|
||||
{
|
||||
for ( int index =0; index < m_result->testFailuresTotal(); ++index)
|
||||
{
|
||||
printFailureDetail( m_result->failures()[ index ] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CompilerOutputter::printFailureDetail( TestFailure *failure )
|
||||
{
|
||||
printFailureLocation( failure->sourceLine() );
|
||||
printFailureType( failure );
|
||||
printFailedTestName( failure );
|
||||
printFailureMessage( failure );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CompilerOutputter::printFailureLocation( SourceLine sourceLine )
|
||||
{
|
||||
if ( !sourceLine.isValid() )
|
||||
{
|
||||
m_stream << "##Failure Location unknown## : ";
|
||||
return;
|
||||
}
|
||||
|
||||
std::string location;
|
||||
for ( unsigned int index = 0; index < m_locationFormat.length(); ++index )
|
||||
{
|
||||
char c = m_locationFormat[ index ];
|
||||
if ( c == '%' && ( index+1 < m_locationFormat.length() ) )
|
||||
{
|
||||
char command = m_locationFormat[index+1];
|
||||
if ( processLocationFormatCommand( command, sourceLine ) )
|
||||
{
|
||||
++index;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
m_stream << c;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
CompilerOutputter::processLocationFormatCommand( char command,
|
||||
const SourceLine &sourceLine )
|
||||
{
|
||||
switch ( command )
|
||||
{
|
||||
case 'p':
|
||||
m_stream << sourceLine.fileName();
|
||||
return true;
|
||||
case 'l':
|
||||
m_stream << sourceLine.lineNumber();
|
||||
return true;
|
||||
case 'f':
|
||||
m_stream << extractBaseName( sourceLine.fileName() );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
std::string
|
||||
CompilerOutputter::extractBaseName( const std::string &fileName ) const
|
||||
{
|
||||
int indexLastDirectorySeparator = fileName.find_last_of( '/' );
|
||||
|
||||
if ( indexLastDirectorySeparator < 0 )
|
||||
indexLastDirectorySeparator = fileName.find_last_of( '\\' );
|
||||
|
||||
if ( indexLastDirectorySeparator < 0 )
|
||||
return fileName;
|
||||
|
||||
return fileName.substr( indexLastDirectorySeparator +1 );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CompilerOutputter::printFailureType( TestFailure *failure )
|
||||
{
|
||||
m_stream << (failure->isError() ? "Error" : "Assertion");
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CompilerOutputter::printFailedTestName( TestFailure *failure )
|
||||
{
|
||||
m_stream << "\nTest name: " << failure->failedTestName();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CompilerOutputter::printFailureMessage( TestFailure *failure )
|
||||
{
|
||||
m_stream << "\n";
|
||||
Exception *thrownException = failure->thrownException();
|
||||
m_stream << thrownException->message().shortDescription() << "\n";
|
||||
|
||||
std::string message = thrownException->message().details();
|
||||
if ( m_wrapColumn > 0 )
|
||||
message = StringTools::wrap( message, m_wrapColumn );
|
||||
|
||||
m_stream << message << "\n";
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CompilerOutputter::printStatistics()
|
||||
{
|
||||
m_stream << "Failures !!!\n";
|
||||
m_stream << "Run: " << m_result->runTests() << " "
|
||||
<< "Failure total: " << m_result->testFailuresTotal() << " "
|
||||
<< "Failures: " << m_result->testFailures() << " "
|
||||
<< "Errors: " << m_result->testErrors()
|
||||
<< "\n";
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CompilerOutputter::setWrapColumn( int wrapColumn )
|
||||
{
|
||||
m_wrapColumn = wrapColumn;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CompilerOutputter::setNoWrap()
|
||||
{
|
||||
m_wrapColumn = 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
CompilerOutputter::wrapColumn() const
|
||||
{
|
||||
return m_wrapColumn;
|
||||
}
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
42
3rdparty/cppunit/src/cppunit/DefaultProtector.cpp
vendored
Normal file
42
3rdparty/cppunit/src/cppunit/DefaultProtector.cpp
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
#include <cppunit/Exception.h>
|
||||
#include <cppunit/extensions/TypeInfoHelper.h>
|
||||
#include "DefaultProtector.h"
|
||||
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
bool
|
||||
DefaultProtector::protect( const Functor &functor,
|
||||
const ProtectorContext &context )
|
||||
{
|
||||
try
|
||||
{
|
||||
return functor();
|
||||
}
|
||||
catch ( Exception &failure )
|
||||
{
|
||||
reportFailure( context, failure );
|
||||
}
|
||||
catch ( std::exception &e )
|
||||
{
|
||||
std::string shortDescription( "uncaught exception of type " );
|
||||
#if defined(CPPUNIT_USE_TYPEINFO_NAME)
|
||||
shortDescription += TypeInfoHelper::getClassName( typeid(e) );
|
||||
#else
|
||||
shortDescription += "std::exception (or derived).";
|
||||
#endif
|
||||
Message message( shortDescription, e.what() );
|
||||
reportError( context, message );
|
||||
}
|
||||
catch ( ... )
|
||||
{
|
||||
reportError( context,
|
||||
Message( "uncaught exception of unknown type") );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
27
3rdparty/cppunit/src/cppunit/DefaultProtector.h
vendored
Normal file
27
3rdparty/cppunit/src/cppunit/DefaultProtector.h
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef CPPUNIT_DEFAULTPROTECTOR_H
|
||||
#define CPPUNIT_DEFAULTPROTECTOR_H
|
||||
|
||||
#include <cppunit/Protector.h>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
/*! \brief Default protector that catch all exceptions (Implementation).
|
||||
*
|
||||
* Implementation detail.
|
||||
* \internal This protector catch and generate a failure for the following
|
||||
* exception types:
|
||||
* - Exception
|
||||
* - std::exception
|
||||
* - ...
|
||||
*/
|
||||
class DefaultProtector : public Protector
|
||||
{
|
||||
public:
|
||||
bool protect( const Functor &functor,
|
||||
const ProtectorContext &context );
|
||||
};
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
#endif // CPPUNIT_DEFAULTPROTECTOR_H
|
||||
|
||||
16
3rdparty/cppunit/src/cppunit/DllMain.cpp
vendored
Normal file
16
3rdparty/cppunit/src/cppunit/DllMain.cpp
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOGDI
|
||||
#define NOUSER
|
||||
#define NOKERNEL
|
||||
#define NOSOUND
|
||||
#define BLENDFUNCTION void // for mingw & gcc
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
BOOL APIENTRY
|
||||
DllMain( HANDLE hModule,
|
||||
DWORD ul_reason_for_call,
|
||||
LPVOID lpReserved )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
77
3rdparty/cppunit/src/cppunit/DynamicLibraryManager.cpp
vendored
Normal file
77
3rdparty/cppunit/src/cppunit/DynamicLibraryManager.cpp
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
#include <cppunit/plugin/DynamicLibraryManager.h>
|
||||
|
||||
#if !defined(CPPUNIT_NO_TESTPLUGIN)
|
||||
#include <cppunit/plugin/DynamicLibraryManagerException.h>
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
|
||||
DynamicLibraryManager::DynamicLibraryManager( const std::string &libraryFileName )
|
||||
: m_libraryHandle( NULL )
|
||||
, m_libraryName( libraryFileName )
|
||||
{
|
||||
loadLibrary( libraryFileName );
|
||||
}
|
||||
|
||||
|
||||
DynamicLibraryManager::~DynamicLibraryManager()
|
||||
{
|
||||
releaseLibrary();
|
||||
}
|
||||
|
||||
|
||||
DynamicLibraryManager::Symbol
|
||||
DynamicLibraryManager::findSymbol( const std::string &symbol )
|
||||
{
|
||||
try
|
||||
{
|
||||
Symbol symbolPointer = doFindSymbol( symbol );
|
||||
if ( symbolPointer != NULL )
|
||||
return symbolPointer;
|
||||
}
|
||||
catch ( ... )
|
||||
{
|
||||
}
|
||||
|
||||
throw DynamicLibraryManagerException( m_libraryName,
|
||||
symbol,
|
||||
DynamicLibraryManagerException::symbolNotFound );
|
||||
return NULL; // keep compiler happy
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DynamicLibraryManager::loadLibrary( const std::string &libraryName )
|
||||
{
|
||||
try
|
||||
{
|
||||
releaseLibrary();
|
||||
m_libraryHandle = doLoadLibrary( libraryName );
|
||||
if ( m_libraryHandle != NULL )
|
||||
return;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
|
||||
throw DynamicLibraryManagerException( m_libraryName,
|
||||
getLastErrorDetail(),
|
||||
DynamicLibraryManagerException::loadingFailed );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DynamicLibraryManager::releaseLibrary()
|
||||
{
|
||||
if ( m_libraryHandle != NULL )
|
||||
{
|
||||
doReleaseLibrary();
|
||||
m_libraryHandle = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
|
||||
#endif // !defined(CPPUNIT_NO_TESTPLUGIN)
|
||||
40
3rdparty/cppunit/src/cppunit/DynamicLibraryManagerException.cpp
vendored
Normal file
40
3rdparty/cppunit/src/cppunit/DynamicLibraryManagerException.cpp
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
#include <cppunit/plugin/DynamicLibraryManagerException.h>
|
||||
|
||||
#if !defined(CPPUNIT_NO_TESTPLUGIN)
|
||||
|
||||
CPPUNIT_NS_BEGIN
|
||||
|
||||
DynamicLibraryManagerException::DynamicLibraryManagerException(
|
||||
const std::string &libraryName,
|
||||
const std::string &errorDetail,
|
||||
Cause cause )
|
||||
: std::runtime_error( "" )
|
||||
, m_message()
|
||||
, m_cause( cause )
|
||||
{
|
||||
if ( cause == loadingFailed )
|
||||
m_message = "Failed to load dynamic library: " + libraryName + "\n" +
|
||||
errorDetail;
|
||||
else
|
||||
m_message = "Symbol [" + errorDetail + "] not found in dynamic libary:" +
|
||||
libraryName;
|
||||
}
|
||||
|
||||
DynamicLibraryManagerException::Cause
|
||||
DynamicLibraryManagerException::getCause() const
|
||||
{
|
||||
return m_cause;
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
DynamicLibraryManagerException::what() const throw()
|
||||
{
|
||||
return m_message.c_str();
|
||||
}
|
||||
|
||||
|
||||
CPPUNIT_NS_END
|
||||
|
||||
|
||||
#endif // !defined(CPPUNIT_NO_TESTPLUGIN)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user