From: Steve Brokenshire Date: Tue, 24 Nov 2015 09:25:43 +0000 (+0000) Subject: Added unit testing. Unit testing is under inital development. X-Git-Tag: release-0.05~4 X-Git-Url: http://Server1/repobrowser/?a=commitdiff_plain;h=e7eaa503e46395e1126c901b1ff0d25388259ba5;p=xestiaab%2F.git Added unit testing. Unit testing is under inital development. --- diff --git a/source/Makefile.in b/source/Makefile.in index 7601f1f..3765ce6 100644 --- a/source/Makefile.in +++ b/source/Makefile.in @@ -124,7 +124,7 @@ imexobjs: $(IMEXOBJS) clean: rm -f $(XAB_OUT) $(BMCO_HELP) tools/bitmapcode.o *.o \ vcard/*.o common/*.o carddav/*.o contacteditor/*.o search/*.o \ - widgets/*.o export/*.o import/*.o + widgets/*.o export/*.o import/*.o tests/$(XAB_OUT)_test distclean: clean rm -f Makefile config.status config.log bitmapsdone \ @@ -143,3 +143,6 @@ install: uninstall: rm @BINDIR@/$(XAB_OUT) + +test: + @GTEST@ diff --git a/source/configure b/source/configure index 0195dcf..6822e23 100755 --- a/source/configure +++ b/source/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for Xestia Address Book 0.03. +# Generated by GNU Autoconf 2.69 for Xestia Address Book 0.05. # # Report bugs to . # @@ -580,8 +580,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='Xestia Address Book' PACKAGE_TARNAME='xestia-address-book' -PACKAGE_VERSION='0.03' -PACKAGE_STRING='Xestia Address Book 0.03' +PACKAGE_VERSION='0.05' +PACKAGE_STRING='Xestia Address Book 0.05' PACKAGE_BUGREPORT='bugs@xestia.co.uk' PACKAGE_URL='' @@ -623,19 +623,22 @@ ac_includes_default="\ ac_subst_vars='LTLIBOBJS LIBOBJS +GTEST +GTEST_FOUND_FALSE +GTEST_FOUND_TRUE DBGSTATUS DBGOUT DEBUG_FALSE DEBUG_TRUE +FOUND_XML2CONFIG_RES_FALSE +FOUND_XML2CONFIG_RES_TRUE +FOUND_XML2CONFIG FOUND_UUIDGEN_RES_FALSE FOUND_UUIDGEN_RES_TRUE FOUND_UUIDGEN FOUND_FILE_RES_FALSE FOUND_FILE_RES_TRUE FOUND_FILE -FOUND_XML2CONFIG_RES_FALSE -FOUND_XML2CONFIG_RES_TRUE -FOUND_XML2CONFIG FOUND_CURLCONFIG_RES_FALSE FOUND_CURLCONFIG_RES_TRUE FOUND_CURLCONFIG @@ -1268,7 +1271,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures Xestia Address Book 0.03 to adapt to many kinds of systems. +\`configure' configures Xestia Address Book 0.05 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1330,7 +1333,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of Xestia Address Book 0.03:";; + short | recursive ) echo "Configuration of Xestia Address Book 0.05:";; esac cat <<\_ACEOF @@ -1428,7 +1431,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -Xestia Address Book configure 0.03 +Xestia Address Book configure 0.05 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1802,11 +1805,148 @@ fi } # ac_fn_cxx_try_link -# ac_fn_cxx_check_type LINENO TYPE VAR INCLUDES -# --------------------------------------------- +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + test -x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link + +# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists, giving a warning if it cannot be compiled using +# the include files in INCLUDES and setting the cache variable VAR +# accordingly. +ac_fn_c_check_header_mongrel () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if eval \${$3+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 +$as_echo_n "checking $2 usability... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_header_compiler=yes +else + ac_header_compiler=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 +$as_echo_n "checking $2 presence... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <$2> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + ac_header_preproc=yes +else + ac_header_preproc=no +fi +rm -f conftest.err conftest.i conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( + yes:no: ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; + no:yes:* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} +( $as_echo "## -------------------------------- ## +## Report this to bugs@xestia.co.uk ## +## -------------------------------- ##" + ) | sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=\$ac_header_compiler" +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_mongrel + +# ac_fn_c_check_type LINENO TYPE VAR INCLUDES +# ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. -ac_fn_cxx_check_type () +ac_fn_c_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 @@ -1827,7 +1967,7 @@ if (sizeof ($2)) return 0; } _ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : +if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 @@ -1840,7 +1980,7 @@ if (sizeof (($2))) return 0; } _ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : +if ac_fn_c_try_compile "$LINENO"; then : else eval "$3=yes" @@ -1854,12 +1994,12 @@ eval ac_res=\$$3 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno -} # ac_fn_cxx_check_type +} # ac_fn_c_check_type cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by Xestia Address Book $as_me 0.03, which was +It was created by Xestia Address Book $as_me 0.05, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3434,6 +3574,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu CPPFLAGS="$CPPFLAGS -std=c++11" CXXFLAGS="$CXXFLAGS -std=c++11" +# Checks for header files. ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' @@ -3828,6 +3969,20 @@ fi done +for ac_header in stdlib.h string.h iostream iomanip ios algorithm map vector utility +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_cxx_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + ac_fn_cxx_check_header_mongrel "$LINENO" "thread" "ac_cv_header_thread" "$ac_includes_default" if test "x$ac_cv_header_thread" = xyes; then : @@ -4215,15 +4370,16 @@ fi -ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu # curl Library + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lcurl" >&5 $as_echo_n "checking for main in -lcurl... " >&6; } if ${ac_cv_lib_curl_main+:} false; then : @@ -4243,7 +4399,7 @@ return main (); return 0; } _ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_curl_main=yes else ac_cv_lib_curl_main=no @@ -4270,7 +4426,8 @@ running configure again." fi -ac_fn_cxx_check_header_mongrel "$LINENO" "curl/curl.h" "ac_cv_header_curl_curl_h" "$ac_includes_default" + +ac_fn_c_check_header_mongrel "$LINENO" "curl/curl.h" "ac_cv_header_curl_curl_h" "$ac_includes_default" if test "x$ac_cv_header_curl_curl_h" = xyes; then : else @@ -4339,135 +4496,6 @@ variable before running configure again." fi -# libxml2 Library - -CPPFLAGSOLD=CPPFLAGS -CPPFLAGS=`xml2-config --cflags` - -# Extract the first word of "xml2-config", so it can be a program name with args. -set dummy xml2-config; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_FOUND_XML2CONFIG+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$FOUND_XML2CONFIG"; then - ac_cv_prog_FOUND_XML2CONFIG="$FOUND_XML2CONFIG" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_FOUND_XML2CONFIG="yes" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - test -z "$ac_cv_prog_FOUND_XML2CONFIG" && ac_cv_prog_FOUND_XML2CONFIG="no" -fi -fi -FOUND_XML2CONFIG=$ac_cv_prog_FOUND_XML2CONFIG -if test -n "$FOUND_XML2CONFIG"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FOUND_XML2CONFIG" >&5 -$as_echo "$FOUND_XML2CONFIG" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - if test x$FOUND_XML2CONFIG = xyes; then - FOUND_XML2CONFIG_RES_TRUE= - FOUND_XML2CONFIG_RES_FALSE='#' -else - FOUND_XML2CONFIG_RES_TRUE='#' - FOUND_XML2CONFIG_RES_FALSE= -fi - - -if test -z "$FOUND_XML2CONFIG_RES_TRUE"; then : - else - echo "Cannot find the xml2-config program on your system. -If it is installed on your system, adjust your PATH environment -variable before running configure again." - exit -1 - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lxml2" >&5 -$as_echo_n "checking for main in -lxml2... " >&6; } -if ${ac_cv_lib_xml2_main+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lxml2 $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - -int -main () -{ -return main (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_lib_xml2_main=yes -else - ac_cv_lib_xml2_main=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_xml2_main" >&5 -$as_echo "$ac_cv_lib_xml2_main" >&6; } -if test "x$ac_cv_lib_xml2_main" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBXML2 1 -_ACEOF - - LIBS="-lxml2 $LIBS" - -else - echo "The libxml2 library must be installed on your system. -Please check that this library is installed properly before -running configure again." - exit -1 - -fi - - -for ac_header in libxml2/libxml/parser.h libxml2/libxml/tree.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_cxx_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -else - echo "The libxml2 library headers must be installed on your system. -Please check that the library headers are installed properly -before running configure again." - exit -1 - -fi - -done - - -CPPFLAGS=CPPFLAGSOLD - # file application # Extract the first word of "file", so it can be a program name with args. @@ -4584,21 +4612,6 @@ variable before running configure again." fi -# Checks for header files. -for ac_header in stdlib.h string.h iostream iomanip ios algorithm map vector utility -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_cxx_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - # Checks for typedefs, structures, and compiler characteristics. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5 $as_echo_n "checking for stdbool.h that conforms to C99... " >&6; } @@ -4667,7 +4680,7 @@ main () return 0; } _ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdbool_h=yes else ac_cv_header_stdbool_h=no @@ -4676,7 +4689,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5 $as_echo "$ac_cv_header_stdbool_h" >&6; } - ac_fn_cxx_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default" + ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default" if test "x$ac_cv_type__Bool" = xyes; then : cat >>confdefs.h <<_ACEOF @@ -4709,7 +4722,7 @@ $ac_kw foo_t foo () {return 0; } #endif _ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_inline=$ac_kw fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext @@ -4736,6 +4749,164 @@ _ACEOF esac +# Check for Google Test and if it exists, enable the tests. + +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + +for ac_header in gtest/gtest.h +do : + ac_fn_cxx_check_header_mongrel "$LINENO" "gtest/gtest.h" "ac_cv_header_gtest_gtest_h" "$ac_includes_default" +if test "x$ac_cv_header_gtest_gtest_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_GTEST_GTEST_H 1 +_ACEOF + gtestfound=yes +else + gtestfound=no +fi + +done + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +# libxml2 Library + +CPPFLAGSOLD=CPPFLAGS +CPPFLAGS=`xml2-config --cflags` + +# Extract the first word of "xml2-config", so it can be a program name with args. +set dummy xml2-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_FOUND_XML2CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$FOUND_XML2CONFIG"; then + ac_cv_prog_FOUND_XML2CONFIG="$FOUND_XML2CONFIG" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_FOUND_XML2CONFIG="yes" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_prog_FOUND_XML2CONFIG" && ac_cv_prog_FOUND_XML2CONFIG="no" +fi +fi +FOUND_XML2CONFIG=$ac_cv_prog_FOUND_XML2CONFIG +if test -n "$FOUND_XML2CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FOUND_XML2CONFIG" >&5 +$as_echo "$FOUND_XML2CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + if test x$FOUND_XML2CONFIG = xyes; then + FOUND_XML2CONFIG_RES_TRUE= + FOUND_XML2CONFIG_RES_FALSE='#' +else + FOUND_XML2CONFIG_RES_TRUE='#' + FOUND_XML2CONFIG_RES_FALSE= +fi + + +if test -z "$FOUND_XML2CONFIG_RES_TRUE"; then : + else + echo "Cannot find the xml2-config program on your system. +If it is installed on your system, adjust your PATH environment +variable before running configure again." + exit -1 + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lxml2" >&5 +$as_echo_n "checking for main in -lxml2... " >&6; } +if ${ac_cv_lib_xml2_main+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lxml2 $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +int +main () +{ +return main (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_xml2_main=yes +else + ac_cv_lib_xml2_main=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_xml2_main" >&5 +$as_echo "$ac_cv_lib_xml2_main" >&6; } +if test "x$ac_cv_lib_xml2_main" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBXML2 1 +_ACEOF + + LIBS="-lxml2 $LIBS" + +else + echo "The libxml2 library must be installed on your system. +Please check that this library is installed properly before +running configure again." + exit -1 + +fi + + +for ac_header in libxml2/libxml/parser.h libxml2/libxml/tree.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +else + echo "The libxml2 library headers must be installed on your system. +Please check that the library headers are installed properly +before running configure again." + exit -1 + +fi + +done + + +CPPFLAGS=CPPFLAGSOLD + # Setup the debug setting. # Check whether --enable-debug was given. @@ -4778,6 +4949,25 @@ if test -z "$DEBUG_TRUE"; then : echo "Debugging mode has been enabled." fi + if test x$gtestfound = xyes; then + GTEST_FOUND_TRUE= + GTEST_FOUND_FALSE='#' +else + GTEST_FOUND_TRUE='#' + GTEST_FOUND_FALSE= +fi + +if test -z "$GTEST_FOUND_TRUE"; then : + GTEST=`cat tests/test.commands` + +else + GTEST="echo \"Google Test was not found on the system.\"" + +fi +if test -z "$GTEST_FOUND_TRUE"; then : + echo "Google Test found on the system. Enabling Unit Tests." +fi; + ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF @@ -4929,10 +5119,6 @@ if test -z "${FOUND_CURLCONFIG_RES_TRUE}" && test -z "${FOUND_CURLCONFIG_RES_FAL as_fn_error $? "conditional \"FOUND_CURLCONFIG_RES\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${FOUND_XML2CONFIG_RES_TRUE}" && test -z "${FOUND_XML2CONFIG_RES_FALSE}"; then - as_fn_error $? "conditional \"FOUND_XML2CONFIG_RES\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi if test -z "${FOUND_FILE_RES_TRUE}" && test -z "${FOUND_FILE_RES_FALSE}"; then as_fn_error $? "conditional \"FOUND_FILE_RES\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 @@ -4941,10 +5127,18 @@ if test -z "${FOUND_UUIDGEN_RES_TRUE}" && test -z "${FOUND_UUIDGEN_RES_FALSE}"; as_fn_error $? "conditional \"FOUND_UUIDGEN_RES\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${FOUND_XML2CONFIG_RES_TRUE}" && test -z "${FOUND_XML2CONFIG_RES_FALSE}"; then + as_fn_error $? "conditional \"FOUND_XML2CONFIG_RES\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${DEBUG_TRUE}" && test -z "${DEBUG_FALSE}"; then as_fn_error $? "conditional \"DEBUG\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${GTEST_FOUND_TRUE}" && test -z "${GTEST_FOUND_FALSE}"; then + as_fn_error $? "conditional \"GTEST_FOUND\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 @@ -5342,7 +5536,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by Xestia Address Book $as_me 0.03, which was +This file was extended by Xestia Address Book $as_me 0.05, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -5395,7 +5589,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -Xestia Address Book config.status 0.03 +Xestia Address Book config.status 0.05 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/source/configure.ac b/source/configure.ac index 76b79ab..d1a6ce8 100644 --- a/source/configure.ac +++ b/source/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ([2.68]) -AC_INIT([Xestia Address Book], [0.03], [bugs@xestia.co.uk]) +AC_INIT([Xestia Address Book], [0.05], [bugs@xestia.co.uk]) #AC_CONFIG_SRCDIR([version.h]) #AC_CONFIG_HEADERS([config.h]) @@ -43,6 +43,9 @@ AC_LANG_PUSH([C++]) CPPFLAGS="$CPPFLAGS -std=c++11" CXXFLAGS="$CXXFLAGS -std=c++11" +# Checks for header files. +AC_CHECK_HEADERS([stdlib.h string.h iostream iomanip ios algorithm map vector utility]) + AC_CHECK_HEADER([thread], [], [echo "The C++ compiler does not support C++11 extensions which is needed for Xestia Address Book. Please install or use a compiler that supports C++11 extensions." @@ -82,7 +85,7 @@ before running configure again." exit -1 ]) -AC_LANG_PUSH([C++]) +AC_LANG_POP([C++]) # curl Library @@ -107,6 +110,38 @@ variable before running configure again." exit -1 ]) +# file application + +AC_CHECK_PROG([FOUND_FILE], [file], [yes], [no]) +AM_CONDITIONAL([FOUND_FILE_RES], [test x$FOUND_FILE = xyes]) + +AM_COND_IF([FOUND_FILE_RES], [], [echo "Cannot find the file program on your system. +If it is installed on your system, adjust your PATH environment +variable before running configure again." + exit -1 + ]) + +# uuidgen application + +AC_CHECK_PROG([FOUND_UUIDGEN], [uuidgen], [yes], [no]) +AM_CONDITIONAL([FOUND_UUIDGEN_RES], [test x$FOUND_UUIDGEN = xyes]) + +AM_COND_IF([FOUND_UUIDGEN_RES], [], [echo "Cannot find the uuidgen program on your system. +If it is installed on your system, adjust your PATH environment +variable before running configure again." + exit -1 + ]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_HEADER_STDBOOL +AC_C_INLINE + +# Check for Google Test and if it exists, enable the tests. + +AC_LANG_PUSH([C++]) +AC_CHECK_HEADERS([gtest/gtest.h], [gtestfound=yes], [gtestfound=no]) +AC_LANG_POP([C++]) + # libxml2 Library CPPFLAGSOLD=CPPFLAGS @@ -135,35 +170,6 @@ before running configure again." CPPFLAGS=CPPFLAGSOLD -# file application - -AC_CHECK_PROG([FOUND_FILE], [file], [yes], [no]) -AM_CONDITIONAL([FOUND_FILE_RES], [test x$FOUND_FILE = xyes]) - -AM_COND_IF([FOUND_FILE_RES], [], [echo "Cannot find the file program on your system. -If it is installed on your system, adjust your PATH environment -variable before running configure again." - exit -1 - ]) - -# uuidgen application - -AC_CHECK_PROG([FOUND_UUIDGEN], [uuidgen], [yes], [no]) -AM_CONDITIONAL([FOUND_UUIDGEN_RES], [test x$FOUND_UUIDGEN = xyes]) - -AM_COND_IF([FOUND_UUIDGEN_RES], [], [echo "Cannot find the uuidgen program on your system. -If it is installed on your system, adjust your PATH environment -variable before running configure again." - exit -1 - ]) - -# Checks for header files. -AC_CHECK_HEADERS([stdlib.h string.h iostream iomanip ios algorithm map vector utility]) - -# Checks for typedefs, structures, and compiler characteristics. -AC_HEADER_STDBOOL -AC_C_INLINE - # Setup the debug setting. AC_ARG_ENABLE([debug], @@ -181,5 +187,10 @@ AM_COND_IF([DEBUG], [AC_SUBST([DBGOUT], ["-O0 -ggdb"])], [AC_SUBST([DBGOUT], ["- AM_COND_IF([DEBUG], [AC_SUBST([DBGSTATUS], ["DEBUG=true"])], [AC_SUBST([DBGSTATUS], ["DEBUG=false"])]) AM_COND_IF([DEBUG], [echo "Debugging mode has been enabled."]) +AM_CONDITIONAL([GTEST_FOUND], [test x$gtestfound = xyes]) +AM_COND_IF([GTEST_FOUND], [AC_SUBST([GTEST], [`cat tests/test.commands`])], + [AC_SUBST([GTEST], ["echo \"Google Test was not found on the system.\""])]) +AM_COND_IF([GTEST_FOUND], [echo "Google Test found on the system. Enabling Unit Tests."]); + AC_CONFIG_FILES([Makefile]) AC_OUTPUT diff --git a/source/tests/LoadCheck-Load1.vcf b/source/tests/LoadCheck-Load1.vcf new file mode 100644 index 0000000..c79e326 --- /dev/null +++ b/source/tests/LoadCheck-Load1.vcf @@ -0,0 +1,6 @@ +BEGIN:VCARD +VERSION:4.0 +FN:Test vCard +TITLE:Knight of the Tests +TITLE:The Tester of Cornwall +END:VCARD diff --git a/source/tests/LoadCheck-Load2.vcf b/source/tests/LoadCheck-Load2.vcf new file mode 100644 index 0000000..f1d1ce6 --- /dev/null +++ b/source/tests/LoadCheck-Load2.vcf @@ -0,0 +1,7 @@ +BEGIN:VCARD +VERSION:4.0 +FN:Test vCard +TITLE:The Third Title +TITLE:Knight of the Tests +TITLE:The Tester of Cornwall +END:VCARD diff --git a/source/tests/LoadCheck-Write.vcf b/source/tests/LoadCheck-Write.vcf new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/source/tests/LoadCheck-Write.vcf @@ -0,0 +1 @@ + diff --git a/source/tests/test.commands b/source/tests/test.commands new file mode 100644 index 0000000..8c94932 --- /dev/null +++ b/source/tests/test.commands @@ -0,0 +1 @@ +$(CPP) $(CPPFLAGS) -pthread -I. vcard/vcard.cpp tests/xestiaab_test.cpp -o tests/$(XAB_OUT)_test $(CPPLIBS) -lgtest diff --git a/source/tests/xestiaab_carddav.h b/source/tests/xestiaab_carddav.h new file mode 100644 index 0000000..a710e89 --- /dev/null +++ b/source/tests/xestiaab_carddav.h @@ -0,0 +1,4 @@ +#include +//#include "../carddav/carddav.h" + +// TODO: Add tests for the CardDAV object. \ No newline at end of file diff --git a/source/tests/xestiaab_contactload.h b/source/tests/xestiaab_contactload.h new file mode 100644 index 0000000..b9b7f46 --- /dev/null +++ b/source/tests/xestiaab_contactload.h @@ -0,0 +1,3 @@ +#include + +// TODO: Add tests for the Contact Loading process. \ No newline at end of file diff --git a/source/tests/xestiaab_contactsave.h b/source/tests/xestiaab_contactsave.h new file mode 100644 index 0000000..2ed016c --- /dev/null +++ b/source/tests/xestiaab_contactsave.h @@ -0,0 +1,3 @@ +#include + +// TODO: Add tests for the Contact Saving process. \ No newline at end of file diff --git a/source/tests/xestiaab_test.cpp b/source/tests/xestiaab_test.cpp new file mode 100644 index 0000000..113e380 --- /dev/null +++ b/source/tests/xestiaab_test.cpp @@ -0,0 +1,118 @@ +#include +#include +#include +#include "xestiaab_carddav.h" +#include "xestiaab_contactload.h" +#include "xestiaab_contactsave.h" +#include "xestiaab_vcard.h" + +enum MenuOpts { + TESTS_CARDDAV = 1, + TESTS_CONTACTLOAD, + TESTS_CONTACTSAVE, + TESTS_VCARD, + TESTS_ALL, + TESTS_QUIT +}; + +void printn(std::string text){ +// printn: Print a line and end with a newline (\n). + + std::cout << text << std::endl; + +} + +void printmenu(){ +// printmenu: Print the menu. + + std::cout << "Select an option:" << std::endl << std::endl; + std::cout << TESTS_CARDDAV << ". CardDAV Object" << std::endl; + std::cout << TESTS_CONTACTLOAD << ". Contact Loading" << std::endl; + std::cout << TESTS_CONTACTSAVE << ". Contact Saving" << std::endl; + std::cout << TESTS_VCARD << ". vCard Object" << std::endl; + std::cout << TESTS_ALL << ". All Tests" << std::endl; + std::cout << TESTS_QUIT << ". Quit" << std::endl; + std::cout << std::endl; + +} + +int main(int argc, char* argv[]){ + + ::testing::InitGoogleTest(&argc, argv); + + printn("Xestia Address Book Unit Testing Application"); + printn("(c)2015 Xestia Software Development"); + + printn(""); + + bool ExitEnabled = false; + std::string StringOption = ""; + int TestResult = 0; + + while(ExitEnabled == false){ + + printmenu(); + + // Get user input. + + std::cout << "Select Option: "; + std::cin >> StringOption; + + int IntOption = -1; + + // Check if input is a number. + + try{ + IntOption = stoi(StringOption); + } + + // Return to the top of the while statement if input + // really isn't a number. + + catch(std::invalid_argument e){ + printn("Error: Selected option is not a number."); + continue; + } + + // Find which option has been selected from the + // input. + + switch(IntOption){ + + case TESTS_CARDDAV: + printn("Running CardDAV tests..."); + ::testing::GTEST_FLAG(filter) = "CardDAV*"; + TestResult = RUN_ALL_TESTS(); + break; + case TESTS_CONTACTLOAD: + printn("Running Contact Loading tests..."); + ::testing::GTEST_FLAG(filter) = "ContactLoad*"; + TestResult = RUN_ALL_TESTS(); + break; + case TESTS_CONTACTSAVE: + printn("Running Contact Saving tests..."); + ::testing::GTEST_FLAG(filter) = "ContactSave*"; + TestResult = RUN_ALL_TESTS(); + break; + case TESTS_VCARD: + printn("Running vCard tests..."); + ::testing::GTEST_FLAG(filter) = "vCard*"; + TestResult = RUN_ALL_TESTS(); + break; + case TESTS_ALL: + printn("Running all tests..."); + ::testing::GTEST_FLAG(filter) = "*"; + TestResult = RUN_ALL_TESTS(); + break; + case TESTS_QUIT: + return 0; + break; + default: + printn("Invalid menu number given."); + break; + + } + + } + +} \ No newline at end of file diff --git a/source/tests/xestiaab_vcard.h b/source/tests/xestiaab_vcard.h new file mode 100644 index 0000000..ca53192 --- /dev/null +++ b/source/tests/xestiaab_vcard.h @@ -0,0 +1,96 @@ +#include +#include +#include "vcard/vcard.h" + +TEST(vCard, LoadCheck){ + + vCard vCardTest; + + // Do a failed loading test. + // LoadCheck-Invalid.vcf should never exist in the tests directory. + + ASSERT_EQ(1, vCardTest.LoadFile("LoadCheck-Invalid.vcf")); + + // Load a vCard that does exist in the tests directory. + + ASSERT_EQ(0, vCardTest.LoadFile("LoadCheck-Load1.vcf")); + +} + +TEST(vCard, SaveCheck){ + + vCard vCardTest; + vCard vCardTest2; + wxFFile vCardTestFileHdl; + wxString vCardTestData; + wxString vCardSaveCheck; + + // Load the contact. + + vCardTest.LoadFile("LoadCheck-Load1.vcf"); + vCardSaveCheck = vCardTest.WriteString(); + + // Load the file again and put it into the vCardTestData + // string. Both sets of data should match. + + vCardTestFileHdl.Open("LoadCheck-Load1.vcf", "r"); + vCardTestFileHdl.ReadAll(&vCardTestData, wxConvAuto()); + vCardTestFileHdl.Close(); + + ASSERT_EQ(vCardSaveCheck, vCardTestData); + + vCardTestData.Clear(); + vCardSaveCheck.Clear(); + + // Add a line and then compare with a saved file. + + vCardTest2.AddRaw(wxT("BEGIN"), wxT("VCARD")); + vCardTest2.AddRaw(wxT("VERSION"), wxT("4.0")); + vCardTest2.AddRaw(wxT("FN"), wxT("Test vCard")); + vCardTest2.AddRaw(wxT("TITLE"), wxT("The Third Title")); + vCardTest2.AddRaw(wxT("TITLE"), wxT("Knight of the Tests")); + vCardTest2.AddRaw(wxT("TITLE"), wxT("The Tester of Cornwall")); + vCardTest2.AddRaw(wxT("END"), wxT("VCARD")); + + vCardSaveCheck = vCardTest2.WriteString(); + + vCardTestFileHdl.Open("LoadCheck-Load2.vcf", "r"); + vCardTestFileHdl.ReadAll(&vCardTestData, wxConvAuto()); + vCardTestFileHdl.Close(); + + ASSERT_EQ(vCardSaveCheck, vCardTestData); + +} + +TEST(vCard, GetStrings){ + + // Get strings. + +} + +TEST(vCard, GetMultipleStrings){ + + // Get multiple strings. + +} + +TEST(vCard, v3Conversion){ + + // Convert from a vCard v4 contact to a + // v3 contact. + +} + +TEST(vCard, v4Conversion){ + + // Convert from a vCard v3 contact to a + // v4 contact. + +} + +TEST(vCard, BackwardCompatability){ + + // Check backward compatability which should + // prevent data loss. + +} \ No newline at end of file