From 4ba859fe5bed361aa7aa3b5a8c0b7c57d8ada1f4 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Sat, 11 Dec 2010 16:36:07 +0100 Subject: [PATCH] Integrate IGs tests - add to run_tests.sh - wrap c-unit around the test cases... --- libcitadel/tests/run_tests.sh | 2 + libcitadel/tests/stripallbut_test.c | 80 +++++++++++++++++++++++++++-- 2 files changed, 77 insertions(+), 5 deletions(-) diff --git a/libcitadel/tests/run_tests.sh b/libcitadel/tests/run_tests.sh index 2c9c1e21a..73a561d66 100755 --- a/libcitadel/tests/run_tests.sh +++ b/libcitadel/tests/run_tests.sh @@ -48,6 +48,8 @@ cat testdata/emailaddresses/email_recipientstrings.txt |$RUN_TEST ./stringbuf_co echo running general stringbuffer tests $RUN_TEST ./stringbuf_test +echo running string tools tests +$RUN_TEST ./stripallbut_test echo running mimeparser tests diff --git a/libcitadel/tests/stripallbut_test.c b/libcitadel/tests/stripallbut_test.c index 2e1d0cff0..cbaef4c49 100644 --- a/libcitadel/tests/stripallbut_test.c +++ b/libcitadel/tests/stripallbut_test.c @@ -1,3 +1,44 @@ + +/* + * CUnit - A Unit testing framework library for C. + * Copyright (C) 2001 Anil Kumar + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library 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 + */ + +#include +#include +#include +#include + + +#ifndef CUNIT_AUTOMATED_H_SEEN +#define CUNIT_AUTOMATED_H_SEEN + +#include +#include +#include + + +CU_EXPORT void CU_automated_run_tests(void); +CU_EXPORT CU_ErrorCode CU_list_tests_to_file(void); +CU_EXPORT void CU_set_output_filename(const char* szFilenameRoot); + + +#endif /* CUNIT_AUTOMATED_H_SEEN */ + #include #include #include @@ -7,7 +48,7 @@ #include "../lib/libcitadel.h" -main() { +static void TestStripAllBut(void) { int i; long l; @@ -59,13 +100,42 @@ main() { char foo[128]; for (i=0; i<(sizeof(teststrings) / sizeof (char *)); ++i) { - printf("Testing stripallbut()\n"); strcpy(foo, teststrings[i]); l = stripallbut(foo, '<', '>'); - assert(!strcmp(foo, strippedstrings[i])); - assert(strlen(foo) == strippedlens[i]); + CU_ASSERT_STRING_EQUAL(foo, strippedstrings[i]); + CU_ASSERT_EQUAL(strlen(foo), strippedlens[i]); } +} + + + +static void AddStringToolsTests(void) +{ + CU_pSuite pGroup = NULL; + CU_pTest pTest = NULL; - exit(0); + pGroup = CU_add_suite("TestStringTools", NULL, NULL); + pTest = CU_add_test(pGroup, "testStripAllBut", TestStripAllBut); +} + +int main(int argc, char* argv[]) +{ + setvbuf(stdout, NULL, _IONBF, 0); + + StartLibCitadel(8); + + CU_set_output_filename("TestAutomated"); + if (CU_initialize_registry()) { + printf("\nInitialize of test Registry failed."); + return 1; + } + AddStringToolsTests(); + + printf("\nTests completed with return value %d.\n", CU_basic_run_tests()); + + + CU_cleanup_registry(); + + return 0; } -- 2.39.2