3 * CUnit - A Unit testing framework library for C.
4 * Copyright (C) 2001 Anil Kumar
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #ifndef CUNIT_AUTOMATED_H_SEEN
28 #define CUNIT_AUTOMATED_H_SEEN
30 #include <CUnit/CUnit.h>
31 #include <CUnit/Basic.h>
32 #include <CUnit/TestDB.h>
35 CU_EXPORT void CU_automated_run_tests(void);
36 CU_EXPORT CU_ErrorCode CU_list_tests_to_file(void);
37 CU_EXPORT void CU_set_output_filename(const char* szFilenameRoot);
40 #endif /* CUNIT_AUTOMATED_H_SEEN */
49 #include "../lib/libcitadel.h"
51 static void TestStripAllBut(void) {
55 char *teststrings[] = {
63 "FSDFSDFSDFSDF<><><>bggt",
64 "FSDFSDFSDF<><eoeo><>bggt",
70 char *strippedstrings[] = {
78 "FSDFSDFSDFSDF<><><>bggt",
79 "FSDFSDFSDF<><eoeo><>bggt",
85 long strippedlens[] = {
102 for (i=0; i<(sizeof(teststrings) / sizeof (char *)); ++i) {
103 strcpy(foo, teststrings[i]);
104 l = stripallbut(foo, '<', '>');
106 CU_ASSERT_STRING_EQUAL(foo, strippedstrings[i]);
107 CU_ASSERT_EQUAL(strlen(foo), strippedlens[i]);
113 static void AddStringToolsTests(void)
115 CU_pSuite pGroup = NULL;
116 CU_pTest pTest = NULL;
118 pGroup = CU_add_suite("TestStringTools", NULL, NULL);
119 pTest = CU_add_test(pGroup, "testStripAllBut", TestStripAllBut);
122 int main(int argc, char* argv[])
124 setvbuf(stdout, NULL, _IONBF, 0);
128 CU_set_output_filename("TestAutomated");
129 if (CU_initialize_registry()) {
130 printf("\nInitialize of test Registry failed.");
133 AddStringToolsTests();
135 printf("\nTests completed with return value %d.\n", CU_basic_run_tests());
138 CU_cleanup_registry();