summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2021-12-29 19:54:46 +0100
committerBruno Haible <bruno@clisp.org>2021-12-29 19:54:46 +0100
commit5209414e95ed830b8b687ae71be8911ef0969e3e (patch)
tree2e19a28e455e6c5178ffe44f25651c96e4e5b7eb /tests
parentcf1af53c980a5683c379cc7352f75d72e5dbe0f4 (diff)
downloadgnulib-5209414e95ed830b8b687ae71be8911ef0969e3e.tar.gz
unilbrk: Improve support for strings that contain CR-LF sequences.
* lib/gen-uni-tables.c (LBP_CR, LBP_LF): New enum values. (get_lbp): For '\r' and '\n', return LBP_CR and LBP_LF, respectively, instead of LBP_BK. (debug_output_lbp, fill_org_lbp, debug_output_org_lbp, lbp_value_to_string): Handle LBP_CR, LBP_LF. * lib/unilbrk/lbrkprop2.h: Regenerated. * lib/unilbrk/lbrktables.h (LBP_CR, LBP_LF): New enum values. * lib/unilbrk.in.h (UC_BREAK_CR_BEFORE_LF): New enum value. (u8_possible_linebreaks, u16_possible_linebreaks, u32_possible_linebreaks, ulc_possible_linebreaks, u8_width_linebreaks, u16_width_linebreaks, u32_width_linebreaks, ulc_width_linebreaks): Declare also a _v2 variant, and use a C macro to activate it by default. * lib/unilbrk/internal.h: New file. * lib/unilbrk/u8-possible-linebreaks.c: Include unilbrk/internal.h. (u8_possible_linebreaks_loop): Renamed from u8_possible_linebreaks. Add 'cr' parameter. (u8_possible_linebreaks, u8_possible_linebreaks_v2): New functions. (main): Update. * lib/unilbrk/u16-possible-linebreaks.c: Include unilbrk/internal.h. (u16_possible_linebreaks_loop): Renamed from u16_possible_linebreaks. Add 'cr' parameter. (u16_possible_linebreaks, u16_possible_linebreaks_v2): New functions. * lib/unilbrk/u32-possible-linebreaks.c: Include unilbrk/internal.h. (u32_possible_linebreaks_loop): Renamed from u32_possible_linebreaks. Add 'cr' parameter. (u32_possible_linebreaks, u32_possible_linebreaks_v2): New functions. * lib/unilbrk/ulc-possible-linebreaks.c: Include unilbrk/internal.h, unilbrk/lbrktables.h. (ulc_possible_linebreaks_internal): Renamed from ulc_possible_linebreaks. Add 'cr' parameter. (ulc_possible_linebreaks, ulc_possible_linebreaks_v2): New functions. (main): Update. * lib/unilbrk/u8-width-linebreaks.c: Include unilbrk/internal.h, unilbrk/lbrktables.h. (u8_width_linebreaks_internal): Renamed from u8_width_linebreaks. Add 'cr' parameter. (u8_width_linebreaks, u8_width_linebreaks_v2): New functions. (main): Update. * lib/unilbrk/u16-width-linebreaks.c: Include unilbrk/internal.h, unilbrk/lbrktables.h. (u16_width_linebreaks_internal): Renamed from u16_width_linebreaks. Add 'cr' parameter. (u16_width_linebreaks, u16_width_linebreaks_v2): New functions. * lib/unilbrk/u32-width-linebreaks.c: Include unilbrk/internal.h, unilbrk/lbrktables.h. (u32_width_linebreaks_internal): Renamed from u32_width_linebreaks. Add 'cr' parameter. (u32_width_linebreaks, u32_width_linebreaks_v2): New functions. * lib/unilbrk/ulc-width-linebreaks.c: Include unilbrk/internal.h, unilbrk/lbrktables.h. (ulc_width_linebreaks_internal): Renamed from ulc_width_linebreaks. Add 'cr' parameter. (ulc_width_linebreaks, ulc_width_linebreaks_v2): New functions. (main): Update. * modules/unilbrk/u8-possible-linebreaks (Files): Add lib/unilbrk/internal.h. * modules/unilbrk/u16-possible-linebreaks (Files): Likewise. * modules/unilbrk/u32-possible-linebreaks (Files): Likewise. * modules/unilbrk/u8-width-linebreaks (Files): Likewise. * tests/unilbrk/test-u8-possible-linebreaks.c (test_function): New function, extracted from main. Add a test of CR-LF handling. (main): Invoke it twice. * tests/unilbrk/test-u16-possible-linebreaks.c (test_function): New function, extracted from main. Add a test of CR-LF handling. (main): Invoke it twice. * tests/unilbrk/test-u32-possible-linebreaks.c (test_function): New function, extracted from main. Add a test of CR-LF handling. (main): Invoke it twice. * tests/unilbrk/test-ulc-possible-linebreaks.c (test_function): New function, extracted from main. (main): Invoke it twice. * tests/unilbrk/test-u8-width-linebreaks.c (test_function): New function, extracted from main. (main): Invoke it twice. * tests/unilbrk/test-u16-width-linebreaks.c (test_function): New function, extracted from main. (main): Invoke it twice. * tests/unilbrk/test-u32-width-linebreaks.c (test_function): New function, extracted from main. (main): Invoke it twice. * tests/unilbrk/test-ulc-width-linebreaks.c (test_function): New function, extracted from main. (main): Invoke it twice.
Diffstat (limited to 'tests')
-rw-r--r--tests/unilbrk/test-u16-possible-linebreaks.c48
-rw-r--r--tests/unilbrk/test-u16-width-linebreaks.c19
-rw-r--r--tests/unilbrk/test-u32-possible-linebreaks.c48
-rw-r--r--tests/unilbrk/test-u32-width-linebreaks.c19
-rw-r--r--tests/unilbrk/test-u8-possible-linebreaks.c47
-rw-r--r--tests/unilbrk/test-u8-width-linebreaks.c19
-rw-r--r--tests/unilbrk/test-ulc-possible-linebreaks.c19
-rw-r--r--tests/unilbrk/test-ulc-width-linebreaks.c17
8 files changed, 179 insertions, 57 deletions
diff --git a/tests/unilbrk/test-u16-possible-linebreaks.c b/tests/unilbrk/test-u16-possible-linebreaks.c
index fedaa9d842..f582a0c752 100644
--- a/tests/unilbrk/test-u16-possible-linebreaks.c
+++ b/tests/unilbrk/test-u16-possible-linebreaks.c
@@ -24,11 +24,12 @@
#include "macros.h"
-int
-main ()
+static void
+test_function (void (*my_u16_possible_linebreaks) (const uint16_t *, size_t, const char *, char *_UC_RESTRICT),
+ int version)
{
/* Test case n = 0. */
- u16_possible_linebreaks (NULL, 0, "GB18030", NULL);
+ my_u16_possible_linebreaks (NULL, 0, "GB18030", NULL);
{
static const uint16_t input[61] =
@@ -45,7 +46,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- u16_possible_linebreaks (input, SIZEOF (input), "GB18030", p);
+ my_u16_possible_linebreaks (input, SIZEOF (input), "GB18030", p);
for (i = 0; i < 61; i++)
{
ASSERT (p[i] == (i == 60 ? UC_BREAK_MANDATORY :
@@ -64,7 +65,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- u16_possible_linebreaks (input, SIZEOF (input), "GB2312", p);
+ my_u16_possible_linebreaks (input, SIZEOF (input), "GB2312", p);
for (i = 0; i < 61; i++)
{
ASSERT (p[i] == (i == 60 ? UC_BREAK_MANDATORY :
@@ -80,6 +81,23 @@ main ()
}
}
+ /* CR LF handling. */
+ {
+ 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++)
+ {
+ ASSERT (p[i] == (i == 1 || i == 3 || i == 6 ? UC_BREAK_MANDATORY :
+ i == 5 ? (version < 2 ? UC_BREAK_MANDATORY : UC_BREAK_CR_BEFORE_LF) :
+ UC_BREAK_PROHIBITED));
+ }
+ free (p);
+ }
+
/* Test that a break is possible after a zero-width space followed by some
regular spaces (rule LB8 in Unicode TR#14 revision 26). */
{
@@ -87,7 +105,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- u16_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
+ my_u16_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
for (i = 0; i < 4; i++)
{
ASSERT (p[i] == (i == 3 ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED));
@@ -105,7 +123,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- u16_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
+ my_u16_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
for (i = 0; i < 21; i++)
{
ASSERT (p[i] == (i == 8 || i == 17 || i == 19 ? UC_BREAK_POSSIBLE :
@@ -125,7 +143,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- u16_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
+ my_u16_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
for (i = 0; i < 16; i++)
{
ASSERT (p[i] == (i == 14 ? UC_BREAK_MANDATORY :
@@ -149,7 +167,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- u16_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
+ my_u16_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
for (i = 0; i < 39; i++)
{
ASSERT (p[i] == (i == 8 || i == 20
@@ -171,7 +189,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- u16_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
+ my_u16_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
for (i = 0; i < 8; i++)
{
ASSERT (p[i] == (i == 4 ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED));
@@ -187,7 +205,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- u16_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
+ my_u16_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
for (i = 0; i < 10; i++)
{
ASSERT (p[i] == (i == 3 || i == 9 ? UC_BREAK_POSSIBLE :
@@ -195,6 +213,14 @@ main ()
}
free (p);
}
+}
+
+int
+main ()
+{
+ test_function (u16_possible_linebreaks, 2);
+#undef u16_possible_linebreaks
+ test_function (u16_possible_linebreaks, 1);
return 0;
}
diff --git a/tests/unilbrk/test-u16-width-linebreaks.c b/tests/unilbrk/test-u16-width-linebreaks.c
index a4297b8252..73946f285d 100644
--- a/tests/unilbrk/test-u16-width-linebreaks.c
+++ b/tests/unilbrk/test-u16-width-linebreaks.c
@@ -24,11 +24,12 @@
#include "macros.h"
-int
-main ()
+static void
+test_function (int (*my_u16_width_linebreaks) (const uint16_t *, size_t, int, int, int, const char *, const char *, char *_UC_RESTRICT),
+ int version)
{
/* Test case n = 0. */
- u16_width_linebreaks (NULL, 0, 80, 0, 0, NULL, "GB18030", NULL);
+ my_u16_width_linebreaks (NULL, 0, 80, 0, 0, NULL, "GB18030", NULL);
{
static const uint16_t input[61] =
@@ -45,7 +46,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- u16_width_linebreaks (input, SIZEOF (input), 25, 0, 0, NULL, "GB18030", p);
+ my_u16_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 :
@@ -59,7 +60,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- u16_width_linebreaks (input, SIZEOF (input), 25, 0, 0, NULL, "GB2312", p);
+ my_u16_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 :
@@ -69,6 +70,14 @@ main ()
free (p);
}
}
+}
+
+int
+main ()
+{
+ test_function (u16_width_linebreaks, 2);
+#undef u16_width_linebreaks
+ test_function (u16_width_linebreaks, 1);
return 0;
}
diff --git a/tests/unilbrk/test-u32-possible-linebreaks.c b/tests/unilbrk/test-u32-possible-linebreaks.c
index 1d8dfb122b..fb435add2c 100644
--- a/tests/unilbrk/test-u32-possible-linebreaks.c
+++ b/tests/unilbrk/test-u32-possible-linebreaks.c
@@ -24,11 +24,12 @@
#include "macros.h"
-int
-main ()
+static void
+test_function (void (*my_u32_possible_linebreaks) (const uint32_t *, size_t, const char *, char *_UC_RESTRICT),
+ int version)
{
/* Test case n = 0. */
- u32_possible_linebreaks (NULL, 0, "GB18030", NULL);
+ my_u32_possible_linebreaks (NULL, 0, "GB18030", NULL);
{
static const uint32_t input[61] =
@@ -45,7 +46,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- u32_possible_linebreaks (input, SIZEOF (input), "GB18030", p);
+ my_u32_possible_linebreaks (input, SIZEOF (input), "GB18030", p);
for (i = 0; i < 61; i++)
{
ASSERT (p[i] == (i == 60 ? UC_BREAK_MANDATORY :
@@ -64,7 +65,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- u32_possible_linebreaks (input, SIZEOF (input), "GB2312", p);
+ my_u32_possible_linebreaks (input, SIZEOF (input), "GB2312", p);
for (i = 0; i < 61; i++)
{
ASSERT (p[i] == (i == 60 ? UC_BREAK_MANDATORY :
@@ -80,6 +81,23 @@ main ()
}
}
+ /* CR LF handling. */
+ {
+ 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++)
+ {
+ ASSERT (p[i] == (i == 1 || i == 3 || i == 6 ? UC_BREAK_MANDATORY :
+ i == 5 ? (version < 2 ? UC_BREAK_MANDATORY : UC_BREAK_CR_BEFORE_LF) :
+ UC_BREAK_PROHIBITED));
+ }
+ free (p);
+ }
+
/* Test that a break is possible after a zero-width space followed by some
regular spaces (rule LB8 in Unicode TR#14 revision 26). */
{
@@ -87,7 +105,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- u32_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
+ my_u32_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
for (i = 0; i < 4; i++)
{
ASSERT (p[i] == (i == 3 ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED));
@@ -105,7 +123,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- u32_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
+ my_u32_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
for (i = 0; i < 21; i++)
{
ASSERT (p[i] == (i == 8 || i == 17 || i == 19 ? UC_BREAK_POSSIBLE :
@@ -125,7 +143,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- u32_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
+ my_u32_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
for (i = 0; i < 16; i++)
{
ASSERT (p[i] == (i == 14 ? UC_BREAK_MANDATORY :
@@ -149,7 +167,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- u32_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
+ my_u32_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
for (i = 0; i < 37; i++)
{
ASSERT (p[i] == (i == 8 || i == 20
@@ -171,7 +189,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- u32_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
+ my_u32_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
for (i = 0; i < 4; i++)
{
ASSERT (p[i] == (i == 2 ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED));
@@ -187,7 +205,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- u32_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
+ my_u32_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
for (i = 0; i < 10; i++)
{
ASSERT (p[i] == (i == 3 || i == 9 ? UC_BREAK_POSSIBLE :
@@ -195,6 +213,14 @@ main ()
}
free (p);
}
+}
+
+int
+main ()
+{
+ test_function (u32_possible_linebreaks, 2);
+#undef u32_possible_linebreaks
+ test_function (u32_possible_linebreaks, 1);
return 0;
}
diff --git a/tests/unilbrk/test-u32-width-linebreaks.c b/tests/unilbrk/test-u32-width-linebreaks.c
index bc38582f9f..7e7dd25cf1 100644
--- a/tests/unilbrk/test-u32-width-linebreaks.c
+++ b/tests/unilbrk/test-u32-width-linebreaks.c
@@ -24,11 +24,12 @@
#include "macros.h"
-int
-main ()
+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)
{
/* Test case n = 0. */
- u32_width_linebreaks (NULL, 0, 80, 0, 0, NULL, "GB18030", NULL);
+ my_u32_width_linebreaks (NULL, 0, 80, 0, 0, NULL, "GB18030", NULL);
{
static const uint32_t input[61] =
@@ -45,7 +46,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- u32_width_linebreaks (input, SIZEOF (input), 25, 0, 0, NULL, "GB18030", p);
+ 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 :
@@ -59,7 +60,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- u32_width_linebreaks (input, SIZEOF (input), 25, 0, 0, NULL, "GB2312", p);
+ 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 :
@@ -69,6 +70,14 @@ main ()
free (p);
}
}
+}
+
+int
+main ()
+{
+ test_function (u32_width_linebreaks, 2);
+#undef u32_width_linebreaks
+ test_function (u32_width_linebreaks, 1);
return 0;
}
diff --git a/tests/unilbrk/test-u8-possible-linebreaks.c b/tests/unilbrk/test-u8-possible-linebreaks.c
index cad7b7afa3..f0ddc02500 100644
--- a/tests/unilbrk/test-u8-possible-linebreaks.c
+++ b/tests/unilbrk/test-u8-possible-linebreaks.c
@@ -24,11 +24,12 @@
#include "macros.h"
-int
-main ()
+static void
+test_function (void (*my_u8_possible_linebreaks) (const uint8_t *, size_t, const char *, char *_UC_RESTRICT),
+ int version)
{
/* Test case n = 0. */
- u8_possible_linebreaks (NULL, 0, "GB18030", NULL);
+ my_u8_possible_linebreaks (NULL, 0, "GB18030", NULL);
{
static const uint8_t input[91] =
@@ -39,7 +40,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- u8_possible_linebreaks (input, SIZEOF (input), "GB18030", p);
+ my_u8_possible_linebreaks (input, SIZEOF (input), "GB18030", p);
for (i = 0; i < 91; i++)
{
ASSERT (p[i] == (i == 90 ? UC_BREAK_MANDATORY :
@@ -58,7 +59,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- u8_possible_linebreaks (input, SIZEOF (input), "GB2312", p);
+ my_u8_possible_linebreaks (input, SIZEOF (input), "GB2312", p);
for (i = 0; i < 91; i++)
{
ASSERT (p[i] == (i == 90 ? UC_BREAK_MANDATORY :
@@ -74,6 +75,22 @@ main ()
}
}
+ /* CR LF handling. */
+ {
+ static const uint8_t input[8] = "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++)
+ {
+ ASSERT (p[i] == (i == 1 || i == 3 || i == 6 ? UC_BREAK_MANDATORY :
+ i == 5 ? (version < 2 ? UC_BREAK_MANDATORY : UC_BREAK_CR_BEFORE_LF) :
+ UC_BREAK_PROHIBITED));
+ }
+ free (p);
+ }
+
/* Test that a break is possible after a zero-width space followed by some
regular spaces (rule LB8 in Unicode TR#14 revision 26). */
{
@@ -81,7 +98,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
+ my_u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
for (i = 0; i < 6; i++)
{
ASSERT (p[i] == (i == 5 ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED));
@@ -95,7 +112,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
+ my_u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
for (i = 0; i < 21; i++)
{
ASSERT (p[i] == (i == 8 || i == 17 || i == 19 ? UC_BREAK_POSSIBLE :
@@ -112,7 +129,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
+ my_u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
for (i = 0; i < 24; i++)
{
ASSERT (p[i] == (i == 21 ? UC_BREAK_MANDATORY :
@@ -134,7 +151,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
+ my_u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
for (i = 0; i < 101; i++)
{
ASSERT (p[i] == (i == 24 || i == 58
@@ -156,7 +173,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
+ my_u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
for (i = 0; i < 16; i++)
{
ASSERT (p[i] == (i == 8 ? UC_BREAK_POSSIBLE : UC_BREAK_PROHIBITED));
@@ -172,7 +189,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
+ my_u8_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
for (i = 0; i < 15; i++)
{
ASSERT (p[i] == (i == 3 || i == 13 ? UC_BREAK_POSSIBLE :
@@ -180,6 +197,14 @@ main ()
}
free (p);
}
+}
+
+int
+main ()
+{
+ test_function (u8_possible_linebreaks, 2);
+#undef u8_possible_linebreaks
+ test_function (u8_possible_linebreaks, 1);
return 0;
}
diff --git a/tests/unilbrk/test-u8-width-linebreaks.c b/tests/unilbrk/test-u8-width-linebreaks.c
index 4deb5451bc..250ba2be37 100644
--- a/tests/unilbrk/test-u8-width-linebreaks.c
+++ b/tests/unilbrk/test-u8-width-linebreaks.c
@@ -24,11 +24,12 @@
#include "macros.h"
-int
-main ()
+static void
+test_function (int (*my_u8_width_linebreaks) (const uint8_t *, size_t, int, int, int, const char *, const char *, char *_UC_RESTRICT),
+ int version)
{
/* Test case n = 0. */
- u8_width_linebreaks (NULL, 0, 80, 0, 0, NULL, "GB18030", NULL);
+ my_u8_width_linebreaks (NULL, 0, 80, 0, 0, NULL, "GB18030", NULL);
{
static const uint8_t input[91] =
@@ -39,7 +40,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- u8_width_linebreaks (input, SIZEOF (input), 25, 0, 0, NULL, "GB18030", p);
+ my_u8_width_linebreaks (input, SIZEOF (input), 25, 0, 0, NULL, "GB18030", p);
for (i = 0; i < 91; i++)
{
ASSERT (p[i] == (i == 90 ? UC_BREAK_MANDATORY :
@@ -53,7 +54,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- u8_width_linebreaks (input, SIZEOF (input), 25, 0, 0, NULL, "GB2312", p);
+ my_u8_width_linebreaks (input, SIZEOF (input), 25, 0, 0, NULL, "GB2312", p);
for (i = 0; i < 91; i++)
{
ASSERT (p[i] == (i == 90 ? UC_BREAK_MANDATORY :
@@ -63,6 +64,14 @@ main ()
free (p);
}
}
+}
+
+int
+main ()
+{
+ test_function (u8_width_linebreaks, 2);
+#undef u8_width_linebreaks
+ test_function (u8_width_linebreaks, 1);
return 0;
}
diff --git a/tests/unilbrk/test-ulc-possible-linebreaks.c b/tests/unilbrk/test-ulc-possible-linebreaks.c
index f3ad7f9222..95742b9df1 100644
--- a/tests/unilbrk/test-ulc-possible-linebreaks.c
+++ b/tests/unilbrk/test-ulc-possible-linebreaks.c
@@ -24,11 +24,12 @@
#include "macros.h"
-int
-main ()
+static void
+test_function (void (*my_ulc_possible_linebreaks) (const char *, size_t, const char *, char *_UC_RESTRICT),
+ int version)
{
/* Test case n = 0. */
- ulc_possible_linebreaks (NULL, 0, "GB18030", NULL);
+ my_ulc_possible_linebreaks (NULL, 0, "GB18030", NULL);
#if HAVE_ICONV
{
@@ -38,7 +39,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- ulc_possible_linebreaks (input, SIZEOF (input), "ISO-8859-1", p);
+ my_ulc_possible_linebreaks (input, SIZEOF (input), "ISO-8859-1", p);
for (i = 0; i < 36; i++)
{
ASSERT (p[i] == (i == 35 ? UC_BREAK_MANDATORY :
@@ -55,7 +56,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- ulc_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
+ my_ulc_possible_linebreaks (input, SIZEOF (input), "UTF-8", p);
for (i = 0; i < 21; i++)
{
ASSERT (p[i] == (i == 8 || i == 17 || i == 19 ? UC_BREAK_POSSIBLE :
@@ -64,6 +65,14 @@ main ()
free (p);
}
#endif
+}
+
+int
+main ()
+{
+ test_function (ulc_possible_linebreaks, 2);
+#undef ulc_possible_linebreaks
+ test_function (ulc_possible_linebreaks, 1);
return 0;
}
diff --git a/tests/unilbrk/test-ulc-width-linebreaks.c b/tests/unilbrk/test-ulc-width-linebreaks.c
index 78fbe7e5dc..7d742eec2a 100644
--- a/tests/unilbrk/test-ulc-width-linebreaks.c
+++ b/tests/unilbrk/test-ulc-width-linebreaks.c
@@ -24,11 +24,12 @@
#include "macros.h"
-int
-main ()
+static void
+test_function (int (*my_ulc_width_linebreaks) (const char *, size_t, int, int, int, const char *, const char *, char *_UC_RESTRICT),
+ int version)
{
/* Test case n = 0. */
- ulc_width_linebreaks (NULL, 0, 80, 0, 0, NULL, "GB18030", NULL);
+ my_ulc_width_linebreaks (NULL, 0, 80, 0, 0, NULL, "GB18030", NULL);
#if HAVE_ICONV
{
@@ -38,7 +39,7 @@ main ()
char *p = (char *) malloc (SIZEOF (input));
size_t i;
- ulc_width_linebreaks (input, SIZEOF (input), 12, 0, 0, NULL, "ISO-8859-1", p);
+ my_ulc_width_linebreaks (input, SIZEOF (input), 12, 0, 0, NULL, "ISO-8859-1", p);
for (i = 0; i < 36; i++)
{
ASSERT (p[i] == (i == 35 ? UC_BREAK_MANDATORY :
@@ -48,6 +49,14 @@ main ()
free (p);
}
#endif
+}
+
+int
+main ()
+{
+ test_function (ulc_width_linebreaks, 2);
+#undef ulc_width_linebreaks
+ test_function (ulc_width_linebreaks, 1);
return 0;
}