2 * Copyright (c) 2002-2006 Asim Jalis
4 * This library is released under the zlib/libpng license as described at
6 * http://www.opensource.org/licenses/zlib-license.html
8 * Here is the statement of the license:
10 * This software is provided 'as-is', without any express or implied warranty.
11 * In no event will the authors be held liable for any damages arising from
12 * the use of this software.
14 * Permission is granted to anyone to use this software for any purpose,
15 * including commercial applications, and to alter it and redistribute it
16 * freely, subject to the following restrictions:
18 * 1. The origin of this software must not be misrepresented; you must not
19 * claim that you wrote the original software. If you use this software in a
20 * product, an acknowledgment in the product documentation would be
21 * appreciated but is not required.
23 * 2. Altered source versions must be plainly marked as such, and must not be
24 * misrepresented as being the original software.
26 * 3. This notice may not be removed or altered from any source distribution.
29 * This file has been modified from the original distribution.
40 char* CuStrAlloc(int size);
41 char* CuStrCopy(const char* old);
43 #define CU_ALLOC(TYPE) ((TYPE*) malloc(sizeof(TYPE)))
45 #define HUGE_STRING_LEN 8192
46 #define STRING_MAX 256
47 #define STRING_INC 256
56 void CuStringInit(CuString* str);
57 CuString* CuStringNew(void);
58 void CuStringRead(CuString* str, char* path);
59 void CuStringAppend(CuString* str, const char* text);
60 void CuStringAppendChar(CuString* str, char ch);
61 void CuStringAppendFormat(CuString* str, const char* format, ...);
62 void CuStringResize(CuString* str, int newSize);
66 typedef struct CuTest CuTest;
68 typedef void (*TestFunction)(CuTest *);
73 TestFunction function;
81 void CuInit(int argc, char *argv[]);
82 void CuTestInit(CuTest* t, char* name, TestFunction function);
83 CuTest* CuTestNew(char* name, TestFunction function);
84 void CuFail(CuTest* tc, const char* message);
85 void CuNotImpl(CuTest* tc, const char* message);
86 void CuAssert(CuTest* tc, const char* message, int condition);
87 void CuAssertTrue(CuTest* tc, int condition);
88 void CuAssertStrEquals(CuTest* tc, const char* expected, const char* actual);
89 void CuAssertStrNEquals(CuTest* tc, const char* expected, const char* actual,
91 void CuAssertIntEquals(CuTest* tc, int expected, int actual);
92 void CuAssertPtrEquals(CuTest* tc, const void* expected, const void* actual);
93 void CuAssertPtrNotNull(CuTest* tc, const void* pointer);
95 void CuTestRun(CuTest* tc);
99 #define MAX_TEST_CASES 1024
101 #define SUITE_ADD_TEST(SUITE,TEST) CuSuiteAdd(SUITE, CuTestNew(#TEST, TEST))
107 CuTest* list[MAX_TEST_CASES];
114 void CuSuiteInit(CuSuite* testSuite, char* name);
115 CuSuite* CuSuiteNew(char* name);
116 void CuSuiteAdd(CuSuite* testSuite, CuTest *testCase);
117 void CuSuiteAddSuite(CuSuite* testSuite, CuSuite* testSuite2);
118 void CuSuiteRun(CuSuite* testSuite);
119 void CuSuiteSummary(CuSuite* testSuite, CuString* summary);
120 void CuSuiteOverView(CuSuite* testSuite, CuString* details);
121 void CuSuiteDetails(CuSuite* testSuite, CuString* details);
127 CuSuite* list[MAX_TEST_CASES];
131 CuSuiteList* CuSuiteListNew(char* name);
132 void CuSuiteListAdd(CuSuiteList* testSuite, CuSuite *testCase);
133 void CuSuiteListRun(CuSuiteList* testSuite);
134 void CuSuiteListRunWithSummary(CuSuiteList* testSuite);
135 void CuSuiteListSummary(CuSuiteList* testSuite, CuString* summary);
136 /* Print details of test suite results; returns total number of
137 * tests which failed. */
138 int CuSuiteListDetails(CuSuiteList* testSuite, CuString* details);
139 #endif /* CU_TEST_H */