summaryrefslogtreecommitdiff
path: root/tests/uniwidth
diff options
context:
space:
mode:
Diffstat (limited to 'tests/uniwidth')
-rw-r--r--tests/uniwidth/test-u16-strwidth.c71
-rw-r--r--tests/uniwidth/test-u16-width.c77
-rw-r--r--tests/uniwidth/test-u32-strwidth.c71
-rw-r--r--tests/uniwidth/test-u32-width.c77
-rw-r--r--tests/uniwidth/test-u8-strwidth.c66
-rw-r--r--tests/uniwidth/test-u8-width.c75
-rw-r--r--tests/uniwidth/test-uc_width.c69
-rw-r--r--tests/uniwidth/test-uc_width2.c97
-rwxr-xr-xtests/uniwidth/test-uc_width2.sh382
9 files changed, 985 insertions, 0 deletions
diff --git a/tests/uniwidth/test-u16-strwidth.c b/tests/uniwidth/test-u16-strwidth.c
new file mode 100644
index 00000000..7365426f
--- /dev/null
+++ b/tests/uniwidth/test-u16-strwidth.c
@@ -0,0 +1,71 @@
+/* Test of u16_strwidth() function.
+ Copyright (C) 2007-2008 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "uniwidth.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ fflush (stderr); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+int
+main ()
+{
+ {
+ static const uint16_t input[] = /* "Danilo Šegan" */
+ { 'D', 'a', 'n', 'i', 'l', 'o', ' ', 0x0160, 'e', 'g', 'a', 'n', 0 };
+ ASSERT (u16_strwidth (input, "UTF-8") == 12);
+ }
+
+ {
+ static const uint16_t input[] = /* "Danilo Šegan" decomposed */
+ { 'D', 'a', 'n', 'i', 'l', 'o', ' ', 'S', 0x030C, 'e', 'g', 'a', 'n', 0 };
+ ASSERT (u16_strwidth (input, "UTF-8") == 12);
+ }
+
+ {
+ static const uint16_t input[] = /* "Данило Шеган" */
+ {
+ 0x0414, 0x0430, 0x043D, 0x0438, 0x043B, 0x043E, ' ',
+ 0x0428, 0x0435, 0x0433, 0x0430, 0x043D, 0
+ };
+ ASSERT (u16_strwidth (input, "UTF-8") == 12);
+ ASSERT (u16_strwidth (input, "EUC-JP") == 23);
+ }
+
+ {
+ static const uint16_t input[] = /* 刘军民 */
+ { 0x5218, 0x519B, 0x6C11, 0 };
+ ASSERT (u16_strwidth (input, "UTF-8") == 6);
+ ASSERT (u16_strwidth (input, "GB2312") == 6);
+ }
+
+ return 0;
+}
diff --git a/tests/uniwidth/test-u16-width.c b/tests/uniwidth/test-u16-width.c
new file mode 100644
index 00000000..b3e2b592
--- /dev/null
+++ b/tests/uniwidth/test-u16-width.c
@@ -0,0 +1,77 @@
+/* Test of u16_width() function.
+ Copyright (C) 2007-2008 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "uniwidth.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ fflush (stderr); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+int
+main ()
+{
+ static const uint16_t input[] =
+ {
+ #define INPUT1_OFFSET 0
+ #define INPUT1_LENGTH 12
+ 'D', 'a', 'n', 'i', 'l', 'o', ' ', 0x0160, 'e', 'g', 'a', 'n',
+ #define INPUT2_OFFSET 12
+ #define INPUT2_LENGTH 13
+ 'D', 'a', 'n', 'i', 'l', 'o', ' ', 'S', 0x030C, 'e', 'g', 'a', 'n',
+ #define INPUT3_OFFSET 25
+ #define INPUT3_LENGTH 12
+ 0x0414, 0x0430, 0x043D, 0x0438, 0x043B, 0x043E, ' ',
+ 0x0428, 0x0435, 0x0433, 0x0430, 0x043D,
+ #define INPUT4_OFFSET 37
+ #define INPUT4_LENGTH 3
+ 0x5218, 0x519B, 0x6C11
+ };
+
+ { /* "Danilo Šegan" */
+ ASSERT (u16_width (input + INPUT1_OFFSET, INPUT1_LENGTH, "UTF-8") == 12);
+ }
+
+ { /* "Danilo Šegan" decomposed */
+ ASSERT (u16_width (input + INPUT2_OFFSET, INPUT2_LENGTH, "UTF-8") == 12);
+ }
+
+ { /* "Данило Шеган" */
+ ASSERT (u16_width (input + INPUT3_OFFSET, INPUT3_LENGTH, "UTF-8") == 12);
+ ASSERT (u16_width (input + INPUT3_OFFSET, INPUT3_LENGTH, "EUC-JP") == 23);
+ }
+
+ { /* 刘军民 */
+ ASSERT (u16_width (input + INPUT4_OFFSET, INPUT4_LENGTH, "UTF-8") == 6);
+ ASSERT (u16_width (input + INPUT4_OFFSET, INPUT4_LENGTH, "GB2312") == 6);
+ }
+
+ return 0;
+}
diff --git a/tests/uniwidth/test-u32-strwidth.c b/tests/uniwidth/test-u32-strwidth.c
new file mode 100644
index 00000000..3976daa9
--- /dev/null
+++ b/tests/uniwidth/test-u32-strwidth.c
@@ -0,0 +1,71 @@
+/* Test of u32_strwidth() function.
+ Copyright (C) 2007-2008 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "uniwidth.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ fflush (stderr); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+int
+main ()
+{
+ {
+ static const uint32_t input[] = /* "Danilo Šegan" */
+ { 'D', 'a', 'n', 'i', 'l', 'o', ' ', 0x0160, 'e', 'g', 'a', 'n', 0 };
+ ASSERT (u32_strwidth (input, "UTF-8") == 12);
+ }
+
+ {
+ static const uint32_t input[] = /* "Danilo Šegan" decomposed */
+ { 'D', 'a', 'n', 'i', 'l', 'o', ' ', 'S', 0x030C, 'e', 'g', 'a', 'n', 0 };
+ ASSERT (u32_strwidth (input, "UTF-8") == 12);
+ }
+
+ {
+ static const uint32_t input[] = /* "Данило Шеган" */
+ {
+ 0x0414, 0x0430, 0x043D, 0x0438, 0x043B, 0x043E, ' ',
+ 0x0428, 0x0435, 0x0433, 0x0430, 0x043D, 0
+ };
+ ASSERT (u32_strwidth (input, "UTF-8") == 12);
+ ASSERT (u32_strwidth (input, "EUC-JP") == 23);
+ }
+
+ {
+ static const uint32_t input[] = /* 刘军民 */
+ { 0x5218, 0x519B, 0x6C11, 0 };
+ ASSERT (u32_strwidth (input, "UTF-8") == 6);
+ ASSERT (u32_strwidth (input, "GB2312") == 6);
+ }
+
+ return 0;
+}
diff --git a/tests/uniwidth/test-u32-width.c b/tests/uniwidth/test-u32-width.c
new file mode 100644
index 00000000..05fd856d
--- /dev/null
+++ b/tests/uniwidth/test-u32-width.c
@@ -0,0 +1,77 @@
+/* Test of u32_width() function.
+ Copyright (C) 2007-2008 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "uniwidth.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ fflush (stderr); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+int
+main ()
+{
+ static const uint32_t input[] =
+ {
+ #define INPUT1_OFFSET 0
+ #define INPUT1_LENGTH 12
+ 'D', 'a', 'n', 'i', 'l', 'o', ' ', 0x0160, 'e', 'g', 'a', 'n',
+ #define INPUT2_OFFSET 12
+ #define INPUT2_LENGTH 13
+ 'D', 'a', 'n', 'i', 'l', 'o', ' ', 'S', 0x030C, 'e', 'g', 'a', 'n',
+ #define INPUT3_OFFSET 25
+ #define INPUT3_LENGTH 12
+ 0x0414, 0x0430, 0x043D, 0x0438, 0x043B, 0x043E, ' ',
+ 0x0428, 0x0435, 0x0433, 0x0430, 0x043D,
+ #define INPUT4_OFFSET 37
+ #define INPUT4_LENGTH 3
+ 0x5218, 0x519B, 0x6C11
+ };
+
+ { /* "Danilo Šegan" */
+ ASSERT (u32_width (input + INPUT1_OFFSET, INPUT1_LENGTH, "UTF-8") == 12);
+ }
+
+ { /* "Danilo Šegan" decomposed */
+ ASSERT (u32_width (input + INPUT2_OFFSET, INPUT2_LENGTH, "UTF-8") == 12);
+ }
+
+ { /* "Данило Шеган" */
+ ASSERT (u32_width (input + INPUT3_OFFSET, INPUT3_LENGTH, "UTF-8") == 12);
+ ASSERT (u32_width (input + INPUT3_OFFSET, INPUT3_LENGTH, "EUC-JP") == 23);
+ }
+
+ { /* 刘军民 */
+ ASSERT (u32_width (input + INPUT4_OFFSET, INPUT4_LENGTH, "UTF-8") == 6);
+ ASSERT (u32_width (input + INPUT4_OFFSET, INPUT4_LENGTH, "GB2312") == 6);
+ }
+
+ return 0;
+}
diff --git a/tests/uniwidth/test-u8-strwidth.c b/tests/uniwidth/test-u8-strwidth.c
new file mode 100644
index 00000000..3fbb39e5
--- /dev/null
+++ b/tests/uniwidth/test-u8-strwidth.c
@@ -0,0 +1,66 @@
+/* Test of u8_strwidth() function.
+ Copyright (C) 2007-2008 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "uniwidth.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ fflush (stderr); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+int
+main ()
+{
+ {
+ static const uint8_t input[] = "Danilo \305\240egan"; /* "Danilo Šegan" */
+ ASSERT (u8_strwidth (input, "UTF-8") == 12);
+ }
+
+ {
+ static const uint8_t input[] = "Danilo S\314\214egan"; /* "Danilo Šegan" decomposed */
+ ASSERT (u8_strwidth (input, "UTF-8") == 12);
+ }
+
+ {
+ static const uint8_t input[] = /* "Данило Шеган" */
+ "\320\224\320\260\320\275\320\270\320\273\320\276 \320\250\320\265\320\263\320\260\320\275";
+ ASSERT (u8_strwidth (input, "UTF-8") == 12);
+ ASSERT (u8_strwidth (input, "EUC-JP") == 23);
+ }
+
+ {
+ static const uint8_t input[] = /* 刘军民 */
+ "\345\210\230\345\206\233\346\260\221";
+ ASSERT (u8_strwidth (input, "UTF-8") == 6);
+ ASSERT (u8_strwidth (input, "GB2312") == 6);
+ }
+
+ return 0;
+}
diff --git a/tests/uniwidth/test-u8-width.c b/tests/uniwidth/test-u8-width.c
new file mode 100644
index 00000000..b2532897
--- /dev/null
+++ b/tests/uniwidth/test-u8-width.c
@@ -0,0 +1,75 @@
+/* Test of u8_width() function.
+ Copyright (C) 2007-2008 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "uniwidth.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ fflush (stderr); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+int
+main ()
+{
+ static const uint8_t input[] =
+ #define INPUT1_OFFSET 0
+ #define INPUT1_LENGTH 13
+ "Danilo \305\240egan"
+ #define INPUT2_OFFSET 13
+ #define INPUT2_LENGTH 14
+ "Danilo S\314\214egan"
+ #define INPUT3_OFFSET 27
+ #define INPUT3_LENGTH 23
+ "\320\224\320\260\320\275\320\270\320\273\320\276 \320\250\320\265\320\263\320\260\320\275"
+ #define INPUT4_OFFSET 50
+ #define INPUT4_LENGTH 9
+ "\345\210\230\345\206\233\346\260\221"
+ ;
+
+ { /* "Danilo Šegan" */
+ ASSERT (u8_width (input + INPUT1_OFFSET, INPUT1_LENGTH, "UTF-8") == 12);
+ }
+
+ { /* "Danilo Šegan" decomposed */
+ ASSERT (u8_width (input + INPUT2_OFFSET, INPUT2_LENGTH, "UTF-8") == 12);
+ }
+
+ { /* "Данило Шеган" */
+ ASSERT (u8_width (input + INPUT3_OFFSET, INPUT3_LENGTH, "UTF-8") == 12);
+ ASSERT (u8_width (input + INPUT3_OFFSET, INPUT3_LENGTH, "EUC-JP") == 23);
+ }
+
+ { /* 刘军民 */
+ ASSERT (u8_width (input + INPUT4_OFFSET, INPUT4_LENGTH, "UTF-8") == 6);
+ ASSERT (u8_width (input + INPUT4_OFFSET, INPUT4_LENGTH, "GB2312") == 6);
+ }
+
+ return 0;
+}
diff --git a/tests/uniwidth/test-uc_width.c b/tests/uniwidth/test-uc_width.c
new file mode 100644
index 00000000..d7335cfd
--- /dev/null
+++ b/tests/uniwidth/test-uc_width.c
@@ -0,0 +1,69 @@
+/* Test of uc_width() function.
+ Copyright (C) 2007-2008 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include "uniwidth.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ fflush (stderr); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+int
+main ()
+{
+ ucs4_t uc;
+
+ /* Test width of ASCII characters. */
+ for (uc = 0x0020; uc < 0x007F; uc++)
+ ASSERT (uc_width (uc, "ISO-8859-2") == 1);
+
+ /* Test width of some non-spacing characters. */
+ ASSERT (uc_width (0x0301, "UTF-8") == 0);
+ ASSERT (uc_width (0x05B0, "UTF-8") == 0);
+
+ /* Test width of some format control characters. */
+ ASSERT (uc_width (0x200E, "UTF-8") == 0);
+ ASSERT (uc_width (0x2060, "UTF-8") == 0);
+ ASSERT (uc_width (0xE0001, "UTF-8") == 0);
+ ASSERT (uc_width (0xE0044, "UTF-8") == 0);
+
+ /* Test width of some zero width characters. */
+ ASSERT (uc_width (0x200B, "UTF-8") == 0);
+ ASSERT (uc_width (0xFEFF, "UTF-8") == 0);
+
+ /* Test width of some CJK characters. */
+ ASSERT (uc_width (0x3000, "UTF-8") == 2);
+ ASSERT (uc_width (0xB250, "UTF-8") == 2);
+ ASSERT (uc_width (0xFF1A, "UTF-8") == 2);
+ ASSERT (uc_width (0x20369, "UTF-8") == 2);
+ ASSERT (uc_width (0x2F876, "UTF-8") == 2);
+
+ return 0;
+}
diff --git a/tests/uniwidth/test-uc_width2.c b/tests/uniwidth/test-uc_width2.c
new file mode 100644
index 00000000..2bf143c2
--- /dev/null
+++ b/tests/uniwidth/test-uc_width2.c
@@ -0,0 +1,97 @@
+/* Test of uc_width() function.
+ Copyright (C) 2007-2008 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
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2008. */
+
+#include <config.h>
+
+#include "uniwidth.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define ASSERT(expr) \
+ do \
+ { \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ fflush (stderr); \
+ abort (); \
+ } \
+ } \
+ while (0)
+
+/* One of 0, '0', '1', 'A', '2'. */
+static char current_width;
+/* The interval for which the current_width holds. */
+static ucs4_t current_start;
+static ucs4_t current_end;
+
+static void
+finish_interval (void)
+{
+ if (current_width != 0)
+ {
+ if (current_start == current_end)
+ printf ("%04X\t\t%c\n", (unsigned) current_start, current_width);
+ else
+ printf ("%04X..%04X\t%c\n", (unsigned) current_start,
+ (unsigned) current_end, current_width);
+ current_width = 0;
+ }
+}
+
+static void
+add_to_interval (ucs4_t uc, char width)
+{
+ if (current_width == width && uc == current_end + 1)
+ current_end = uc;
+ else
+ {
+ finish_interval ();
+ current_width = width;
+ current_start = current_end = uc;
+ }
+}
+
+int
+main ()
+{
+ ucs4_t uc;
+
+ for (uc = 0; uc < 0x110000; uc++)
+ {
+ int w1 = uc_width (uc, "UTF-8");
+ int w2 = uc_width (uc, "GBK");
+ char width =
+ (w1 == 0 && w2 == 0 ? '0' :
+ w1 == 1 && w2 == 1 ? '1' :
+ w1 == 1 && w2 == 2 ? 'A' :
+ w1 == 2 && w2 == 2 ? '2' :
+ 0);
+ if (width == 0)
+ {
+ /* uc must be a control character. */
+ ASSERT (w1 < 0 && w2 < 0);
+ }
+ else
+ add_to_interval (uc, width);
+ }
+ finish_interval ();
+
+ return 0;
+}
diff --git a/tests/uniwidth/test-uc_width2.sh b/tests/uniwidth/test-uc_width2.sh
new file mode 100755
index 00000000..484288c9
--- /dev/null
+++ b/tests/uniwidth/test-uc_width2.sh
@@ -0,0 +1,382 @@
+#!/bin/sh
+
+tmpfiles=""
+trap 'rm -fr $tmpfiles' 1 2 3 15
+
+tmpfiles="$tmpfiles uc_width.out"
+./test-uc_width2${EXEEXT} | LC_ALL=C tr -d '\r' > uc_width.out
+
+tmpfiles="$tmpfiles uc_width.ok"
+cat > uc_width.ok <<\EOF
+0000 0
+0020..007E 1
+00A0 1
+00A1..00AC A
+00AD 0
+00AE..02FF A
+0300..036F 0
+0370..0482 A
+0483..0489 0
+048A..0590 A
+0591..05BD 0
+05BE A
+05BF 0
+05C0 A
+05C1..05C2 0
+05C3 A
+05C4..05C5 0
+05C6 A
+05C7 0
+05C8..05FF A
+0600..0603 0
+0604..060F A
+0610..061A 0
+061B..064A A
+064B..065E 0
+065F..066F A
+0670 0
+0671..06D5 A
+06D6..06E4 0
+06E5..06E6 A
+06E7..06E8 0
+06E9 A
+06EA..06ED 0
+06EE..070E A
+070F 0
+0710 A
+0711 0
+0712..072F A
+0730..074A 0
+074B..07A5 A
+07A6..07B0 0
+07B1..07EA A
+07EB..07F3 0
+07F4..0900 A
+0901..0902 0
+0903..093B A
+093C 0
+093D..0940 A
+0941..0948 0
+0949..094C A
+094D 0
+094E..0950 A
+0951..0954 0
+0955..0961 A
+0962..0963 0
+0964..0980 A
+0981 0
+0982..09BB A
+09BC 0
+09BD..09C0 A
+09C1..09C4 0
+09C5..09CC A
+09CD 0
+09CE..09E1 A
+09E2..09E3 0
+09E4..0A00 A
+0A01..0A02 0
+0A03..0A3B A
+0A3C 0
+0A3D..0A40 A
+0A41..0A42 0
+0A43..0A46 A
+0A47..0A48 0
+0A49..0A4A A
+0A4B..0A4D 0
+0A4E..0A50 A
+0A51 0
+0A52..0A6F A
+0A70..0A71 0
+0A72..0A74 A
+0A75 0
+0A76..0A80 A
+0A81..0A82 0
+0A83..0ABB A
+0ABC 0
+0ABD..0AC0 A
+0AC1..0AC5 0
+0AC6 A
+0AC7..0AC8 0
+0AC9..0ACC A
+0ACD 0
+0ACE..0AE1 A
+0AE2..0AE3 0
+0AE4..0B00 A
+0B01 0
+0B02..0B3B A
+0B3C 0
+0B3D..0B3E A
+0B3F 0
+0B40 A
+0B41..0B44 0
+0B45..0B4C A
+0B4D 0
+0B4E..0B55 A
+0B56 0
+0B57..0B61 A
+0B62..0B63 0
+0B64..0B81 A
+0B82 0
+0B83..0BBF A
+0BC0 0
+0BC1..0BCC A
+0BCD 0
+0BCE..0C3D A
+0C3E..0C40 0
+0C41..0C45 A
+0C46..0C48 0
+0C49 A
+0C4A..0C4D 0
+0C4E..0C54 A
+0C55..0C56 0
+0C57..0C61 A
+0C62..0C63 0
+0C64..0CBB A
+0CBC 0
+0CBD..0CCB A
+0CCC..0CCD 0
+0CCE..0CE1 A
+0CE2..0CE3 0
+0CE4..0D40 A
+0D41..0D44 0
+0D45..0D4C A
+0D4D 0
+0D4E..0D61 A
+0D62..0D63 0
+0D64..0DC9 A
+0DCA 0
+0DCB..0DD1 A
+0DD2..0DD4 0
+0DD5 A
+0DD6 0
+0DD7..0E30 A
+0E31 0
+0E32..0E33 A
+0E34..0E3A 0
+0E3B..0E46 A
+0E47..0E4E 0
+0E4F..0EB0 A
+0EB1 0
+0EB2..0EB3 A
+0EB4..0EB9 0
+0EBA A
+0EBB..0EBC 0
+0EBD..0EC7 A
+0EC8..0ECD 0
+0ECE..0F17 A
+0F18..0F19 0
+0F1A..0F34 A
+0F35 0
+0F36 A
+0F37 0
+0F38 A
+0F39 0
+0F3A..0F70 A
+0F71..0F7E 0
+0F7F A
+0F80..0F84 0
+0F85 A
+0F86..0F87 0
+0F88..0F8F A
+0F90..0F97 0
+0F98 A
+0F99..0FBC 0
+0FBD..0FC5 A
+0FC6 0
+0FC7..102C A
+102D..1030 0
+1031 A
+1032..1037 0
+1038 A
+1039..103A 0
+103B..103C A
+103D..103E 0
+103F..1057 A
+1058..1059 0
+105A..105D A
+105E..1060 0
+1061..1070 A
+1071..1074 0
+1075..1081 A
+1082 0
+1083..1084 A
+1085..1086 0
+1087..108C A
+108D 0
+108E..10FF A
+1100..115F 2
+1160..135E A
+135F 0
+1360..1711 A
+1712..1714 0
+1715..1731 A
+1732..1734 0
+1735..1751 A
+1752..1753 0
+1754..1771 A
+1772..1773 0
+1774..17B3 A
+17B4..17B5 0
+17B6 A
+17B7..17BD 0
+17BE..17C5 A
+17C6 0
+17C7..17C8 A
+17C9..17D3 0
+17D4..17DC A
+17DD 0
+17DE..180A A
+180B..180D 0
+180E..18A8 A
+18A9 0
+18AA..191F A
+1920..1922 0
+1923..1926 A
+1927..1928 0
+1929..1931 A
+1932 0
+1933..1938 A
+1939..193B 0
+193C..1A16 A
+1A17..1A18 0
+1A19..1AFF A
+1B00..1B03 0
+1B04..1B33 A
+1B34 0
+1B35 A
+1B36..1B3A 0
+1B3B A
+1B3C 0
+1B3D..1B41 A
+1B42 0
+1B43..1B6A A
+1B6B..1B73 0
+1B74..1B7F A
+1B80..1B81 0
+1B82..1BA1 A
+1BA2..1BA5 0
+1BA6..1BA7 A
+1BA8..1BA9 0
+1BAA..1C2B A
+1C2C..1C33 0
+1C34..1C35 A
+1C36..1C37 0
+1C38..1DBF A
+1DC0..1DE6 0
+1DE7..1DFD A
+1DFE..1DFF 0
+1E00..200A A
+200B..200F 0
+2010..2029 A
+202A..202E 0
+202F..205F A
+2060..2064 0
+2065..2069 A
+206A..206F 0
+2070..20A8 A
+20A9 1
+20AA..20CF A
+20D0..20F0 0
+20F1..2328 A
+2329..232A 2
+232B..2DDF A
+2DE0..2DFF 0
+2E00..2E7F A
+2E80..3029 2
+302A..302F 0
+3030..303E 2
+303F A
+3040..3098 2
+3099..309A 0
+309B..4DBF 2
+4DC0..4DFF A
+4E00..A4CF 2
+A4D0..A66E A
+A66F..A672 0
+A673..A67B A
+A67C..A67D 0
+A67E..A801 A
+A802 0
+A803..A805 A
+A806 0
+A807..A80A A
+A80B 0
+A80C..A824 A
+A825..A826 0
+A827..A8C3 A
+A8C4 0
+A8C5..A925 A
+A926..A92D 0
+A92E..A946 A
+A947..A951 0
+A952..AA28 A
+AA29..AA2E 0
+AA2F..AA30 A
+AA31..AA32 0
+AA33..AA34 A
+AA35..AA36 0
+AA37..AA42 A
+AA43 0
+AA44..AA4B A
+AA4C 0
+AA4D..ABFF A
+AC00..D7A3 2
+D7A4..F8FF A
+F900..FAFF 2
+FB00..FB1D A
+FB1E 0
+FB1F..FDFF A
+FE00..FE0F 0
+FE10..FE1F 2
+FE20..FE26 0
+FE27..FE2F A
+FE30..FE6F 2
+FE70..FEFE A
+FEFF 0
+FF00..FF60 2
+FF61..FFDF 1
+FFE0..FFE6 2
+FFE7..FFF8 1
+FFF9..FFFB 0
+FFFC..101FC 1
+101FD 0
+101FE..10A00 1
+10A01..10A03 0
+10A04 1
+10A05..10A06 0
+10A07..10A0B 1
+10A0C..10A0F 0
+10A10..10A37 1
+10A38..10A3A 0
+10A3B..10A3E 1
+10A3F 0
+10A40..1D166 1
+1D167..1D169 0
+1D16A..1D17A 1
+1D17B..1D182 0
+1D183..1D184 1
+1D185..1D18B 0
+1D18C..1D1A9 1
+1D1AA..1D1AD 0
+1D1AE..1D241 1
+1D242..1D244 0
+1D245..1FFFF 1
+20000..2A6D6 2
+2A6D7..2F7FF 1
+2F800..2FA1D 2
+2FA1E..E0000 1
+E0001 0
+E0002..E001F 1
+E0020..E007F 0
+E0080..E00FF 1
+E0100..E01EF 0
+E01F0..10FFFF 1
+EOF
+
+: ${DIFF=diff}
+${DIFF} uc_width.ok uc_width.out
+result=$?
+
+rm -fr $tmpfiles
+
+exit $result