Commit 561a9392 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

added some simple unit tests using CppUnit.


git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@94 e5f2f494-b856-4b98-b285-d166d9295462
parent 6deb954c
......@@ -110,6 +110,9 @@ CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CPPUNIT_INCLUDES = @CPPUNIT_INCLUDES@
CPPUNIT_LDADD = @CPPUNIT_LDADD@
CPPUNIT_LDFLAGS = @CPPUNIT_LDFLAGS@
CXX = @CXX@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
......
......@@ -595,6 +595,11 @@ ac_subst_vars='am__EXEEXT_FALSE
am__EXEEXT_TRUE
LTLIBOBJS
LIBOBJS
CPPUNIT_LDADD
CPPUNIT_LDFLAGS
CPPUNIT_INCLUDES
HAVE_CPPUNIT_FALSE
HAVE_CPPUNIT_TRUE
EGREP
GREP
CPP
......@@ -686,6 +691,7 @@ ac_subst_files=''
ac_user_opts='
enable_option_checking
enable_dependency_tracking
with_cppunit
'
ac_precious_vars='build_alias
host_alias
......@@ -1317,6 +1323,11 @@ Optional Features:
--disable-dependency-tracking speeds up one-time build
--enable-dependency-tracking do not reject slow dependency extractors
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-cppunit=PATH specify a path to CppUnit header files (PATH/include) and library (PATH/lib)
Some influential environment variables:
CXX C++ compiler command
CXXFLAGS C++ compiler flags
......@@ -4464,6 +4475,39 @@ _ACEOF
fi
#
# Check availablity of CppUnit, which will be used for unit tests.
#
# Check whether --with-cppunit was given.
if test "${with_cppunit+set}" = set; then :
withval=$with_cppunit; cppunit_path="$withval"
else
cppunit_path="no"
fi
if test "$cppunit_path" != "no"
then
CPPUNIT_INCLUDES="-I${cppunit_path}/include"
CPPUNIT_LDFLAGS="-L${cppunit_path}/lib"
CPPUNIT_LDADD="-lcppunit"
else
CPPUNIT_INCLUDES=
CPPUNIT_LDFLAGS=
CPPUNIT_LDADD=
fi
if test $cppunit_path != "no"; then
HAVE_CPPUNIT_TRUE=
HAVE_CPPUNIT_FALSE='#'
else
HAVE_CPPUNIT_TRUE='#'
HAVE_CPPUNIT_FALSE=
fi
# Checks for library functions.
ac_config_files="$ac_config_files Makefile src/Makefile src/lib/Makefile src/lib/dns/Makefile"
......@@ -4585,6 +4629,10 @@ if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
as_fn_error "conditional \"am__fastdepCC\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${HAVE_CPPUNIT_TRUE}" && test -z "${HAVE_CPPUNIT_FALSE}"; then
as_fn_error "conditional \"HAVE_CPPUNIT\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
: ${CONFIG_STATUS=./config.status}
ac_write_fail=0
......
......@@ -20,6 +20,27 @@ AC_PROG_RANLIB
AC_HEADER_STDBOOL
AC_TYPE_SIZE_T
#
# Check availablity of CppUnit, which will be used for unit tests.
#
AC_ARG_WITH(cppunit,
[ --with-cppunit=PATH specify a path to CppUnit header files (PATH/include) and library (PATH/lib)],
cppunit_path="$withval", cppunit_path="no")
if test "$cppunit_path" != "no"
then
CPPUNIT_INCLUDES="-I${cppunit_path}/include"
CPPUNIT_LDFLAGS="-L${cppunit_path}/lib"
CPPUNIT_LDADD="-lcppunit"
else
CPPUNIT_INCLUDES=
CPPUNIT_LDFLAGS=
CPPUNIT_LDADD=
fi
AM_CONDITIONAL(HAVE_CPPUNIT, test $cppunit_path != "no")
AC_SUBST(CPPUNIT_INCLUDES)
AC_SUBST(CPPUNIT_LDFLAGS)
AC_SUBST(CPPUNIT_LDADD)
# Checks for library functions.
AC_CONFIG_FILES([Makefile
......
......@@ -95,6 +95,9 @@ CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CPPUNIT_INCLUDES = @CPPUNIT_INCLUDES@
CPPUNIT_LDADD = @CPPUNIT_LDADD@
CPPUNIT_LDFLAGS = @CPPUNIT_LDFLAGS@
CXX = @CXX@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
......
......@@ -95,6 +95,9 @@ CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CPPUNIT_INCLUDES = @CPPUNIT_INCLUDES@
CPPUNIT_LDADD = @CPPUNIT_LDADD@
CPPUNIT_LDFLAGS = @CPPUNIT_LDFLAGS@
CXX = @CXX@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
......
......@@ -2,3 +2,16 @@ AM_CPPFLAGS = -I$(top_srcdir)/src/lib
lib_LIBRARIES = libdns.a
libdns_a_SOURCES = name.cc name.h
if HAVE_CPPUNIT
TEST_PROGRAM = run_unittests
else
TEST_PROGRAM =
endif
TESTS = $(TEST_PROGRAM)
noinst_PROGRAMS = $(TEST_PROGRAM)
run_unittests_SOURCES = name_unittest.cc name_unittest.h run_unittests.cc
run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(CPPUNIT_INCLUDES)
run_unittests_LDFLAGS = $(CPPUNIT_LDFLAGS)
run_unittests_LDADD = ./libdns.a $(CPPUNIT_LDADD)
......@@ -15,6 +15,7 @@
@SET_MAKE@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
......@@ -32,6 +33,8 @@ POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
TESTS = $(am__EXEEXT_1)
noinst_PROGRAMS = $(am__EXEEXT_1)
subdir = src/lib/dns
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
......@@ -71,6 +74,15 @@ libdns_a_AR = $(AR) $(ARFLAGS)
libdns_a_LIBADD =
am_libdns_a_OBJECTS = name.$(OBJEXT)
libdns_a_OBJECTS = $(am_libdns_a_OBJECTS)
@HAVE_CPPUNIT_TRUE@am__EXEEXT_1 = run_unittests$(EXEEXT)
PROGRAMS = $(noinst_PROGRAMS)
am_run_unittests_OBJECTS = run_unittests-name_unittest.$(OBJEXT) \
run_unittests-run_unittests.$(OBJEXT)
run_unittests_OBJECTS = $(am_run_unittests_OBJECTS)
am__DEPENDENCIES_1 =
run_unittests_DEPENDENCIES = ./libdns.a $(am__DEPENDENCIES_1)
run_unittests_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \
$(run_unittests_LDFLAGS) $(LDFLAGS) -o $@
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
......@@ -84,10 +96,12 @@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(libdns_a_SOURCES)
DIST_SOURCES = $(libdns_a_SOURCES)
SOURCES = $(libdns_a_SOURCES) $(run_unittests_SOURCES)
DIST_SOURCES = $(libdns_a_SOURCES) $(run_unittests_SOURCES)
ETAGS = etags
CTAGS = ctags
am__tty_colors = \
red=; grn=; lgn=; blu=; std=
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
......@@ -100,6 +114,9 @@ CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CPPUNIT_INCLUDES = @CPPUNIT_INCLUDES@
CPPUNIT_LDADD = @CPPUNIT_LDADD@
CPPUNIT_LDFLAGS = @CPPUNIT_LDFLAGS@
CXX = @CXX@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
......@@ -183,6 +200,12 @@ top_srcdir = @top_srcdir@
AM_CPPFLAGS = -I$(top_srcdir)/src/lib
lib_LIBRARIES = libdns.a
libdns_a_SOURCES = name.cc name.h
@HAVE_CPPUNIT_FALSE@TEST_PROGRAM =
@HAVE_CPPUNIT_TRUE@TEST_PROGRAM = run_unittests
run_unittests_SOURCES = name_unittest.cc name_unittest.h run_unittests.cc
run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(CPPUNIT_INCLUDES)
run_unittests_LDFLAGS = $(CPPUNIT_LDFLAGS)
run_unittests_LDADD = ./libdns.a $(CPPUNIT_LDADD)
all: all-am
.SUFFIXES:
......@@ -254,6 +277,12 @@ libdns.a: $(libdns_a_OBJECTS) $(libdns_a_DEPENDENCIES)
$(libdns_a_AR) libdns.a $(libdns_a_OBJECTS) $(libdns_a_LIBADD)
$(RANLIB) libdns.a
clean-noinstPROGRAMS:
-test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
run_unittests$(EXEEXT): $(run_unittests_OBJECTS) $(run_unittests_DEPENDENCIES)
@rm -f run_unittests$(EXEEXT)
$(run_unittests_LINK) $(run_unittests_OBJECTS) $(run_unittests_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
......@@ -261,6 +290,8 @@ distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/name.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run_unittests-name_unittest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run_unittests-run_unittests.Po@am__quote@
.cc.o:
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
......@@ -276,6 +307,34 @@ distclean-compile:
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
run_unittests-name_unittest.o: name_unittest.cc
@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-name_unittest.o -MD -MP -MF $(DEPDIR)/run_unittests-name_unittest.Tpo -c -o run_unittests-name_unittest.o `test -f 'name_unittest.cc' || echo '$(srcdir)/'`name_unittest.cc
@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/run_unittests-name_unittest.Tpo $(DEPDIR)/run_unittests-name_unittest.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='name_unittest.cc' object='run_unittests-name_unittest.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-name_unittest.o `test -f 'name_unittest.cc' || echo '$(srcdir)/'`name_unittest.cc
run_unittests-name_unittest.obj: name_unittest.cc
@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-name_unittest.obj -MD -MP -MF $(DEPDIR)/run_unittests-name_unittest.Tpo -c -o run_unittests-name_unittest.obj `if test -f 'name_unittest.cc'; then $(CYGPATH_W) 'name_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/name_unittest.cc'; fi`
@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/run_unittests-name_unittest.Tpo $(DEPDIR)/run_unittests-name_unittest.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='name_unittest.cc' object='run_unittests-name_unittest.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-name_unittest.obj `if test -f 'name_unittest.cc'; then $(CYGPATH_W) 'name_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/name_unittest.cc'; fi`
run_unittests-run_unittests.o: run_unittests.cc
@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-run_unittests.o -MD -MP -MF $(DEPDIR)/run_unittests-run_unittests.Tpo -c -o run_unittests-run_unittests.o `test -f 'run_unittests.cc' || echo '$(srcdir)/'`run_unittests.cc
@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/run_unittests-run_unittests.Tpo $(DEPDIR)/run_unittests-run_unittests.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='run_unittests.cc' object='run_unittests-run_unittests.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-run_unittests.o `test -f 'run_unittests.cc' || echo '$(srcdir)/'`run_unittests.cc
run_unittests-run_unittests.obj: run_unittests.cc
@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-run_unittests.obj -MD -MP -MF $(DEPDIR)/run_unittests-run_unittests.Tpo -c -o run_unittests-run_unittests.obj `if test -f 'run_unittests.cc'; then $(CYGPATH_W) 'run_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/run_unittests.cc'; fi`
@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/run_unittests-run_unittests.Tpo $(DEPDIR)/run_unittests-run_unittests.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='run_unittests.cc' object='run_unittests-run_unittests.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-run_unittests.obj `if test -f 'run_unittests.cc'; then $(CYGPATH_W) 'run_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/run_unittests.cc'; fi`
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
......@@ -328,6 +387,98 @@ GTAGS:
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 \
echo "$$grn$$dashes"; \
else \
echo "$$red$$dashes"; \
fi; \
echo "$$banner"; \
test -z "$$skipped" || echo "$$skipped"; \
test -z "$$report" || echo "$$report"; \
echo "$$dashes$$std"; \
test "$$failed" -eq 0; \
else :; fi
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
......@@ -359,8 +510,9 @@ distdir: $(DISTFILES)
fi; \
done
check-am: all-am
$(MAKE) $(AM_MAKEFLAGS) check-TESTS
check: check-am
all-am: Makefile $(LIBRARIES)
all-am: Makefile $(LIBRARIES) $(PROGRAMS)
installdirs:
for dir in "$(DESTDIR)$(libdir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
......@@ -392,7 +544,8 @@ maintainer-clean-generic:
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libLIBRARIES mostlyclean-am
clean-am: clean-generic clean-libLIBRARIES clean-noinstPROGRAMS \
mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
......@@ -459,17 +612,18 @@ ps-am:
uninstall-am: uninstall-libLIBRARIES
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libLIBRARIES ctags distclean distclean-compile \
distclean-generic 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-libLIBRARIES install-man install-pdf \
install-pdf-am install-ps install-ps-am install-strip \
installcheck installcheck-am installdirs maintainer-clean \
.MAKE: check-am install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
clean-generic clean-libLIBRARIES clean-noinstPROGRAMS ctags \
distclean distclean-compile distclean-generic 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-libLIBRARIES 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 pdf pdf-am ps ps-am tags uninstall \
uninstall-am uninstall-libLIBRARIES
......
......@@ -264,33 +264,13 @@ Name::from_string(const string &namestring)
labels++;
//INSIST(labels <= 127);
offsets_[labels] = nused;
// added a trailing \0
ndata_.push_back('\0');
++labels;
++nused;
offsets_[labels] = nused;
}
#ifdef notyet
if (origin != NULL) {
if (nrem < origin.length_)
throw ISCNoSpace();
pos = 0;
n1 = origin.length_;
nrem -= n1;
while (n1 > 0) {
n2 = origin.ndata[pos++];
INSIST(n2 <= 63); /* no bitstring support */
ndata.push_back(n2);
n1 -= n2 + 1;
nused += n2 + 1;
while (n2 > 0) {
c = origin.ndata[pos++];
ndata.push_back(c);
n2--;
}
labels++;
if (n1 > 0) {
INSIST(labels <= 127);
offsets[labels] = nused;
}
}
}
#endif
}
labels_ = labels;
......
// Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
// $Id$
#include <string>
#include <cppunit/TestAssert.h>
#include <dns/name.h>
#include <dns/name_unittest.h>
using ISC::DNS::Name;
void
NameTest::get_length()
{
Name name("www.example.cam");
//01234567890123456 => length should be 17.
CPPUNIT_ASSERT_EQUAL(17, static_cast<int>(name.get_length()));
}
void
NameTest::to_text()
{
Name name("www.isc.org");
CPPUNIT_ASSERT_EQUAL(std::string("www.isc.org"), name.to_text(true));
CPPUNIT_ASSERT_EQUAL(std::string("www.isc.org."), name.to_text(false));
}
/*
* Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id$ */
#ifndef __NAME_UNITTEST_H
#define __NAME_UNITTEST_H 1
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/TestFixture.h>
class NameTest : public CppUnit::TestFixture {
public:
void get_length();
void to_text();
//static CppUnit::Test* suite();
CPPUNIT_TEST_SUITE(NameTest);
CPPUNIT_TEST(get_length);
CPPUNIT_TEST(to_text);
CPPUNIT_TEST_SUITE_END();
};
#endif // __NAME_UNITTEST_H
// Local Variables:
// mode: c++
// End:
// Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
// $Id$
#include <iostream>
#include <stdexcept>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/TestCase.h>
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>
#include <cppunit/TextTestProgressListener.h>
#include <dns/name_unittest.h>
int
main(int argc, char* argv[])
{
CppUnit::TestRunner runner;
CppUnit::TestResult controller;
// Add a listener that colllects test result
CppUnit::TestResultCollector result;
controller.addListener( &result );
// Add a listener that print dots as test run.
CppUnit::TextTestProgressListener progress;
controller.addListener(&progress);
runner.addTest(NameTest::suite());
try {
std::cout << "Running ";
runner.run(controller, "");
std::cerr << std::endl;
// Print test in a compiler compatible format.
CppUnit::CompilerOutputter outputter(&result, std::cerr);
outputter.write();
} catch (std::invalid_argument& e) { // Test path not resolved
std::cerr << std::endl
<< "ERROR: " << e.what()
<< std::endl;
return 0;
}
return (result.wasSuccessful() ? 0 : 1);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!