| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| |
|
|
| #include <config.h> |
|
|
| #include "unilbrk.h" |
|
|
| #include <stdlib.h> |
|
|
| #include "macros.h" |
|
|
| static void |
| test_function (int (*my_u32_width_linebreaks) (const uint32_t *, size_t, int, int, int, const char *, const char *, char *_UC_RESTRICT), |
| int version) |
| { |
| |
| my_u32_width_linebreaks (NULL, 0, 80, 0, 0, NULL, "GB18030", NULL); |
|
|
| { |
| static const uint32_t input[61] = |
| |
| { 'G', 'r', 0x00FC, 0x00DF, ' ', 'G', 'o', 't', 't', '.', ' ', |
| 0x0417, 0x0434, 0x0440, 0x0430, 0x0432, 0x0441, 0x0442, 0x0432, 0x0443, |
| 0x0439, 0x0442, 0x0435, '!', ' ', |
| 'x', '=', '(', '-', 'b', 0x00B1, 's', 'q', 'r', 't', '(', 'b', 0x00B2, |
| '-', '4', 'a', 'c', ')', ')', '/', '(', '2', 'a', ')', ' ', ' ', |
| 0x65E5, 0x672C, 0x8A9E, ',', 0x4E2D, 0x6587, ',', 0xD55C, 0xAE00, '\n' |
| }; |
|
|
| { |
| char *p = (char *) malloc (SIZEOF (input)); |
| size_t i; |
|
|
| my_u32_width_linebreaks (input, SIZEOF (input), 25, 0, 0, NULL, "GB18030", p); |
| for (i = 0; i < 61; i++) |
| { |
| ASSERT (p[i] == (i == 60 ? UC_BREAK_MANDATORY : |
| i == 25 || i == 45 ? UC_BREAK_POSSIBLE : |
| UC_BREAK_PROHIBITED)); |
| } |
| free (p); |
| } |
|
|
| { |
| char *p = (char *) malloc (SIZEOF (input)); |
| size_t i; |
|
|
| my_u32_width_linebreaks (input, SIZEOF (input), 25, 0, 0, NULL, "GB2312", p); |
| for (i = 0; i < 61; i++) |
| { |
| ASSERT (p[i] == (i == 60 ? UC_BREAK_MANDATORY : |
| i == 11 || i == 25 || i == 45 ? UC_BREAK_POSSIBLE : |
| UC_BREAK_PROHIBITED)); |
| } |
| free (p); |
| } |
| } |
| } |
|
|
| int |
| main () |
| { |
| test_function (u32_width_linebreaks, 2); |
| #ifdef IN_LIBUNISTRING_GNULIB_TESTS |
| # undef u32_width_linebreaks |
| test_function (u32_width_linebreaks, 1); |
| #endif |
|
|
| return test_exit_status; |
| } |
|
|