From: Wilfried Göesgens Date: Thu, 22 Oct 2009 23:04:31 +0000 (+0000) Subject: * add stdin for decoding tests X-Git-Tag: v7.86~721 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=079f36f8276a044a1a1c4d8fdad29fed1da47476 * add stdin for decoding tests --- diff --git a/libcitadel/tests/stringbuf_conversion.c b/libcitadel/tests/stringbuf_conversion.c index d83afcdc0..5c7c36fbb 100644 --- a/libcitadel/tests/stringbuf_conversion.c +++ b/libcitadel/tests/stringbuf_conversion.c @@ -21,11 +21,15 @@ #include #include #include +#include +#include #include "stringbuf_test.h" #include "../lib/libcitadel.h" +int fromstdin = 0; + static void TestRevalidateStrBuf(StrBuf *Buf) { CU_ASSERT(strlen(ChrPtr(Buf)) == StrLength(Buf)); @@ -87,6 +91,36 @@ static void TestRFC822Decode(void) } +static void TestRFC822DecodeStdin(void) +{ + int fdin = 0;// STDIN + const char *Err; + StrBuf *Target; + StrBuf *Source; + StrBuf *DefaultCharset; + StrBuf *FoundCharset; + + DefaultCharset = NewStrBufPlain(HKEY("iso-8859-1")); + FoundCharset = NewStrBuf(); + Source = NewStrBuf(); + + while (fdin == 0) { + + StrBufTCP_read_line(Source, &fdin, 0, &Err); + Target = NewStrBuf(); + + StrBuf_RFC822_to_Utf8(Target, Source, DefaultCharset, FoundCharset); + + TestRevalidateStrBuf(Target); + printf("the ugly multi:>%s<\n", ChrPtr(Target)); + FreeStrBuf(&Target); + } + FreeStrBuf(&Source); + FreeStrBuf(&FoundCharset); + FreeStrBuf(&DefaultCharset); +} + + static void AddStrBufSimlpeTests(void) { @@ -94,17 +128,31 @@ static void AddStrBufSimlpeTests(void) CU_pTest pTest = NULL; pGroup = CU_add_suite("TestStringBufConversions", NULL, NULL); - pTest = CU_add_test(pGroup, "testRFC822Decode", TestRFC822Decode); - pTest = CU_add_test(pGroup, "testRFC822Decode1", TestRFC822Decode); - pTest = CU_add_test(pGroup, "testRFC822Decode2", TestRFC822Decode); - pTest = CU_add_test(pGroup, "testRFC822Decode3", TestRFC822Decode); - + if (!fromstdin) { + pTest = CU_add_test(pGroup, "testRFC822Decode", TestRFC822Decode); + pTest = CU_add_test(pGroup, "testRFC822Decode1", TestRFC822Decode); + pTest = CU_add_test(pGroup, "testRFC822Decode2", TestRFC822Decode); + pTest = CU_add_test(pGroup, "testRFC822Decode3", TestRFC822Decode); + } + else + pTest = CU_add_test(pGroup, "testRFC822Decode3", TestRFC822DecodeStdin); } int main(int argc, char* argv[]) { + int a; + + while ((a = getopt(argc, argv, "i")) != EOF) + switch (a) { + case 'i': + fromstdin = 1; + + break; + } + + setvbuf(stdout, NULL, _IONBF, 0); StartLibCitadel(8);