/* WARNING: This file was generated by dkct. Changes you make here will be lost if dkct is run again! You should modify the original source and run dkct on it. Original source: test-wstr.ctr */ /* Copyright (C) 2011-2013, Dirk Krause Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above opyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** @file test-wstr.c The test-wstr module. */ #line 10 "test-wstr.ctr" #include "dk3all.h" #line 15 "test-wstr.ctr" static wchar_t const t1[] = { L" <.? Dies ist ein Test. >;! " }; static wchar_t const t2[] = { L" <.? dies ist ein test. >;! " }; static wchar_t const t3[] = { L" <.? Dies ist ein Test. >;! " }; static wchar_t const t4[] = { L" <.? Dies ist noch ein Test. >;! " }; static wchar_t const t5[] = { L"c:\\windows\\system32" }; static wchar_t const t6[] = { L"/test/erwin" }; static wchar_t const t7[] = { L"../test/erwin" }; static wchar_t const * const ta[] = { L"Dies", L"ist", L"ein", L"Test", NULL }; static wchar_t const * const ta2[] = { L"D$ies", L"i$st", L"e$in", L"T$est", NULL }; static wchar_t const * const ta3[] = { L"yes", L"y", L"no", L"no", L"ja", L"nein", L"vielleicht", NULL }; DK3_MAIN { wchar_t *p1; wchar_t mytest[256]; wchar_t const * const *p2; #line 53 "test-wstr.ctr" p1 = t1; printf("Text: \"%ls\"\n", t1); wcscpy(mytest, t1); p1 = mytest; while(*p1) { *p1 = dk3str_w_tolower(*p1); p1++; } printf("Tolower: \"%ls\"\n", mytest); p1 = mytest; wcscpy(mytest, t1); p1 = mytest; while(*p1) { *p1 = dk3str_w_toupper(*p1); p1++; } printf("Toupper: \"%ls\"\n", mytest); printf("Search for \"i\": \""); p1 = dk3str_w_chr_fb(t1, 'i'); if(p1) { printf("%ls", p1); } printf("\"\n"); printf("Right search for \"i\": \""); p1 = dk3str_w_rchr_fb(t1, 'i'); if(p1) { printf("%ls", p1); } printf("\"\n"); printf("Length %u %u\n", (unsigned)dk3str_w_len_fb(t1),(unsigned)wcslen(t1)); printf("Dup: \""); p1 = dk3str_w_dup(t1); if(p1) { printf("%ls", p1); dk3_delete(p1); } printf("\"\n"); printf("t1 = \"%ls\"\n", t1); printf("t2 = \"%ls\"\n", t2); printf("t3 = \"%ls\"\n", t3); printf("t4 = \"%ls\"\n", t4); printf("cmp t1 / t2 = %d\n", dk3str_w_cmp_fb(t1, t2)); printf("cmp t1 / t3 = %d\n", dk3str_w_cmp_fb(t1, t3)); printf("cmp t4 / t2 = %d\n", dk3str_w_cmp_fb(t1, t4)); printf("cmp t2 / t3 = %d\n", dk3str_w_cmp_fb(t2, t3)); printf("cmp t2 / t4 = %d\n", dk3str_w_cmp_fb(t2, t4)); printf("cmp t3 / t4 = %d\n", dk3str_w_cmp_fb(t3, t4)); printf("casecmp t1 / t2 = %d\n", dk3str_w_casecmp_fb(t1, t2)); printf("casecmp t1 / t3 = %d\n", dk3str_w_casecmp_fb(t1, t3)); printf("casecmp t4 / t2 = %d\n", dk3str_w_casecmp_fb(t1, t4)); printf("casecmp t2 / t3 = %d\n", dk3str_w_casecmp_fb(t2, t3)); printf("casecmp t2 / t4 = %d\n", dk3str_w_casecmp_fb(t2, t4)); printf("casecmp t3 / t4 = %d\n", dk3str_w_casecmp_fb(t3, t4)); printf("ncmp t1 / t2 = %d\n", dk3str_w_ncmp_fb(t1, t2, 5)); printf("ncmp t1 / t3 = %d\n", dk3str_w_ncmp_fb(t1, t3, 5)); printf("ncmp t4 / t2 = %d\n", dk3str_w_ncmp_fb(t1, t4, 5)); printf("ncmp t2 / t3 = %d\n", dk3str_w_ncmp_fb(t2, t3, 5)); printf("ncmp t2 / t4 = %d\n", dk3str_w_ncmp_fb(t2, t4, 5)); printf("ncmp t3 / t4 = %d\n", dk3str_w_ncmp_fb(t3, t4, 5)); printf("cmp t1 / t2 = %d\n", dk3str_w_cmp(t1, t2)); printf("cmp t1 / t3 = %d\n", dk3str_w_cmp(t1, t3)); printf("cmp t4 / t2 = %d\n", dk3str_w_cmp(t1, t4)); printf("cmp t2 / t3 = %d\n", dk3str_w_cmp(t2, t3)); printf("cmp t2 / t4 = %d\n", dk3str_w_cmp(t2, t4)); printf("cmp t3 / t4 = %d\n", dk3str_w_cmp(t3, t4)); printf("casecmp t1 / t2 = %d\n", dk3str_w_casecmp(t1, t2)); printf("casecmp t1 / t3 = %d\n", dk3str_w_casecmp(t1, t3)); printf("casecmp t4 / t2 = %d\n", dk3str_w_casecmp(t1, t4)); printf("casecmp t2 / t3 = %d\n", dk3str_w_casecmp(t2, t3)); printf("casecmp t2 / t4 = %d\n", dk3str_w_casecmp(t2, t4)); printf("casecmp t3 / t4 = %d\n", dk3str_w_casecmp(t3, t4)); printf("ncmp t1 / t2 = %d\n", dk3str_w_ncmp(t1, t2, 5)); printf("ncmp t1 / t3 = %d\n", dk3str_w_ncmp(t1, t3, 5)); printf("ncmp t4 / t2 = %d\n", dk3str_w_ncmp(t1, t4, 5)); printf("ncmp t2 / t3 = %d\n", dk3str_w_ncmp(t2, t3, 5)); printf("ncmp t2 / t4 = %d\n", dk3str_w_ncmp(t2, t4, 5)); printf("ncmp t3 / t4 = %d\n", dk3str_w_ncmp(t3, t4, 5)); dk3str_w_cpy_fb(mytest, t1); printf("cpy \"%ls\"\n", mytest); dk3str_w_cpy(mytest, t1); printf("cpy \"%ls\"\n", mytest); dk3str_w_ncpy_fb(mytest, t1, 10); printf("ncpy \"%ls\"\n", mytest); dk3str_w_ncpy(mytest, t1, 10); printf("ncpy \"%ls\"\n", mytest); dk3str_w_cat_fb(mytest, t1); printf("cat \"%ls\"\n", mytest); dk3str_w_cat(mytest, t1); printf("cat \"%ls\"\n", mytest); printf("array index \"ein\" %d\n", dk3str_w_array_index(ta, L"ein", 0)); printf("array index \"Ein\" %d\n", dk3str_w_array_index(ta, L"Ein", 0)); printf("array index \"noch\" %d\n", dk3str_w_array_index(ta, L"noch", 0)); printf("array index \"ein\" %d\n", dk3str_w_array_index(ta, L"ein", 1)); printf("array index \"Ein\" %d\n", dk3str_w_array_index(ta, L"Ein", 1)); printf("array index \"noch\" %d\n", dk3str_w_array_index(ta, L"noch", 1)); wcscpy(mytest, t1); p1 = dk3str_w_start(mytest, NULL); if(p1) { printf("start \"%ls\"\n", p1); while((p1 = dk3str_w_next(p1, NULL))) { #line 142 "test-wstr.ctr" printf("next \"%ls\"\n", p1); } } printf("Test mit chomp\n"); wcscpy(mytest, t1); p1 = dk3str_w_start(mytest, NULL); if(p1) { dk3str_w_chomp(p1, NULL); printf("chomp \"%ls\"\n", p1); } printf("array abbr \"i\" %d\n", dk3str_w_array_abbr(ta2, L"i", L'$', 0)); printf("array abbr \"is\" %d\n", dk3str_w_array_abbr(ta2, L"is", L'$', 0)); printf("array abbr \"ist\" %d\n", dk3str_w_array_abbr(ta2, L"ist", L'$', 0)); printf("array abbr \"istt\" %d\n", dk3str_w_array_abbr(ta2, L"istt", L'$', 0)); printf("array abbr \"I\" %d\n", dk3str_w_array_abbr(ta2, L"I", L'$', 0)); printf("array abbr \"Is\" %d\n", dk3str_w_array_abbr(ta2, L"Is", L'$', 0)); printf("array abbr \"Ist\" %d\n", dk3str_w_array_abbr(ta2, L"Ist", L'$', 0)); printf("array abbr \"Istt\" %d\n", dk3str_w_array_abbr(ta2, L"Istt", L'$', 0)); printf("array abbr \"i\" %d\n", dk3str_w_array_abbr(ta2, L"i", L'$', 1)); printf("array abbr \"is\" %d\n", dk3str_w_array_abbr(ta2, L"is", L'$', 1)); printf("array abbr \"ist\" %d\n", dk3str_w_array_abbr(ta2, L"ist", L'$', 1)); printf("array abbr \"istt\" %d\n", dk3str_w_array_abbr(ta2, L"istt", L'$', 1)); printf("array abbr \"I\" %d\n", dk3str_w_array_abbr(ta2, L"I", L'$', 1)); printf("array abbr \"Is\" %d\n", dk3str_w_array_abbr(ta2, L"Is", L'$', 1)); printf("array abbr \"Ist\" %d\n", dk3str_w_array_abbr(ta2, L"Ist", L'$', 1)); printf("array abbr \"Istt\" %d\n", dk3str_w_array_abbr(ta2, L"Istt", L'$', 1)); p2 = ta3; while(*p2) { printf( "bool / on \"%ls\" %d / %d\n", *p2, dk3str_w_is_bool(*p2), dk3str_w_is_on(*p2) ); p2++; } wcscpy(mytest, t1); dk3str_w_normalize(mytest, NULL, '-'); printf("normalize \"%ls\"\n", mytest); wcscpy(mytest, t5); dk3str_w_correct_filename(mytest); printf("correct \"%ls\"\n", mytest); printf("abs \"%ls\" %d\n", t6, dk3str_w_is_abs_path(t6)); printf("abs \"%ls\" %d\n", t7, dk3str_w_is_abs_path(t7)); wcscpy(mytest, t6); dk3str_w_append_path(mytest, sizeof(mytest), t7); printf("append \"%ls\"\n", mytest); wcscpy(mytest, t6); dk3str_w_append_path(mytest, sizeof(mytest), t6); printf("append \"%ls\"\n", mytest); #line 191 "test-wstr.ctr" exit(0); return 0; }