Mercurial > hg > octave-nkf > gnulib-hg
changeset 10355:017cb54cf1da
Complete test of uc_width results.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 24 Aug 2008 12:27:42 +0200 |
parents | 259e0fdc6c66 |
children | 224235ce930f |
files | ChangeLog modules/uniwidth/width-tests tests/uniwidth/test-uc_width2.c tests/uniwidth/test-uc_width2.sh |
diffstat | 4 files changed, 440 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2008-08-24 Bruno Haible <bruno@clisp.org> + * tests/uniwidth/test-uc_width2.c: New file. + * tests/uniwidth/test-uc_width2.sh: New file. + * modules/uniwidth/width-tests (Files): Add the new files. + (TESTS): Add uniwidth/test-uc_width2.sh. + (TESTS_ENVIRONMENT): New variable. + (check_PROGRAMS): Add test-uc_width2. + (test_uc_width2_SOURCES): New variable. + Fix uc_width(0x00AB) bug, introduced on 2007-07-08. * lib/uniwidth/width.c (nonspacing_table_data): Set bit for 0x00AD, not 0x00AB.
--- a/modules/uniwidth/width-tests +++ b/modules/uniwidth/width-tests @@ -1,12 +1,16 @@ Files: tests/uniwidth/test-uc_width.c +tests/uniwidth/test-uc_width2.c +tests/uniwidth/test-uc_width2.sh Depends-on: configure.ac: Makefile.am: -TESTS += test-uc_width -check_PROGRAMS += test-uc_width +TESTS += test-uc_width uniwidth/test-uc_width2.sh +TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' +check_PROGRAMS += test-uc_width test-uc_width2 test_uc_width_SOURCES = uniwidth/test-uc_width.c +test_uc_width2_SOURCES = uniwidth/test-uc_width2.c
new file mode 100644 --- /dev/null +++ b/tests/uniwidth/test-uc_width2.c @@ -0,0 +1,96 @@ +/* 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", current_start, current_width); + else + printf ("%04X..%04X\t%c\n", current_start, 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; +}
new file mode 100755 --- /dev/null +++ b/tests/uniwidth/test-uc_width2.sh @@ -0,0 +1,330 @@ +#!/bin/sh + +tmpfiles="" +trap 'rm -fr $tmpfiles' 1 2 3 15 + +tmpfiles="$tmpfiles uc_width.out" +./test-uc_width2${EXEEXT} > 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..0486 0 +0487 A +0488..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..0615 0 +0616..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..0A6F A +0A70..0A71 0 +0A72..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..0B43 0 +0B44..0B4C A +0B4D 0 +0B4E..0B55 A +0B56 0 +0B57..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..0CBB A +0CBC 0 +0CBD..0CCB A +0CCC..0CCD 0 +0CCE..0CE1 A +0CE2..0CE3 0 +0CE4..0D40 A +0D41..0D43 0 +0D44..0D4C A +0D4D 0 +0D4E..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 0 +1033..1035 A +1036..1037 0 +1038 A +1039 0 +103A..1057 A +1058..1059 0 +105A..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..192B 0 +192C..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..1DBF A +1DC0..1DCA 0 +1DCB..1DFD A +1DFE..1DFF 0 +1E00..200A A +200B..200F 0 +2010..2029 A +202A..202E 0 +202F..205F A +2060..2063 0 +2064..2069 A +206A..206F 0 +2070..20A8 A +20A9 1 +20AA..20CF A +20D0..20EF 0 +20F0..2328 A +2329..232A 2 +232B..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..A801 A +A802 0 +A803..A805 A +A806 0 +A807..A80A A +A80B 0 +A80C..A824 A +A825..A826 0 +A827..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..FE23 0 +FE24..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..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