Main Page | Modules | Namespace List | Data Structures | File List | Data Fields | Globals

/home/oden/RPM/BUILD/apr-util-1.0.0/test/CuTest.h

00001 /* 00002 * Copyright (c) 2002-2006 Asim Jalis 00003 * 00004 * This library is released under the zlib/libpng license as described at 00005 * 00006 * http://www.opensource.org/licenses/zlib-license.html 00007 * 00008 * Here is the statement of the license: 00009 * 00010 * This software is provided 'as-is', without any express or implied warranty. 00011 * In no event will the authors be held liable for any damages arising from 00012 * the use of this software. 00013 * 00014 * Permission is granted to anyone to use this software for any purpose, 00015 * including commercial applications, and to alter it and redistribute it 00016 * freely, subject to the following restrictions: 00017 * 00018 * 1. The origin of this software must not be misrepresented; you must not 00019 * claim that you wrote the original software. If you use this software in a 00020 * product, an acknowledgment in the product documentation would be 00021 * appreciated but is not required. 00022 * 00023 * 2. Altered source versions must be plainly marked as such, and must not be 00024 * misrepresented as being the original software. 00025 * 00026 * 3. This notice may not be removed or altered from any source distribution. 00027 */ 00028 /* 00029 * This file has been modified from the original distribution. 00030 */ 00031 00032 #ifndef CU_TEST_H 00033 #define CU_TEST_H 00034 00035 #include <setjmp.h> 00036 #include <stdarg.h> 00037 00038 /* CuString */ 00039 00040 char* CuStrAlloc(int size); 00041 char* CuStrCopy(const char* old); 00042 00043 #define CU_ALLOC(TYPE) ((TYPE*) malloc(sizeof(TYPE))) 00044 00045 #define HUGE_STRING_LEN 8192 00046 #define STRING_MAX 256 00047 #define STRING_INC 256 00048 00049 typedef struct 00050 { 00051 int length; 00052 int size; 00053 char* buffer; 00054 } CuString; 00055 00056 void CuStringInit(CuString* str); 00057 CuString* CuStringNew(void); 00058 void CuStringRead(CuString* str, char* path); 00059 void CuStringAppend(CuString* str, const char* text); 00060 void CuStringAppendChar(CuString* str, char ch); 00061 void CuStringAppendFormat(CuString* str, const char* format, ...); 00062 void CuStringResize(CuString* str, int newSize); 00063 00064 /* CuTest */ 00065 00066 typedef struct CuTest CuTest; 00067 00068 typedef void (*TestFunction)(CuTest *); 00069 00070 struct CuTest 00071 { 00072 char* name; 00073 TestFunction function; 00074 int notimpl; 00075 int failed; 00076 int ran; 00077 char* message; 00078 jmp_buf *jumpBuf; 00079 }; 00080 00081 void CuInit(int argc, char *argv[]); 00082 void CuTestInit(CuTest* t, char* name, TestFunction function); 00083 CuTest* CuTestNew(char* name, TestFunction function); 00084 void CuFail(CuTest* tc, const char* message); 00085 void CuNotImpl(CuTest* tc, const char* message); 00086 void CuAssert(CuTest* tc, const char* message, int condition); 00087 void CuAssertTrue(CuTest* tc, int condition); 00088 void CuAssertStrEquals(CuTest* tc, const char* expected, const char* actual); 00089 void CuAssertStrNEquals(CuTest* tc, const char* expected, const char* actual, 00090 int n); 00091 void CuAssertIntEquals(CuTest* tc, int expected, int actual); 00092 void CuAssertPtrEquals(CuTest* tc, const void* expected, const void* actual); 00093 void CuAssertPtrNotNull(CuTest* tc, const void* pointer); 00094 00095 void CuTestRun(CuTest* tc); 00096 00097 /* CuSuite */ 00098 00099 #define MAX_TEST_CASES 1024 00100 00101 #define SUITE_ADD_TEST(SUITE,TEST) CuSuiteAdd(SUITE, CuTestNew(#TEST, TEST)) 00102 00103 typedef struct 00104 { 00105 char *name; 00106 int count; 00107 CuTest* list[MAX_TEST_CASES]; 00108 int failCount; 00109 int notimplCount; 00110 00111 } CuSuite; 00112 00113 00114 void CuSuiteInit(CuSuite* testSuite, char* name); 00115 CuSuite* CuSuiteNew(char* name); 00116 void CuSuiteAdd(CuSuite* testSuite, CuTest *testCase); 00117 void CuSuiteAddSuite(CuSuite* testSuite, CuSuite* testSuite2); 00118 void CuSuiteRun(CuSuite* testSuite); 00119 void CuSuiteSummary(CuSuite* testSuite, CuString* summary); 00120 void CuSuiteOverView(CuSuite* testSuite, CuString* details); 00121 void CuSuiteDetails(CuSuite* testSuite, CuString* details); 00122 00123 typedef struct 00124 { 00125 char *name; 00126 int count; 00127 CuSuite* list[MAX_TEST_CASES]; 00128 } CuSuiteList; 00129 00130 00131 CuSuiteList* CuSuiteListNew(char* name); 00132 void CuSuiteListAdd(CuSuiteList* testSuite, CuSuite *testCase); 00133 void CuSuiteListRun(CuSuiteList* testSuite); 00134 void CuSuiteListRunWithSummary(CuSuiteList* testSuite); 00135 void CuSuiteListSummary(CuSuiteList* testSuite, CuString* summary); 00136 /* Print details of test suite results; returns total number of 00137 * tests which failed. */ 00138 int CuSuiteListDetails(CuSuiteList* testSuite, CuString* details); 00139 #endif /* CU_TEST_H */ 00140

Generated on Thu Sep 16 13:48:14 2004 for Apache Portable Runtime Utility Library by doxygen 1.3.7