summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorunknown <unknown@unknown>2009-10-23 04:29:39 +0000
committerunknown <unknown@unknown>2009-10-23 04:29:39 +0000
commitddf5c42f67757000d6ec7686b92a667c2a252dca (patch)
treee070b352fab4b285b7a4ea547d0cbfff9b7fb4d1 /test
downloadiksemel-ddf5c42f67757000d6ec7686b92a667c2a252dca.zip
iksemel-ddf5c42f67757000d6ec7686b92a667c2a252dca.tar.gz
iksemel-ddf5c42f67757000d6ec7686b92a667c2a252dca.tar.xz
Imported from iksemel-1.3.tar.gz.
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am33
-rw-r--r--test/Makefile.in570
-rw-r--r--test/tst-dom.c164
-rw-r--r--test/tst-filter.c260
-rw-r--r--test/tst-iks.c77
-rw-r--r--test/tst-ikstack.c54
-rw-r--r--test/tst-jid.c63
-rw-r--r--test/tst-md5.c38
-rw-r--r--test/tst-sax.c384
-rw-r--r--test/tst-sha.c38
10 files changed, 1681 insertions, 0 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
new file mode 100644
index 0000000..a82402f
--- /dev/null
+++ b/test/Makefile.am
@@ -0,0 +1,33 @@
+##
+## Process this file with automake to produce Makefile.in
+##
+
+INCLUDES = -I$(top_srcdir)/include
+
+TESTS = tst-ikstack tst-iks tst-sax tst-dom tst-sha tst-md5 tst-filter tst-jid
+
+noinst_PROGRAMS = tst-ikstack tst-iks tst-sax tst-dom tst-sha tst-md5 tst-filter tst-jid
+
+tst_ikstack_LDADD = $(top_builddir)/src/libiksemel.la
+tst_ikstack_SOURCES = tst-ikstack.c
+
+tst_iks_LDADD = $(top_builddir)/src/libiksemel.la
+tst_iks_SOURCES = tst-iks.c
+
+tst_sax_LDADD = $(top_builddir)/src/libiksemel.la
+tst_sax_SOURCES = tst-sax.c
+
+tst_dom_LDADD = $(top_builddir)/src/libiksemel.la
+tst_dom_SOURCES = tst-dom.c
+
+tst_sha_LDADD = $(top_builddir)/src/libiksemel.la
+tst_sha_SOURCES = tst-sha.c
+
+tst_md5_LDADD = $(top_builddir)/src/libiksemel.la
+tst_md5_SOURCES = tst-md5.c
+
+tst_filter_LDADD = $(top_builddir)/src/libiksemel.la
+tst_filter_SOURCES = tst-filter.c
+
+tst_jid_LDADD = $(top_builddir)/src/libiksemel.la
+tst_jid_SOURCES = tst-jid.c
diff --git a/test/Makefile.in b/test/Makefile.in
new file mode 100644
index 0000000..a47e568
--- /dev/null
+++ b/test/Makefile.in
@@ -0,0 +1,570 @@
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005 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@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ..
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
+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@
+noinst_PROGRAMS = tst-ikstack$(EXEEXT) tst-iks$(EXEEXT) \
+ tst-sax$(EXEEXT) tst-dom$(EXEEXT) tst-sha$(EXEEXT) \
+ tst-md5$(EXEEXT) tst-filter$(EXEEXT) tst-jid$(EXEEXT)
+subdir = test
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/include/config.h
+CONFIG_CLEAN_FILES =
+PROGRAMS = $(noinst_PROGRAMS)
+am_tst_dom_OBJECTS = tst-dom.$(OBJEXT)
+tst_dom_OBJECTS = $(am_tst_dom_OBJECTS)
+tst_dom_DEPENDENCIES = $(top_builddir)/src/libiksemel.la
+am_tst_filter_OBJECTS = tst-filter.$(OBJEXT)
+tst_filter_OBJECTS = $(am_tst_filter_OBJECTS)
+tst_filter_DEPENDENCIES = $(top_builddir)/src/libiksemel.la
+am_tst_iks_OBJECTS = tst-iks.$(OBJEXT)
+tst_iks_OBJECTS = $(am_tst_iks_OBJECTS)
+tst_iks_DEPENDENCIES = $(top_builddir)/src/libiksemel.la
+am_tst_ikstack_OBJECTS = tst-ikstack.$(OBJEXT)
+tst_ikstack_OBJECTS = $(am_tst_ikstack_OBJECTS)
+tst_ikstack_DEPENDENCIES = $(top_builddir)/src/libiksemel.la
+am_tst_jid_OBJECTS = tst-jid.$(OBJEXT)
+tst_jid_OBJECTS = $(am_tst_jid_OBJECTS)
+tst_jid_DEPENDENCIES = $(top_builddir)/src/libiksemel.la
+am_tst_md5_OBJECTS = tst-md5.$(OBJEXT)
+tst_md5_OBJECTS = $(am_tst_md5_OBJECTS)
+tst_md5_DEPENDENCIES = $(top_builddir)/src/libiksemel.la
+am_tst_sax_OBJECTS = tst-sax.$(OBJEXT)
+tst_sax_OBJECTS = $(am_tst_sax_OBJECTS)
+tst_sax_DEPENDENCIES = $(top_builddir)/src/libiksemel.la
+am_tst_sha_OBJECTS = tst-sha.$(OBJEXT)
+tst_sha_OBJECTS = $(am_tst_sha_OBJECTS)
+tst_sha_DEPENDENCIES = $(top_builddir)/src/libiksemel.la
+DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+SOURCES = $(tst_dom_SOURCES) $(tst_filter_SOURCES) $(tst_iks_SOURCES) \
+ $(tst_ikstack_SOURCES) $(tst_jid_SOURCES) $(tst_md5_SOURCES) \
+ $(tst_sax_SOURCES) $(tst_sha_SOURCES)
+DIST_SOURCES = $(tst_dom_SOURCES) $(tst_filter_SOURCES) \
+ $(tst_iks_SOURCES) $(tst_ikstack_SOURCES) $(tst_jid_SOURCES) \
+ $(tst_md5_SOURCES) $(tst_sax_SOURCES) $(tst_sha_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DO_POSIX_FALSE = @DO_POSIX_FALSE@
+DO_POSIX_TRUE = @DO_POSIX_TRUE@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBGNUTLS_CFLAGS = @LIBGNUTLS_CFLAGS@
+LIBGNUTLS_CONFIG = @LIBGNUTLS_CONFIG@
+LIBGNUTLS_LIBS = @LIBGNUTLS_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+ac_ct_OBJDUMP = @ac_ct_OBJDUMP@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
+am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
+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@
+datadir = @datadir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+INCLUDES = -I$(top_srcdir)/include
+TESTS = tst-ikstack tst-iks tst-sax tst-dom tst-sha tst-md5 tst-filter tst-jid
+tst_ikstack_LDADD = $(top_builddir)/src/libiksemel.la
+tst_ikstack_SOURCES = tst-ikstack.c
+tst_iks_LDADD = $(top_builddir)/src/libiksemel.la
+tst_iks_SOURCES = tst-iks.c
+tst_sax_LDADD = $(top_builddir)/src/libiksemel.la
+tst_sax_SOURCES = tst-sax.c
+tst_dom_LDADD = $(top_builddir)/src/libiksemel.la
+tst_dom_SOURCES = tst-dom.c
+tst_sha_LDADD = $(top_builddir)/src/libiksemel.la
+tst_sha_SOURCES = tst-sha.c
+tst_md5_LDADD = $(top_builddir)/src/libiksemel.la
+tst_md5_SOURCES = tst-md5.c
+tst_filter_LDADD = $(top_builddir)/src/libiksemel.la
+tst_filter_SOURCES = tst-filter.c
+tst_jid_LDADD = $(top_builddir)/src/libiksemel.la
+tst_jid_SOURCES = tst-jid.c
+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 \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu test/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu test/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
+
+clean-noinstPROGRAMS:
+ @list='$(noinst_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+tst-dom$(EXEEXT): $(tst_dom_OBJECTS) $(tst_dom_DEPENDENCIES)
+ @rm -f tst-dom$(EXEEXT)
+ $(LINK) $(tst_dom_LDFLAGS) $(tst_dom_OBJECTS) $(tst_dom_LDADD) $(LIBS)
+tst-filter$(EXEEXT): $(tst_filter_OBJECTS) $(tst_filter_DEPENDENCIES)
+ @rm -f tst-filter$(EXEEXT)
+ $(LINK) $(tst_filter_LDFLAGS) $(tst_filter_OBJECTS) $(tst_filter_LDADD) $(LIBS)
+tst-iks$(EXEEXT): $(tst_iks_OBJECTS) $(tst_iks_DEPENDENCIES)
+ @rm -f tst-iks$(EXEEXT)
+ $(LINK) $(tst_iks_LDFLAGS) $(tst_iks_OBJECTS) $(tst_iks_LDADD) $(LIBS)
+tst-ikstack$(EXEEXT): $(tst_ikstack_OBJECTS) $(tst_ikstack_DEPENDENCIES)
+ @rm -f tst-ikstack$(EXEEXT)
+ $(LINK) $(tst_ikstack_LDFLAGS) $(tst_ikstack_OBJECTS) $(tst_ikstack_LDADD) $(LIBS)
+tst-jid$(EXEEXT): $(tst_jid_OBJECTS) $(tst_jid_DEPENDENCIES)
+ @rm -f tst-jid$(EXEEXT)
+ $(LINK) $(tst_jid_LDFLAGS) $(tst_jid_OBJECTS) $(tst_jid_LDADD) $(LIBS)
+tst-md5$(EXEEXT): $(tst_md5_OBJECTS) $(tst_md5_DEPENDENCIES)
+ @rm -f tst-md5$(EXEEXT)
+ $(LINK) $(tst_md5_LDFLAGS) $(tst_md5_OBJECTS) $(tst_md5_LDADD) $(LIBS)
+tst-sax$(EXEEXT): $(tst_sax_OBJECTS) $(tst_sax_DEPENDENCIES)
+ @rm -f tst-sax$(EXEEXT)
+ $(LINK) $(tst_sax_LDFLAGS) $(tst_sax_OBJECTS) $(tst_sax_LDADD) $(LIBS)
+tst-sha$(EXEEXT): $(tst_sha_OBJECTS) $(tst_sha_DEPENDENCIES)
+ @rm -f tst-sha$(EXEEXT)
+ $(LINK) $(tst_sha_LDFLAGS) $(tst_sha_OBJECTS) $(tst_sha_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tst-dom.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tst-filter.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tst-iks.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tst-ikstack.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tst-jid.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tst-md5.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tst-sax.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tst-sha.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@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@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@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@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@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
+
+distclean-libtool:
+ -rm -f libtool
+uninstall-info-am:
+
+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; } \
+ END { for (i in files) print i; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ 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; } \
+ END { for (i in files) print i; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ 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; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && 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)'; \
+ 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`; \
+ echo "XPASS: $$tst"; \
+ ;; \
+ *) \
+ echo "PASS: $$tst"; \
+ ;; \
+ esac; \
+ elif test $$? -ne 77; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *" $$tst "*) \
+ xfail=`expr $$xfail + 1`; \
+ echo "XFAIL: $$tst"; \
+ ;; \
+ *) \
+ failed=`expr $$failed + 1`; \
+ echo "FAIL: $$tst"; \
+ ;; \
+ esac; \
+ else \
+ skip=`expr $$skip + 1`; \
+ echo "SKIP: $$tst"; \
+ fi; \
+ done; \
+ if test "$$failed" -eq 0; then \
+ if test "$$xfail" -eq 0; then \
+ banner="All $$all tests passed"; \
+ else \
+ 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 \
+ banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
+ fi; \
+ fi; \
+ dashes="$$banner"; \
+ skipped=""; \
+ if test "$$skip" -ne 0; then \
+ skipped="($$skip tests were not run)"; \
+ 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`; \
+ echo "$$dashes"; \
+ echo "$$banner"; \
+ test -z "$$skipped" || echo "$$skipped"; \
+ test -z "$$report" || echo "$$report"; \
+ echo "$$dashes"; \
+ test "$$failed" -eq 0; \
+ else :; fi
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+ list='$(DISTFILES)'; for file in $$list; do \
+ case $$file in \
+ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+ $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+ esac; \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+ dir="/$$dir"; \
+ $(mkdir_p) "$(distdir)$$dir"; \
+ else \
+ dir=''; \
+ fi; \
+ if test -d $$d/$$file; then \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$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-TESTS
+check: check-am
+all-am: Makefile $(PROGRAMS)
+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:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-libtool distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-exec-am:
+
+install-info: install-info-am
+
+install-man:
+
+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: uninstall-info-am
+
+.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
+ clean-generic clean-libtool clean-noinstPROGRAMS 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-exec install-exec-am install-info \
+ install-info-am install-man 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 uninstall-info-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/test/tst-dom.c b/test/tst-dom.c
new file mode 100644
index 0000000..693509e
--- /dev/null
+++ b/test/tst-dom.c
@@ -0,0 +1,164 @@
+/* iksemel (XML parser for Jabber)
+** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
+** This code is free software; you can redistribute it and/or
+** modify it under the terms of GNU Lesser General Public License.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+
+#include "iksemel.h"
+
+iks *my_x;
+int nr_tests;
+
+#define PR_TEST printf ("DOM test %d:\n", nr_tests)
+
+void
+document (char *xml)
+{
+ enum ikserror err;
+ iksparser *p;
+
+ nr_tests++;
+ if (my_x) iks_delete (my_x);
+ p = iks_dom_new (&my_x);
+ err = iks_parse (p, xml, 0, 1);
+ switch (err) {
+ case IKS_OK:
+ break;
+ case IKS_NOMEM:
+ PR_TEST;
+ puts ("Not enough memory.");
+ exit (1);
+ case IKS_BADXML:
+ PR_TEST;
+ printf ("Invalid xml at byte %ld in\n[%s]\n", iks_nr_bytes (p), xml);
+ exit (1);
+ case IKS_HOOK:
+ PR_TEST;
+ puts ("Hook.");
+ }
+ iks_parser_delete (p);
+}
+
+void
+tag (char *name, ...)
+{
+ iks *x;
+ va_list ap;
+
+ x = my_x;
+ va_start (ap, name);
+ while (1) {
+ char *name = iks_name (x);
+ char *tmp = va_arg (ap, char*);
+ if (NULL == tmp) break;
+ x = iks_find (x, tmp);
+ if (!x) {
+ PR_TEST;
+ printf ("Tag <%s> is not a child of tag <%s>\n", tmp, name);
+ exit (1);
+ }
+ }
+ if (!x || NULL == iks_find (x, name)) {
+ PR_TEST;
+ printf ("Tag <%s> is not a child of tag <%s>\n", name, iks_name (x));
+ exit (1);
+ }
+ va_end (ap);
+}
+
+void
+cdata (char *data, ...)
+{
+ iks *x;
+ va_list ap;
+
+ x = my_x;
+ va_start (ap, data);
+ while (1) {
+ char *name = iks_name (x);
+ char *tmp = va_arg (ap, char*);
+ if (NULL == tmp) break;
+ x = iks_find (x, tmp);
+ if (!x) {
+ PR_TEST;
+ printf ("Tag <%s> is not a child of tag <%s>\n", tmp, name);
+ exit (1);
+ }
+ }
+ if (iks_strcmp ( iks_cdata (iks_child (x)), data) != 0) {
+ PR_TEST;
+ printf ("CDATA [%s] not found.\n", data);
+ exit (1);
+ }
+ va_end (ap);
+}
+
+void
+attrib (char *att, char *val, ...)
+{
+ iks *x;
+ va_list ap;
+
+ x = my_x;
+ va_start (ap, val);
+ while (1) {
+ char *name = iks_name (x);
+ char *tmp = va_arg (ap, char*);
+ if (NULL == tmp) break;
+ x = iks_find (x, tmp);
+ if (!x) {
+ PR_TEST;
+ printf ("Tag <%s> is not a child of tag <%s>\n", tmp, name);
+ exit (1);
+ }
+ }
+ if (iks_strcmp (val, iks_find_attrib (x, att)) != 0) {
+ PR_TEST;
+ printf ("Attribute '%s' not found.\n", att);
+ exit (1);
+ }
+ va_end (ap);
+}
+
+void
+string (char *xml)
+{
+ char *tmp;
+
+ tmp = iks_string (iks_stack (my_x), my_x);
+ if (iks_strcmp (tmp, xml) != 0) {
+ PR_TEST;
+ printf ("Result: %s\n", tmp);
+ printf ("Expected: %s\n", xml);
+ exit (1);
+ }
+}
+
+static char buf[] =
+ "<presence id='JCOM_11' to='lala@j.org' type='available'><status>"
+ "&quot; &lt;online&amp;dangerous&gt; &quot;</status>meow<a><b c='d'/>"
+ "</a><test/></presence>";
+
+int main (int argc, char *argv[])
+{
+ document ("<atag></atag>");
+ string ("<atag/>");
+
+ document ("<test>lala<b>bold</b>blablabla<a><c/></a></test>");
+ tag ("b", 0);
+ tag ("c", "a", 0);
+ string ("<test>lala<b>bold</b>blablabla<a><c/></a></test>");
+
+ document (buf);
+ cdata ("\" <online&dangerous> \"", "status", 0);
+ attrib ("c", "d", "a", "b", 0);
+ tag ("test", 0);
+ string (buf);
+
+ return 0;
+}
diff --git a/test/tst-filter.c b/test/tst-filter.c
new file mode 100644
index 0000000..64adbd1
--- /dev/null
+++ b/test/tst-filter.c
@@ -0,0 +1,260 @@
+/* iksemel (XML parser for Jabber)
+** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
+** This code is free software; you can redistribute it and/or
+** modify it under the terms of GNU Lesser General Public License.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <locale.h>
+#include <assert.h>
+
+#include "iksemel.h"
+
+struct {
+ iksfilter *f;
+ char *xml;
+ int nr;
+ iksFilterHook *hook[20];
+ int nr_hook;
+ iksFilterHook *call[20];
+ int nr_call;
+} tester;
+
+void
+document (char *xml)
+{
+ tester.nr++;
+ tester.xml = xml;
+ tester.nr_hook = 0;
+}
+
+void
+hook (iksFilterHook *hk)
+{
+ tester.hook[tester.nr_hook++] = hk;
+}
+
+void
+debug (void)
+{
+ int i;
+
+ printf ("Filter test %d:\n", tester.nr);
+ if (tester.nr_hook) {
+ puts ("Expected hook order:");
+ for (i = 0; i < tester.nr_hook; i++) {
+ printf (" ");
+ tester.hook[i] (NULL, NULL);
+ }
+ } else {
+ puts("No hooks expected.");
+ }
+ if (tester.nr_call) {
+ puts ("Hook order:");
+ for (i = 0; i < tester.nr_call; i++) {
+ printf (" ");
+ tester.call[i] (NULL, NULL);
+ }
+ } else {
+ puts("No hooks called.");
+ }
+ exit (1);
+}
+
+void
+test (void)
+{
+ iksparser *prs;
+ iks *x;
+ int i;
+
+ tester.nr_call = 0;
+
+ prs = iks_dom_new (&x);
+ iks_parse (prs, tester.xml, strlen (tester.xml), 1);
+ iks_parser_delete (prs);
+ iks_filter_packet (tester.f, iks_packet (x));
+ iks_delete (x);
+
+ if (tester.nr_call != tester.nr_hook) debug ();
+ for (i = 0; i < tester.nr_hook; i++) {
+ if (tester.call[i] != tester.hook[i]) debug ();
+ }
+}
+
+#define DEBUG(x) if (NULL == pak) { puts ( (x) ); return IKS_FILTER_PASS; }
+
+int
+on_msg (void *user_data, ikspak *pak)
+{
+ DEBUG ("on_msg");
+ assert (IKS_PAK_MESSAGE == pak->type);
+ tester.call[tester.nr_call++] = on_msg;
+ return IKS_FILTER_PASS;
+}
+
+int
+on_iq (void *user_data, ikspak *pak)
+{
+ DEBUG ("on_iq");
+ assert (IKS_PAK_IQ == pak->type);
+ tester.call[tester.nr_call++] = on_iq;
+ return IKS_FILTER_PASS;
+}
+
+int
+on_iq_result (void *user_data, ikspak *pak)
+{
+ DEBUG ("on_iq_result");
+ assert (IKS_PAK_IQ == pak->type);
+ assert (IKS_TYPE_RESULT == pak->subtype);
+ tester.call[tester.nr_call++] = on_iq_result;
+ return IKS_FILTER_PASS;
+}
+
+int
+on_iq_result_id_auth (void *user_data, ikspak *pak)
+{
+ DEBUG ("on_iq_result_id_auth");
+ assert (IKS_PAK_IQ == pak->type);
+ assert (IKS_TYPE_RESULT == pak->subtype);
+ assert (iks_strcmp (pak->id, "auth") == 0);
+ tester.call[tester.nr_call++] = on_iq_result_id_auth;
+ return IKS_FILTER_PASS;
+}
+
+int
+on_id_auth (void *user_data, ikspak *pak)
+{
+ DEBUG ("on_id_auth");
+ assert (iks_strcmp (pak->id, "auth") == 0);
+ tester.call[tester.nr_call++] = on_id_auth;
+ return IKS_FILTER_PASS;
+}
+
+int
+on_from_patrician (void *user_data, ikspak *pak)
+{
+ DEBUG ("on_from_patrician");
+ assert (iks_strcmp (pak->from->partial, "patrician@morpork.gov") == 0);
+ tester.call[tester.nr_call++] = on_from_patrician;
+ return IKS_FILTER_PASS;
+}
+
+int
+on_msg_chat_from_patrician (void *user_data, ikspak *pak)
+{
+ DEBUG ("on_msg_chat_from_patrician");
+ assert (pak->type == IKS_PAK_MESSAGE);
+ assert (pak->subtype == IKS_TYPE_CHAT);
+ assert (iks_strcmp (pak->from->partial, "patrician@morpork.gov") == 0);
+ tester.call[tester.nr_call++] = on_msg_chat_from_patrician;
+ return IKS_FILTER_PASS;
+}
+
+int
+on_id_albatros (void *user_data, ikspak *pak)
+{
+ DEBUG ("on_id_albatros");
+ assert (iks_strcmp (pak->id, "albatros") == 0);
+ tester.call[tester.nr_call++] = on_id_albatros;
+ return IKS_FILTER_PASS;
+}
+
+int
+on_from_dean (void *user_data, ikspak *pak)
+{
+ DEBUG ("on_from_dean");
+ assert (iks_strcmp (pak->from->partial, "dean@unseen.edu") == 0);
+ tester.call[tester.nr_call++] = on_from_dean;
+ return IKS_FILTER_PASS;
+}
+
+int
+main (int argc, char *argv[])
+{
+ tester.f = iks_filter_new ();
+ iks_filter_add_rule (tester.f, on_msg, 0,
+ IKS_RULE_TYPE, IKS_PAK_MESSAGE,
+ IKS_RULE_DONE);
+ iks_filter_add_rule (tester.f, on_iq, 0,
+ IKS_RULE_TYPE, IKS_PAK_IQ,
+ IKS_RULE_DONE);
+ iks_filter_add_rule (tester.f, on_iq_result, 0,
+ IKS_RULE_TYPE, IKS_PAK_IQ,
+ IKS_RULE_SUBTYPE, IKS_TYPE_RESULT,
+ IKS_RULE_DONE);
+ iks_filter_add_rule (tester.f, on_iq_result_id_auth, 0,
+ IKS_RULE_TYPE, IKS_PAK_IQ,
+ IKS_RULE_SUBTYPE, IKS_TYPE_RESULT,
+ IKS_RULE_ID, "auth",
+ IKS_RULE_DONE);
+ iks_filter_add_rule (tester.f, on_id_auth, 0,
+ IKS_RULE_ID, "auth",
+ IKS_RULE_DONE);
+ iks_filter_add_rule (tester.f, on_from_dean, 0,
+ IKS_RULE_FROM_PARTIAL, "dean@unseen.edu",
+ IKS_RULE_DONE);
+ iks_filter_add_rule (tester.f, on_from_patrician, 0,
+ IKS_RULE_FROM_PARTIAL, "patrician@morpork.gov",
+ IKS_RULE_DONE);
+ iks_filter_add_rule (tester.f, on_msg_chat_from_patrician, 0,
+ IKS_RULE_TYPE, IKS_PAK_MESSAGE,
+ IKS_RULE_SUBTYPE, IKS_TYPE_CHAT,
+ IKS_RULE_FROM_PARTIAL, "patrician@morpork.gov",
+ IKS_RULE_DONE);
+ iks_filter_add_rule (tester.f, on_id_albatros, 0,
+ IKS_RULE_ID, "albatros",
+ IKS_RULE_DONE);
+
+ document ("<message from='dean@unseen.edu' id='1234'><body>Born to Rune.</body></message>");
+ hook (on_from_dean);
+ hook (on_msg);
+ test ();
+
+ document ("<presence from='librarian@unseen.edu' show='away'/>");
+ test ();
+
+ document ("<message from='rincewind@unseen.edu' type='chat' id='albatros'><body>yaaargh</body></message>");
+ hook (on_id_albatros);
+ hook (on_msg);
+ test ();
+
+ document ("<iq type='get' from='rincewind@unseen.edu'><query xmlns='jabber:time'/></iq>");
+ hook (on_iq);
+ test ();
+
+ document ("<message from='patrician@morpork.gov'><body>so you admit it?</body></message>");
+ hook (on_from_patrician);
+ hook (on_msg);
+ test ();
+
+ document ("<iq type='result' from='rincewind@unseen.edu'><query xmlns='jabber:version'><name>cabbar</name><version>1.0</version></query></iq>");
+ hook (on_iq_result);
+ hook (on_iq);
+ test ();
+
+ document ("<presence from='dean@unseen.edu/psi' type='unavailable'/>");
+ hook (on_from_dean);
+ test ();
+
+ document ("<message from='patrician@morpork.gov' type='chat' id='albatros'><body>hmm</body></message>");
+ hook (on_id_albatros);
+ hook (on_msg_chat_from_patrician);
+ hook (on_from_patrician);
+ hook (on_msg);
+ test ();
+
+ document ("<iq type='result' id='auth'/>");
+ hook (on_iq_result_id_auth);
+ hook (on_id_auth);
+ hook (on_iq_result);
+ hook (on_iq);
+ test ();
+
+ iks_filter_delete (tester.f);
+
+ return 0;
+}
diff --git a/test/tst-iks.c b/test/tst-iks.c
new file mode 100644
index 0000000..5573b07
--- /dev/null
+++ b/test/tst-iks.c
@@ -0,0 +1,77 @@
+/* iksemel (XML parser for Jabber)
+** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
+** This code is free software; you can redistribute it and/or
+** modify it under the terms of GNU Lesser General Public License.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <locale.h>
+
+#include "iksemel.h"
+
+int main (int argc, char *argv[])
+{
+ static char xml[] =
+ "<iq type='result' to='ydobon@jabber.org'><query xmlns='jabber:iq:version'>"
+ "<name>TestClient</name><os>SuxOS 2000</os><version><stable solidity='rock'/>"
+ "1.2.0 patchlevel 2</version></query></iq>";
+ static char xml2[] =
+ "<Ni><C/>lala<br/><A/>Hello World<B/></Ni>";
+ iks *x, *y, *z;
+ char *t;
+
+ setlocale (LC_ALL, "");
+
+ x = iks_new ("iq");
+ iks_insert_attrib (x, "type", "resultypo");
+ iks_insert_attrib (x, "type", "result");
+ iks_insert_attrib (x, "to", "ydobon@jabber.org");
+ y = iks_new_within ("query", iks_stack (x));
+ iks_insert_cdata (iks_insert (y, "name"), "TestClient", 10);
+ iks_insert_cdata (iks_insert (y, "os"), "SuxOS", 0);
+ z = iks_insert (y, "version");
+ iks_insert (z, "stable");
+ iks_insert_cdata (z, "1.2", 3);
+ iks_insert_cdata (z, ".0 patchlevel 2", 0);
+ iks_insert_node (x, y);
+ z = iks_find (y, "os");
+ iks_insert_attrib (z, "error", "yes");
+ iks_insert_attrib (z, "error", NULL);
+ iks_insert_cdata (z, " 2000", 5);
+ z = iks_next (z);
+ z = iks_find (z, "stable");
+ iks_insert_attrib (z, "solidity", "rock");
+ z = iks_parent (iks_parent (z));
+ iks_insert_attrib (z, "xmlns", "jabber:iq:version");
+
+ t = iks_string (iks_stack (x), x);
+ if(!t || strcmp(t, xml) != 0) {
+ printf("Result: %s\n", t);
+ printf("Expected: %s\n", xml);
+ return 1;
+ }
+ iks_delete(x);
+
+
+ x = iks_new ("Ni");
+ y = iks_insert (x, "br");
+ z = iks_prepend_cdata (y, "lala", 4);
+ iks_prepend (z, "C");
+ z = iks_insert_cdata (x, "Hello", 5);
+ y = iks_append (z, "B");
+ iks_prepend (z, "A");
+ iks_append_cdata (z, " ", 1);
+ iks_prepend_cdata (y, "World", 5);
+
+ t = iks_string (iks_stack (x), x);
+ if(!t || strcmp(t, xml2) != 0) {
+ printf("Result: %s\n", t);
+ printf("Expected: %s\n", xml2);
+ return 1;
+ }
+ iks_delete(x);
+
+ return 0;
+}
diff --git a/test/tst-ikstack.c b/test/tst-ikstack.c
new file mode 100644
index 0000000..9e8459f
--- /dev/null
+++ b/test/tst-ikstack.c
@@ -0,0 +1,54 @@
+/* iksemel (XML parser for Jabber)
+** Copyright (C) 2000-2004 Gurer Ozen <madcat@e-kolay.net>
+** This code is free software; you can redistribute it and/or
+** modify it under the terms of GNU Lesser General Public License.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "iksemel.h"
+
+struct align_test { char a; double b; };
+#define DEFAULT_ALIGNMENT ((size_t) ((char *) &((struct align_test *) 0)->b - (char *) 0))
+#define ALIGN_MASK ( DEFAULT_ALIGNMENT - 1 )
+
+const char buf[] = "1234567890abcdefghijklmnopqrstuv";
+
+void
+test_stack (int cs)
+{
+ ikstack *s;
+ char *mem, *old;
+ int i;
+
+ s = iks_stack_new (cs, cs);
+ old = NULL;
+ for (i = 0; i < strlen (buf); i++) {
+ iks_stack_strdup (s, buf, i);
+ mem = iks_stack_alloc (s, i);
+ if (((unsigned long) mem) & ALIGN_MASK) {
+ printf ("ikstack bug, addr %p should be a multiply of %d\n",
+ mem, DEFAULT_ALIGNMENT);
+ exit (1);
+ }
+ memset (mem, 'x', i);
+ old = iks_stack_strcat (s, old, 0, buf + i, 1);
+ }
+ if (strcmp (old, buf) != 0) {
+ printf ("ikstack strcat bug:\nExpected: %s\n Result: %s\n", buf, old);
+ exit (1);
+ }
+ iks_stack_delete (s);
+}
+
+int main (int argc, char *argv[])
+{
+ test_stack (0);
+ test_stack (16);
+ test_stack (237);
+ test_stack (1024);
+
+ return 0;
+}
diff --git a/test/tst-jid.c b/test/tst-jid.c
new file mode 100644
index 0000000..66406c7
--- /dev/null
+++ b/test/tst-jid.c
@@ -0,0 +1,63 @@
+/* iksemel (XML parser for Jabber)
+** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
+** This code is free software; you can redistribute it and/or
+** modify it under the terms of GNU Lesser General Public License.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <locale.h>
+
+#include "iksemel.h"
+
+ikstack *my_stack;
+
+void
+print_id (iksid *id)
+{
+ printf (" Full: [%s]\n Partial: [%s]\n User: [%s]\n Server: [%s]\n Resource: [%s]\n",
+ id->full, id->partial, id->user, id->server, id->resource);
+}
+
+#define BUG(x) { print_id ( (x) ); exit (1); }
+
+void
+test_id (char *id, char *partial, char *user, char *server, char *resource)
+{
+ iksid *a;
+
+ a = iks_id_new (my_stack, id);
+ if ((a->partial || partial) && iks_strcmp (a->partial, partial) != 0) BUG(a);
+ if ((a->user || user) && iks_strcmp (a->user, user) != 0) BUG(a);
+ if ((a->server || server) && iks_strcmp (a->server, server) != 0) BUG(a);
+ if ((a->resource || resource) && iks_strcmp (a->resource, resource) != 0) BUG(a);
+}
+
+void
+test_cmp (char *stra, char *strb, int parts, int diff)
+{
+ iksid *a, *b;
+
+ a = iks_id_new (my_stack, stra);
+ b = iks_id_new (my_stack, strb);
+ if (diff != iks_id_cmp (a, b, parts)) exit (1);
+}
+
+int main (int argc, char *argv[])
+{
+ my_stack = iks_stack_new (1024, 1024);
+
+ test_id ("jabber:madcat@jabber.org/cabbar", "madcat@jabber.org", "madcat", "jabber.org", "cabbar");
+ test_id ("bob@silent.org", "bob@silent.org", "bob", "silent.org", NULL);
+
+ test_cmp ("dante@jabber.org/hell", "dante@jabber.org/heaven", IKS_ID_PARTIAL, 0);
+ test_cmp ("madcat@jabber.org/cabbar", "madcat@jabber.org/jabberx", IKS_ID_FULL, IKS_ID_RESOURCE);
+ test_cmp ("dean@unseen.edu/pda", "librarian@unseen.edu/jabberx", IKS_ID_FULL, IKS_ID_USER | IKS_ID_RESOURCE);
+ test_cmp ("patrician@morpork.gov/gabber", "cohen@guild.org/gsm", IKS_ID_FULL, IKS_ID_FULL);
+ test_cmp ("peter@family.com", "peter@family.com/clam", IKS_ID_PARTIAL, 0);
+
+ iks_stack_delete (my_stack);
+
+ return 0;
+}
diff --git a/test/tst-md5.c b/test/tst-md5.c
new file mode 100644
index 0000000..82584ae
--- /dev/null
+++ b/test/tst-md5.c
@@ -0,0 +1,38 @@
+/* iksemel (XML parser for Jabber)
+** Copyright (C) 2004 Gurer Ozen <madcat@e-kolay.net>
+** This code is free software; you can redistribute it and/or
+** modify it under the terms of GNU Lesser General Public License.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "iksemel.h"
+
+int main (int argc, char *argv[])
+{
+ struct lala {
+ char *str;
+ char *hash;
+ } known_hashes[] = {
+ { "abc", "900150983cd24fb0d6963f7d28e17f72" },
+ { "12345678901234567890123456789012345678901234567890123456789012345678901234567890",
+ "57edf4a22be3c955ac49da2e2107b67a" },
+ { NULL, NULL }
+ };
+ int i = 0;
+ char buf[33];
+
+ while (known_hashes[i].str) {
+ iks_md5 (known_hashes[i].str, buf);
+ if (strcmp (buf, known_hashes[i].hash) != 0) {
+ printf("MD5 hash of \"%s\"\n", known_hashes[i].str);
+ printf(" Result: %s\n", buf);
+ printf(" Expected: %s\n", known_hashes[i].hash);
+ return 1;
+ }
+ i++;
+ }
+ return 0;
+}
diff --git a/test/tst-sax.c b/test/tst-sax.c
new file mode 100644
index 0000000..77a5c13
--- /dev/null
+++ b/test/tst-sax.c
@@ -0,0 +1,384 @@
+/* iksemel (XML parser for Jabber)
+** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
+** This code is free software; you can redistribute it and/or
+** modify it under the terms of GNU Lesser General Public License.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+
+#include "iksemel.h"
+
+struct element_s {
+ struct element_s *next;
+ enum ikstype type;
+
+ enum ikstagtype tag;
+ char *name;
+ int nr_atts;
+ char *atts[10];
+ char *vals[10];
+
+ char *cdata;
+ int len;
+};
+
+struct {
+ char *doc;
+ int len;
+ struct element_s *elements;
+ struct element_s *last_element;
+ struct element_s *cur;
+ int nr_tests;
+ int nr_cur;
+ int blocksize;
+} tester;
+
+void
+document (char *xml)
+{
+ if (tester.elements) {
+ struct element_s *tmp;
+ for (; tester.elements; tester.elements = tmp) {
+ tmp = tester.elements->next;
+ free (tester.elements);
+ }
+ }
+ tester.doc = xml;
+ tester.len = strlen (xml);
+ tester.elements = NULL;
+ tester.last_element = NULL;
+ tester.nr_tests++;
+}
+
+void
+element (enum ikstype type, ...)
+{
+ struct element_s *el;
+ va_list ap;
+ char *tmp;
+
+ el = malloc (sizeof (struct element_s));
+ memset (el, 0, sizeof (struct element_s));
+ el->type = type;
+
+ va_start (ap, type);
+ switch (type) {
+ case IKS_TAG:
+ el->tag = va_arg (ap, int);
+ el->name = va_arg (ap, char*);
+ if (IKS_CLOSE == el->tag) break;
+ while (1) {
+ tmp = va_arg (ap, char*);
+ if (tmp) {
+ el->atts[el->nr_atts] = tmp;
+ el->vals[el->nr_atts] = va_arg (ap, char*);
+ el->nr_atts++;
+ } else {
+ break;
+ }
+ }
+ break;
+ case IKS_CDATA:
+ tmp = va_arg (ap, char*);
+ el->cdata = tmp;
+ el->len = strlen (tmp);
+ break;
+ case IKS_NONE:
+ case IKS_ATTRIBUTE:
+ puts ("invalid element() call");
+ exit (1);
+ }
+ va_end (ap);
+
+ if (NULL == tester.elements) tester.elements = el;
+ if (tester.last_element) tester.last_element->next = el;
+ tester.last_element = el;
+}
+
+#define PRINT_TEST printf ("Sax test %d, blocksize %d, element %d:\n", tester.nr_tests, tester.blocksize, tester.nr_cur)
+#define NEXT_ELEM { tester.cur = tester.cur->next; tester.nr_cur++; }
+
+void
+debug_tag (enum ikstagtype type, char *name, char **atts)
+{
+ int i;
+
+ PRINT_TEST;
+ if (tester.cur && tester.cur->type == IKS_TAG) {
+ switch (tester.cur->tag) {
+ case IKS_OPEN:
+ printf (" Expecting tag <%s>\n", tester.cur->name);
+ break;
+ case IKS_CLOSE:
+ printf (" Expecting tag </%s>\n", tester.cur->name);
+ break;
+ case IKS_SINGLE:
+ printf (" Expecting tag <%s/>\n", tester.cur->name);
+ break;
+ }
+ for (i = 0; i < tester.cur->nr_atts; i++) {
+ printf (" %s='%s'\n", tester.cur->atts[i], tester.cur->vals[i]);
+ }
+ } else {
+ printf (" Not expecting a tag here.\n");
+ }
+ switch (type) {
+ case IKS_OPEN:
+ printf (" Got tag <%s>\n", name);
+ break;
+ case IKS_CLOSE:
+ printf (" Got tag </%s>\n", name);
+ break;
+ case IKS_SINGLE:
+ printf (" Got tag <%s/>\n", name);
+ break;
+ }
+ i = 0;
+ while (atts && atts[i]) {
+ printf (" %s='%s'\n", atts[i], atts[i+1]);
+ i += 2;
+ }
+}
+
+#define TAG_FAIL { debug_tag (type,name,atts); exit (1); }
+
+int
+tagHook (void *udata, char *name, char **atts, int type)
+{
+ int nr, i, flag;
+
+ if (!tester.cur) TAG_FAIL;
+ if (tester.cur->type != IKS_TAG) TAG_FAIL;
+ if (tester.cur->tag != type) TAG_FAIL;
+ if (iks_strcmp (tester.cur->name, name) != 0) TAG_FAIL;
+ if (!atts && tester.cur->nr_atts > 0) TAG_FAIL;
+ if (atts && tester.cur->nr_atts == 0) TAG_FAIL;
+
+ nr = tester.cur->nr_atts;
+ while (nr) {
+ flag = 0;
+ for (i = 0;atts[i]; i+= 2) {
+ if (iks_strcmp (atts[i], tester.cur->atts[nr-1]) == 0 && iks_strcmp (atts[i+1], tester.cur->vals[nr-1]) == 0) {
+ flag = 1;
+ break;
+ }
+ }
+ if (flag == 0) TAG_FAIL;
+ nr--;
+ }
+
+ NEXT_ELEM;
+ return IKS_OK;
+}
+
+void
+debug_cdata (char *data, size_t len, int pos)
+{
+ int i;
+
+ PRINT_TEST;
+ if (tester.cur && tester.cur->type == IKS_CDATA)
+ printf (" Expecting cdata [%s]\n", tester.cur->cdata);
+ else
+ printf (" Not expecting cdata here\n");
+ printf (" Got cdata [");
+ for (i = 0; i < len; i++) putchar (data[i]);
+ printf ("] at the pos %d.\n", pos);
+}
+
+#define CDATA_FAIL { debug_cdata (data, len, pos); exit (1); }
+
+int
+cdataHook (void *udata, char *data, size_t len)
+{
+ static int pos = 0;
+
+ if (!tester.cur) CDATA_FAIL;
+ if (tester.cur->type != IKS_CDATA) CDATA_FAIL;
+ if (iks_strncmp (tester.cur->cdata + pos, data, len) != 0) CDATA_FAIL;
+ pos += len;
+ if (pos > tester.cur->len) CDATA_FAIL;
+ if (pos == tester.cur->len) {
+ pos = 0;
+ NEXT_ELEM;
+ }
+ return IKS_OK;
+}
+
+void
+test_size (int blocksize)
+{
+ enum ikserror err;
+ iksparser *prs;
+ int i, len;
+
+ tester.cur = tester.elements;
+ tester.nr_cur = 1;
+ tester.blocksize = blocksize;
+ len = tester.len;
+
+ prs = iks_sax_new (NULL, tagHook, cdataHook);
+ i = 0;
+ if (0 == blocksize) blocksize = len;
+ while (i < len) {
+ if (i + blocksize > len) blocksize = len - i;
+ err = iks_parse (prs, tester.doc + i, blocksize, 0);
+ switch (err) {
+ case IKS_OK:
+ break;
+ case IKS_NOMEM:
+ exit (1);
+ case IKS_BADXML:
+ PRINT_TEST;
+ printf ("Invalid xml at byte %ld in\n[%s]\n", iks_nr_bytes (prs), tester.doc);
+ exit (1);
+ case IKS_HOOK:
+ exit (1);
+ }
+ i += blocksize;
+ }
+ if (tester.cur) exit (1);
+ iks_parser_delete (prs);
+}
+
+void
+test (void)
+{
+ int i;
+
+ for (i = 0; i < tester.len; i++) {
+ test_size (i);
+ }
+}
+
+void
+test_bad (int badbyte)
+{
+ iksparser *p;
+ enum ikserror err;
+
+ p = iks_sax_new (NULL, NULL, NULL);
+ err = iks_parse (p, tester.doc, tester.len, 1);
+ switch (err) {
+ case IKS_OK:
+ break;
+ case IKS_NOMEM:
+ exit (1);
+ case IKS_BADXML:
+ if (iks_nr_bytes (p) == badbyte) return;
+ break;
+ case IKS_HOOK:
+ exit (1);
+ }
+ printf ("Sax test %d:\n", tester.nr_tests);
+ printf ("Expected bad byte %d, got %ld in\n[%s]\n", badbyte, iks_nr_bytes (p), tester.doc);
+ exit (1);
+}
+
+int
+main (int argc, char *argv[])
+{
+ document ("<lonely/>");
+ element (IKS_TAG, IKS_SINGLE, "lonely", 0);
+ test ();
+
+ document ("<?xml version='1.0'?><parent><child/><child/>child</parent>");
+ element (IKS_TAG, IKS_OPEN, "parent", 0);
+ element (IKS_TAG, IKS_SINGLE, "child", 0);
+ element (IKS_TAG, IKS_SINGLE, "child", 0);
+ element (IKS_CDATA, "child");
+ element (IKS_TAG, IKS_CLOSE, "parent");
+ test ();
+
+ document ("<mytag abc='123' id=\"XC72\"></mytag>");
+ element (IKS_TAG, IKS_OPEN, "mytag", "abc", "123", "id", "XC72", 0);
+ element (IKS_TAG, IKS_CLOSE, "mytag");
+ test ();
+
+ document ("<body>I&apos;m fixing parser&amp;tester for &quot;&lt;&quot; and &quot;&gt;&quot; chars.</body>");
+ element (IKS_TAG, IKS_OPEN, "body", 0);
+ element (IKS_CDATA, "I'm fixing parser&tester for \"<\" and \">\" chars.");
+ element (IKS_TAG, IKS_CLOSE, "body");
+ test ();
+
+ document ("<tag a='1' b='2' c='3' d='4' e='5' f='6' g='7' id='xyz9'><sub></sub></tag>");
+ element (IKS_TAG, IKS_OPEN, "tag", "a", "1", "b", "2", "c", "3", "d", "4", "e", "5", "f", "6", "g", "7", "id", "xyz9", 0);
+ element (IKS_TAG, IKS_OPEN, "sub", 0);
+ element (IKS_TAG, IKS_CLOSE, "sub");
+ element (IKS_TAG, IKS_CLOSE, "tag");
+ test ();
+
+ document ("<item url='http://jabber.org'><!-- little comment -->Jabber Site</item>");
+ element (IKS_TAG, IKS_OPEN, "item", "url", "http://jabber.org", 0);
+ element (IKS_CDATA, "Jabber Site");
+ element (IKS_TAG, IKS_CLOSE, "item");
+ test ();
+
+ document ("<index><!-- <item> - tag has no childs --><item name='lala' page='42'/></index>");
+ element (IKS_TAG, IKS_OPEN, "index", 0);
+ element (IKS_TAG, IKS_SINGLE, "item", "name", "lala", "page", "42", 0);
+ element (IKS_TAG, IKS_CLOSE, "index");
+ test ();
+
+ document ("<ka>1234<![CDATA[ <ka> lala ] ]] ]]] ]]>4321</ka>");
+ element (IKS_TAG, IKS_OPEN, "ka", 0);
+ element (IKS_CDATA, "1234 <ka> lala ] ]] ]]] 4321");
+ element (IKS_TAG, IKS_CLOSE, "ka");
+ test ();
+
+ document ("<test><standalone be='happy'/>abcd<br/>&lt;escape&gt;</test>");
+ element (IKS_TAG, IKS_OPEN, "test", 0);
+ element (IKS_TAG, IKS_SINGLE, "standalone", "be", "happy", 0);
+ element (IKS_CDATA, "abcd");
+ element (IKS_TAG, IKS_SINGLE, "br", 0);
+ element (IKS_CDATA, "<escape>");
+ element (IKS_TAG, IKS_CLOSE, "test");
+ test ();
+
+ document ("<a><b>john&amp;mary<c><d e='f' g='123456' h='madcat' klm='nop'/></c></b></a>");
+ element (IKS_TAG, IKS_OPEN, "a", 0);
+ element (IKS_TAG, IKS_OPEN, "b", 0);
+ element (IKS_CDATA, "john&mary");
+ element (IKS_TAG, IKS_OPEN, "c", 0);
+ element (IKS_TAG, IKS_SINGLE, "d", "e", "f", "g", "123456", "h", "madcat", "klm", "nop", 0);
+ element (IKS_TAG, IKS_CLOSE, "c", 0);
+ element (IKS_TAG, IKS_CLOSE, "b", 0);
+ element (IKS_TAG, IKS_CLOSE, "a", 0);
+ test ();
+
+ document ("<test>\xFF</test>");
+ test_bad (6);
+
+ document ("<t\0></t>");
+ tester.len = 8;
+ test_bad (2);
+
+ document ("<a><b/><c></c/></a>");
+ test_bad (13);
+
+ document ("<e><!-- -- --></e>");
+ test_bad (10);
+
+ document ("<g><test a='123'/ b='lala'></g>");
+ test_bad (17);
+
+ document ("<ha><!-- <lala> --><!- comment -></ha>");
+ test_bad (22);
+
+ document ("<lol>&lt;<&gt;</lol>");
+ test_bad (16);
+
+ document ("<a>\xC0\x80</a>");
+ test_bad (3);
+
+ document ("<\x8F\x85></\x8F\x85>");
+ test_bad (1);
+
+ document ("<utf8>\xC1\x80<br/>\xED\x95\x9C\xEA\xB5\xAD\xEC\x96\xB4<err>\xC1\x65</err></utf8>");
+ test_bad (28);
+
+ return 0;
+}
diff --git a/test/tst-sha.c b/test/tst-sha.c
new file mode 100644
index 0000000..ff6b3e3
--- /dev/null
+++ b/test/tst-sha.c
@@ -0,0 +1,38 @@
+/* iksemel (XML parser for Jabber)
+** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
+** This code is free software; you can redistribute it and/or
+** modify it under the terms of GNU Lesser General Public License.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "iksemel.h"
+
+int main (int argc, char *argv[])
+{
+ struct lala {
+ char *str;
+ char *hash;
+ } known_hashes[] = {
+ { "abc", "a9993e364706816aba3e25717850c26c9cd0d89d" },
+ { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+ "84983e441c3bd26ebaae4aa1f95129e5e54670f1" },
+ { NULL, NULL }
+ };
+ int i = 0;
+ char buf[42];
+
+ while (known_hashes[i].str) {
+ iks_sha (known_hashes[i].str, buf);
+ if (strcmp (buf, known_hashes[i].hash) != 0) {
+ printf("SHA1 hash of \"%s\"\n", known_hashes[i].str);
+ printf(" Result: %s\n", buf);
+ printf(" Expected: %s\n", known_hashes[i].hash);
+ return 1;
+ }
+ i++;
+ }
+ return 0;
+}