aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJonathan McCrohan <jmccrohan@gmail.com>2011-12-01 22:56:23 +0000
committerJonathan McCrohan <jmccrohan@gmail.com>2011-12-01 22:56:23 +0000
commit429e46051dba814e7d6c74368eb1bba550222cbe (patch)
treeed1dd43cd23c69f156aae2165006a16a66262cef /tests
parent58bf1382be0cbcf3f9649286fd2719b789a1595f (diff)
downloadlibconfig-429e46051dba814e7d6c74368eb1bba550222cbe.tar.gz
Imported Upstream version 1.4.8upstream/1.4.8
Diffstat (limited to '')
-rw-r--r--tests/Makefile.am15
-rw-r--r--tests/Makefile.in503
-rw-r--r--tests/testdata/bad_input_0.cfg1
-rw-r--r--tests/testdata/bad_input_1.cfg7
-rw-r--r--tests/testdata/input_0.cfg0
-rw-r--r--tests/testdata/input_1.cfg3
-rw-r--r--tests/testdata/input_2.cfg18
-rw-r--r--tests/testdata/input_3.cfg7
-rw-r--r--tests/testdata/input_4.cfg8
-rw-r--r--tests/testdata/input_5.cfg1
-rw-r--r--tests/testdata/more.cfg2
-rw-r--r--tests/testdata/output_0.cfg0
-rw-r--r--tests/testdata/output_1.cfg0
-rw-r--r--tests/testdata/output_2.cfg3
-rw-r--r--tests/testdata/output_3.cfg3
-rw-r--r--tests/testdata/output_4.cfg2
-rw-r--r--tests/testdata/output_5.cfg1
-rw-r--r--tests/testdata/parse_error_0.txt1
-rw-r--r--tests/testdata/parse_error_1.txt1
-rw-r--r--tests/tests.c216
-rw-r--r--tests/tests.vcproj237
21 files changed, 1029 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 0000000..5d773f1
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,15 @@
+
+noinst_PROGRAMS = libconfig_tests
+
+libconfig_tests_SOURCES = tests.c
+
+libconfig_tests_CPPFLAGS = -I../tinytest -I../lib
+
+libconfig_tests_LDADD = -L../tinytest -ltinytest \
+ -L../lib/.libs -lconfig
+
+
+EXTRA_DIST = \
+ tests.vcproj \
+ testdata/*.cfg \
+ testdata/*.txt
diff --git a/tests/Makefile.in b/tests/Makefile.in
new file mode 100644
index 0000000..c9f388f
--- /dev/null
+++ b/tests/Makefile.in
@@ -0,0 +1,503 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 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@
+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@
+target_triplet = @target@
+noinst_PROGRAMS = libconfig_tests$(EXEEXT)
+subdir = tests
+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 = $(SHELL) $(top_srcdir)/aux-build/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/ac_config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+PROGRAMS = $(noinst_PROGRAMS)
+am_libconfig_tests_OBJECTS = libconfig_tests-tests.$(OBJEXT)
+libconfig_tests_OBJECTS = $(am_libconfig_tests_OBJECTS)
+libconfig_tests_DEPENDENCIES =
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/aux-build/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 = $(libconfig_tests_SOURCES)
+DIST_SOURCES = $(libconfig_tests_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+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@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+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@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+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@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+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@
+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 = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+libconfig_tests_SOURCES = tests.c
+libconfig_tests_CPPFLAGS = -I../tinytest -I../lib
+libconfig_tests_LDADD = -L../tinytest -ltinytest \
+ -L../lib/.libs -lconfig
+
+EXTRA_DIST = \
+ tests.vcproj \
+ testdata/*.cfg \
+ testdata/*.txt
+
+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-noinstPROGRAMS:
+ @list='$(noinst_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
+libconfig_tests$(EXEEXT): $(libconfig_tests_OBJECTS) $(libconfig_tests_DEPENDENCIES)
+ @rm -f libconfig_tests$(EXEEXT)
+ $(LINK) $(libconfig_tests_OBJECTS) $(libconfig_tests_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libconfig_tests-tests.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 $@ $<
+
+libconfig_tests-tests.o: tests.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig_tests_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libconfig_tests-tests.o -MD -MP -MF $(DEPDIR)/libconfig_tests-tests.Tpo -c -o libconfig_tests-tests.o `test -f 'tests.c' || echo '$(srcdir)/'`tests.c
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libconfig_tests-tests.Tpo $(DEPDIR)/libconfig_tests-tests.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tests.c' object='libconfig_tests-tests.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig_tests_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libconfig_tests-tests.o `test -f 'tests.c' || echo '$(srcdir)/'`tests.c
+
+libconfig_tests-tests.obj: tests.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig_tests_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libconfig_tests-tests.obj -MD -MP -MF $(DEPDIR)/libconfig_tests-tests.Tpo -c -o libconfig_tests-tests.obj `if test -f 'tests.c'; then $(CYGPATH_W) 'tests.c'; else $(CYGPATH_W) '$(srcdir)/tests.c'; fi`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libconfig_tests-tests.Tpo $(DEPDIR)/libconfig_tests-tests.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tests.c' object='libconfig_tests-tests.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig_tests_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libconfig_tests-tests.obj `if test -f 'tests.c'; then $(CYGPATH_W) 'tests.c'; else $(CYGPATH_W) '$(srcdir)/tests.c'; fi`
+
+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
+
+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
+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)
+ -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."
+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-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: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check 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-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/testdata/bad_input_0.cfg b/tests/testdata/bad_input_0.cfg
new file mode 100644
index 0000000..587be6b
--- /dev/null
+++ b/tests/testdata/bad_input_0.cfg
@@ -0,0 +1 @@
+x
diff --git a/tests/testdata/bad_input_1.cfg b/tests/testdata/bad_input_1.cfg
new file mode 100644
index 0000000..ee788b6
--- /dev/null
+++ b/tests/testdata/bad_input_1.cfg
@@ -0,0 +1,7 @@
+
+foo:
+{
+ a = 100;
+ b = 10;
+ a = "hello";
+};
diff --git a/tests/testdata/input_0.cfg b/tests/testdata/input_0.cfg
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/testdata/input_0.cfg
diff --git a/tests/testdata/input_1.cfg b/tests/testdata/input_1.cfg
new file mode 100644
index 0000000..131bb5e
--- /dev/null
+++ b/tests/testdata/input_1.cfg
@@ -0,0 +1,3 @@
+// Empty file
+
+// (no settings, only comments)
diff --git a/tests/testdata/input_2.cfg b/tests/testdata/input_2.cfg
new file mode 100644
index 0000000..e342dca
--- /dev/null
+++ b/tests/testdata/input_2.cfg
@@ -0,0 +1,18 @@
+
+// File with extraneous whitespace.
+
+ foo = 1;
+
+
+
+ bar
+ =
+ "Hello, "
+ "world!"
+;
+
+
+baz = 2;
+
+
+
diff --git a/tests/testdata/input_3.cfg b/tests/testdata/input_3.cfg
new file mode 100644
index 0000000..ce71ad6
--- /dev/null
+++ b/tests/testdata/input_3.cfg
@@ -0,0 +1,7 @@
+// File has no trailing newline.
+
+foo = 1;
+
+bar = 2;
+
+baz = 3; \ No newline at end of file
diff --git a/tests/testdata/input_4.cfg b/tests/testdata/input_4.cfg
new file mode 100644
index 0000000..f803875
--- /dev/null
+++ b/tests/testdata/input_4.cfg
@@ -0,0 +1,8 @@
+// Last line has whitespace but no trailing newline.
+
+foo = 1;
+
+
+bar = 2;
+
+ \ No newline at end of file
diff --git a/tests/testdata/input_5.cfg b/tests/testdata/input_5.cfg
new file mode 100644
index 0000000..777a424
--- /dev/null
+++ b/tests/testdata/input_5.cfg
@@ -0,0 +1 @@
+@include "more.cfg"
diff --git a/tests/testdata/more.cfg b/tests/testdata/more.cfg
new file mode 100644
index 0000000..dad36e1
--- /dev/null
+++ b/tests/testdata/more.cfg
@@ -0,0 +1,2 @@
+
+message = "Hello, world!";
diff --git a/tests/testdata/output_0.cfg b/tests/testdata/output_0.cfg
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/testdata/output_0.cfg
diff --git a/tests/testdata/output_1.cfg b/tests/testdata/output_1.cfg
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/testdata/output_1.cfg
diff --git a/tests/testdata/output_2.cfg b/tests/testdata/output_2.cfg
new file mode 100644
index 0000000..80db4ae
--- /dev/null
+++ b/tests/testdata/output_2.cfg
@@ -0,0 +1,3 @@
+foo = 1;
+bar = "Hello, world!";
+baz = 2;
diff --git a/tests/testdata/output_3.cfg b/tests/testdata/output_3.cfg
new file mode 100644
index 0000000..6a3d003
--- /dev/null
+++ b/tests/testdata/output_3.cfg
@@ -0,0 +1,3 @@
+foo = 1;
+bar = 2;
+baz = 3;
diff --git a/tests/testdata/output_4.cfg b/tests/testdata/output_4.cfg
new file mode 100644
index 0000000..78abe90
--- /dev/null
+++ b/tests/testdata/output_4.cfg
@@ -0,0 +1,2 @@
+foo = 1;
+bar = 2;
diff --git a/tests/testdata/output_5.cfg b/tests/testdata/output_5.cfg
new file mode 100644
index 0000000..25817c4
--- /dev/null
+++ b/tests/testdata/output_5.cfg
@@ -0,0 +1 @@
+message = "Hello, world!";
diff --git a/tests/testdata/parse_error_0.txt b/tests/testdata/parse_error_0.txt
new file mode 100644
index 0000000..dd4f68c
--- /dev/null
+++ b/tests/testdata/parse_error_0.txt
@@ -0,0 +1 @@
+2 syntax error
diff --git a/tests/testdata/parse_error_1.txt b/tests/testdata/parse_error_1.txt
new file mode 100644
index 0000000..ce70b88
--- /dev/null
+++ b/tests/testdata/parse_error_1.txt
@@ -0,0 +1 @@
+6 duplicate setting name
diff --git a/tests/tests.c b/tests/tests.c
new file mode 100644
index 0000000..298c402
--- /dev/null
+++ b/tests/tests.c
@@ -0,0 +1,216 @@
+/* ----------------------------------------------------------------------------
+ libconfig - A library for processing structured configuration files
+ Copyright (C) 2005-2010 Mark A Lindner
+
+ This file is part of libconfig.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, see
+ <http://www.gnu.org/licenses/>.
+ ----------------------------------------------------------------------------
+*/
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+#include <libconfig.h>
+#include <tinytest.h>
+
+/* ------------------------------------------------------------------------- */
+
+static void parse_and_compare(const char *input_file, const char *output_file)
+{
+ config_t cfg;
+ int ok;
+
+ config_init(&cfg);
+ config_set_include_dir(&cfg, "./testdata");
+
+ ok = config_read_file(&cfg, input_file);
+ if(!ok)
+ {
+ printf("error: %s:%d\n", config_error_text(&cfg),
+ config_error_line(&cfg));
+ }
+ TT_ASSERT_TRUE(ok);
+
+ remove("temp.cfg");
+ TT_ASSERT_TRUE(config_write_file(&cfg, "temp.cfg"));
+
+ TT_ASSERT_FILE_EQ("temp.cfg", output_file);
+ remove("temp.cfg");
+
+ config_destroy(&cfg);
+}
+
+static void parse_file_and_compare_error(const char *input_file,
+ const char *parse_error)
+{
+ config_t cfg;
+ char actual_error[128];
+ char expected_error[128];
+
+ config_init(&cfg);
+ TT_ASSERT_FALSE(config_read_file(&cfg, input_file));
+
+ snprintf(expected_error, sizeof(expected_error), "%s:%s",
+ input_file, parse_error);
+
+ snprintf(actual_error, sizeof(actual_error), "%s:%d %s\n",
+ config_error_file(&cfg), config_error_line(&cfg),
+ config_error_text(&cfg));
+
+ config_destroy(&cfg);
+
+ TT_ASSERT_STR_EQ(actual_error, expected_error);
+}
+
+static void parse_string_and_compare_error(const char *input_text,
+ const char *parse_error)
+{
+ config_t cfg;
+ char actual_error[128];
+ char expected_error[128];
+
+ config_init(&cfg);
+ TT_ASSERT_FALSE(config_read_string(&cfg, input_text));
+
+ snprintf(expected_error, sizeof(expected_error), "(null):%s", parse_error);
+
+ snprintf(actual_error, sizeof(actual_error), "%s:%d %s\n",
+ config_error_file(&cfg), config_error_line(&cfg),
+ config_error_text(&cfg));
+
+ config_destroy(&cfg);
+
+ TT_ASSERT_STR_EQ(actual_error, expected_error);
+}
+
+static const char *read_file_to_string(const char *file)
+{
+ struct stat stbuf;
+ FILE *fp;
+ int size;
+ char *buf;
+ size_t r;
+
+ TT_ASSERT_INT_EQ(0, stat(file, &stbuf));
+
+ size = stbuf.st_size;
+ buf = (char *)malloc(size + 1);
+
+ fp = fopen(file, "rt");
+ TT_ASSERT_PTR_NOTNULL(fp);
+
+ r = fread(buf, 1, size, fp);
+ fclose(fp);
+
+ TT_ASSERT_INT_EQ(size, r);
+
+ *(buf + size) = 0;
+ return(buf);
+}
+
+/* ------------------------------------------------------------------------- */
+
+TT_TEST(ParsingAndFormatting)
+{
+ int i;
+
+ for(i = 0;; ++i)
+ {
+ char input_file[128], output_file[128];
+ sprintf(input_file, "testdata/input_%d.cfg", i);
+ sprintf(output_file, "testdata/output_%d.cfg", i);
+ printf("parsing %s\n", input_file);
+
+ if((access(input_file, F_OK) != 0) || (access(output_file, F_OK) != 0))
+ break;
+
+ parse_and_compare(input_file, output_file);
+ }
+}
+
+/* ------------------------------------------------------------------------- */
+
+TT_TEST(ParseInvalidFiles)
+{
+ int i;
+
+ for(i = 0;; ++i)
+ {
+ char input_file[128], error_file[128];
+ char error_text[128];
+ FILE *fp;
+
+ sprintf(input_file, "testdata/bad_input_%d.cfg", i);
+ sprintf(error_file, "testdata/parse_error_%d.txt", i);
+
+ if((access(input_file, F_OK) != 0) || (access(error_file, F_OK) != 0))
+ break;
+
+ fp = fopen(error_file, "rt");
+ TT_ASSERT_PTR_NOTNULL(fp);
+ TT_ASSERT_PTR_NOTNULL(fgets(error_text, sizeof(error_text), fp));
+ fclose(fp);
+
+ parse_file_and_compare_error(input_file, error_text);
+ }
+}
+
+/* ------------------------------------------------------------------------- */
+
+TT_TEST(ParseInvalidStrings)
+{
+ int i;
+
+ for(i = 0;; ++i)
+ {
+ char input_file[128], error_file[128];
+ const char *input_text;
+ char error_text[128];
+ FILE *fp;
+
+ sprintf(input_file, "testdata/bad_input_%d.cfg", i);
+ sprintf(error_file, "testdata/parse_error_%d.txt", i);
+
+ if((access(input_file, F_OK) != 0) || (access(error_file, F_OK) != 0))
+ break;
+
+ input_text = read_file_to_string(input_file);
+
+ fp = fopen(error_file, "rt");
+ TT_ASSERT_PTR_NOTNULL(fp);
+ TT_ASSERT_PTR_NOTNULL(fgets(error_text, sizeof(error_text), fp));
+ fclose(fp);
+
+ parse_string_and_compare_error(input_text, error_text);
+
+ free((void *)input_text);
+ }
+}
+
+/* ------------------------------------------------------------------------- */
+
+int main(int argc, char **argv)
+{
+ TT_SUITE_START(LibConfigTests);
+ TT_SUITE_TEST(LibConfigTests, ParsingAndFormatting);
+ TT_SUITE_TEST(LibConfigTests, ParseInvalidFiles);
+ TT_SUITE_TEST(LibConfigTests, ParseInvalidStrings);
+ TT_SUITE_RUN(LibConfigTests);
+ TT_SUITE_END(LibConfigTests);
+
+ return(0);
+}
diff --git a/tests/tests.vcproj b/tests/tests.vcproj
new file mode 100644
index 0000000..545caef
--- /dev/null
+++ b/tests/tests.vcproj
@@ -0,0 +1,237 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="libconfig_tests"
+ ProjectGUID="{E4FF1E84-9D5A-4A45-A5E5-8B99CA895172}"
+ RootNamespace="libconfig_tests"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ProjectName).$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../lib;../tinytest"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ RuntimeLibrary="3"
+ CompileAs="1"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ProjectName).$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../lib;../tinytest"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ CompileAs="1"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ >
+ <File
+ RelativePath=".\tests.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ >
+ </Filter>
+ <Filter
+ Name="Data Files"
+ >
+ <File
+ RelativePath=".\testdata\bad_input_0.cfg"
+ >
+ </File>
+ <File
+ RelativePath=".\testdata\bad_input_1.cfg"
+ >
+ </File>
+ <File
+ RelativePath=".\testdata\input_0.cfg"
+ >
+ </File>
+ <File
+ RelativePath=".\testdata\input_1.cfg"
+ >
+ </File>
+ <File
+ RelativePath=".\testdata\input_2.cfg"
+ >
+ </File>
+ <File
+ RelativePath=".\testdata\input_3.cfg"
+ >
+ </File>
+ <File
+ RelativePath=".\testdata\input_4.cfg"
+ >
+ </File>
+ <File
+ RelativePath=".\testdata\output_0.cfg"
+ >
+ </File>
+ <File
+ RelativePath=".\testdata\output_1.cfg"
+ >
+ </File>
+ <File
+ RelativePath=".\testdata\output_2.cfg"
+ >
+ </File>
+ <File
+ RelativePath=".\testdata\output_3.cfg"
+ >
+ </File>
+ <File
+ RelativePath=".\testdata\output_4.cfg"
+ >
+ </File>
+ <File
+ RelativePath=".\testdata\parse_error_0.txt"
+ >
+ </File>
+ <File
+ RelativePath=".\testdata\parse_error_1.txt"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>