diff options
Diffstat (limited to 'tests/unilbrk')
| -rw-r--r-- | tests/unilbrk/test-u16-possible-linebreaks.c | 35 | ||||
| -rw-r--r-- | tests/unilbrk/test-u16-width-linebreaks.c | 8 | ||||
| -rw-r--r-- | tests/unilbrk/test-u32-possible-linebreaks.c | 35 | ||||
| -rw-r--r-- | tests/unilbrk/test-u32-width-linebreaks.c | 8 | ||||
| -rw-r--r-- | tests/unilbrk/test-u8-possible-linebreaks.c | 35 | ||||
| -rw-r--r-- | tests/unilbrk/test-u8-width-linebreaks.c | 8 | ||||
| -rw-r--r-- | tests/unilbrk/test-uc-possible-linebreaks.c | 111 | ||||
| -rw-r--r-- | tests/unilbrk/test-ulc-possible-linebreaks.c | 8 | ||||
| -rw-r--r-- | tests/unilbrk/test-ulc-width-linebreaks.c | 5 | ||||
| -rw-r--r-- | tests/unilbrk/test-unilbrk-h.c | 2 |
10 files changed, 104 insertions, 151 deletions
diff --git a/tests/unilbrk/test-u16-possible-linebreaks.c b/tests/unilbrk/test-u16-possible-linebreaks.c index c66a7331..93448045 100644 --- a/tests/unilbrk/test-u16-possible-linebreaks.c +++ b/tests/unilbrk/test-u16-possible-linebreaks.c @@ -1,5 +1,5 @@ /* Test of line breaking of UTF-16 strings. - Copyright (C) 2008-2025 Free Software Foundation, Inc. + Copyright (C) 2008-2026 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 @@ -44,10 +44,9 @@ test_function (void (*my_u16_possible_linebreaks) (const uint16_t *, size_t, con { char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u16_possible_linebreaks (input, SIZEOF (input), "GB18030", p); - for (i = 0; i < 61; i++) + for (size_t i = 0; i < 61; i++) { ASSERT (p[i] == (i == 60 ? UC_BREAK_MANDATORY : i == 5 @@ -63,10 +62,9 @@ test_function (void (*my_u16_possible_linebreaks) (const uint16_t *, size_t, con { char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u16_possible_linebreaks (input, SIZEOF (input), "GB2312", p); - for (i = 0; i < 61; i++) + for (size_t i = 0; i < 61; i++) { ASSERT (p[i] == (i == 60 ? UC_BREAK_MANDATORY : i == 5 @@ -86,10 +84,9 @@ test_function (void (*my_u16_possible_linebreaks) (const uint16_t *, size_t, con static const uint16_t input[8] = { 'a', '\n', 'b', '\r', 'c', '\r', '\n', 'd' }; char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u16_possible_linebreaks (input, SIZEOF (input), "UTF-8", p); - for (i = 0; i < 8; i++) + for (size_t i = 0; i < 8; i++) { ASSERT (p[i] == (i == 1 || i == 3 || i == 6 ? UC_BREAK_MANDATORY : i == 5 ? (version < 2 ? UC_BREAK_MANDATORY : UC_BREAK_CR_BEFORE_LF) : @@ -103,10 +100,9 @@ test_function (void (*my_u16_possible_linebreaks) (const uint16_t *, size_t, con { static const uint16_t input[4] = { 'x', 0x200B, ' ', 'y' }; char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u16_possible_linebreaks (input, SIZEOF (input), "UTF-8", p); - for (i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { ASSERT (p[i] == (i == 3 ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED)); } @@ -121,10 +117,9 @@ test_function (void (*my_u16_possible_linebreaks) (const uint16_t *, size_t, con 'e', 'n', 'c', 'e', '.', '<', '/', 'P', '>' }; char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u16_possible_linebreaks (input, SIZEOF (input), "UTF-8", p); - for (i = 0; i < 21; i++) + for (size_t i = 0; i < 21; i++) { ASSERT (p[i] == (i == 8 || i == 17 || i == 19 ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED)); @@ -141,10 +136,9 @@ test_function (void (*my_u16_possible_linebreaks) (const uint16_t *, size_t, con 0x0300 }; char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u16_possible_linebreaks (input, SIZEOF (input), "UTF-8", p); - for (i = 0; i < 16; i++) + for (size_t i = 0; i < 16; i++) { ASSERT (p[i] == (i == 14 ? UC_BREAK_MANDATORY : i == 6 || i == 9 || i == 11 ? UC_BREAK_POSSIBLE : @@ -165,10 +159,9 @@ test_function (void (*my_u16_possible_linebreaks) (const uint16_t *, size_t, con 0x261D, 0x200D, 0xD83C, 0xDFFF, '\n', }; char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u16_possible_linebreaks (input, SIZEOF (input), "UTF-8", p); - for (i = 0; i < 39; i++) + for (size_t i = 0; i < 39; i++) { ASSERT (p[i] == (i == 8 || i == 20 || i == 24 || i == 29 @@ -187,10 +180,9 @@ test_function (void (*my_u16_possible_linebreaks) (const uint16_t *, size_t, con static const uint16_t input[8] = { 0xD83C, 0xDDE9, 0xD83C, 0xDDEA, 0xD83C, 0xDDEB, 0xD83C, 0xDDF7 }; char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u16_possible_linebreaks (input, SIZEOF (input), "UTF-8", p); - for (i = 0; i < 8; i++) + for (size_t i = 0; i < 8; i++) { ASSERT (p[i] == (i == 4 ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED)); } @@ -203,10 +195,9 @@ test_function (void (*my_u16_possible_linebreaks) (const uint16_t *, size_t, con static const uint16_t input[10] = /* "ab-אב-αβ-ω" */ { 'a', 'b', '-', 0x05D0, 0x05D1, '-', 0x03B1, 0x03B2, '-', 0x03C9 }; char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u16_possible_linebreaks (input, SIZEOF (input), "UTF-8", p); - for (i = 0; i < 10; i++) + for (size_t i = 0; i < 10; i++) { ASSERT (p[i] == (i == 3 || i == 9 ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED)); @@ -222,10 +213,9 @@ test_function (void (*my_u16_possible_linebreaks) (const uint16_t *, size_t, con 'G', 0x300C, 0x30E6, 0x30CB, 0x30B3, 0x30FC, 0x30C9, 0x300D }; char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u16_possible_linebreaks (input, SIZEOF (input), "UTF-8", p); - for (i = 0; i < 17; i++) + for (size_t i = 0; i < 17; i++) { ASSERT (p[i] == (i == 1 || i == 2 || i == 3 || i == 4 || i == 5 || i == 6 || i == 7 || i == 8 || i == 9 @@ -240,10 +230,9 @@ test_function (void (*my_u16_possible_linebreaks) (const uint16_t *, size_t, con { static const uint16_t input[4] = { 0xD83F, 0xDFFC, 0xD83C, 0xDFFF }; char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u16_possible_linebreaks (input, SIZEOF (input), "UTF-8", p); - for (i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { ASSERT (p[i] == UC_BREAK_PROHIBITED); } diff --git a/tests/unilbrk/test-u16-width-linebreaks.c b/tests/unilbrk/test-u16-width-linebreaks.c index e2a9b6bc..ba3bf9ea 100644 --- a/tests/unilbrk/test-u16-width-linebreaks.c +++ b/tests/unilbrk/test-u16-width-linebreaks.c @@ -1,5 +1,5 @@ /* Test of line breaking of UTF-16 strings. - Copyright (C) 2008-2025 Free Software Foundation, Inc. + Copyright (C) 2008-2026 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 @@ -44,10 +44,9 @@ test_function (int (*my_u16_width_linebreaks) (const uint16_t *, size_t, int, in { char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u16_width_linebreaks (input, SIZEOF (input), 25, 0, 0, NULL, "GB18030", p); - for (i = 0; i < 61; i++) + for (size_t i = 0; i < 61; i++) { ASSERT (p[i] == (i == 60 ? UC_BREAK_MANDATORY : i == 25 || i == 45 ? UC_BREAK_POSSIBLE : @@ -58,10 +57,9 @@ test_function (int (*my_u16_width_linebreaks) (const uint16_t *, size_t, int, in { char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u16_width_linebreaks (input, SIZEOF (input), 25, 0, 0, NULL, "GB2312", p); - for (i = 0; i < 61; i++) + for (size_t i = 0; i < 61; i++) { ASSERT (p[i] == (i == 60 ? UC_BREAK_MANDATORY : i == 11 || i == 25 || i == 45 ? UC_BREAK_POSSIBLE : diff --git a/tests/unilbrk/test-u32-possible-linebreaks.c b/tests/unilbrk/test-u32-possible-linebreaks.c index f70d07f9..8bec8e6e 100644 --- a/tests/unilbrk/test-u32-possible-linebreaks.c +++ b/tests/unilbrk/test-u32-possible-linebreaks.c @@ -1,5 +1,5 @@ /* Test of line breaking of UTF-32 strings. - Copyright (C) 2008-2025 Free Software Foundation, Inc. + Copyright (C) 2008-2026 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 @@ -44,10 +44,9 @@ test_function (void (*my_u32_possible_linebreaks) (const uint32_t *, size_t, con { char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u32_possible_linebreaks (input, SIZEOF (input), "GB18030", p); - for (i = 0; i < 61; i++) + for (size_t i = 0; i < 61; i++) { ASSERT (p[i] == (i == 60 ? UC_BREAK_MANDATORY : i == 5 @@ -63,10 +62,9 @@ test_function (void (*my_u32_possible_linebreaks) (const uint32_t *, size_t, con { char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u32_possible_linebreaks (input, SIZEOF (input), "GB2312", p); - for (i = 0; i < 61; i++) + for (size_t i = 0; i < 61; i++) { ASSERT (p[i] == (i == 60 ? UC_BREAK_MANDATORY : i == 5 @@ -86,10 +84,9 @@ test_function (void (*my_u32_possible_linebreaks) (const uint32_t *, size_t, con static const uint32_t input[8] = { 'a', '\n', 'b', '\r', 'c', '\r', '\n', 'd' }; char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u32_possible_linebreaks (input, SIZEOF (input), "UTF-8", p); - for (i = 0; i < 8; i++) + for (size_t i = 0; i < 8; i++) { ASSERT (p[i] == (i == 1 || i == 3 || i == 6 ? UC_BREAK_MANDATORY : i == 5 ? (version < 2 ? UC_BREAK_MANDATORY : UC_BREAK_CR_BEFORE_LF) : @@ -103,10 +100,9 @@ test_function (void (*my_u32_possible_linebreaks) (const uint32_t *, size_t, con { static const uint32_t input[4] = { 'x', 0x200B, ' ', 'y' }; char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u32_possible_linebreaks (input, SIZEOF (input), "UTF-8", p); - for (i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { ASSERT (p[i] == (i == 3 ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED)); } @@ -121,10 +117,9 @@ test_function (void (*my_u32_possible_linebreaks) (const uint32_t *, size_t, con 'e', 'n', 'c', 'e', '.', '<', '/', 'P', '>' }; char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u32_possible_linebreaks (input, SIZEOF (input), "UTF-8", p); - for (i = 0; i < 21; i++) + for (size_t i = 0; i < 21; i++) { ASSERT (p[i] == (i == 8 || i == 17 || i == 19 ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED)); @@ -141,10 +136,9 @@ test_function (void (*my_u32_possible_linebreaks) (const uint32_t *, size_t, con 0x0300 }; char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u32_possible_linebreaks (input, SIZEOF (input), "UTF-8", p); - for (i = 0; i < 16; i++) + for (size_t i = 0; i < 16; i++) { ASSERT (p[i] == (i == 14 ? UC_BREAK_MANDATORY : i == 6 || i == 9 || i == 11 ? UC_BREAK_POSSIBLE : @@ -165,10 +159,9 @@ test_function (void (*my_u32_possible_linebreaks) (const uint32_t *, size_t, con 0x261D, 0x200D, 0x1F3FF, '\n', }; char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u32_possible_linebreaks (input, SIZEOF (input), "UTF-8", p); - for (i = 0; i < 37; i++) + for (size_t i = 0; i < 37; i++) { ASSERT (p[i] == (i == 8 || i == 20 || i == 24 || i == 29 @@ -187,10 +180,9 @@ test_function (void (*my_u32_possible_linebreaks) (const uint32_t *, size_t, con static const uint32_t input[4] = { 0x1F1E9, 0x1F1EA, 0x1F1EB, 0x1F1F7 }; char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u32_possible_linebreaks (input, SIZEOF (input), "UTF-8", p); - for (i = 0; i < 4; i++) + for (size_t i = 0; i < 4; i++) { ASSERT (p[i] == (i == 2 ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED)); } @@ -203,10 +195,9 @@ test_function (void (*my_u32_possible_linebreaks) (const uint32_t *, size_t, con static const uint32_t input[10] = /* "ab-אב-αβ-ω" */ { 'a', 'b', '-', 0x05D0, 0x05D1, '-', 0x03B1, 0x03B2, '-', 0x03C9 }; char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u32_possible_linebreaks (input, SIZEOF (input), "UTF-8", p); - for (i = 0; i < 10; i++) + for (size_t i = 0; i < 10; i++) { ASSERT (p[i] == (i == 3 || i == 9 ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED)); @@ -222,10 +213,9 @@ test_function (void (*my_u32_possible_linebreaks) (const uint32_t *, size_t, con 'G', 0x300C, 0x30E6, 0x30CB, 0x30B3, 0x30FC, 0x30C9, 0x300D }; char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u32_possible_linebreaks (input, SIZEOF (input), "UTF-8", p); - for (i = 0; i < 17; i++) + for (size_t i = 0; i < 17; i++) { ASSERT (p[i] == (i == 1 || i == 2 || i == 3 || i == 4 || i == 5 || i == 6 || i == 7 || i == 8 || i == 9 @@ -240,10 +230,9 @@ test_function (void (*my_u32_possible_linebreaks) (const uint32_t *, size_t, con { static const uint32_t input[2] = { 0x1FFFC, 0x1F3FF }; char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u32_possible_linebreaks (input, SIZEOF (input), "UTF-8", p); - for (i = 0; i < 2; i++) + for (size_t i = 0; i < 2; i++) { ASSERT (p[i] == UC_BREAK_PROHIBITED); } diff --git a/tests/unilbrk/test-u32-width-linebreaks.c b/tests/unilbrk/test-u32-width-linebreaks.c index 68ffbb2f..09e7652a 100644 --- a/tests/unilbrk/test-u32-width-linebreaks.c +++ b/tests/unilbrk/test-u32-width-linebreaks.c @@ -1,5 +1,5 @@ /* Test of line breaking of UTF-32 strings. - Copyright (C) 2008-2025 Free Software Foundation, Inc. + Copyright (C) 2008-2026 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 @@ -44,10 +44,9 @@ test_function (int (*my_u32_width_linebreaks) (const uint32_t *, size_t, int, in { 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++) + for (size_t i = 0; i < 61; i++) { ASSERT (p[i] == (i == 60 ? UC_BREAK_MANDATORY : i == 25 || i == 45 ? UC_BREAK_POSSIBLE : @@ -58,10 +57,9 @@ test_function (int (*my_u32_width_linebreaks) (const uint32_t *, size_t, int, in { 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++) + for (size_t i = 0; i < 61; i++) { ASSERT (p[i] == (i == 60 ? UC_BREAK_MANDATORY : i == 11 || i == 25 || i == 45 ? UC_BREAK_POSSIBLE : diff --git a/tests/unilbrk/test-u8-possible-linebreaks.c b/tests/unilbrk/test-u8-possible-linebreaks.c index 88a0d30c..4616f00c 100644 --- a/tests/unilbrk/test-u8-possible-linebreaks.c +++ b/tests/unilbrk/test-u8-possible-linebreaks.c @@ -1,5 +1,5 @@ /* Test of line breaking of UTF-8 strings. - Copyright (C) 2008-2025 Free Software Foundation, Inc. + Copyright (C) 2008-2026 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 @@ -38,10 +38,9 @@ test_function (void (*my_u8_possible_linebreaks) (const uint8_t *, size_t, const { char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u8_possible_linebreaks (input, SIZEOF (input), "GB18030", p); - for (i = 0; i < 91; i++) + for (size_t i = 0; i < 91; i++) { ASSERT (p[i] == (i == 90 ? UC_BREAK_MANDATORY : i == 7 @@ -57,10 +56,9 @@ test_function (void (*my_u8_possible_linebreaks) (const uint8_t *, size_t, const { char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u8_possible_linebreaks (input, SIZEOF (input), "GB2312", p); - for (i = 0; i < 91; i++) + for (size_t i = 0; i < 91; i++) { ASSERT (p[i] == (i == 90 ? UC_BREAK_MANDATORY : i == 7 @@ -79,10 +77,9 @@ test_function (void (*my_u8_possible_linebreaks) (const uint8_t *, size_t, const { static const uint8_t input[8] _GL_ATTRIBUTE_NONSTRING = "a\nb\rc\r\nd"; char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p); - for (i = 0; i < 8; i++) + for (size_t i = 0; i < 8; i++) { ASSERT (p[i] == (i == 1 || i == 3 || i == 6 ? UC_BREAK_MANDATORY : i == 5 ? (version < 2 ? UC_BREAK_MANDATORY : UC_BREAK_CR_BEFORE_LF) : @@ -96,10 +93,9 @@ test_function (void (*my_u8_possible_linebreaks) (const uint8_t *, size_t, const { static const uint8_t input[6] _GL_ATTRIBUTE_NONSTRING = "x\342\200\213 y"; char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p); - for (i = 0; i < 6; i++) + for (size_t i = 0; i < 6; i++) { ASSERT (p[i] == (i == 5 ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED)); } @@ -110,10 +106,9 @@ test_function (void (*my_u8_possible_linebreaks) (const uint8_t *, size_t, const { static const uint8_t input[21] _GL_ATTRIBUTE_NONSTRING = "<P>Some sentence.</P>"; char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p); - for (i = 0; i < 21; i++) + for (size_t i = 0; i < 21; i++) { ASSERT (p[i] == (i == 8 || i == 17 || i == 19 ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED)); @@ -127,10 +122,9 @@ test_function (void (*my_u8_possible_linebreaks) (const uint8_t *, size_t, const "a\314\200\314\201e\314\200 \314\201o \314\200 o\302\240\314\200\n" "\314\200"; char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p); - for (i = 0; i < 24; i++) + for (size_t i = 0; i < 24; i++) { ASSERT (p[i] == (i == 21 ? UC_BREAK_MANDATORY : i == 9 || i == 13 || i == 16 ? UC_BREAK_POSSIBLE : @@ -149,10 +143,9 @@ test_function (void (*my_u8_possible_linebreaks) (const uint8_t *, size_t, const "\342\230\235\360\237\217\277\n" /* "☝🏿" */ "\342\230\235\342\200\215\360\237\217\277\n"; char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p); - for (i = 0; i < 101; i++) + for (size_t i = 0; i < 101; i++) { ASSERT (p[i] == (i == 24 || i == 58 || i == 68 || i == 81 @@ -171,10 +164,9 @@ test_function (void (*my_u8_possible_linebreaks) (const uint8_t *, size_t, const static const uint8_t input[16] _GL_ATTRIBUTE_NONSTRING = "\360\237\207\251\360\237\207\252\360\237\207\253\360\237\207\267"; char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p); - for (i = 0; i < 16; i++) + for (size_t i = 0; i < 16; i++) { ASSERT (p[i] == (i == 8 ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED)); } @@ -187,10 +179,9 @@ test_function (void (*my_u8_possible_linebreaks) (const uint8_t *, size_t, const static const uint8_t input[15] _GL_ATTRIBUTE_NONSTRING = /* "ab-אב-αβ-ω" */ "ab-\327\220\327\221-\316\261\316\262-\317\211"; char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p); - for (i = 0; i < 15; i++) + for (size_t i = 0; i < 15; i++) { ASSERT (p[i] == (i == 3 || i == 13 ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED)); @@ -206,10 +197,9 @@ test_function (void (*my_u8_possible_linebreaks) (const uint8_t *, size_t, const "\345\255\227\346\213\241\345\274\265G\343\200\214\343\203\246" "\343\203\213\343\202\263\343\203\274\343\203\211\343\200\215"; char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p); - for (i = 0; i < 49; i++) + for (size_t i = 0; i < 49; i++) { ASSERT (p[i] == (i == 3 || i == 6 || i == 9 || i == 12 || i == 15 || i == 18 || i == 21 || i == 24 || i == 27 @@ -225,10 +215,9 @@ test_function (void (*my_u8_possible_linebreaks) (const uint8_t *, size_t, const static const uint8_t input[8] _GL_ATTRIBUTE_NONSTRING = "\360\237\277\274\360\237\217\277"; char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p); - for (i = 0; i < 8; i++) + for (size_t i = 0; i < 8; i++) { ASSERT (p[i] == UC_BREAK_PROHIBITED); } diff --git a/tests/unilbrk/test-u8-width-linebreaks.c b/tests/unilbrk/test-u8-width-linebreaks.c index a9c9378b..60e3e383 100644 --- a/tests/unilbrk/test-u8-width-linebreaks.c +++ b/tests/unilbrk/test-u8-width-linebreaks.c @@ -1,5 +1,5 @@ /* Test of line breaking of UTF-8 strings. - Copyright (C) 2008-2025 Free Software Foundation, Inc. + Copyright (C) 2008-2026 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 @@ -38,10 +38,9 @@ test_function (int (*my_u8_width_linebreaks) (const uint8_t *, size_t, int, int, { char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u8_width_linebreaks (input, SIZEOF (input), 25, 0, 0, NULL, "GB18030", p); - for (i = 0; i < 91; i++) + for (size_t i = 0; i < 91; i++) { ASSERT (p[i] == (i == 90 ? UC_BREAK_MANDATORY : i == 39 || i == 61 ? UC_BREAK_POSSIBLE : @@ -52,10 +51,9 @@ test_function (int (*my_u8_width_linebreaks) (const uint8_t *, size_t, int, int, { char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_u8_width_linebreaks (input, SIZEOF (input), 25, 0, 0, NULL, "GB2312", p); - for (i = 0; i < 91; i++) + for (size_t i = 0; i < 91; i++) { ASSERT (p[i] == (i == 90 ? UC_BREAK_MANDATORY : i == 13 || i == 39 || i == 61 ? UC_BREAK_POSSIBLE : diff --git a/tests/unilbrk/test-uc-possible-linebreaks.c b/tests/unilbrk/test-uc-possible-linebreaks.c index a54699b6..bf268286 100644 --- a/tests/unilbrk/test-uc-possible-linebreaks.c +++ b/tests/unilbrk/test-uc-possible-linebreaks.c @@ -1,5 +1,5 @@ /* Line break function test, using test data from UCD. - Copyright (C) 2024-2025 Free Software Foundation, Inc. + Copyright (C) 2024-2026 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -118,71 +118,66 @@ main (int argc, char *argv[]) u32_possible_linebreaks (input, i - 1, "UTF-8", breaks); int matches = 1; - { - int j; - for (j = 0; j < i - 1; j++) - { - /* The character U+FFFC has line break property CB, which according - to rule (LB1) is resolved "into other line breaking classes - depending on criteria outside the scope of this algorithm". - Thus it makes no sense to check the breaks[] entry before or - after such a character. */ - if (!(input[j] == 0xFFFC - || (j > 0 && input[j - 1] == 0xFFFC) - /* Also consider intervening characters with property LBP_CM - or LBP_ZWJ, per (LB9). */ - || (j > 1 && (input[j - 1] == 0x0308 || input[j - 1] == 0x200D) - && input[j - 2] == 0xFFFC))) - /* A regional indicator with a combining character is nonsense, - because regional indicators are supposed to come in pairs. */ - if (!(j >= 2 && (input[0] >= 0x1F1E6 && input[0] <= 0x1F1FF) - && input[1] == 0x0308)) - /* It is nonsense to treat U+1F8FF differently than U+1F02C. - Both are unassigned Extended_Pictographic characters and - should therefore be treated like LBP_EB (or LBP_ID, if you - want), not like LBP_AL. See rule (LB30b). */ - if (!(input[j] == 0x1F8FF - || (j > 0 && input[j - 1] == 0x1F8FF) - /* Also consider intervening characters with property LBP_CM - or LBP_ZWJ, per (LB9). */ - || (j > 1 && (input[j - 1] == 0x0308 || input[j - 1] == 0x200D) - && input[j - 2] == 0x1F8FF))) - /* There is a disagreement regarding whether to allow a line break - after a U+0020 SPACE character at the start of the text. - We consider that the start of the text is equivalent to the - state after a newline was seen; hence the loop starts with - property LBP_BK. By the rules (LB4,LB5,LB6) an extra line - break after a mandatory line break is undesired, even with - intervening spaces (because these rules come before (LB18)). - Whereas the LineBreakTest.txt file allows a line break after - the space. - Similarly when the first two characters at the start of the - text have property LBP_CM and LBP_ZWJ, respectively. (LB9). */ - if (!(((j == 1 || (j > 1 && ((input[j - 2] >= 0x000A && input[j - 2] <= 0x000D) || input[j - 2] == 0x0085))) - && input[j - 1] == 0x0020) - || ((j == 2 || (j > 2 && ((input[j - 3] >= 0x000A && input[j - 3] <= 0x000D) || input[j - 3] == 0x0085))) - && ((input[j - 2] == 0x0020 && input[j - 1] == 0x0020) - || (input[j - 2] == 0x0308 && input[j - 1] == 0x200D) - || (input[j - 2] == 0x200D && input[j - 1] == 0x0308))))) - matches &= (!(breaks[j] == UC_BREAK_PROHIBITED - || breaks[j] == UC_BREAK_MANDATORY - || breaks[j] == UC_BREAK_CR_BEFORE_LF) - || (j > 0 && breaks[j - 1] == UC_BREAK_MANDATORY)) - == breaks_expected[j]; - } - } + for (int j = 0; j < i - 1; j++) + { + /* The character U+FFFC has line break property CB, which according + to rule (LB1) is resolved "into other line breaking classes + depending on criteria outside the scope of this algorithm". + Thus it makes no sense to check the breaks[] entry before or + after such a character. */ + if (!(input[j] == 0xFFFC + || (j > 0 && input[j - 1] == 0xFFFC) + /* Also consider intervening characters with property LBP_CM + or LBP_ZWJ, per (LB9). */ + || (j > 1 && (input[j - 1] == 0x0308 || input[j - 1] == 0x200D) + && input[j - 2] == 0xFFFC))) + /* A regional indicator with a combining character is nonsense, + because regional indicators are supposed to come in pairs. */ + if (!(j >= 2 && (input[0] >= 0x1F1E6 && input[0] <= 0x1F1FF) + && input[1] == 0x0308)) + /* It is nonsense to treat U+1F8FF differently than U+1F02C. + Both are unassigned Extended_Pictographic characters and + should therefore be treated like LBP_EB (or LBP_ID, if you + want), not like LBP_AL. See rule (LB30b). */ + if (!(input[j] == 0x1F8FF + || (j > 0 && input[j - 1] == 0x1F8FF) + /* Also consider intervening characters with property LBP_CM + or LBP_ZWJ, per (LB9). */ + || (j > 1 && (input[j - 1] == 0x0308 || input[j - 1] == 0x200D) + && input[j - 2] == 0x1F8FF))) + /* There is a disagreement regarding whether to allow a line break + after a U+0020 SPACE character at the start of the text. + We consider that the start of the text is equivalent to the + state after a newline was seen; hence the loop starts with + property LBP_BK. By the rules (LB4,LB5,LB6) an extra line + break after a mandatory line break is undesired, even with + intervening spaces (because these rules come before (LB18)). + Whereas the LineBreakTest.txt file allows a line break after + the space. + Similarly when the first two characters at the start of the + text have property LBP_CM and LBP_ZWJ, respectively. (LB9). */ + if (!(((j == 1 || (j > 1 && ((input[j - 2] >= 0x000A && input[j - 2] <= 0x000D) || input[j - 2] == 0x0085))) + && input[j - 1] == 0x0020) + || ((j == 2 || (j > 2 && ((input[j - 3] >= 0x000A && input[j - 3] <= 0x000D) || input[j - 3] == 0x0085))) + && ((input[j - 2] == 0x0020 && input[j - 1] == 0x0020) + || (input[j - 2] == 0x0308 && input[j - 1] == 0x200D) + || (input[j - 2] == 0x200D && input[j - 1] == 0x0308))))) + matches &= (!(breaks[j] == UC_BREAK_PROHIBITED + || breaks[j] == UC_BREAK_MANDATORY + || breaks[j] == UC_BREAK_CR_BEFORE_LF) + || (j > 0 && breaks[j - 1] == UC_BREAK_MANDATORY)) + == breaks_expected[j]; + } if (!matches) { - int j; - fprintf (stderr, "%s:%d: expected: ", filename, lineno); - for (j = 0; j < i - 1; j++) + for (int j = 0; j < i - 1; j++) fprintf (stderr, "%s U+%04X ", breaks_expected[j] == 1 ? "\303\267" : "\303\227", input[j]); fprintf (stderr, "\n"); fprintf (stderr, "%s:%d: actual: ", filename, lineno); - for (j = 0; j < i - 1; j++) + for (int j = 0; j < i - 1; j++) fprintf (stderr, "%s U+%04X ", (!(breaks[j] == UC_BREAK_PROHIBITED || breaks[j] == UC_BREAK_MANDATORY diff --git a/tests/unilbrk/test-ulc-possible-linebreaks.c b/tests/unilbrk/test-ulc-possible-linebreaks.c index 70c572ca..d821cf3d 100644 --- a/tests/unilbrk/test-ulc-possible-linebreaks.c +++ b/tests/unilbrk/test-ulc-possible-linebreaks.c @@ -1,5 +1,5 @@ /* Test of line breaking of strings. - Copyright (C) 2008-2025 Free Software Foundation, Inc. + Copyright (C) 2008-2026 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 @@ -37,10 +37,9 @@ test_function (void (*my_ulc_possible_linebreaks) (const char *, size_t, const c /* "Grüß Gott. x=(-b±sqrt(b²-4ac))/(2a)" */ "Gr\374\337 Gott. x=(-b\261sqrt(b\262-4ac))/(2a)\n"; char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_ulc_possible_linebreaks (input, SIZEOF (input), "ISO-8859-1", p); - for (i = 0; i < 36; i++) + for (size_t i = 0; i < 36; i++) { ASSERT (p[i] == (i == 35 ? UC_BREAK_MANDATORY : i == 5 || i == 11 || i == 15 @@ -55,10 +54,9 @@ test_function (void (*my_ulc_possible_linebreaks) (const char *, size_t, const c static const char input[21] _GL_ATTRIBUTE_NONSTRING = "<P>Some sentence.</P>"; char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_ulc_possible_linebreaks (input, SIZEOF (input), "UTF-8", p); - for (i = 0; i < 21; i++) + for (size_t i = 0; i < 21; i++) { ASSERT (p[i] == (i == 8 || i == 17 || i == 19 ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED)); diff --git a/tests/unilbrk/test-ulc-width-linebreaks.c b/tests/unilbrk/test-ulc-width-linebreaks.c index b9c74b23..52423e39 100644 --- a/tests/unilbrk/test-ulc-width-linebreaks.c +++ b/tests/unilbrk/test-ulc-width-linebreaks.c @@ -1,5 +1,5 @@ /* Test of line breaking of strings. - Copyright (C) 2008-2025 Free Software Foundation, Inc. + Copyright (C) 2008-2026 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 @@ -37,10 +37,9 @@ test_function (int (*my_ulc_width_linebreaks) (const char *, size_t, int, int, i /* "Grüß Gott. x=(-b±sqrt(b²-4ac))/(2a)" */ "Gr\374\337 Gott. x=(-b\261sqrt(b\262-4ac))/(2a)\n"; char *p = (char *) malloc (SIZEOF (input)); - size_t i; my_ulc_width_linebreaks (input, SIZEOF (input), 12, 0, 0, NULL, "ISO-8859-1", p); - for (i = 0; i < 36; i++) + for (size_t i = 0; i < 36; i++) { ASSERT (p[i] == (i == 35 ? UC_BREAK_MANDATORY : i == 11 || i == 15 || i == 31 ? UC_BREAK_POSSIBLE : diff --git a/tests/unilbrk/test-unilbrk-h.c b/tests/unilbrk/test-unilbrk-h.c index c06cbeeb..146bddfe 100644 --- a/tests/unilbrk/test-unilbrk-h.c +++ b/tests/unilbrk/test-unilbrk-h.c @@ -1,5 +1,5 @@ /* Test of <unilbrk.h>. - Copyright (C) 2025 Free Software Foundation, Inc. + Copyright (C) 2025-2026 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 |
