summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAnas Nashif <anas.nashif@intel.com>2012-11-04 07:14:38 -0800
committerAnas Nashif <anas.nashif@intel.com>2012-11-04 07:14:38 -0800
commite28c3fb0c3efaee49f10d1aa87e5eb9170cdf17a (patch)
tree87c37522bc6462b73c5f327716e8063f8387ec34 /tests
downloadlibthai-e28c3fb0c3efaee49f10d1aa87e5eb9170cdf17a.tar.gz
libthai-e28c3fb0c3efaee49f10d1aa87e5eb9170cdf17a.tar.bz2
libthai-e28c3fb0c3efaee49f10d1aa87e5eb9170cdf17a.zip
Imported Upstream version 0.1.18upstream/0.1.18upstream
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am84
-rw-r--r--tests/Makefile.in741
-rw-r--r--tests/sorted.txt96
-rw-r--r--tests/sorttest.txt96
-rwxr-xr-xtests/test-thbrk.sh6
-rwxr-xr-xtests/test-thcoll.sh8
-rwxr-xr-xtests/test-thwbrk.sh6
-rw-r--r--tests/test_thbrk.c73
-rw-r--r--tests/test_thcell.c258
-rw-r--r--tests/test_thctype.c156
-rw-r--r--tests/test_thinp.c88
-rw-r--r--tests/test_thrend.c92
-rw-r--r--tests/test_thstr.c24
-rw-r--r--tests/test_thwbrk.c78
-rw-r--r--tests/test_thwchar.c63
-rw-r--r--tests/thsort.c113
16 files changed, 1982 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 0000000..41cb99b
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,84 @@
+MAINTAINERCLEANFILES = Makefile.in
+
+INCLUDES = -I$(top_srcdir)/include
+
+EXTRA_DIST = sorttest.txt sorted.txt test-thcoll.sh test-thbrk.sh test-thwbrk.sh
+
+TESTS_ENVIRONMENT = top_builddir=$(top_builddir)
+
+TESTS = \
+ test_thctype \
+ test_thcell \
+ test_thinp \
+ test_thrend \
+ test_thstr \
+ test-thcoll.sh \
+ test-thbrk.sh \
+ test_thwchar \
+ test-thwbrk.sh
+
+check_SCRIPTS = \
+ test-thcoll.sh \
+ test-thbrk.sh \
+ test-thwbrk.sh
+
+check_PROGRAMS = \
+ test_thctype \
+ test_thcell \
+ test_thinp \
+ test_thrend \
+ test_thstr \
+ thsort \
+ test_thbrk \
+ test_thwchar \
+ test_thwbrk
+
+test_thctype_SOURCES = test_thctype.c
+test_thctype_LDADD = $(top_builddir)/src/thctype/libthctype.la
+
+test_thcell_SOURCES = test_thcell.c
+test_thcell_LDADD = \
+ $(top_builddir)/src/thcell/libthcell.la \
+ $(top_builddir)/src/thctype/libthctype.la
+
+test_thinp_SOURCES = test_thinp.c
+test_thinp_LDADD = \
+ $(top_builddir)/src/thinp/libthinp.la \
+ $(top_builddir)/src/thcell/libthcell.la \
+ $(top_builddir)/src/thctype/libthctype.la
+
+test_thrend_SOURCES = test_thrend.c
+test_thrend_LDADD = \
+ $(top_builddir)/src/thrend/libthrend.la \
+ $(top_builddir)/src/thcell/libthcell.la \
+ $(top_builddir)/src/thctype/libthctype.la
+
+test_thstr_SOURCES = test_thstr.c
+test_thstr_LDADD = \
+ $(top_builddir)/src/thstr/libthstr.la \
+ $(top_builddir)/src/thctype/libthctype.la
+
+thsort_SOURCES = thsort.c
+thsort_LDADD = \
+ $(top_builddir)/src/thcoll/libthcoll.la \
+ $(top_builddir)/src/thctype/libthctype.la
+
+test_thbrk_SOURCES = test_thbrk.c
+test_thbrk_LDADD = \
+ $(top_builddir)/src/thbrk/libthbrk.la \
+ $(top_builddir)/src/thwchar/libthwchar.la \
+ $(top_builddir)/src/thstr/libthstr.la \
+ $(top_builddir)/src/thctype/libthctype.la
+
+test_thwchar_SOURCES = test_thwchar.c
+test_thwchar_LDADD = $(top_builddir)/src/thwchar/libthwchar.la
+
+test_thwbrk_SOURCES = test_thwbrk.c
+test_thwbrk_LDADD = \
+ $(top_builddir)/src/thwbrk/libthwbrk.la \
+ $(top_builddir)/src/thwchar/libthwchar.la \
+ $(top_builddir)/src/thbrk/libthbrk.la \
+ $(top_builddir)/src/thwchar/libthwchar.la \
+ $(top_builddir)/src/thstr/libthstr.la \
+ $(top_builddir)/src/thctype/libthctype.la
+
diff --git a/tests/Makefile.in b/tests/Makefile.in
new file mode 100644
index 0000000..f04066d
--- /dev/null
+++ b/tests/Makefile.in
@@ -0,0 +1,741 @@
+# Makefile.in generated by automake 1.11.5 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+am__make_dryrun = \
+ { \
+ am__dry=no; \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
+ | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
+ *) \
+ for am__flg in $$MAKEFLAGS; do \
+ case $$am__flg in \
+ *=*|--*) ;; \
+ *n*) am__dry=yes; break;; \
+ esac; \
+ done;; \
+ esac; \
+ test $$am__dry = yes; \
+ }
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+TESTS = test_thctype$(EXEEXT) test_thcell$(EXEEXT) test_thinp$(EXEEXT) \
+ test_thrend$(EXEEXT) test_thstr$(EXEEXT) test-thcoll.sh \
+ test-thbrk.sh test_thwchar$(EXEEXT) test-thwbrk.sh
+check_PROGRAMS = test_thctype$(EXEEXT) test_thcell$(EXEEXT) \
+ test_thinp$(EXEEXT) test_thrend$(EXEEXT) test_thstr$(EXEEXT) \
+ thsort$(EXEEXT) test_thbrk$(EXEEXT) test_thwchar$(EXEEXT) \
+ test_thwbrk$(EXEEXT)
+subdir = tests
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am_test_thbrk_OBJECTS = test_thbrk.$(OBJEXT)
+test_thbrk_OBJECTS = $(am_test_thbrk_OBJECTS)
+test_thbrk_DEPENDENCIES = $(top_builddir)/src/thbrk/libthbrk.la \
+ $(top_builddir)/src/thwchar/libthwchar.la \
+ $(top_builddir)/src/thstr/libthstr.la \
+ $(top_builddir)/src/thctype/libthctype.la
+am_test_thcell_OBJECTS = test_thcell.$(OBJEXT)
+test_thcell_OBJECTS = $(am_test_thcell_OBJECTS)
+test_thcell_DEPENDENCIES = $(top_builddir)/src/thcell/libthcell.la \
+ $(top_builddir)/src/thctype/libthctype.la
+am_test_thctype_OBJECTS = test_thctype.$(OBJEXT)
+test_thctype_OBJECTS = $(am_test_thctype_OBJECTS)
+test_thctype_DEPENDENCIES = $(top_builddir)/src/thctype/libthctype.la
+am_test_thinp_OBJECTS = test_thinp.$(OBJEXT)
+test_thinp_OBJECTS = $(am_test_thinp_OBJECTS)
+test_thinp_DEPENDENCIES = $(top_builddir)/src/thinp/libthinp.la \
+ $(top_builddir)/src/thcell/libthcell.la \
+ $(top_builddir)/src/thctype/libthctype.la
+am_test_thrend_OBJECTS = test_thrend.$(OBJEXT)
+test_thrend_OBJECTS = $(am_test_thrend_OBJECTS)
+test_thrend_DEPENDENCIES = $(top_builddir)/src/thrend/libthrend.la \
+ $(top_builddir)/src/thcell/libthcell.la \
+ $(top_builddir)/src/thctype/libthctype.la
+am_test_thstr_OBJECTS = test_thstr.$(OBJEXT)
+test_thstr_OBJECTS = $(am_test_thstr_OBJECTS)
+test_thstr_DEPENDENCIES = $(top_builddir)/src/thstr/libthstr.la \
+ $(top_builddir)/src/thctype/libthctype.la
+am_test_thwbrk_OBJECTS = test_thwbrk.$(OBJEXT)
+test_thwbrk_OBJECTS = $(am_test_thwbrk_OBJECTS)
+test_thwbrk_DEPENDENCIES = $(top_builddir)/src/thwbrk/libthwbrk.la \
+ $(top_builddir)/src/thwchar/libthwchar.la \
+ $(top_builddir)/src/thbrk/libthbrk.la \
+ $(top_builddir)/src/thwchar/libthwchar.la \
+ $(top_builddir)/src/thstr/libthstr.la \
+ $(top_builddir)/src/thctype/libthctype.la
+am_test_thwchar_OBJECTS = test_thwchar.$(OBJEXT)
+test_thwchar_OBJECTS = $(am_test_thwchar_OBJECTS)
+test_thwchar_DEPENDENCIES = $(top_builddir)/src/thwchar/libthwchar.la
+am_thsort_OBJECTS = thsort.$(OBJEXT)
+thsort_OBJECTS = $(am_thsort_OBJECTS)
+thsort_DEPENDENCIES = $(top_builddir)/src/thcoll/libthcoll.la \
+ $(top_builddir)/src/thctype/libthctype.la
+DEFAULT_INCLUDES = -I.@am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(test_thbrk_SOURCES) $(test_thcell_SOURCES) \
+ $(test_thctype_SOURCES) $(test_thinp_SOURCES) \
+ $(test_thrend_SOURCES) $(test_thstr_SOURCES) \
+ $(test_thwbrk_SOURCES) $(test_thwchar_SOURCES) \
+ $(thsort_SOURCES)
+DIST_SOURCES = $(test_thbrk_SOURCES) $(test_thcell_SOURCES) \
+ $(test_thctype_SOURCES) $(test_thinp_SOURCES) \
+ $(test_thrend_SOURCES) $(test_thstr_SOURCES) \
+ $(test_thwbrk_SOURCES) $(test_thwchar_SOURCES) \
+ $(thsort_SOURCES)
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+ETAGS = etags
+CTAGS = ctags
+am__tty_colors = \
+red=; grn=; lgn=; blu=; std=
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DATRIE_CFLAGS = @DATRIE_CFLAGS@
+DATRIE_LIBS = @DATRIE_LIBS@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DOXYGEN = @DOXYGEN@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+LT_AGE = @LT_AGE@
+LT_CURRENT = @LT_CURRENT@
+LT_REVISION = @LT_REVISION@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+TRIETOOL = @TRIETOOL@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+htmldocdir = @htmldocdir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+MAINTAINERCLEANFILES = Makefile.in
+INCLUDES = -I$(top_srcdir)/include
+EXTRA_DIST = sorttest.txt sorted.txt test-thcoll.sh test-thbrk.sh test-thwbrk.sh
+TESTS_ENVIRONMENT = top_builddir=$(top_builddir)
+check_SCRIPTS = \
+ test-thcoll.sh \
+ test-thbrk.sh \
+ test-thwbrk.sh
+
+test_thctype_SOURCES = test_thctype.c
+test_thctype_LDADD = $(top_builddir)/src/thctype/libthctype.la
+test_thcell_SOURCES = test_thcell.c
+test_thcell_LDADD = \
+ $(top_builddir)/src/thcell/libthcell.la \
+ $(top_builddir)/src/thctype/libthctype.la
+
+test_thinp_SOURCES = test_thinp.c
+test_thinp_LDADD = \
+ $(top_builddir)/src/thinp/libthinp.la \
+ $(top_builddir)/src/thcell/libthcell.la \
+ $(top_builddir)/src/thctype/libthctype.la
+
+test_thrend_SOURCES = test_thrend.c
+test_thrend_LDADD = \
+ $(top_builddir)/src/thrend/libthrend.la \
+ $(top_builddir)/src/thcell/libthcell.la \
+ $(top_builddir)/src/thctype/libthctype.la
+
+test_thstr_SOURCES = test_thstr.c
+test_thstr_LDADD = \
+ $(top_builddir)/src/thstr/libthstr.la \
+ $(top_builddir)/src/thctype/libthctype.la
+
+thsort_SOURCES = thsort.c
+thsort_LDADD = \
+ $(top_builddir)/src/thcoll/libthcoll.la \
+ $(top_builddir)/src/thctype/libthctype.la
+
+test_thbrk_SOURCES = test_thbrk.c
+test_thbrk_LDADD = \
+ $(top_builddir)/src/thbrk/libthbrk.la \
+ $(top_builddir)/src/thwchar/libthwchar.la \
+ $(top_builddir)/src/thstr/libthstr.la \
+ $(top_builddir)/src/thctype/libthctype.la
+
+test_thwchar_SOURCES = test_thwchar.c
+test_thwchar_LDADD = $(top_builddir)/src/thwchar/libthwchar.la
+test_thwbrk_SOURCES = test_thwbrk.c
+test_thwbrk_LDADD = \
+ $(top_builddir)/src/thwbrk/libthwbrk.la \
+ $(top_builddir)/src/thwchar/libthwchar.la \
+ $(top_builddir)/src/thbrk/libthbrk.la \
+ $(top_builddir)/src/thwchar/libthwchar.la \
+ $(top_builddir)/src/thstr/libthstr.la \
+ $(top_builddir)/src/thctype/libthctype.la
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu tests/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-checkPROGRAMS:
+ @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
+test_thbrk$(EXEEXT): $(test_thbrk_OBJECTS) $(test_thbrk_DEPENDENCIES) $(EXTRA_test_thbrk_DEPENDENCIES)
+ @rm -f test_thbrk$(EXEEXT)
+ $(LINK) $(test_thbrk_OBJECTS) $(test_thbrk_LDADD) $(LIBS)
+test_thcell$(EXEEXT): $(test_thcell_OBJECTS) $(test_thcell_DEPENDENCIES) $(EXTRA_test_thcell_DEPENDENCIES)
+ @rm -f test_thcell$(EXEEXT)
+ $(LINK) $(test_thcell_OBJECTS) $(test_thcell_LDADD) $(LIBS)
+test_thctype$(EXEEXT): $(test_thctype_OBJECTS) $(test_thctype_DEPENDENCIES) $(EXTRA_test_thctype_DEPENDENCIES)
+ @rm -f test_thctype$(EXEEXT)
+ $(LINK) $(test_thctype_OBJECTS) $(test_thctype_LDADD) $(LIBS)
+test_thinp$(EXEEXT): $(test_thinp_OBJECTS) $(test_thinp_DEPENDENCIES) $(EXTRA_test_thinp_DEPENDENCIES)
+ @rm -f test_thinp$(EXEEXT)
+ $(LINK) $(test_thinp_OBJECTS) $(test_thinp_LDADD) $(LIBS)
+test_thrend$(EXEEXT): $(test_thrend_OBJECTS) $(test_thrend_DEPENDENCIES) $(EXTRA_test_thrend_DEPENDENCIES)
+ @rm -f test_thrend$(EXEEXT)
+ $(LINK) $(test_thrend_OBJECTS) $(test_thrend_LDADD) $(LIBS)
+test_thstr$(EXEEXT): $(test_thstr_OBJECTS) $(test_thstr_DEPENDENCIES) $(EXTRA_test_thstr_DEPENDENCIES)
+ @rm -f test_thstr$(EXEEXT)
+ $(LINK) $(test_thstr_OBJECTS) $(test_thstr_LDADD) $(LIBS)
+test_thwbrk$(EXEEXT): $(test_thwbrk_OBJECTS) $(test_thwbrk_DEPENDENCIES) $(EXTRA_test_thwbrk_DEPENDENCIES)
+ @rm -f test_thwbrk$(EXEEXT)
+ $(LINK) $(test_thwbrk_OBJECTS) $(test_thwbrk_LDADD) $(LIBS)
+test_thwchar$(EXEEXT): $(test_thwchar_OBJECTS) $(test_thwchar_DEPENDENCIES) $(EXTRA_test_thwchar_DEPENDENCIES)
+ @rm -f test_thwchar$(EXEEXT)
+ $(LINK) $(test_thwchar_OBJECTS) $(test_thwchar_LDADD) $(LIBS)
+thsort$(EXEEXT): $(thsort_OBJECTS) $(thsort_DEPENDENCIES) $(EXTRA_thsort_DEPENDENCIES)
+ @rm -f thsort$(EXEEXT)
+ $(LINK) $(thsort_OBJECTS) $(thsort_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_thbrk.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_thcell.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_thctype.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_thinp.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_thrend.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_thstr.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_thwbrk.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_thwchar.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/thsort.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+check-TESTS: $(TESTS)
+ @failed=0; all=0; xfail=0; xpass=0; skip=0; \
+ srcdir=$(srcdir); export srcdir; \
+ list=' $(TESTS) '; \
+ $(am__tty_colors); \
+ if test -n "$$list"; then \
+ for tst in $$list; do \
+ if test -f ./$$tst; then dir=./; \
+ elif test -f $$tst; then dir=; \
+ else dir="$(srcdir)/"; fi; \
+ if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$tst[\ \ ]*) \
+ xpass=`expr $$xpass + 1`; \
+ failed=`expr $$failed + 1`; \
+ col=$$red; res=XPASS; \
+ ;; \
+ *) \
+ col=$$grn; res=PASS; \
+ ;; \
+ esac; \
+ elif test $$? -ne 77; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$tst[\ \ ]*) \
+ xfail=`expr $$xfail + 1`; \
+ col=$$lgn; res=XFAIL; \
+ ;; \
+ *) \
+ failed=`expr $$failed + 1`; \
+ col=$$red; res=FAIL; \
+ ;; \
+ esac; \
+ else \
+ skip=`expr $$skip + 1`; \
+ col=$$blu; res=SKIP; \
+ fi; \
+ echo "$${col}$$res$${std}: $$tst"; \
+ done; \
+ if test "$$all" -eq 1; then \
+ tests="test"; \
+ All=""; \
+ else \
+ tests="tests"; \
+ All="All "; \
+ fi; \
+ if test "$$failed" -eq 0; then \
+ if test "$$xfail" -eq 0; then \
+ banner="$$All$$all $$tests passed"; \
+ else \
+ if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
+ banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
+ fi; \
+ else \
+ if test "$$xpass" -eq 0; then \
+ banner="$$failed of $$all $$tests failed"; \
+ else \
+ if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
+ banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
+ fi; \
+ fi; \
+ dashes="$$banner"; \
+ skipped=""; \
+ if test "$$skip" -ne 0; then \
+ if test "$$skip" -eq 1; then \
+ skipped="($$skip test was not run)"; \
+ else \
+ skipped="($$skip tests were not run)"; \
+ fi; \
+ test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$skipped"; \
+ fi; \
+ report=""; \
+ if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
+ report="Please report to $(PACKAGE_BUGREPORT)"; \
+ test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$report"; \
+ fi; \
+ dashes=`echo "$$dashes" | sed s/./=/g`; \
+ if test "$$failed" -eq 0; then \
+ col="$$grn"; \
+ else \
+ col="$$red"; \
+ fi; \
+ echo "$${col}$$dashes$${std}"; \
+ echo "$${col}$$banner$${std}"; \
+ test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \
+ test -z "$$report" || echo "$${col}$$report$${std}"; \
+ echo "$${col}$$dashes$${std}"; \
+ test "$$failed" -eq 0; \
+ else :; fi
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+ $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) $(check_SCRIPTS)
+ $(MAKE) $(AM_MAKEFLAGS) check-TESTS
+check: check-am
+all-am: Makefile
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+ -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
+clean: clean-am
+
+clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: check-am install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
+ clean-checkPROGRAMS clean-generic clean-libtool ctags \
+ distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-data \
+ install-data-am install-dvi install-dvi-am install-exec \
+ install-exec-am install-html install-html-am install-info \
+ install-info-am install-man install-pdf install-pdf-am \
+ install-ps install-ps-am install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/tests/sorted.txt b/tests/sorted.txt
new file mode 100644
index 0000000..fd31c9b
--- /dev/null
+++ b/tests/sorted.txt
@@ -0,0 +1,96 @@
+@@@@@
+0000
+10 litre
+10 litre (10 ÅÔµÃ)
+10 litre (ñð ÅÔµÃ)
+10 ÅÔµÃ
+ñð ÅÔµÃ
+10 ÅԵà (10 litre)
+ñð ÅԵà (10 litre)
+ñð ÅԵà [10 litre]
+ñð ÅԵà {10 litre}
+9999
+a
+A
+a-
+A-
+a.
+A.
+a'
+-a
+A-1
+aa
+AA
+a.a.
+A.A.
+AAA
+A.A.A.
+AAAA
+A.A.A.L.
+A.A.A.S.
+Aachen
+A.A.E.
+A.Ae.E.
+A.A.E.E.
+AAES
+AAF
+A.Agr
+aah
+Aalborg
+aide
+air
+air@@@
+@@@air
+C.A.F
+Canon
+coop
+COOP
+co-op
+CO-OP
+Copenhegen
+McArthur
+Mc Arthur
+Mc Mahon
+vice-president
+vice versa
+vice-versa
+¡¡
+-¡ÃÐáÂè§
+¡ÃÒº
+¢Ò§
+¢èÒ§
+¢éÒ§
+¢éÒ§æ
+¢éÒ§¡Ãдҹ
+¢éÒ§¢Öé¹
+¢éÒ§¤ÇÒÂ
+¢éÒ§æ ¤Ùæ
+¢éÒ§à§Ô¹
+¢éÒ§áÃÁ
+¢éÒ§ÍÍ¡
+á¢ç§
+á¢è§
+á¢é§
+á¢é§¢ÇÒ
+á¢ç§¢Ñ¹
+á¢è§¢Ñ¹
+·ÙÅà¡ÅéÒ
+·ÙÅà¡ÅéÒÏ
+·ÙÅà¡ÅéÒ·ÙÅ¡ÃÐËÁèÍÁ
+ºØ­­Ò
+ºØ­Ëŧ
+ºØ­-Ëŧ
+»Ò
+»èÒ
+»éÒ
+»êÒ
+»ëÒ
+»Ò¹
+»èÒ¹
+»éÒ¹
+»êÒ¹
+»ëÒ¹
+á»é§
+Ͼ³Ï
+¾³ÔªÂì
+ÁéÒ
diff --git a/tests/sorttest.txt b/tests/sorttest.txt
new file mode 100644
index 0000000..19e0181
--- /dev/null
+++ b/tests/sorttest.txt
@@ -0,0 +1,96 @@
+-¡ÃÐáÂè§
+¡¡
+¡ÃÒº
+¢èÒ§
+¢éÒ§
+¢éÒ§¡Ãдҹ
+¢éÒ§¢Öé¹
+¢éÒ§¤ÇÒÂ
+¢éÒ§à§Ô¹
+¢éÒ§áÃÁ
+¢éÒ§ÍÍ¡
+¢éÒ§æ
+¢éÒ§æ ¤Ùæ
+¢Ò§
+á¢ç§
+á¢è§
+á¢è§¢Ñ¹
+á¢é§
+á¢é§¢ÇÒ
+á¢ç§¢Ñ¹
+·ÙÅà¡ÅéÒ
+·ÙÅà¡ÅéÒ·ÙÅ¡ÃÐËÁèÍÁ
+·ÙÅà¡ÅéÒÏ
+ºØ­­Ò
+ºØ­-Ëŧ
+ºØ­Ëŧ
+»èÒ
+»èÒ¹
+»éÒ
+»éÒ¹
+»êÒ
+»êÒ¹
+»ëÒ
+»ëÒ¹
+»Ò
+»Ò¹
+á»é§
+¾³ÔªÂì
+ÁéÒ
+Ͼ³Ï
+A
+a
+a'
+A-
+a-
+-a
+A.
+a.
+A-1
+aa
+AA
+A.A.
+a.a.
+AAA
+A.A.A.
+AAAA
+A.A.A.L.
+A.A.A.S.
+Aachen
+A.A.E.
+A.Ae.E.
+A.A.E.E.
+AAES
+AAF
+A.Agr
+aah
+@@@@@
+0000
+9999
+Aalborg
+aide
+air
+@@@air
+air@@@
+C.A.F
+Canon
+coop
+co-op
+COOP
+CO-OP
+Copenhegen
+McArthur
+Mc Arthur
+Mc Mahon
+vice-president
+vice versa
+vice-versa
+10 ÅÔµÃ
+ñð ÅÔµÃ
+10 litre
+10 litre (10 ÅÔµÃ)
+10 ÅԵà (10 litre)
+10 litre (ñð ÅÔµÃ)
+ñð ÅԵà (10 litre)
+ñð ÅԵà [10 litre]
+ñð ÅԵà {10 litre}
diff --git a/tests/test-thbrk.sh b/tests/test-thbrk.sh
new file mode 100755
index 0000000..39176fa
--- /dev/null
+++ b/tests/test-thbrk.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+srcdir=${srcdir-.}
+top_builddir=${top_builddir-.}
+
+LIBTHAI_DICTDIR=${top_builddir}/data $top_builddir/tests/test_thbrk
diff --git a/tests/test-thcoll.sh b/tests/test-thcoll.sh
new file mode 100755
index 0000000..9ad93b3
--- /dev/null
+++ b/tests/test-thcoll.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+srcdir=${srcdir-.}
+top_builddir=${top_builddir-.}
+
+$top_builddir/tests/thsort $srcdir/sorttest.txt out.txt
+cmp $srcdir/sorted.txt out.txt && rm -f out.txt
+
diff --git a/tests/test-thwbrk.sh b/tests/test-thwbrk.sh
new file mode 100755
index 0000000..302dc1b
--- /dev/null
+++ b/tests/test-thwbrk.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+srcdir=${srcdir-.}
+top_builddir=${top_builddir-.}
+
+LIBTHAI_DICTDIR=${top_builddir}/data $top_builddir/tests/test_thwbrk
diff --git a/tests/test_thbrk.c b/tests/test_thbrk.c
new file mode 100644
index 0000000..d1ffbb6
--- /dev/null
+++ b/tests/test_thbrk.c
@@ -0,0 +1,73 @@
+/* Test driver for thbrk
+ */
+
+#define MAXLINELENGTH 1000
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <thai/thbrk.h>
+
+/* run with "-i" argument to get the interactive version
+ otherwise it will run the self test and exit */
+
+int main (int argc, char* argv[])
+{
+ thchar_t str[MAXLINELENGTH];
+ thchar_t out[MAXLINELENGTH*6+1];
+ int pos[MAXLINELENGTH];
+ int outputLength;
+ int numCut, i;
+ int interactive = 0;
+
+ if (argc >= 2) {
+ if (0 == strcmp (argv[1], "-i"))
+ interactive = 1;
+ }
+
+ if (interactive) {
+ while (!feof (stdin)) {
+ printf ("Please enter thai words/sentences: ");
+ fgets ((char *)str, MAXLINELENGTH-1, stdin);
+ if (!feof (stdin)) {
+ numCut = th_brk (str, pos, MAXLINELENGTH);
+ printf ("Total %d cut points.", numCut);
+ if (numCut > 0) {
+ printf ("Cut points list: %d", pos[0]);
+ for (i = 1; i < numCut; i++) {
+ printf(", %d", pos[i]);
+ }
+ }
+ printf("\n");
+ outputLength = th_brk_line (str, out, sizeof out, "<WBR>");
+ printf ("Output string length is %d\n", outputLength-1); /* the penultimate is \n */
+ printf ("Output string is %s", out);
+ printf("***********************************************************************\n");
+ }
+ }
+ } else {
+ strcpy ((char *)str, "ÊÇÑÊ´Õ¤ÃѺ ¡Í.ÃÁ¹. ¹Õèà»ç¹¡Ò÷´ÊͺµÑÇàͧ");
+ printf ("Testing with string: %s\n", str);
+ numCut = th_brk (str, pos, MAXLINELENGTH);
+ printf ("Total %d cut points.", numCut);
+ if (numCut != 7) {
+ printf("Error! should be 7.. test th_brk() failed...\n");
+ exit (-1);
+ }
+
+ printf("Cut points list: %d", pos[0]);
+ for (i = 1; i < numCut; i++) {
+ printf(", %d", pos[i]);
+ }
+ printf("\n");
+ outputLength = th_brk_line (str, out, sizeof out, "<WBR>");
+ printf ("Output string is %s\n", out);
+ printf ("Output string length is %d\n", outputLength);
+ if (outputLength != 75) {
+ printf ("Error! should be 75.. test th_brk_line() failed...\n");
+ exit (-1);
+ }
+ printf ("*** End of thbrk self test ******\n");
+ }
+ return 0;
+}
diff --git a/tests/test_thcell.c b/tests/test_thcell.c
new file mode 100644
index 0000000..a9bb738
--- /dev/null
+++ b/tests/test_thcell.c
@@ -0,0 +1,258 @@
+/*
+ * test_thcell.c : Test suite for <thai/thcell.h> functions
+ * Created: 2001-08-09
+ * Author: Theppitak Karoonboonyanan
+ */
+
+#include <thai/thcell.h>
+#include <thai/tis.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static const thchar_t test_msg[] = "¹éÓ¹ÓÓ¡Õè¡èÕ¡Øè¡èØ¡Øì¡ìØ¡Ôì¡ìÔàÔàÓà鹡Ôí¡×ç";
+static const struct thcell_t test_ans_nodecomp_am[] = {
+ { TIS_NO_NU, 0, TIS_MAI_THO },
+ { TIS_SARA_AM, 0, 0 },
+ { TIS_NO_NU, 0, 0 },
+ { TIS_SARA_AM, 0, 0 },
+ { TIS_SARA_AM, 0, 0 },
+ { TIS_KO_KAI, TIS_SARA_II, TIS_MAI_EK },
+ { TIS_KO_KAI, 0, TIS_MAI_EK },
+ { 0, TIS_SARA_II, 0 },
+ { TIS_KO_KAI, TIS_SARA_U, TIS_MAI_EK },
+ { TIS_KO_KAI, 0, TIS_MAI_EK },
+ { 0, TIS_SARA_U, 0 },
+ { TIS_KO_KAI, TIS_SARA_U, TIS_THANTHAKHAT },
+ { TIS_KO_KAI, 0, TIS_THANTHAKHAT },
+ { 0, TIS_SARA_U, 0 },
+ { TIS_KO_KAI, TIS_SARA_I, TIS_THANTHAKHAT },
+ { TIS_KO_KAI, 0, TIS_THANTHAKHAT },
+ { 0, TIS_SARA_I, 0 },
+ { TIS_SARA_E, 0, 0 },
+ { 0, TIS_SARA_I, 0 },
+ { TIS_SARA_E, 0, 0 },
+ { TIS_SARA_AM, 0, 0 },
+ { TIS_SARA_E, 0, 0 },
+ { 0, 0, TIS_MAI_THO },
+ { TIS_NO_NU, 0, 0 },
+ { TIS_KO_KAI, TIS_SARA_I, TIS_NIKHAHIT },
+ { TIS_KO_KAI, TIS_SARA_UEE, TIS_MAITAIKHU },
+ { 0, 0, 0 }
+};
+static const struct thcell_t test_ans_decomp_am[] = {
+ { TIS_NO_NU, TIS_SARA_AM, TIS_MAI_THO },
+ { TIS_NO_NU, TIS_SARA_AM, 0 },
+ { 0, TIS_SARA_AM, 0 },
+ { TIS_KO_KAI, TIS_SARA_II, TIS_MAI_EK },
+ { TIS_KO_KAI, 0, TIS_MAI_EK },
+ { 0, TIS_SARA_II, 0 },
+ { TIS_KO_KAI, TIS_SARA_U, TIS_MAI_EK },
+ { TIS_KO_KAI, 0, TIS_MAI_EK },
+ { 0, TIS_SARA_U, 0 },
+ { TIS_KO_KAI, TIS_SARA_U, TIS_THANTHAKHAT },
+ { TIS_KO_KAI, 0, TIS_THANTHAKHAT },
+ { 0, TIS_SARA_U, 0 },
+ { TIS_KO_KAI, TIS_SARA_I, TIS_THANTHAKHAT },
+ { TIS_KO_KAI, 0, TIS_THANTHAKHAT },
+ { 0, TIS_SARA_I, 0 },
+ { TIS_SARA_E, 0, 0 },
+ { 0, TIS_SARA_I, 0 },
+ { TIS_SARA_E, 0, 0 },
+ { 0, TIS_SARA_AM, 0 },
+ { TIS_SARA_E, 0, 0 },
+ { 0, 0, TIS_MAI_THO },
+ { TIS_NO_NU, 0, 0 },
+ { TIS_KO_KAI, TIS_SARA_I, TIS_NIKHAHIT },
+ { TIS_KO_KAI, TIS_SARA_UEE, TIS_MAITAIKHU },
+ { 0, 0, 0 }
+};
+
+int test_th_next_cell()
+{
+ int err_no = 0;
+ const thchar_t *s;
+ int len;
+ const struct thcell_t *pCell;
+
+ fprintf(stderr, "testing th_next_cell() without decomposing SARA AM...\n");
+ pCell = test_ans_nodecomp_am;
+ s = test_msg;
+ len = strlen((const char *)test_msg);
+ while (*s) {
+ struct thcell_t aCell;
+ size_t nChars;
+
+ nChars = th_next_cell(s, len, &aCell, 0);
+ s += nChars; len -= nChars;
+ if (aCell.base != pCell->base ||
+ aCell.hilo != pCell->hilo ||
+ aCell.top != pCell->top)
+ {
+ fprintf(stderr, "(%c,%c,%c) != (%c,%c,%c)\n",
+ aCell.base, aCell.hilo, aCell.top,
+ pCell->base, pCell->hilo, pCell->top);
+ ++err_no;
+ }
+ if (pCell->base || pCell->hilo || pCell->top)
+ ++pCell;
+ }
+
+ fprintf(stderr, "testing th_next_cell() decomposing SARA AM...\n");
+ s = test_msg;
+ len = strlen((const char *)test_msg);
+ pCell = test_ans_decomp_am;
+ while (*s) {
+ struct thcell_t aCell;
+ size_t nChars;
+
+ nChars = th_next_cell(s, len, &aCell, 1);
+ s += nChars; len -= nChars;
+ if (aCell.base != pCell->base ||
+ aCell.hilo != pCell->hilo ||
+ aCell.top != pCell->top)
+ {
+ fprintf(stderr, "(%c,%c,%c) != (%c,%c,%c)\n",
+ aCell.base, aCell.hilo, aCell.top,
+ pCell->base, pCell->hilo, pCell->top);
+ ++err_no;
+ }
+ if (pCell->base || pCell->hilo || pCell->top)
+ ++pCell;
+ }
+
+ return err_no;
+}
+
+int test_th_prev_cell()
+{
+ int err_no = 0;
+ const thchar_t *s;
+ int pos;
+ const struct thcell_t *pCell;
+
+ fprintf(stderr, "testing th_prev_cell() without decomposing SARA AM...\n");
+ pCell = test_ans_nodecomp_am +
+ (sizeof test_ans_nodecomp_am)/(sizeof test_ans_nodecomp_am[0]) - 2;
+ s = test_msg;
+ pos = strlen((const char *)test_msg);
+ while (pos > 0) {
+ struct thcell_t aCell;
+
+ pos -= th_prev_cell(s, pos, &aCell, 0);
+ if (aCell.base != pCell->base ||
+ aCell.hilo != pCell->hilo ||
+ aCell.top != pCell->top)
+ {
+ fprintf(stderr, "(%c,%c,%c) != (%c,%c,%c)\n",
+ aCell.base, aCell.hilo, aCell.top,
+ pCell->base, pCell->hilo, pCell->top);
+ ++err_no;
+ }
+ if (pCell > test_ans_nodecomp_am)
+ --pCell;
+ }
+
+ fprintf(stderr, "testing th_prev_cell() decomposing SARA AM...\n");
+ pCell = test_ans_decomp_am +
+ (sizeof test_ans_decomp_am)/(sizeof test_ans_decomp_am[0]) - 2;
+ s = test_msg;
+ pos = strlen((const char *)test_msg);
+ while (pos > 0) {
+ struct thcell_t aCell;
+
+ pos -= th_prev_cell(s, pos, &aCell, 1);
+ if (aCell.base != pCell->base ||
+ aCell.hilo != pCell->hilo ||
+ aCell.top != pCell->top)
+ {
+ fprintf(stderr, "(%c,%c,%c) != (%c,%c,%c)\n",
+ aCell.base, aCell.hilo, aCell.top,
+ pCell->base, pCell->hilo, pCell->top);
+ ++err_no;
+ }
+ if (pCell > test_ans_decomp_am)
+ --pCell;
+ }
+
+ return err_no;
+}
+
+#define TESTCELLS 10
+
+int test_th_make_cells()
+{
+ int err_no = 0;
+ struct thcell_t *cells;
+ const thchar_t *s;
+ int len;
+ const struct thcell_t *pCell;
+
+ cells = (struct thcell_t *) malloc(TESTCELLS * sizeof(struct thcell_t));
+
+ fprintf(stderr, "testing th_make_cells() without decomposing SARA AM...\n");
+ pCell = test_ans_nodecomp_am;
+ s = test_msg;
+ len = strlen((const char *)test_msg);
+
+ while (*s) {
+ size_t nCells = TESTCELLS;
+ size_t i;
+ size_t nChars = th_make_cells(s, len, cells, &nCells, 0);
+ s += nChars; len -= nChars;
+ for (i = 0; i < nCells; ++i) {
+ if (cells[i].base != pCell->base ||
+ cells[i].hilo != pCell->hilo ||
+ cells[i].top != pCell->top)
+ {
+ fprintf(stderr, "(%c,%c,%c) != (%c,%c,%c)\n",
+ cells[i].base, cells[i].hilo, cells[i].top,
+ pCell->base, pCell->hilo, pCell->top);
+ ++err_no;
+ }
+ if (pCell->base || pCell->hilo || pCell->top)
+ ++pCell;
+ }
+ }
+
+ fprintf(stderr, "testing th_make_cells() decomposing SARA AM...\n");
+ pCell = test_ans_decomp_am;
+ s = test_msg;
+ len = strlen((const char *)test_msg);
+
+ while (*s) {
+ size_t nCells = TESTCELLS;
+ size_t i;
+ size_t nChars = th_make_cells(s, len, cells, &nCells, 1);
+ s += nChars; len -= nChars;
+ for (i = 0; i < nCells; ++i) {
+ if (cells[i].base != pCell->base ||
+ cells[i].hilo != pCell->hilo ||
+ cells[i].top != pCell->top)
+ {
+ fprintf(stderr, "(%c,%c,%c) != (%c,%c,%c)\n",
+ cells[i].base, cells[i].hilo, cells[i].top,
+ pCell->base, pCell->hilo, pCell->top);
+ ++err_no;
+ }
+ if (pCell->base || pCell->hilo || pCell->top)
+ ++pCell;
+ }
+ }
+
+ free(cells);
+
+ return err_no;
+}
+
+int main()
+{
+ int err_no = 0;
+
+ err_no += test_th_next_cell();
+ err_no += test_th_prev_cell();
+ err_no += test_th_make_cells();
+
+ return err_no;
+}
+
diff --git a/tests/test_thctype.c b/tests/test_thctype.c
new file mode 100644
index 0000000..691693d
--- /dev/null
+++ b/tests/test_thctype.c
@@ -0,0 +1,156 @@
+/*
+ * test_thctype.c : Test bed for <thai/thctype.h> functions
+ * Created: 2001-07-31
+ * Author: Theppitak Karoonboonyanan
+ */
+
+#include <thai/thctype.h>
+#include <stdio.h>
+
+struct char_range {
+ thchar_t begin;
+ thchar_t end;
+};
+
+const struct char_range tis_ranges[] = {
+ { 0x00, 0x7f }, { 0xa1, 0xda }, { 0xdf, 0xfb }, { 0, 0 }
+};
+
+const struct char_range thai_ranges[] = {
+ { 0xa1, 0xda }, { 0xdf, 0xfb }, { 0, 0 }
+};
+
+const struct char_range eng_ranges[] = {
+ { 0x00, 0x7f }, { 0, 0 }
+};
+
+const struct char_range thcons_ranges[] = {
+ { 0xa1, 0xc3 }, { 0xc5, 0xc5 }, { 0xc7, 0xce }, { 0, 0 }
+};
+
+const struct char_range tlcons_ranges[] = {
+ { 0xa1, 0xac }, { 0xb1, 0xba }, { 0xbc, 0xbc }, { 0xbe, 0xbe },
+ { 0xc0, 0xc3 }, { 0xc5, 0xc5 }, { 0xc7, 0xcb }, { 0xcd, 0xce },
+ { 0, 0 }
+};
+
+const struct char_range oscons_ranges[] = {
+ { 0xbb, 0xbb }, { 0xbd, 0xbd }, { 0xbf, 0xbf }, { 0xcc, 0xcc },
+ { 0, 0 }
+};
+
+const struct char_range uscons_ranges[] = {
+ { 0xae, 0xaf }, { 0, 0 }
+};
+
+const struct char_range spcons_ranges[] = {
+ { 0xad, 0xad }, { 0xb0, 0xb0 }, { 0, 0 }
+};
+
+const struct char_range thvowel_ranges[] = {
+ { 0xc4, 0xc4 }, { 0xc6, 0xc6 }, { 0xd0, 0xd9 }, { 0xe0, 0xe5 }, { 0, 0 }
+};
+
+const struct char_range ldvowel_ranges[] = {
+ { 0xe0, 0xe4 }, { 0, 0 }
+};
+
+const struct char_range flvowel_ranges[] = {
+ { 0xc4, 0xc4 }, { 0xc6, 0xc6 }, { 0xd0, 0xd0 }, { 0xd2, 0xd3 },
+ { 0xe5, 0xe5 }, { 0, 0 }
+};
+
+const struct char_range upvowel_ranges[] = {
+ { 0xd1, 0xd1 }, { 0xd4, 0xd7 }, { 0, 0 }
+};
+
+const struct char_range blvowel_ranges[] = {
+ { 0xd8, 0xd9 }, { 0, 0 }
+};
+
+const struct char_range thtone_ranges[] = {
+ { 0xe8, 0xeb }, { 0, 0 }
+};
+
+const struct char_range thdiac_ranges[] = {
+ { 0xda, 0xda }, { 0xe7, 0xe7 }, { 0xec, 0xee }, { 0, 0 }
+};
+
+const struct char_range thdigit_ranges[] = {
+ { 0x30, 0x39 }, { 0xf0, 0xf9 }, { 0, 0 }
+};
+
+const struct char_range thpunct_ranges[] = {
+ { 0x21, 0x2f }, { 0x3a, 0x40 }, { 0x5b, 0x60 }, { 0x7b, 0x7e },
+ { 0xcf, 0xcf }, { 0xdf, 0xdf }, { 0xe6, 0xe6 }, { 0xef, 0xef },
+ { 0xfa, 0xfb }, { 0, 0 }
+};
+
+int test_bool_funcs(const struct char_range ranges[], int (*fn)(thchar_t))
+{
+ const struct char_range *pRange = ranges;
+ int err_code = 0;
+ thchar_t c = 0;
+
+ while (pRange->end) {
+ /* out-of-range check */
+ while (c < pRange->begin) {
+ if ((*fn)(c)) {
+ fprintf(stderr, "+%02x ", c);
+ err_code = 1;
+ }
+ ++c;
+ }
+ /* in-range check */
+ while (c <= pRange->end) {
+ if (!(*fn)(c)) {
+ fprintf(stderr, "-%02x ", c);
+ err_code = 1;
+ }
+ ++c;
+ }
+ ++pRange;
+ }
+ /* out-of-range check */
+ while (c < 0xff) {
+ if ((*fn)(c)) {
+ fprintf(stderr, "+%02x ", c);
+ err_code = 1;
+ }
+ ++c;
+ }
+ /* 0xff itself */
+ if ((*fn)(c)) {
+ fprintf(stderr, "+%02x ", c);
+ err_code = 1;
+ }
+ fprintf(stderr, "\n");
+
+ return err_code;
+}
+
+int main()
+{
+ int err_code = 0;
+
+ err_code += test_bool_funcs(tis_ranges, th_istis);
+ err_code += test_bool_funcs(thai_ranges, th_isthai);
+ err_code += test_bool_funcs(eng_ranges, th_iseng);
+ err_code += test_bool_funcs(thcons_ranges, th_isthcons);
+ err_code += test_bool_funcs(thvowel_ranges, th_isthvowel);
+ err_code += test_bool_funcs(thtone_ranges, th_isthtone);
+ err_code += test_bool_funcs(thdiac_ranges, th_isthdiac);
+ err_code += test_bool_funcs(thdigit_ranges, th_isthdigit);
+ err_code += test_bool_funcs(thpunct_ranges, th_isthpunct);
+ err_code += test_bool_funcs(tlcons_ranges, th_istaillesscons);
+ err_code += test_bool_funcs(oscons_ranges, th_isovershootcons);
+ err_code += test_bool_funcs(uscons_ranges, th_isundershootcons);
+ err_code += test_bool_funcs(spcons_ranges, th_isundersplitcons);
+ err_code += test_bool_funcs(ldvowel_ranges, th_isldvowel);
+ err_code += test_bool_funcs(flvowel_ranges, th_isflvowel);
+ err_code += test_bool_funcs(upvowel_ranges, th_isupvowel);
+ err_code += test_bool_funcs(blvowel_ranges, th_isblvowel);
+
+ return err_code;
+}
+
diff --git a/tests/test_thinp.c b/tests/test_thinp.c
new file mode 100644
index 0000000..cc4ba7d
--- /dev/null
+++ b/tests/test_thinp.c
@@ -0,0 +1,88 @@
+/*
+ * test_thinp.c : Test suite for <thai/thinp.h> functions
+ * Created: 2001-08-09
+ * Author: Theppitak Karoonboonyanan
+ */
+
+#include <thai/thinp.h>
+#include <string.h>
+#include <stdio.h>
+
+const thchar_t test_keys[] = "¹éÓ¹Óé¡Õè¡èÕ¡Øè¡èØ¡Øì¡ìØ¡Ôì¡ìÔàÔàÓàé¹ÔìѹìѹØèÔ¹ÒìÄÒÆÒ";
+const thchar_t res_level0[] = "¹éÓ¹Óé¡Õè¡èÕ¡Øè¡èØ¡Øì¡ìØ¡Ôì¡ìÔàÔàÓàé¹ÔìѹìѹØèÔ¹ÒìÄÒÆÒ";
+const thchar_t res_level1[] = "¹éÓ¹Ó¡Õè¡è¡Øè¡è¡Øì¡ì¡Ôì¡ìààÓà¹Ôì¹ì¹Øè¹ÒÄÒÆÒ";
+const thchar_t res_level2[] = "¹éÓ¹Ó¡Õè¡è¡Øè¡è¡Øì¡ì¡Ôì¡ìà¹Ôì¹ì¹Øè¹ÒÄ";
+const thchar_t res_validate[] = "¹éÓ¹éÓ¡Õè¡Õè¡Øè¡Øè¡Øì¡Øì¡Ôì¡Ôìà¹Ñ¹Ñ¹Ôè¹ÒÄåÆå";
+
+static int test_simple_input(const thchar_t keys[],
+ const thchar_t ans[], int level)
+{
+ thchar_t buffer[80];
+ int cur_pos = 0;
+ int err_no = 0;
+
+ while (*keys) {
+ thchar_t prev_c = cur_pos ? buffer[cur_pos-1] : 0;
+ if (th_isaccept(prev_c, *keys, level)) {
+ buffer[cur_pos++] = *keys;
+ }
+ ++keys;
+ }
+ buffer[cur_pos] = 0;
+
+ err_no = strcmp((const char*)buffer, (const char*)ans);
+ if (err_no != 0) {
+ fprintf(stderr, "(%s)!=(%s)\n", buffer, ans);
+ }
+ return err_no;
+}
+
+static int test_th_isaccept()
+{
+ int err_no = 0;
+
+ err_no += test_simple_input(test_keys, res_level0, 0);
+ err_no += test_simple_input(test_keys, res_level1, 1);
+ err_no += test_simple_input(test_keys, res_level2, 2);
+
+ return err_no;
+}
+
+static int test_th_validate()
+{
+ int err_no = 0;
+ thchar_t buffer[80];
+ int cur_pos = 0;
+ const thchar_t *keys = test_keys;
+
+ while (*keys) {
+ struct thcell_t prev_cell;
+ struct thinpconv_t conv;
+
+ th_prev_cell(buffer, cur_pos, &prev_cell, 1);
+ if (th_validate(prev_cell, *keys, &conv)) {
+ strcpy(&buffer[cur_pos + conv.offset], conv.conv);
+ cur_pos += conv.offset + strlen(conv.conv);
+ }
+ ++keys;
+ }
+ buffer[cur_pos] = 0;
+
+ err_no = strcmp((const char*)buffer, (const char*)res_validate);
+ if (err_no != 0) {
+ fprintf(stderr, "(%s)!=(%s)\n", buffer, res_validate);
+ }
+
+ return err_no;
+}
+
+int main()
+{
+ int err_no = 0;
+
+ err_no += test_th_isaccept();
+ err_no += test_th_validate();
+
+ return err_no ? 1 : 0;
+}
+
diff --git a/tests/test_thrend.c b/tests/test_thrend.c
new file mode 100644
index 0000000..60667e9
--- /dev/null
+++ b/tests/test_thrend.c
@@ -0,0 +1,92 @@
+/*
+ * test_thrend.c : Test suite for <thai/thrend.h> functions
+ * Created: 2001-08-10
+ * Author: Theppitak Karoonboonyanan
+ */
+
+#include <thai/thrend.h>
+#include <string.h>
+#include <stdio.h>
+
+static const thchar_t test_msg[] = "¾èÍ»Ùè¾Õè»Õè®Ø°Ø­Ø¡Ó»Ó¡éÓ»éÓ»Óé·èÕ¡ç»ç¡Ôíà¡×çÍ¡";
+static const thchar_t ans_tis[] = "¾èÍ»Ùè¾Õè»Õè®Ø°Ø­Ø¡íÒ»íÒ¡íéÒ»íéÒ»íÒ\xddé·è\xddÕ¡ç»ç¡Ôíà¡×çÍ¡";
+static const thchar_t ans_tis_nd[] = "¾èÍ»Ùè¾Õè»Õè®Ø°Ø­Ø¡Ó»Ó¡éÓ»éÓ»Ó\xddé·è\xddÕ¡ç»ç¡Ôíà¡×çÍ¡";
+static const thglyph_t ans_win_nd[] = "¾\x8bÍ»Ù\x86¾Õè»\x82\x9b®\xfc\x80Ø\x90Ø¡Ó»Ó¡\x8cÓ»\x87Ó»Ó\xdd\x8c·\x8b\xddÕ¡ç»\x9a¡Ôíà¡×çÍ¡";
+static const thglyph_t ans_win[] = "¾\x8bÍ»Ù\x86¾Õè»\x82\x9b®\xfc\x80Ø\x90Ø¡íÒ»\x99Ò¡íéÒ»\x99\x9cÒ»\x99Ò\xdd\x8c·\x8b\xddÕ¡ç»\x9a¡Ôíà¡×çÍ¡";
+static const thglyph_t ans_mac_nd[] = "¾\x88Í»Ù\x83¾Õè»\x95\x98®\xfc\x80Ø\x90Ø¡Ó»Ó¡\x89Ó»\x84Ó»Ó\xdd\x89·\x88\xddÕ¡ç»\x93¡Ôíà¡×çÍ¡";
+static const thglyph_t ans_mac[] = "¾\x88Í»Ù\x83¾Õè»\x95\x98®\xfc\x80Ø\x90Ø¡íÒ»\x8fÒ¡íéÒ»\x8f\x99Ò»\x8fÒ\xdd\x89·\x88\xddÕ¡ç»\x93¡Ôíà¡×çÍ¡";
+
+int test_th_render_tis()
+{
+ thglyph_t rend_buff[80];
+ int err_no = 0;
+
+ fprintf(stderr, "Testing th_render_text_tis() w/o decomposing SARA AM\n");
+ th_render_text_tis(test_msg, rend_buff, sizeof rend_buff, 0);
+ if (strcmp((const char*)rend_buff, (const char*)ans_tis_nd) != 0) {
+ fprintf(stderr, "(%s)!=(%s)\n", rend_buff, ans_tis_nd);
+ ++err_no;
+ }
+ fprintf(stderr, "Testing th_render_text_tis() decomposing SARA AM\n");
+ th_render_text_tis(test_msg, rend_buff, sizeof rend_buff, 1);
+ if (strcmp((const char*)rend_buff, (const char*)ans_tis) != 0) {
+ fprintf(stderr, "(%s)!=(%s)\n", rend_buff, ans_tis);
+ ++err_no;
+ }
+
+ return err_no;
+}
+
+int test_th_render_win()
+{
+ thglyph_t rend_buff[80];
+ int err_no = 0;
+
+ fprintf(stderr, "Testing th_render_text_win() w/o decomposing SARA AM\n");
+ th_render_text_win(test_msg, rend_buff, sizeof rend_buff, 0);
+ if (strcmp((const char*)rend_buff, (const char*)ans_win_nd) != 0) {
+ fprintf(stderr, "(%s)!=(%s)\n", rend_buff, ans_win_nd);
+ ++err_no;
+ }
+ fprintf(stderr, "Testing th_render_text_win() decomposing SARA AM\n");
+ th_render_text_win(test_msg, rend_buff, sizeof rend_buff, 1);
+ if (strcmp((const char*)rend_buff, (const char*)ans_win) != 0) {
+ fprintf(stderr, "(%s)!=(%s)\n", rend_buff, ans_win);
+ ++err_no;
+ }
+
+ return err_no;
+}
+
+int test_th_render_mac()
+{
+ thglyph_t rend_buff[80];
+ int err_no = 0;
+
+ fprintf(stderr, "Testing th_render_text_mac() w/o decomposing SARA AM\n");
+ th_render_text_mac(test_msg, rend_buff, sizeof rend_buff, 0);
+ if (strcmp((const char*)rend_buff, (const char*)ans_mac_nd) != 0) {
+ fprintf(stderr, "(%s)!=(%s)\n", rend_buff, ans_mac_nd);
+ ++err_no;
+ }
+ fprintf(stderr, "Testing th_render_text_mac() decomposing SARA AM\n");
+ th_render_text_mac(test_msg, rend_buff, sizeof rend_buff, 1);
+ if (strcmp((const char*)rend_buff, (const char*)ans_mac) != 0) {
+ fprintf(stderr, "(%s)!=(%s)\n", rend_buff, ans_mac);
+ ++err_no;
+ }
+
+ return err_no;
+}
+
+int main()
+{
+ int err_no = 0;
+
+ err_no += test_th_render_tis();
+ err_no += test_th_render_win();
+ err_no += test_th_render_mac();
+
+ return err_no;
+}
+
diff --git a/tests/test_thstr.c b/tests/test_thstr.c
new file mode 100644
index 0000000..44ebe1f
--- /dev/null
+++ b/tests/test_thstr.c
@@ -0,0 +1,24 @@
+/*
+ * test_thstr.c : Test suite for <thai/thstr.h> functions
+ * Created: 2001-08-03
+ * Author: Theppitak Karoonboonyanan
+ */
+
+#include <thai/thstr.h>
+#include <string.h>
+
+int test_th_normalize()
+{
+ const thchar_t* test_str = (const thchar_t *)"¤Øس»èÙ«èèÙ«èèÒ";
+ const thchar_t* ans_str = (const thchar_t *)"¤Ø³»Ùè«Ùè«èÒ";
+ thchar_t resBuff[50];
+
+ th_normalize(resBuff, test_str, sizeof resBuff);
+ return (strcmp((const char *)resBuff, (const char *)ans_str) == 0) ? 0 : 1;
+}
+
+int main()
+{
+ return test_th_normalize();
+}
+
diff --git a/tests/test_thwbrk.c b/tests/test_thwbrk.c
new file mode 100644
index 0000000..cd4738a
--- /dev/null
+++ b/tests/test_thwbrk.c
@@ -0,0 +1,78 @@
+/* Test driver for thwbrk
+ */
+
+#define MAXLINELENGTH 1000
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <thai/thbrk.h>
+#include <thai/thwchar.h>
+#include <thai/thwbrk.h>
+#include <wchar.h>
+
+int main (int argc, char* argv[])
+{
+ thchar_t str[MAXLINELENGTH];
+ thwchar_t ustr[MAXLINELENGTH], uout[MAXLINELENGTH], unicodeCutCode[6];
+
+ thchar_t out1[MAXLINELENGTH*2+1];
+ thchar_t out2[MAXLINELENGTH];
+ int pos[MAXLINELENGTH];
+ int outputLength, unicodeCutCodeLength;
+ int numCut, i;
+
+ strcpy ((char *)str, "ÊÇÑÊ´Õ¤ÃѺ ¡Í.ÃÁ¹. ¹Õèà»ç¹¡Ò÷´ÊͺµÑÇàͧ");
+ printf ("Testing with input string: %s\n", str);
+
+ printf ("Converting to Unicode...\n");
+ th_tis2uni_line (str, ustr, MAXLINELENGTH);
+
+ printf ("Calling th_wbrk()...\n");
+ numCut = th_wbrk (ustr, pos, MAXLINELENGTH);
+
+ printf ("Total %d cut points.", numCut);
+ if (numCut > 0) {
+ printf ("Cut points list: %d", pos[0]);
+ for (i = 1; i < numCut; i++) {
+ printf (", %d", pos[i]);
+ }
+ }
+ printf ("\n");
+ if (numCut != 7) {
+ printf ("Error! Should have 7 cut points.\n Test th_wbrk() failed...\n");
+ exit (-1);
+ }
+
+ unicodeCutCodeLength = th_tis2uni_line ((const thchar_t *) "<WBR>",
+ (thwchar_t*) unicodeCutCode, 6);
+
+ printf ("Calling th_wbrk_line() ....\n");
+ outputLength = th_wbrk_line (ustr, (thwchar_t*) uout, MAXLINELENGTH,
+ unicodeCutCode);
+
+ printf ("Return value from th_wbrk_line is %d\n", outputLength);
+ printf ("Output string length is %d\n", wcslen(uout));
+ if (outputLength != 75) {
+ printf ("Error! Output string length != 75. "
+ "Test th_wbrk_line() failed...\n");
+ exit (-1);
+ }
+
+ printf ("Compare with result from th_brk_line()..\n");
+ th_brk_line (str, out1, MAXLINELENGTH*2+1, "<WBR>");
+ th_uni2tis_line(uout, out2, MAXLINELENGTH);
+
+ if (strcmp ((const char *)out1, (const char *)out2) == 0) {
+ printf ("Correct! .. test th_wbrk_line() passed...\n");
+ } else {
+ printf ("Error! Comparison of results from th_brk_line() "
+ "and th_wbrk_line() failed.\n");
+ printf ("th_brk_line :\"%s\"\n", out1);
+ printf ("th_wbrk_line:\"%s\"\n", out2);
+ printf ("Test th_wbrk_line() failed...\n");
+ exit (-1);
+ }
+
+ return 0;
+}
diff --git a/tests/test_thwchar.c b/tests/test_thwchar.c
new file mode 100644
index 0000000..16cd414
--- /dev/null
+++ b/tests/test_thwchar.c
@@ -0,0 +1,63 @@
+/* Test driver for thwchar
+ */
+
+#define MAXLINELENGTH 1000
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <thai/thwchar.h>
+
+static const thchar_t win_sample[] = "¾\x8bÍ»Ù\x86¾Õè»\x82\x9b®\xfc\x80Ø\x90Ø¡íÒ»\x99Ò¡íéÒ»\x99\x9cÒ»\x99Ò \x8c·\x8b Õ¡ç»\x9a";
+static const thchar_t mac_sample[] = "¾\x88Í»Ù\x83¾Õè»\x95\x98®\xd8\xb0Ø\xadØ¡íÒ»\x8fÒ¡íéÒ»\x8f\x99Ò»\x8fÒ \x89·\x88 Õ¡ç»\x93";
+
+int main (int argc, char* argv[])
+{
+ thchar_t tis_620_0[MAXLINELENGTH];
+ thchar_t newtis_620_0[MAXLINELENGTH];
+ thwchar_t uni[MAXLINELENGTH];
+ int outputLength;
+ const thchar_t *pc;
+ int err = 0;
+
+ strcpy(tis_620_0,"ÊÇÑÊ´Õ¤ÃѺ ¹Õèà»ç¹¡Ò÷´ÊͺµÑÇàͧ");
+
+ fprintf(stderr, "Testing thwchar...\n");
+ fprintf(stderr, "Input: tis-620-0 string of length %d: %s\n",
+ strlen(tis_620_0), tis_620_0);
+
+ /* tis-620-0 to Unicode conversion */
+ outputLength = th_tis2uni_line(tis_620_0, uni, MAXLINELENGTH);
+ fprintf(stderr, "Output: Unicode string of length %d:", wcslen(uni));
+
+ /* Unicode to tis-620-0 conversion */
+ fprintf(stderr, "\nConvert back to tis-620-0 string...\n");
+ outputLength = th_uni2tis_line(uni, newtis_620_0, MAXLINELENGTH);
+ fprintf(stderr, "Output: tis-620-0 string of length %d: %s\n",
+ strlen(newtis_620_0), newtis_620_0);
+
+ if (strcmp(newtis_620_0, tis_620_0) == 0) {
+ fprintf(stderr, " Input = output, correct! Test thwchar OK.\n");
+ } else {
+ fprintf(stderr, " Input != output, incorrect!!\n");
+ err = 1;
+ }
+
+ /* Test Unicode <-> Win/Mac extensions */
+ for (pc = win_sample; *pc; ++pc) {
+ if (th_uni2winthai(th_winthai2uni(*pc)) != *pc) {
+ fprintf(stderr, "Inconsistent uni<->winthai conv: %02x -> %04lx, %02x\n",
+ *pc, th_winthai2uni(*pc), th_uni2winthai(th_winthai2uni(*pc)));
+ err = 1;
+ }
+ }
+ for (pc = mac_sample; *pc; ++pc) {
+ if (th_uni2macthai(th_macthai2uni(*pc)) != *pc) {
+ fprintf(stderr, "Inconsistent uni<->macthai conv: %02x -> %04lx, %02x\n",
+ *pc, th_macthai2uni(*pc), th_uni2macthai(th_macthai2uni(*pc)));
+ err = 1;
+ }
+ }
+
+ return err;
+}
diff --git a/tests/thsort.c b/tests/thsort.c
new file mode 100644
index 0000000..ea19fde
--- /dev/null
+++ b/tests/thsort.c
@@ -0,0 +1,113 @@
+/*
+ * thsort.c - word list sorting routine
+ * Created: 26 Nov 1998
+ * Author: Theppitak Karoonboonyanan <thep@linux.thai.net>
+ */
+
+#include <thai/thcoll.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+/* for qsort() */
+typedef int (*CMPFUNC)(const void *, const void *);
+
+static size_t readData(FILE *dataFile, thchar_t *data[], int maxData)
+{
+ size_t nData = 0;
+ static char wordBuf[128];
+
+ while (nData < maxData && fgets(wordBuf, sizeof wordBuf, dataFile) != NULL)
+ {
+ int len = strlen(wordBuf);
+ if (len == 0) { return nData; }
+ /* eliminate terminating '\n' */
+ wordBuf[--len] = 0;
+
+ /* allocate & copy the line */
+ data[nData] = (thchar_t*)malloc(len+1);
+ if (data[nData] == NULL) {
+ printf("Warning: Only %d items were read\n", nData);
+ return nData;
+ }
+ strcpy((char*)data[nData], wordBuf);
+ nData++;
+ }
+
+ return nData;
+}
+
+static void freeData(thchar_t *data[], size_t nItems)
+{
+ size_t i;
+
+ for (i=0; i<nItems; i++) {
+ free(data[i]);
+ }
+}
+
+static int dataCmp(const thchar_t **pStr1, const thchar_t **pStr2)
+{
+ return th_strcoll(*pStr1, *pStr2);
+}
+
+static void sortData(thchar_t *data[], size_t nItems)
+{
+ qsort(data, nItems, sizeof data[0], (CMPFUNC)dataCmp);
+}
+
+static void writeData(FILE *outFile, thchar_t *data[], size_t nItems)
+{
+ size_t i;
+
+ for (i = nItems; i > 0; i--) {
+ fprintf(outFile, "%s\n", *data);
+ data++;
+ }
+}
+
+#define MAX_DATA 40000
+static thchar_t *data[MAX_DATA];
+
+int main(int argc, char *argv[])
+{
+ FILE *dataFile;
+ FILE *outFile;
+ size_t dataRead;
+ char DataFileName[64];
+ char OutFileName[64];
+
+ if (argc == 3) {
+ strcpy(DataFileName, argv[1]);
+ strcpy(OutFileName, argv[2]);
+ } else {
+ fprintf(stderr, "Usage: thsort <input file> <output file>\n");
+ return 1;
+ }
+
+ dataFile = fopen(DataFileName, "rt");
+ if (dataFile == NULL) {
+ fprintf(stderr, "Can't open file %s\n", DataFileName);
+ perror("fopen");
+ return 1;
+ }
+
+ outFile = fopen(OutFileName, "wt");
+ if (outFile == NULL) {
+ fprintf(stderr, "Can't open file %s for write\n", OutFileName);
+ perror("fopen");
+ return 1;
+ }
+
+ dataRead = readData(dataFile, data, MAX_DATA);
+ sortData(data, dataRead);
+ writeData(outFile, data, dataRead);
+ freeData(data, dataRead);
+
+ fclose(outFile);
+ fclose(dataFile);
+
+ return 0;
+}
+