X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Funiconv%2Ftest-u32-strconv-to-enc.c;h=584d1912198700a6d8c0d03f5113c624172cbeef;hb=ae006b4d5d64c1a5e1ac2b5bd45350d4d3ebb060;hp=eef3d04d96e227decf6a4659173f93a2cdf7a8a7;hpb=e220635fc952c63b533873f2af39ec76aed4b4e3;p=gnulib.git diff --git a/tests/uniconv/test-u32-strconv-to-enc.c b/tests/uniconv/test-u32-strconv-to-enc.c index eef3d04d9..584d19121 100644 --- a/tests/uniconv/test-u32-strconv-to-enc.c +++ b/tests/uniconv/test-u32-strconv-to-enc.c @@ -1,5 +1,5 @@ /* Test of conversion from UTF-32 to legacy encodings. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,22 +21,9 @@ #include "uniconv.h" #include -#include #include #include - -#define SIZEOF(array) (sizeof (array) / sizeof (array[0])) -#define ASSERT(expr) \ - do \ - { \ - if (!(expr)) \ - { \ - fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ - fflush (stderr); \ - abort (); \ - } \ - } \ - while (0) +#include "macros.h" int main () @@ -54,11 +41,11 @@ main () { enum iconv_ilseq_handler handler = handlers[h]; static const uint32_t input[] = /* Ärger mit bösen Bübchen ohne Augenmaß */ - { - 0xC4, 'r', 'g', 'e', 'r', ' ', 'm', 'i', 't', ' ', 'b', 0xF6, 's', - 'e', 'n', ' ', 'B', 0xFC, 'b', 'c', 'h', 'e', 'n', ' ', 'o', 'h', - 'n', 'e', ' ', 'A', 'u', 'g', 'e', 'n', 'm', 'a', 0xDF, 0 - }; + { + 0xC4, 'r', 'g', 'e', 'r', ' ', 'm', 'i', 't', ' ', 'b', 0xF6, 's', + 'e', 'n', ' ', 'B', 0xFC, 'b', 'c', 'h', 'e', 'n', ' ', 'o', 'h', + 'n', 'e', ' ', 'A', 'u', 'g', 'e', 'n', 'm', 'a', 0xDF, 0 + }; static const char expected[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; char *result = u32_strconv_to_encoding (input, "ISO-8859-1", handler); ASSERT (result != NULL); @@ -71,35 +58,35 @@ main () { enum iconv_ilseq_handler handler = handlers[h]; static const uint32_t input[] = /* Rafał Maszkowski */ - { - 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w', - 's', 'k', 'i', 0 - }; + { + 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w', + 's', 'k', 'i', 0 + }; char *result = u32_strconv_to_encoding (input, "ISO-8859-1", handler); switch (handler) - { - case iconveh_error: - ASSERT (result == NULL && errno == EILSEQ); - break; - case iconveh_question_mark: - { - static const char expected[] = "Rafa? Maszkowski"; - static const char expected_translit[] = "Rafal Maszkowski"; - ASSERT (result != NULL); - ASSERT (strcmp (result, expected) == 0 - || strcmp (result, expected_translit) == 0); - free (result); - } - break; - case iconveh_escape_sequence: - { - static const char expected[] = "Rafa\\u0142 Maszkowski"; - ASSERT (result != NULL); - ASSERT (strcmp (result, expected) == 0); - free (result); - } - break; - } + { + case iconveh_error: + ASSERT (result == NULL && errno == EILSEQ); + break; + case iconveh_question_mark: + { + static const char expected[] = "Rafa? Maszkowski"; + static const char expected_translit[] = "Rafal Maszkowski"; + ASSERT (result != NULL); + ASSERT (strcmp (result, expected) == 0 + || strcmp (result, expected_translit) == 0); + free (result); + } + break; + case iconveh_escape_sequence: + { + static const char expected[] = "Rafa\\u0142 Maszkowski"; + ASSERT (result != NULL); + ASSERT (strcmp (result, expected) == 0); + free (result); + } + break; + } } #endif