.gitgnore, fix indent (no spaces, etc...)
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/.ccls-cache/
|
18
AllTests.c
18
AllTests.c
@@ -7,19 +7,19 @@ CuSuite* CuStringGetSuite();
|
|||||||
|
|
||||||
void RunAllTests(void)
|
void RunAllTests(void)
|
||||||
{
|
{
|
||||||
CuString *output = CuStringNew();
|
CuString *output = CuStringNew();
|
||||||
CuSuite* suite = CuSuiteNew();
|
CuSuite* suite = CuSuiteNew();
|
||||||
|
|
||||||
CuSuiteAddSuite(suite, CuGetSuite());
|
CuSuiteAddSuite(suite, CuGetSuite());
|
||||||
CuSuiteAddSuite(suite, CuStringGetSuite());
|
CuSuiteAddSuite(suite, CuStringGetSuite());
|
||||||
|
|
||||||
CuSuiteRun(suite);
|
CuSuiteRun(suite);
|
||||||
CuSuiteSummary(suite, output);
|
CuSuiteSummary(suite, output);
|
||||||
CuSuiteDetails(suite, output);
|
CuSuiteDetails(suite, output);
|
||||||
printf("%s\n", output->buffer);
|
printf("%s\n", output->buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
RunAllTests();
|
RunAllTests();
|
||||||
}
|
}
|
||||||
|
370
CuTest.c
370
CuTest.c
@@ -13,16 +13,16 @@
|
|||||||
|
|
||||||
char* CuStrAlloc(int size)
|
char* CuStrAlloc(int size)
|
||||||
{
|
{
|
||||||
char* newStr = (char*) malloc( sizeof(char) * (size) );
|
char* newStr = (char*) malloc( sizeof(char) * (size) );
|
||||||
return newStr;
|
return newStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* CuStrCopy(const char* old)
|
char* CuStrCopy(const char* old)
|
||||||
{
|
{
|
||||||
int len = strlen(old);
|
int len = strlen(old);
|
||||||
char* newStr = CuStrAlloc(len + 1);
|
char* newStr = CuStrAlloc(len + 1);
|
||||||
strcpy(newStr, old);
|
strcpy(newStr, old);
|
||||||
return newStr;
|
return newStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*
|
/*-------------------------------------------------------------------------*
|
||||||
@@ -31,78 +31,78 @@ char* CuStrCopy(const char* old)
|
|||||||
|
|
||||||
void CuStringInit(CuString* str)
|
void CuStringInit(CuString* str)
|
||||||
{
|
{
|
||||||
str->length = 0;
|
str->length = 0;
|
||||||
str->size = STRING_MAX;
|
str->size = STRING_MAX;
|
||||||
str->buffer = (char*) malloc(sizeof(char) * str->size);
|
str->buffer = (char*) malloc(sizeof(char) * str->size);
|
||||||
str->buffer[0] = '\0';
|
str->buffer[0] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
CuString* CuStringNew(void)
|
CuString* CuStringNew(void)
|
||||||
{
|
{
|
||||||
CuString* str = (CuString*) malloc(sizeof(CuString));
|
CuString* str = (CuString*) malloc(sizeof(CuString));
|
||||||
str->length = 0;
|
str->length = 0;
|
||||||
str->size = STRING_MAX;
|
str->size = STRING_MAX;
|
||||||
str->buffer = (char*) malloc(sizeof(char) * str->size);
|
str->buffer = (char*) malloc(sizeof(char) * str->size);
|
||||||
str->buffer[0] = '\0';
|
str->buffer[0] = '\0';
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CuStringDelete(CuString *str)
|
void CuStringDelete(CuString *str)
|
||||||
{
|
{
|
||||||
if (!str) return;
|
if (!str) return;
|
||||||
free(str->buffer);
|
free(str->buffer);
|
||||||
free(str);
|
free(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CuStringResize(CuString* str, int newSize)
|
void CuStringResize(CuString* str, int newSize)
|
||||||
{
|
{
|
||||||
str->buffer = (char*) realloc(str->buffer, sizeof(char) * newSize);
|
str->buffer = (char*) realloc(str->buffer, sizeof(char) * newSize);
|
||||||
str->size = newSize;
|
str->size = newSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CuStringAppend(CuString* str, const char* text)
|
void CuStringAppend(CuString* str, const char* text)
|
||||||
{
|
{
|
||||||
int length;
|
int length;
|
||||||
|
|
||||||
if (text == NULL) {
|
if (text == NULL) {
|
||||||
text = "NULL";
|
text = "NULL";
|
||||||
}
|
}
|
||||||
|
|
||||||
length = strlen(text);
|
length = strlen(text);
|
||||||
if (str->length + length + 1 >= str->size)
|
if (str->length + length + 1 >= str->size)
|
||||||
CuStringResize(str, str->length + length + 1 + STRING_INC);
|
CuStringResize(str, str->length + length + 1 + STRING_INC);
|
||||||
str->length += length;
|
str->length += length;
|
||||||
strcat(str->buffer, text);
|
strcat(str->buffer, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CuStringAppendChar(CuString* str, char ch)
|
void CuStringAppendChar(CuString* str, char ch)
|
||||||
{
|
{
|
||||||
char text[2];
|
char text[2];
|
||||||
text[0] = ch;
|
text[0] = ch;
|
||||||
text[1] = '\0';
|
text[1] = '\0';
|
||||||
CuStringAppend(str, text);
|
CuStringAppend(str, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CuStringAppendFormat(CuString* str, const char* format, ...)
|
void CuStringAppendFormat(CuString* str, const char* format, ...)
|
||||||
{
|
{
|
||||||
va_list argp;
|
va_list argp;
|
||||||
char buf[HUGE_STRING_LEN];
|
char buf[HUGE_STRING_LEN];
|
||||||
va_start(argp, format);
|
va_start(argp, format);
|
||||||
vsprintf(buf, format, argp);
|
vsprintf(buf, format, argp);
|
||||||
va_end(argp);
|
va_end(argp);
|
||||||
CuStringAppend(str, buf);
|
CuStringAppend(str, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CuStringInsert(CuString* str, const char* text, int pos)
|
void CuStringInsert(CuString* str, const char* text, int pos)
|
||||||
{
|
{
|
||||||
int length = strlen(text);
|
int length = strlen(text);
|
||||||
if (pos > str->length)
|
if (pos > str->length)
|
||||||
pos = str->length;
|
pos = str->length;
|
||||||
if (str->length + length + 1 >= str->size)
|
if (str->length + length + 1 >= str->size)
|
||||||
CuStringResize(str, str->length + length + 1 + STRING_INC);
|
CuStringResize(str, str->length + length + 1 + STRING_INC);
|
||||||
memmove(str->buffer + pos + length, str->buffer + pos, (str->length - pos) + 1);
|
memmove(str->buffer + pos + length, str->buffer + pos, (str->length - pos) + 1);
|
||||||
str->length += length;
|
str->length += length;
|
||||||
memcpy(str->buffer + pos, text, length);
|
memcpy(str->buffer + pos, text, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*
|
/*-------------------------------------------------------------------------*
|
||||||
@@ -111,124 +111,124 @@ void CuStringInsert(CuString* str, const char* text, int pos)
|
|||||||
|
|
||||||
void CuTestInit(CuTest* t, const char* name, TestFunction function)
|
void CuTestInit(CuTest* t, const char* name, TestFunction function)
|
||||||
{
|
{
|
||||||
t->name = CuStrCopy(name);
|
t->name = CuStrCopy(name);
|
||||||
t->failed = 0;
|
t->failed = 0;
|
||||||
t->ran = 0;
|
t->ran = 0;
|
||||||
t->message = NULL;
|
t->message = NULL;
|
||||||
t->function = function;
|
t->function = function;
|
||||||
t->jumpBuf = NULL;
|
t->jumpBuf = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CuTest* CuTestNew(const char* name, TestFunction function)
|
CuTest* CuTestNew(const char* name, TestFunction function)
|
||||||
{
|
{
|
||||||
CuTest* tc = CU_ALLOC(CuTest);
|
CuTest* tc = CU_ALLOC(CuTest);
|
||||||
CuTestInit(tc, name, function);
|
CuTestInit(tc, name, function);
|
||||||
return tc;
|
return tc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CuTestDelete(CuTest *t)
|
void CuTestDelete(CuTest *t)
|
||||||
{
|
{
|
||||||
if (!t) return;
|
if (!t) return;
|
||||||
free(t->name);
|
free(t->name);
|
||||||
free(t);
|
free(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CuTestRun(CuTest* tc)
|
void CuTestRun(CuTest* tc)
|
||||||
{
|
{
|
||||||
jmp_buf buf;
|
jmp_buf buf;
|
||||||
tc->jumpBuf = &buf;
|
tc->jumpBuf = &buf;
|
||||||
if (setjmp(buf) == 0)
|
if (setjmp(buf) == 0)
|
||||||
{
|
{
|
||||||
tc->ran = 1;
|
tc->ran = 1;
|
||||||
(tc->function)(tc);
|
(tc->function)(tc);
|
||||||
}
|
}
|
||||||
tc->jumpBuf = 0;
|
tc->jumpBuf = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CuFailInternal(CuTest* tc, const char* file, int line, CuString* string)
|
static void CuFailInternal(CuTest* tc, const char* file, int line, CuString* string)
|
||||||
{
|
{
|
||||||
char buf[HUGE_STRING_LEN];
|
char buf[HUGE_STRING_LEN];
|
||||||
|
|
||||||
sprintf(buf, "%s:%d: ", file, line);
|
sprintf(buf, "%s:%d: ", file, line);
|
||||||
CuStringInsert(string, buf, 0);
|
CuStringInsert(string, buf, 0);
|
||||||
|
|
||||||
tc->failed = 1;
|
tc->failed = 1;
|
||||||
tc->message = string->buffer;
|
tc->message = string->buffer;
|
||||||
if (tc->jumpBuf != 0) longjmp(*(tc->jumpBuf), 0);
|
if (tc->jumpBuf != 0) longjmp(*(tc->jumpBuf), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CuFail_Line(CuTest* tc, const char* file, int line, const char* message2, const char* message)
|
void CuFail_Line(CuTest* tc, const char* file, int line, const char* message2, const char* message)
|
||||||
{
|
{
|
||||||
CuString string;
|
CuString string;
|
||||||
|
|
||||||
CuStringInit(&string);
|
CuStringInit(&string);
|
||||||
if (message2 != NULL)
|
if (message2 != NULL)
|
||||||
{
|
{
|
||||||
CuStringAppend(&string, message2);
|
CuStringAppend(&string, message2);
|
||||||
CuStringAppend(&string, ": ");
|
CuStringAppend(&string, ": ");
|
||||||
}
|
}
|
||||||
CuStringAppend(&string, message);
|
CuStringAppend(&string, message);
|
||||||
CuFailInternal(tc, file, line, &string);
|
CuFailInternal(tc, file, line, &string);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CuAssert_Line(CuTest* tc, const char* file, int line, const char* message, int condition)
|
void CuAssert_Line(CuTest* tc, const char* file, int line, const char* message, int condition)
|
||||||
{
|
{
|
||||||
if (condition) return;
|
if (condition) return;
|
||||||
CuFail_Line(tc, file, line, NULL, message);
|
CuFail_Line(tc, file, line, NULL, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CuAssertStrEquals_LineMsg(CuTest* tc, const char* file, int line, const char* message,
|
void CuAssertStrEquals_LineMsg(CuTest* tc, const char* file, int line, const char* message,
|
||||||
const char* expected, const char* actual)
|
const char* expected, const char* actual)
|
||||||
{
|
{
|
||||||
CuString string;
|
CuString string;
|
||||||
if ((expected == NULL && actual == NULL) ||
|
if ((expected == NULL && actual == NULL) ||
|
||||||
(expected != NULL && actual != NULL &&
|
(expected != NULL && actual != NULL &&
|
||||||
strcmp(expected, actual) == 0))
|
strcmp(expected, actual) == 0))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CuStringInit(&string);
|
CuStringInit(&string);
|
||||||
if (message != NULL)
|
if (message != NULL)
|
||||||
{
|
{
|
||||||
CuStringAppend(&string, message);
|
CuStringAppend(&string, message);
|
||||||
CuStringAppend(&string, ": ");
|
CuStringAppend(&string, ": ");
|
||||||
}
|
}
|
||||||
CuStringAppend(&string, "expected <");
|
CuStringAppend(&string, "expected <");
|
||||||
CuStringAppend(&string, expected);
|
CuStringAppend(&string, expected);
|
||||||
CuStringAppend(&string, "> but was <");
|
CuStringAppend(&string, "> but was <");
|
||||||
CuStringAppend(&string, actual);
|
CuStringAppend(&string, actual);
|
||||||
CuStringAppend(&string, ">");
|
CuStringAppend(&string, ">");
|
||||||
CuFailInternal(tc, file, line, &string);
|
CuFailInternal(tc, file, line, &string);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CuAssertIntEquals_LineMsg(CuTest* tc, const char* file, int line, const char* message,
|
void CuAssertIntEquals_LineMsg(CuTest* tc, const char* file, int line, const char* message,
|
||||||
int expected, int actual)
|
int expected, int actual)
|
||||||
{
|
{
|
||||||
char buf[STRING_MAX];
|
char buf[STRING_MAX];
|
||||||
if (expected == actual) return;
|
if (expected == actual) return;
|
||||||
sprintf(buf, "expected <%d> but was <%d>", expected, actual);
|
sprintf(buf, "expected <%d> but was <%d>", expected, actual);
|
||||||
CuFail_Line(tc, file, line, message, buf);
|
CuFail_Line(tc, file, line, message, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CuAssertDblEquals_LineMsg(CuTest* tc, const char* file, int line, const char* message,
|
void CuAssertDblEquals_LineMsg(CuTest* tc, const char* file, int line, const char* message,
|
||||||
double expected, double actual, double delta)
|
double expected, double actual, double delta)
|
||||||
{
|
{
|
||||||
char buf[STRING_MAX];
|
char buf[STRING_MAX];
|
||||||
if (fabs(expected - actual) <= delta) return;
|
if (fabs(expected - actual) <= delta) return;
|
||||||
/* sprintf(buf, "expected <%lf> but was <%lf>", expected, actual); */
|
/* sprintf(buf, "expected <%lf> but was <%lf>", expected, actual); */
|
||||||
sprintf(buf, "expected <%f> but was <%f>", expected, actual);
|
sprintf(buf, "expected <%f> but was <%f>", expected, actual);
|
||||||
|
|
||||||
CuFail_Line(tc, file, line, message, buf);
|
CuFail_Line(tc, file, line, message, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CuAssertPtrEquals_LineMsg(CuTest* tc, const char* file, int line, const char* message,
|
void CuAssertPtrEquals_LineMsg(CuTest* tc, const char* file, int line, const char* message,
|
||||||
void* expected, void* actual)
|
void* expected, void* actual)
|
||||||
{
|
{
|
||||||
char buf[STRING_MAX];
|
char buf[STRING_MAX];
|
||||||
if (expected == actual) return;
|
if (expected == actual) return;
|
||||||
sprintf(buf, "expected pointer <0x%p> but was <0x%p>", expected, actual);
|
sprintf(buf, "expected pointer <0x%p> but was <0x%p>", expected, actual);
|
||||||
CuFail_Line(tc, file, line, message, buf);
|
CuFail_Line(tc, file, line, message, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -238,103 +238,103 @@ void CuAssertPtrEquals_LineMsg(CuTest* tc, const char* file, int line, const cha
|
|||||||
|
|
||||||
void CuSuiteInit(CuSuite* testSuite)
|
void CuSuiteInit(CuSuite* testSuite)
|
||||||
{
|
{
|
||||||
testSuite->count = 0;
|
testSuite->count = 0;
|
||||||
testSuite->failCount = 0;
|
testSuite->failCount = 0;
|
||||||
memset(testSuite->list, 0, sizeof(testSuite->list));
|
memset(testSuite->list, 0, sizeof(testSuite->list));
|
||||||
}
|
}
|
||||||
|
|
||||||
CuSuite* CuSuiteNew(void)
|
CuSuite* CuSuiteNew(void)
|
||||||
{
|
{
|
||||||
CuSuite* testSuite = CU_ALLOC(CuSuite);
|
CuSuite* testSuite = CU_ALLOC(CuSuite);
|
||||||
CuSuiteInit(testSuite);
|
CuSuiteInit(testSuite);
|
||||||
return testSuite;
|
return testSuite;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CuSuiteDelete(CuSuite *testSuite)
|
void CuSuiteDelete(CuSuite *testSuite)
|
||||||
{
|
{
|
||||||
unsigned int n;
|
unsigned int n;
|
||||||
for (n=0; n < MAX_TEST_CASES; n++)
|
for (n=0; n < MAX_TEST_CASES; n++)
|
||||||
|
{
|
||||||
|
if (testSuite->list[n])
|
||||||
{
|
{
|
||||||
if (testSuite->list[n])
|
CuTestDelete(testSuite->list[n]);
|
||||||
{
|
|
||||||
CuTestDelete(testSuite->list[n]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
free(testSuite);
|
}
|
||||||
|
free(testSuite);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CuSuiteAdd(CuSuite* testSuite, CuTest *testCase)
|
void CuSuiteAdd(CuSuite* testSuite, CuTest *testCase)
|
||||||
{
|
{
|
||||||
assert(testSuite->count < MAX_TEST_CASES);
|
assert(testSuite->count < MAX_TEST_CASES);
|
||||||
testSuite->list[testSuite->count] = testCase;
|
testSuite->list[testSuite->count] = testCase;
|
||||||
testSuite->count++;
|
testSuite->count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CuSuiteAddSuite(CuSuite* testSuite, CuSuite* testSuite2)
|
void CuSuiteAddSuite(CuSuite* testSuite, CuSuite* testSuite2)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0 ; i < testSuite2->count ; ++i)
|
for (i = 0 ; i < testSuite2->count ; ++i)
|
||||||
{
|
{
|
||||||
CuTest* testCase = testSuite2->list[i];
|
CuTest* testCase = testSuite2->list[i];
|
||||||
CuSuiteAdd(testSuite, testCase);
|
CuSuiteAdd(testSuite, testCase);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CuSuiteRun(CuSuite* testSuite)
|
void CuSuiteRun(CuSuite* testSuite)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0 ; i < testSuite->count ; ++i)
|
for (i = 0 ; i < testSuite->count ; ++i)
|
||||||
{
|
{
|
||||||
CuTest* testCase = testSuite->list[i];
|
CuTest* testCase = testSuite->list[i];
|
||||||
CuTestRun(testCase);
|
CuTestRun(testCase);
|
||||||
if (testCase->failed) { testSuite->failCount += 1; }
|
if (testCase->failed) { testSuite->failCount += 1; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CuSuiteSummary(CuSuite* testSuite, CuString* summary)
|
void CuSuiteSummary(CuSuite* testSuite, CuString* summary)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0 ; i < testSuite->count ; ++i)
|
for (i = 0 ; i < testSuite->count ; ++i)
|
||||||
{
|
{
|
||||||
CuTest* testCase = testSuite->list[i];
|
CuTest* testCase = testSuite->list[i];
|
||||||
CuStringAppend(summary, testCase->failed ? "F" : ".");
|
CuStringAppend(summary, testCase->failed ? "F" : ".");
|
||||||
}
|
}
|
||||||
CuStringAppend(summary, "\n\n");
|
CuStringAppend(summary, "\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CuSuiteDetails(CuSuite* testSuite, CuString* details)
|
void CuSuiteDetails(CuSuite* testSuite, CuString* details)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int failCount = 0;
|
int failCount = 0;
|
||||||
|
|
||||||
if (testSuite->failCount == 0)
|
if (testSuite->failCount == 0)
|
||||||
{
|
{
|
||||||
int passCount = testSuite->count - testSuite->failCount;
|
int passCount = testSuite->count - testSuite->failCount;
|
||||||
const char* testWord = passCount == 1 ? "test" : "tests";
|
const char* testWord = passCount == 1 ? "test" : "tests";
|
||||||
CuStringAppendFormat(details, "OK (%d %s)\n", passCount, testWord);
|
CuStringAppendFormat(details, "OK (%d %s)\n", passCount, testWord);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (testSuite->failCount == 1)
|
if (testSuite->failCount == 1)
|
||||||
CuStringAppend(details, "There was 1 failure:\n");
|
CuStringAppend(details, "There was 1 failure:\n");
|
||||||
else
|
else
|
||||||
CuStringAppendFormat(details, "There were %d failures:\n", testSuite->failCount);
|
CuStringAppendFormat(details, "There were %d failures:\n", testSuite->failCount);
|
||||||
|
|
||||||
for (i = 0 ; i < testSuite->count ; ++i)
|
for (i = 0 ; i < testSuite->count ; ++i)
|
||||||
{
|
{
|
||||||
CuTest* testCase = testSuite->list[i];
|
CuTest* testCase = testSuite->list[i];
|
||||||
if (testCase->failed)
|
if (testCase->failed)
|
||||||
{
|
{
|
||||||
failCount++;
|
failCount++;
|
||||||
CuStringAppendFormat(details, "%d) %s: %s\n",
|
CuStringAppendFormat(details, "%d) %s: %s\n",
|
||||||
failCount, testCase->name, testCase->message);
|
failCount, testCase->name, testCase->message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CuStringAppend(details, "\n!!!FAILURES!!!\n");
|
CuStringAppend(details, "\n!!!FAILURES!!!\n");
|
||||||
|
|
||||||
CuStringAppendFormat(details, "Runs: %d ", testSuite->count);
|
CuStringAppendFormat(details, "Runs: %d ", testSuite->count);
|
||||||
CuStringAppendFormat(details, "Passes: %d ", testSuite->count - testSuite->failCount);
|
CuStringAppendFormat(details, "Passes: %d ", testSuite->count - testSuite->failCount);
|
||||||
CuStringAppendFormat(details, "Fails: %d\n", testSuite->failCount);
|
CuStringAppendFormat(details, "Fails: %d\n", testSuite->failCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
40
CuTest.h
40
CuTest.h
@@ -17,9 +17,9 @@ char* CuStrCopy(const char* old);
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int length;
|
int length;
|
||||||
int size;
|
int size;
|
||||||
char* buffer;
|
char* buffer;
|
||||||
} CuString;
|
} CuString;
|
||||||
|
|
||||||
void CuStringInit(CuString* str);
|
void CuStringInit(CuString* str);
|
||||||
@@ -40,12 +40,12 @@ typedef void (*TestFunction)(CuTest *);
|
|||||||
|
|
||||||
struct CuTest
|
struct CuTest
|
||||||
{
|
{
|
||||||
char* name;
|
char* name;
|
||||||
TestFunction function;
|
TestFunction function;
|
||||||
int failed;
|
int failed;
|
||||||
int ran;
|
int ran;
|
||||||
const char* message;
|
const char* message;
|
||||||
jmp_buf *jumpBuf;
|
jmp_buf *jumpBuf;
|
||||||
};
|
};
|
||||||
|
|
||||||
void CuTestInit(CuTest* t, const char* name, TestFunction function);
|
void CuTestInit(CuTest* t, const char* name, TestFunction function);
|
||||||
@@ -57,17 +57,17 @@ void CuTestDelete(CuTest *t);
|
|||||||
void CuFail_Line(CuTest* tc, const char* file, int line, const char* message2, const char* message);
|
void CuFail_Line(CuTest* tc, const char* file, int line, const char* message2, const char* message);
|
||||||
void CuAssert_Line(CuTest* tc, const char* file, int line, const char* message, int condition);
|
void CuAssert_Line(CuTest* tc, const char* file, int line, const char* message, int condition);
|
||||||
void CuAssertStrEquals_LineMsg(CuTest* tc,
|
void CuAssertStrEquals_LineMsg(CuTest* tc,
|
||||||
const char* file, int line, const char* message,
|
const char* file, int line, const char* message,
|
||||||
const char* expected, const char* actual);
|
const char* expected, const char* actual);
|
||||||
void CuAssertIntEquals_LineMsg(CuTest* tc,
|
void CuAssertIntEquals_LineMsg(CuTest* tc,
|
||||||
const char* file, int line, const char* message,
|
const char* file, int line, const char* message,
|
||||||
int expected, int actual);
|
int expected, int actual);
|
||||||
void CuAssertDblEquals_LineMsg(CuTest* tc,
|
void CuAssertDblEquals_LineMsg(CuTest* tc,
|
||||||
const char* file, int line, const char* message,
|
const char* file, int line, const char* message,
|
||||||
double expected, double actual, double delta);
|
double expected, double actual, double delta);
|
||||||
void CuAssertPtrEquals_LineMsg(CuTest* tc,
|
void CuAssertPtrEquals_LineMsg(CuTest* tc,
|
||||||
const char* file, int line, const char* message,
|
const char* file, int line, const char* message,
|
||||||
void* expected, void* actual);
|
void* expected, void* actual);
|
||||||
|
|
||||||
/* public assert functions */
|
/* public assert functions */
|
||||||
|
|
||||||
@@ -95,9 +95,9 @@ void CuAssertPtrEquals_LineMsg(CuTest* tc,
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
CuTest* list[MAX_TEST_CASES];
|
CuTest* list[MAX_TEST_CASES];
|
||||||
int failCount;
|
int failCount;
|
||||||
|
|
||||||
} CuSuite;
|
} CuSuite;
|
||||||
|
|
||||||
|
878
CuTestTest.c
878
CuTestTest.c
File diff suppressed because it is too large
Load Diff
@@ -24,7 +24,7 @@ cat $FILES | grep '^void Test' |
|
|||||||
-e 's/^/extern /'
|
-e 's/^/extern /'
|
||||||
|
|
||||||
echo \
|
echo \
|
||||||
'
|
'
|
||||||
|
|
||||||
void RunAllTests(void)
|
void RunAllTests(void)
|
||||||
{
|
{
|
||||||
@@ -39,7 +39,7 @@ cat $FILES | grep '^void Test' |
|
|||||||
-e 's/$/);/'
|
-e 's/$/);/'
|
||||||
|
|
||||||
echo \
|
echo \
|
||||||
'
|
'
|
||||||
CuSuiteRun(suite);
|
CuSuiteRun(suite);
|
||||||
CuSuiteSummary(suite, output);
|
CuSuiteSummary(suite, output);
|
||||||
CuSuiteDetails(suite, output);
|
CuSuiteDetails(suite, output);
|
||||||
|
22
style.css
22
style.css
@@ -1,21 +1,21 @@
|
|||||||
BODY {
|
BODY {
|
||||||
font-family: "Verdana,Arial,sans-serif";
|
font-family: "Verdana,Arial,sans-serif";
|
||||||
font-size: 10pt;
|
font-size: 10pt;
|
||||||
}
|
}
|
||||||
PRE.LIST {
|
PRE.LIST {
|
||||||
background: #CFD9FF;
|
background: #CFD9FF;
|
||||||
border: 1ex solid #AAAAE6;
|
border: 1ex solid #AAAAE6;
|
||||||
padding: 1ex;
|
padding: 1ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRE.SNIP {
|
PRE.SNIP {
|
||||||
background: #CFD9FF;
|
background: #CFD9FF;
|
||||||
padding: 1ex;
|
padding: 1ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRE.CONSOLE {
|
PRE.CONSOLE {
|
||||||
color: #CCCCCC;
|
color: #CCCCCC;
|
||||||
background: #000000;
|
background: #000000;
|
||||||
font-family: "Courier New,Courier";
|
font-family: "Courier New,Courier";
|
||||||
padding: 1ex;
|
padding: 1ex;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user