subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1849354 - in /subversion/trunk: ./ build/ac-macros/ subversion/bindings/cxx/src/aprwrap/ subversion/bindings/cxx/tests/
Date Thu, 20 Dec 2018 01:33:47 GMT
Author: brane
Date: Thu Dec 20 01:33:47 2018
New Revision: 1849354

URL: http://svn.apache.org/viewvc?rev=1849354&view=rev
Log:
Switch all SVN++ tests to Boost.Test.

* build/ac-macros/ax_boost_unit_test_framework.m4: New; imported from the Autoconf Archive.
* LICENSE: Add entry for ax_boost_unit_test_framework.m4.
* aclocal.m4: Include ax_boost_unit_test_framework.m4.

* Makefile.in
  (BOOST_TEST_CPPFLAGS): Rename from BOOST_CPPFLAGS, redefine.
  (BOOST_TEST_LDFLAGS): Rename from BOOST_LDFLAGS, redefine.
  (COMPILE_SVNXX): Rename from COMPILE_SVNXX_CXX, redefine.
  (COMPILE_SVNXX_TEST): Rename from COMPILE_SVNXX_CXX_BOOST, redefine.
  (LINK_SVNXX_TEST): Rename from LINK_CXX_BOOST, redefine.

* build.conf
  (libsvnxx, svnxx-tests): Update compile and link commands.

* configure.ac: Update SVN++ bits.

* subversion/bindings/cxx/src/aprwrap/array.hpp:
   Add comments to mark obsolete constructs that should change to C++11 idiom.
* subversion/bindings/cxx/src/aprwrap/hash.hpp: Likewise.

* subversion/bindings/cxx/tests/cxxhl-tests.cpp.
* subversion/bindings/cxx/tests/test_aprwrap.cpp: Removed.

* subversion/bindings/cxx/tests/svnxx-tests.cpp,
* subversion/bindings/cxx/tests/fixture_initialize_apr.hpp,
* subversion/bindings/cxx/tests/test_aprwrap_array_helpers.hpp: New.

* subversion/bindings/cxx/tests/test_aprwrap_arrays.cpp,
* subversion/bindings/cxx/tests/test_aprwrap_const_arrays.cpp,
* subversion/bindings/cxx/tests/test_aprwrap_hashes.cpp,
* subversion/bindings/cxx/tests/test_aprwrap_pools.cpp: New; extracted from the
   removed test_aprwrap.cpp and reworked for Boost.Test.

* subversion/bindings/cxx/tests/test_exceptions.cpp: Renamed from test_exception.cpp
   and reworked for Boost.Test.

Added:
    subversion/trunk/build/ac-macros/ax_boost_unit_test_framework.m4
    subversion/trunk/subversion/bindings/cxx/tests/svnxx-tests.cpp   (with props)
    subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_array_helpers.hpp   (with props)
    subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_arrays.cpp
      - copied, changed from r1849322, subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap.cpp
    subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_const_arrays.cpp
      - copied, changed from r1849322, subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap.cpp
    subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_hashes.cpp
      - copied, changed from r1849322, subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap.cpp
    subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_pools.cpp
      - copied, changed from r1849322, subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap.cpp
    subversion/trunk/subversion/bindings/cxx/tests/test_exceptions.cpp
      - copied, changed from r1849353, subversion/trunk/subversion/bindings/cxx/tests/test_exception.cpp
Removed:
    subversion/trunk/subversion/bindings/cxx/tests/cxxhl-tests.cpp
    subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap.cpp
    subversion/trunk/subversion/bindings/cxx/tests/test_exception.cpp
Modified:
    subversion/trunk/LICENSE
    subversion/trunk/Makefile.in
    subversion/trunk/aclocal.m4
    subversion/trunk/build.conf
    subversion/trunk/configure.ac
    subversion/trunk/subversion/bindings/cxx/src/aprwrap/array.hpp
    subversion/trunk/subversion/bindings/cxx/src/aprwrap/hash.hpp
    subversion/trunk/subversion/bindings/cxx/tests/fixture_initialize_apr.hpp

Modified: subversion/trunk/LICENSE
URL: http://svn.apache.org/viewvc/subversion/trunk/LICENSE?rev=1849354&r1=1849353&r2=1849354&view=diff
==============================================================================
--- subversion/trunk/LICENSE (original)
+++ subversion/trunk/LICENSE Thu Dec 20 01:33:47 2018
@@ -424,12 +424,23 @@ For the (modified) LZ4 library files in
   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
   THE POSSIBILITY OF SUCH DAMAGE.
 
-For the Boost autoconf macros in build/ac-macros/ax_boost_base.m4:
+For the Autoconf Archive macros for Boost:
 
-  Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
-  Copyright (c) 2009 Peter Adolphs
+ * in build/ac-macros/ax_boost_base.m4:
 
-  Copying and distribution of this file, with or without modification, are
-  permitted in any medium without royalty provided the copyright notice
-  and this notice are preserved. This file is offered as-is, without any
-  warranty.
+   Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
+   Copyright (c) 2009 Peter Adolphs
+
+   Copying and distribution of this file, with or without modification, are
+   permitted in any medium without royalty provided the copyright notice
+   and this notice are preserved. This file is offered as-is, without any
+   warranty.
+
+ * in build/ac-macros/ax_boost_unit_test_framework.m4:
+
+   Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
+
+   Copying and distribution of this file, with or without modification, are
+   permitted in any medium without royalty provided the copyright notice
+   and this notice are preserved. This file is offered as-is, without any
+   warranty.

Modified: subversion/trunk/Makefile.in
URL: http://svn.apache.org/viewvc/subversion/trunk/Makefile.in?rev=1849354&r1=1849353&r2=1849354&view=diff
==============================================================================
--- subversion/trunk/Makefile.in (original)
+++ subversion/trunk/Makefile.in Thu Dec 20 01:33:47 2018
@@ -141,8 +141,8 @@ APACHE_INCLUDES = @APACHE_INCLUDES@
 APACHE_LIBEXECDIR = $(DESTDIR)@APACHE_LIBEXECDIR@
 APACHE_LDFLAGS = @APACHE_LDFLAGS@
 
-BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
-BOOST_LDFLAGS = @BOOST_LDFLAGS@
+BOOST_TEST_CPPFLAGS = @BOOST_CPPFLAGS@ -DBOOST_TEST_DYN_LINK -DBOOST_TEST_NO_MAIN
+BOOST_TEST_LDFLAGS = @BOOST_LDFLAGS@ @BOOST_UNIT_TEST_FRAMEWORK_LIB@
 
 SWIG = @SWIG@
 SWIG_PY_INCLUDES = @SWIG_PY_INCLUDES@ -I$(SWIG_SRC_DIR)/python/libsvn_swig_py
@@ -261,14 +261,14 @@ TEST_SHLIB_VAR_SWIG_RB=\
   fi;
 
 # special compilation for files destined for SVN++
-COMPILE_SVNXX_CXX = $(LT_COMPILE_CXX) $(SVNXX_INCLUDES) -o $@ -c
-COMPILE_SVNXX_CXX_BOOST = $(LT_COMPILE_CXX) $(SVNXX_INCLUDES) $(BOOST_CPPFLAGS) -o $@ -c
+COMPILE_SVNXX = $(LT_COMPILE_CXX) $(SVNXX_INCLUDES) -o $@ -c
+COMPILE_SVNXX_TEST = $(LT_COMPILE_CXX) $(SVNXX_INCLUDES) $(BOOST_TEST_CPPFLAGS) -o $@ -c
 
 LINK = $(LIBTOOL) $(LTFLAGS) --mode=link $(CC) $(LT_LDFLAGS) $(CFLAGS) $(LDFLAGS) -rpath $(libdir)
 LINK_LIB = $(LINK) $(LT_SO_VERSION)
 LINK_CXX = $(LIBTOOL) $(LTCXXFLAGS) --mode=link $(CXX) $(LT_LDFLAGS) $(CXXFLAGS) $(LDFLAGS) -rpath $(libdir)
 LINK_CXX_LIB = $(LINK_CXX) $(LT_SO_VERSION)
-LINK_CXX_BOOST = $(LINK_CXX) $(BOOST_LDFLAGS)
+LINK_SVNXX_TEST = $(LINK_CXX) $(BOOST_TEST_LDFLAGS)
 
 # special link rule for mod_dav_svn
 LINK_APACHE_MOD = $(LIBTOOL) $(LTFLAGS) --mode=link $(CC) $(LT_LDFLAGS) $(CFLAGS) $(LDFLAGS) -rpath $(APACHE_LIBEXECDIR) -avoid-version -module $(APACHE_LDFLAGS) -shared

Modified: subversion/trunk/aclocal.m4
URL: http://svn.apache.org/viewvc/subversion/trunk/aclocal.m4?rev=1849354&r1=1849353&r2=1849354&view=diff
==============================================================================
--- subversion/trunk/aclocal.m4 (original)
+++ subversion/trunk/aclocal.m4 Thu Dec 20 01:33:47 2018
@@ -36,6 +36,7 @@ sinclude(build/ac-macros/apr.m4)
 sinclude(build/ac-macros/aprutil.m4)
 sinclude(build/ac-macros/apr_memcache.m4)
 sinclude(build/ac-macros/ax_boost_base.m4)
+sinclude(build/ac-macros/ax_boost_unit_test_framework.m4)
 sinclude(build/ac-macros/berkeley-db.m4)
 sinclude(build/ac-macros/compiler.m4)
 sinclude(build/ac-macros/ctypesgen.m4)

Modified: subversion/trunk/build.conf
URL: http://svn.apache.org/viewvc/subversion/trunk/build.conf?rev=1849354&r1=1849353&r2=1849354&view=diff
==============================================================================
--- subversion/trunk/build.conf (original)
+++ subversion/trunk/build.conf Thu Dec 20 01:33:47 2018
@@ -737,7 +737,7 @@ libs = libsvn_repos libsvn_client libsvn
 sources = src/*.cpp src/aprwrap/*.cpp
 install = svnxx-lib
 msvc-static = yes
-compile-cmd = $(COMPILE_SVNXX_CXX)
+compile-cmd = $(COMPILE_SVNXX)
 link-cmd = $(LINK_CXX_LIB)
 
 [svnxx-tests]
@@ -748,8 +748,8 @@ path = subversion/bindings/cxx
 libs = libsvnxx apr
 sources = tests/*.cpp
 install = svnxx-tests
-compile-cmd = $(COMPILE_SVNXX_CXX_BOOST)
-link-cmd = $(LINK_CXX_BOOST)
+compile-cmd = $(COMPILE_SVNXX_TEST)
+link-cmd = $(LINK_SVNXX_TEST)
 
 # ----------------------------------------------------------------------------
 #

Added: subversion/trunk/build/ac-macros/ax_boost_unit_test_framework.m4
URL: http://svn.apache.org/viewvc/subversion/trunk/build/ac-macros/ax_boost_unit_test_framework.m4?rev=1849354&view=auto
==============================================================================
--- subversion/trunk/build/ac-macros/ax_boost_unit_test_framework.m4 (added)
+++ subversion/trunk/build/ac-macros/ax_boost_unit_test_framework.m4 Thu Dec 20 01:33:47 2018
@@ -0,0 +1,137 @@
+# =================================================================================
+#  https://www.gnu.org/software/autoconf-archive/ax_boost_unit_test_framework.html
+# =================================================================================
+#
+# SYNOPSIS
+#
+#   AX_BOOST_UNIT_TEST_FRAMEWORK
+#
+# DESCRIPTION
+#
+#   Test for Unit_Test_Framework library from the Boost C++ libraries. The
+#   macro requires a preceding call to AX_BOOST_BASE. Further documentation
+#   is available at <http://randspringer.de/boost/index.html>.
+#
+#   This macro calls:
+#
+#     AC_SUBST(BOOST_UNIT_TEST_FRAMEWORK_LIB)
+#
+#   And sets:
+#
+#     HAVE_BOOST_UNIT_TEST_FRAMEWORK
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 21
+
+AC_DEFUN([AX_BOOST_UNIT_TEST_FRAMEWORK],
+[
+	AC_ARG_WITH([boost-unit-test-framework],
+	AS_HELP_STRING([--with-boost-unit-test-framework@<:@=special-lib@:>@],
+                   [use the Unit_Test_Framework library from boost - it is possible to specify a certain library for the linker
+                        e.g. --with-boost-unit-test-framework=boost_unit_test_framework-gcc ]),
+        [
+        if test "$withval" = "no"; then
+			want_boost="no"
+        elif test "$withval" = "yes"; then
+            want_boost="yes"
+            ax_boost_user_unit_test_framework_lib=""
+        else
+		    want_boost="yes"
+		ax_boost_user_unit_test_framework_lib="$withval"
+		fi
+        ],
+        [want_boost="yes"]
+	)
+
+	if test "x$want_boost" = "xyes"; then
+        AC_REQUIRE([AC_PROG_CC])
+		CPPFLAGS_SAVED="$CPPFLAGS"
+		CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
+		export CPPFLAGS
+
+		LDFLAGS_SAVED="$LDFLAGS"
+		LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
+		export LDFLAGS
+
+        AC_CACHE_CHECK(whether the Boost::Unit_Test_Framework library is available,
+					   ax_cv_boost_unit_test_framework,
+        [AC_LANG_PUSH([C++])
+			 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/test/unit_test.hpp>]],
+                                    [[using boost::unit_test::test_suite;
+							 test_suite* test= BOOST_TEST_SUITE( "Unit test example 1" ); if (test == NULL) { return 1; } else { return 0; }]])],
+                   ax_cv_boost_unit_test_framework=yes, ax_cv_boost_unit_test_framework=no)
+         AC_LANG_POP([C++])
+		])
+		if test "x$ax_cv_boost_unit_test_framework" = "xyes"; then
+			AC_DEFINE(HAVE_BOOST_UNIT_TEST_FRAMEWORK,,[define if the Boost::Unit_Test_Framework library is available])
+            BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
+
+            if test "x$ax_boost_user_unit_test_framework_lib" = "x"; then
+			saved_ldflags="${LDFLAGS}"
+                for monitor_library in `ls $BOOSTLIBDIR/libboost_unit_test_framework*.so* $BOOSTLIBDIR/libboost_unit_test_framework*.dylib* $BOOSTLIBDIR/libboost_unit_test_framework*.a* 2>/dev/null` ; do
+                    if test -r $monitor_library ; then
+                       libextension=`echo $monitor_library | sed 's,.*/,,' | sed -e 's;^lib\(boost_unit_test_framework.*\)\.so.*$;\1;' -e 's;^lib\(boost_unit_test_framework.*\)\.dylib.*$;\1;' -e 's;^lib\(boost_unit_test_framework.*\)\.a.*$;\1;'`
+                       ax_lib=${libextension}
+                       link_unit_test_framework="yes"
+                    else
+                       link_unit_test_framework="no"
+                    fi
+
+			    if test "x$link_unit_test_framework" = "xyes"; then
+                      BOOST_UNIT_TEST_FRAMEWORK_LIB="-l$ax_lib"
+                      AC_SUBST(BOOST_UNIT_TEST_FRAMEWORK_LIB)
+					  break
+				    fi
+                done
+                if test "x$link_unit_test_framework" != "xyes"; then
+                for libextension in `ls $BOOSTLIBDIR/boost_unit_test_framework*.dll* $BOOSTLIBDIR/boost_unit_test_framework*.a* 2>/dev/null  | sed 's,.*/,,' | sed -e 's;^\(boost_unit_test_framework.*\)\.dll.*$;\1;' -e 's;^\(boost_unit_test_framework.*\)\.a.*$;\1;'` ; do
+                     ax_lib=${libextension}
+				    AC_CHECK_LIB($ax_lib, exit,
+                                 [BOOST_UNIT_TEST_FRAMEWORK_LIB="-l$ax_lib"; AC_SUBST(BOOST_UNIT_TEST_FRAMEWORK_LIB) link_unit_test_framework="yes"; break],
+                                 [link_unit_test_framework="no"])
+				done
+                fi
+            else
+                link_unit_test_framework="no"
+			saved_ldflags="${LDFLAGS}"
+                for ax_lib in boost_unit_test_framework-$ax_boost_user_unit_test_framework_lib $ax_boost_user_unit_test_framework_lib ; do
+                   if test "x$link_unit_test_framework" = "xyes"; then
+                      break;
+                   fi
+                   for unittest_library in `ls $BOOSTLIBDIR/lib${ax_lib}.so* $BOOSTLIBDIR/lib${ax_lib}.a* 2>/dev/null` ; do
+                   if test -r $unittest_library ; then
+                       libextension=`echo $unittest_library | sed 's,.*/,,' | sed -e 's;^lib\(boost_unit_test_framework.*\)\.so.*$;\1;' -e 's;^lib\(boost_unit_test_framework.*\)\.a*$;\1;'`
+                       ax_lib=${libextension}
+                       link_unit_test_framework="yes"
+                    else
+                       link_unit_test_framework="no"
+                    fi
+
+				if test "x$link_unit_test_framework" = "xyes"; then
+                        BOOST_UNIT_TEST_FRAMEWORK_LIB="-l$ax_lib"
+                        AC_SUBST(BOOST_UNIT_TEST_FRAMEWORK_LIB)
+					    break
+				    fi
+                  done
+               done
+            fi
+            if test "x$ax_lib" = "x"; then
+                AC_MSG_ERROR(Could not find a version of the library!)
+            fi
+			if test "x$link_unit_test_framework" != "xyes"; then
+				AC_MSG_ERROR(Could not link against $ax_lib !)
+			fi
+		fi
+
+		CPPFLAGS="$CPPFLAGS_SAVED"
+	LDFLAGS="$LDFLAGS_SAVED"
+	fi
+])

Modified: subversion/trunk/configure.ac
URL: http://svn.apache.org/viewvc/subversion/trunk/configure.ac?rev=1849354&r1=1849353&r2=1849354&view=diff
==============================================================================
--- subversion/trunk/configure.ac (original)
+++ subversion/trunk/configure.ac Thu Dec 20 01:33:47 2018
@@ -1439,7 +1439,12 @@ AC_SUBST(SVN_FS_LIB_LINK)
 
 # ==== SVN++ =================================================================
 
-AX_BOOST_BASE([1.58],[SVN_HAVE_CXX_BOOST=true],[SVN_HAVE_CXX_BOOST=false])
+AX_BOOST_BASE([1.58],
+  [
+    SVN_HAVE_CXX_BOOST=true
+    AX_BOOST_UNIT_TEST_FRAMEWORK
+  ],
+  [SVN_HAVE_CXX_BOOST=false])
 AC_SUBST(SVN_HAVE_CXX_BOOST)
 
 # ==== JavaHL ================================================================

Modified: subversion/trunk/subversion/bindings/cxx/src/aprwrap/array.hpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxx/src/aprwrap/array.hpp?rev=1849354&r1=1849353&r2=1849354&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/cxx/src/aprwrap/array.hpp (original)
+++ subversion/trunk/subversion/bindings/cxx/src/aprwrap/array.hpp Thu Dec 20 01:33:47 2018
@@ -142,6 +142,8 @@ public:
 
   /**
    * Abstract base class for mutable iteration callback functors.
+   *
+   * FIXME: obsolete; see below.
    */
   struct Iteration
   {
@@ -155,6 +157,8 @@ public:
   /**
    * Iterate over all the values pairs in the array, invoking
    * @a callback for each one.
+   *
+   * FIXME: should use std::function instead.
    */
   void iterate(Iteration& callback)
     {
@@ -165,6 +169,8 @@ public:
 
   /**
    * Abstract base class for immutable iteration callback functors.
+   *
+   * FIXME: obsolete; see below.
    */
   struct ConstIteration
   {
@@ -178,6 +184,8 @@ public:
   /**
    * Iterate over all the values pairs in the array, invoking
    * @a callback for each one.
+   *
+   * FIXME: should use std::function instead.
    */
   void iterate(ConstIteration& callback) const
     {
@@ -259,12 +267,16 @@ public:
 
   /**
    * Abstract base class for immutable iteration callback functors.
+   *
+   * FIXME: obsolete; see below.
    */
   typedef typename inherited::ConstIteration Iteration;
 
   /**
    * Iterate over all the values pairs in the array, invoking
    * @a callback for each one.
+   *
+   * FIXME: should use std::function instead.
    */
   void iterate(Iteration& callback) const
     {

Modified: subversion/trunk/subversion/bindings/cxx/src/aprwrap/hash.hpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxx/src/aprwrap/hash.hpp?rev=1849354&r1=1849353&r2=1849354&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/cxx/src/aprwrap/hash.hpp (original)
+++ subversion/trunk/subversion/bindings/cxx/src/aprwrap/hash.hpp Thu Dec 20 01:33:47 2018
@@ -50,6 +50,8 @@ public:
    * Iterate over all the key-value pairs in the hash table, invoking
    * @a callback for each pair.
    * Uses @a scratch_pool for temporary allocations.
+   *
+   * FIXME: should use std::function instead.
    */
   void iterate(Iteration& callback, const Pool& scratch_pool);
 

Modified: subversion/trunk/subversion/bindings/cxx/tests/fixture_initialize_apr.hpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxx/tests/fixture_initialize_apr.hpp?rev=1849354&r1=1849353&r2=1849354&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/cxx/tests/fixture_initialize_apr.hpp (original)
+++ subversion/trunk/subversion/bindings/cxx/tests/fixture_initialize_apr.hpp Thu Dec 20 01:33:47 2018
@@ -19,6 +19,10 @@
  * ====================================================================
  */
 
+#ifndef __cplusplus
+#error "This is a C++ header file."
+#endif
+
 #ifndef SVNXX_TEST_FIXTURE_INITIALIZE_APR_HPP
 #define SVNXX_TEST_FIXTURE_INITIALIZE_APR_HPP
 

Added: subversion/trunk/subversion/bindings/cxx/tests/svnxx-tests.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxx/tests/svnxx-tests.cpp?rev=1849354&view=auto
==============================================================================
--- subversion/trunk/subversion/bindings/cxx/tests/svnxx-tests.cpp (added)
+++ subversion/trunk/subversion/bindings/cxx/tests/svnxx-tests.cpp Thu Dec 20 01:33:47 2018
@@ -0,0 +1,30 @@
+/*
+ * ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one
+ *    or more contributor license agreements.  See the NOTICE file
+ *    distributed with this work for additional information
+ *    regarding copyright ownership.  The ASF licenses this file
+ *    to you under the Apache License, Version 2.0 (the
+ *    "License"); you may not use this file except in compliance
+ *    with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing,
+ *    software distributed under the License is distributed on an
+ *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *    KIND, either express or implied.  See the License for the
+ *    specific language governing permissions and limitations
+ *    under the License.
+ * ====================================================================
+ */
+
+#define BOOST_TEST_MODULE svnxx
+#include <boost/test/unit_test.hpp>
+
+#include "fixture_initialize_apr.hpp"
+
+int main (int argc, char* argv[])
+{
+  return boost::unit_test::unit_test_main(&init_unit_test, argc, argv);
+}

Propchange: subversion/trunk/subversion/bindings/cxx/tests/svnxx-tests.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_array_helpers.hpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_array_helpers.hpp?rev=1849354&view=auto
==============================================================================
--- subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_array_helpers.hpp (added)
+++ subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_array_helpers.hpp Thu Dec 20 01:33:47 2018
@@ -0,0 +1,47 @@
+/*
+ * ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one
+ *    or more contributor license agreements.  See the NOTICE file
+ *    distributed with this work for additional information
+ *    regarding copyright ownership.  The ASF licenses this file
+ *    to you under the Apache License, Version 2.0 (the
+ *    "License"); you may not use this file except in compliance
+ *    with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing,
+ *    software distributed under the License is distributed on an
+ *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *    KIND, either express or implied.  See the License for the
+ *    specific language governing permissions and limitations
+ *    under the License.
+ * ====================================================================
+ */
+
+#ifndef __cplusplus
+#error "This is a C++ header file."
+#endif
+
+#ifndef SVNXX_TEST_APRWRAP_ARRAY_HELPERS_HPP
+#define SVNXX_TEST_APRWRAP_ARRAY_HELPERS_HPP
+
+namespace {
+// Create a randomly-ordered array of constant strings.
+apr_array_header_t* fill_array(APR::Pool& pool)
+{
+  apr_array_header_t* a = apr_array_make(pool.get(), 0, sizeof(const char*));
+  APR_ARRAY_PUSH(a, const char*) = "primus";
+  APR_ARRAY_PUSH(a, const char*) = "secundus";
+  APR_ARRAY_PUSH(a, const char*) = "tertius";
+  APR_ARRAY_PUSH(a, const char*) = "quartus";
+  APR_ARRAY_PUSH(a, const char*) = "quintus";
+  APR_ARRAY_PUSH(a, const char*) = "sextus";
+  APR_ARRAY_PUSH(a, const char*) = "septimus";
+  std::random_shuffle(&APR_ARRAY_IDX(a, 0, const char*),
+                      &APR_ARRAY_IDX(a, a->nelts, const char*));
+  return a;
+}
+} // anonymous namespace
+
+#endif  // SVNXX_TEST_APRWRAP_ARRAY_HELPERS_HPP

Propchange: subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_array_helpers.hpp
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_arrays.cpp (from r1849322, subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap.cpp)
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_arrays.cpp?p2=subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_arrays.cpp&p1=subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap.cpp&r1=1849322&r2=1849354&rev=1849354&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap.cpp (original)
+++ subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_arrays.cpp Thu Dec 20 01:33:47 2018
@@ -19,151 +19,92 @@
  * ====================================================================
  */
 
+#include <boost/test/unit_test.hpp>
+
 #include <algorithm>
 #include <stdexcept>
 
 #include "../src/aprwrap.hpp"
 
-#include <gmock/gmock.h>
-
-//
-// Pools
-//
-
-TEST(Pools, InitializeGlobalPool)
-{
-  APR::Pool pool;
-  EXPECT_THAT(pool.get(), testing::NotNull());
-  EXPECT_THAT(apr_pool_parent_get(pool.get()), testing::NotNull());
-}
-
-TEST(Pools, CreateSubpool)
-{
-  APR::Pool pool;
-  APR::Pool subpool(&pool);
-  EXPECT_EQ(pool.get(), apr_pool_parent_get(subpool.get()));
-}
-
-TEST(Pools, TypedAllocate)
-{
-  APR::Pool pool;
-  const unsigned char* buffer = pool.alloc<unsigned char>(1);
-  EXPECT_THAT(buffer, testing::NotNull());
-}
-
-// N.B.: This test may pass randomly even if zero-filled allocation
-// does not work correctly, since we cannot make assumptions about the
-// values of uninitialized memory.
-TEST(Pools, TypedAllocateZerofill)
-{
-  APR::Pool pool;
-  static const std::size_t size = 32757;
-  const unsigned char* buffer = pool.allocz<unsigned char>(size);
-  ASSERT_THAT(buffer, testing::NotNull());
-  EXPECT_EQ(size, std::count(buffer, buffer + size, 0));
-}
-
-//
-// Array helper functions
-//
-
-namespace {
-// Create a randomly-ordered array of constant strings.
-apr_array_header_t* fill_array(APR::Pool& pool)
-{
-  apr_array_header_t* a = apr_array_make(pool.get(), 0, sizeof(const char*));
-  APR_ARRAY_PUSH(a, const char*) = "primus";
-  APR_ARRAY_PUSH(a, const char*) = "secundus";
-  APR_ARRAY_PUSH(a, const char*) = "tertius";
-  APR_ARRAY_PUSH(a, const char*) = "quartus";
-  APR_ARRAY_PUSH(a, const char*) = "quintus";
-  APR_ARRAY_PUSH(a, const char*) = "sextus";
-  APR_ARRAY_PUSH(a, const char*) = "septimus";
-  std::random_shuffle(&APR_ARRAY_IDX(a, 0, const char*),
-                      &APR_ARRAY_IDX(a, a->nelts, const char*));
-  return a;
-}
-} // anonymous namespace
+#include "test_aprwrap_array_helpers.hpp"
 
-//
-// Arrays
-//
+BOOST_AUTO_TEST_SUITE(aprwrap_arrays);
 
-TEST(Arrays, CreateArray)
+BOOST_AUTO_TEST_CASE(create_array)
 {
   typedef APR::Array<unsigned char> Array;
 
   APR::Pool pool;
   Array array(pool);
 
-  EXPECT_THAT(array.array(), testing::NotNull());
-  EXPECT_EQ(0, array.size());
-  EXPECT_EQ(sizeof(unsigned char), sizeof(Array::value_type));
-  EXPECT_EQ(sizeof(Array::value_type), array.array()->elt_size);
+  BOOST_TEST(array.array() != nullptr);
+  BOOST_TEST(array.size() == 0);
+  BOOST_TEST(sizeof(Array::value_type) == sizeof(unsigned char));
+  BOOST_TEST(array.array()->elt_size == sizeof(Array::value_type));
 }
 
-TEST(Arrays, WrapArray)
+BOOST_AUTO_TEST_CASE(wrap_array)
 {
   typedef APR::Array<unsigned char> Array;
 
   APR::Pool pool;
   apr_array_header_t* apr_array =
     apr_array_make(pool.get(), 0, sizeof(Array::value_type));
-  ASSERT_THAT(apr_array, testing::NotNull());
+  BOOST_TEST_REQUIRE(apr_array != nullptr);
 
   Array array(apr_array);
-  EXPECT_EQ(apr_array, array.array());
-  EXPECT_EQ(0, array.size());
+  BOOST_TEST(array.array() == apr_array);
+  BOOST_TEST(array.size() == 0);
 }
 
-TEST(Arrays, RewrapTypeMismatch)
+BOOST_AUTO_TEST_CASE(rewrap_type_mismatch)
 {
   typedef APR::Array<unsigned char> ByteArray;
   typedef APR::Array<int> IntArray;
 
   APR::Pool pool;
-  EXPECT_THROW(ByteArray array(IntArray(pool).array()),
-               std::invalid_argument);
+  BOOST_CHECK_THROW(ByteArray array(IntArray(pool).array()),
+                    std::invalid_argument);
 }
 
-TEST(Arrays, OutOfBounds)
+BOOST_AUTO_TEST_CASE(out_of_bounds)
 {
   typedef APR::Array<unsigned char> Array;
 
   APR::Pool pool;
   Array array(pool);
 
-  EXPECT_THROW(array.at(-1), std::out_of_range);
-  EXPECT_THROW(array.at(array.size()), std::out_of_range);
+  BOOST_CHECK_THROW(array.at(-1), std::out_of_range);
+  BOOST_CHECK_THROW(array.at(array.size()), std::out_of_range);
 }
 
-TEST(Arrays, Indexing)
+BOOST_AUTO_TEST_CASE(indexing)
 {
   typedef APR::Array<const char*> Array;
 
   APR::Pool pool;
   Array array(fill_array(pool));
 
-  EXPECT_STREQ(array[0], APR_ARRAY_IDX(array.array(), 0, Array::value_type));
-  EXPECT_STREQ(array[array.size() - 1], APR_ARRAY_IDX(array.array(),
+  BOOST_TEST(array[0] == APR_ARRAY_IDX(array.array(), 0, Array::value_type));
+  BOOST_TEST(array[array.size() - 1] == APR_ARRAY_IDX(array.array(),
                                                       array.array()->nelts - 1,
                                                       Array::value_type));
 }
 
-TEST(Arrays, CheckedIndexing)
+BOOST_AUTO_TEST_CASE(checked_indexing)
 {
   typedef APR::Array<const char*> Array;
 
   APR::Pool pool;
   Array array(fill_array(pool));
 
-  EXPECT_STREQ(array.at(0), APR_ARRAY_IDX(array.array(), 0, Array::value_type));
-  EXPECT_STREQ(array.at(array.size() - 1),
-               APR_ARRAY_IDX(array.array(), array.array()->nelts - 1,
-                             Array::value_type));
+  BOOST_TEST(array.at(0) == APR_ARRAY_IDX(array.array(), 0, Array::value_type));
+  BOOST_TEST(array.at(array.size() - 1) == APR_ARRAY_IDX(array.array(),
+                                                         array.array()->nelts - 1,
+                                                         Array::value_type));
 }
 
-TEST(Arrays, Iteration)
+BOOST_AUTO_TEST_CASE(iteration)
 {
   typedef APR::Array<const char*> Array;
 
@@ -178,7 +119,7 @@ TEST(Arrays, Iteration)
 
     bool operator()(Array::value_type& value)
       {
-        EXPECT_STREQ(value, APR_ARRAY_IDX(m_raw_array, m_index,
+        BOOST_TEST(value == APR_ARRAY_IDX(m_raw_array, m_index,
                                           Array::value_type));
         ++m_index;
         return true;
@@ -190,9 +131,19 @@ TEST(Arrays, Iteration)
   } callback(array.array());
 
   array.iterate(callback);
+
+  // TODO: Fix iteration to take std::function.
+  // Array::size_type index = 0;
+  // apr_array_header_t* raw_array = array.array();
+  // array.iterate(
+  //     [&index, &raw_array](Array::value_type& value) {
+  //       BOOST_TEST(value == APR_ARRAY_IDX(raw_array, index, Array::value_type));
+  //       ++index;
+  //       return true;
+  //     });
 }
 
-TEST(Arrays, ConstIteration)
+BOOST_AUTO_TEST_CASE(const_iteration)
 {
   typedef APR::Array<const char*> Array;
 
@@ -207,7 +158,7 @@ TEST(Arrays, ConstIteration)
 
     bool operator()(const Array::value_type& value)
       {
-        EXPECT_STREQ(value, APR_ARRAY_IDX(m_raw_array, m_index,
+        BOOST_TEST(value == APR_ARRAY_IDX(m_raw_array, m_index,
                                           Array::value_type));
         ++m_index;
         return true;
@@ -221,7 +172,7 @@ TEST(Arrays, ConstIteration)
   array.iterate(callback);
 }
 
-TEST(Arrays, Push)
+BOOST_AUTO_TEST_CASE(push)
 {
   typedef APR::Array<const char*> Array;
 
@@ -236,14 +187,14 @@ TEST(Arrays, Push)
   array.push("nonus");
   array.push("decimus");
 
-  EXPECT_EQ(point + 3, array.size());
-  EXPECT_STREQ(first, array[0]);
-  EXPECT_STREQ(last, array[point - 1]);
-  EXPECT_STREQ("octavius", array[point]);
-  EXPECT_STREQ("decimus", array[array.size() - 1]);
+  BOOST_TEST(array.size() == point + 3);
+  BOOST_TEST(array[0] == first);
+  BOOST_TEST(array[point - 1] == last);
+  BOOST_TEST(array[point] == "octavius");
+  BOOST_TEST(array[array.size() - 1] == "decimus");
 }
 
-TEST(Arrays, Pop)
+BOOST_AUTO_TEST_CASE(pop)
 {
   typedef APR::Array<const char*> Array;
 
@@ -252,184 +203,12 @@ TEST(Arrays, Pop)
 
   for (Array::size_type i = 0, z = array.size(); i <= z; ++i)
     {
-      const char** last = (!array.array()->nelts ? NULL
+      const char** last = (!array.array()->nelts ? nullptr
                            : &APR_ARRAY_IDX(array.array(),
                                             array.array()->nelts - 1,
-                                            const char*));
-      EXPECT_EQ(last, array.pop());
+                                            Array::value_type));
+      BOOST_TEST(array.pop() == last);
     }
 }
 
-//
-// ConstArrays
-//
-
-TEST(ConstArrays, WrapArray)
-{
-  typedef APR::ConstArray<unsigned char> Array;
-
-  APR::Pool pool;
-  const apr_array_header_t* apr_array =
-    apr_array_make(pool.get(), 0, sizeof(Array::value_type));
-  ASSERT_THAT(apr_array, testing::NotNull());
-
-  Array array(apr_array);
-  EXPECT_EQ(apr_array, array.array());
-  EXPECT_EQ(0, array.size());
-}
-
-TEST(ConstArrays, RewrapTypeMismatch)
-{
-  typedef APR::ConstArray<unsigned char> ByteArray;
-  typedef APR::Array<int> IntArray;
-
-  APR::Pool pool;
-  EXPECT_THROW(ByteArray array(IntArray(pool).array()),
-               std::invalid_argument);
-}
-
-TEST(ConstArrays, OutOfBounds)
-{
-  typedef APR::ConstArray<unsigned char> Array;
-
-  APR::Pool pool;
-  Array array = Array(APR::Array<Array::value_type>(pool));
-
-  EXPECT_THROW(array.at(-1), std::out_of_range);
-  EXPECT_THROW(array.at(array.size()), std::out_of_range);
-}
-
-TEST(ConstArrays, Indexing)
-{
-  typedef APR::ConstArray<const char*> Array;
-
-  APR::Pool pool;
-  Array array(fill_array(pool));
-
-  EXPECT_STREQ(array[0], APR_ARRAY_IDX(array.array(), 0, Array::value_type));
-  EXPECT_STREQ(array[array.size() - 1], APR_ARRAY_IDX(array.array(),
-                                                      array.array()->nelts - 1,
-                                                      Array::value_type));
-}
-
-TEST(ConstArrays, CheckedIndexing)
-{
-  typedef APR::ConstArray<const char*> Array;
-
-  APR::Pool pool;
-  Array array(fill_array(pool));
-
-  EXPECT_STREQ(array.at(0), APR_ARRAY_IDX(array.array(), 0, Array::value_type));
-  EXPECT_STREQ(array.at(array.size() - 1),
-               APR_ARRAY_IDX(array.array(), array.array()->nelts - 1,
-                             Array::value_type));
-}
-
-TEST(ConstArrays, Iteration)
-{
-  typedef APR::ConstArray<const char*> Array;
-
-  APR::Pool pool;
-  Array array(fill_array(pool));
-
-  struct Iteration : public Array::Iteration
-  {
-    Iteration(const  apr_array_header_t* raw_array)
-      : m_index(0), m_raw_array(raw_array)
-      {}
-
-    bool operator()(const Array::value_type& value)
-      {
-        EXPECT_STREQ(value, APR_ARRAY_IDX(m_raw_array, m_index,
-                                          Array::value_type));
-        ++m_index;
-        return true;
-      }
-
-  private:
-    Array::size_type m_index;
-    const apr_array_header_t* m_raw_array;
-  } callback(array.array());
-
-  array.iterate(callback);
-}
-
-//
-// Hash tables
-//
-
-TEST(Hashes, StringHash)
-{
-  typedef APR::Hash<char, const char> H;
-
-  APR::Pool pool;
-  H hash(pool);
-  hash.set("aa", "a");
-  hash.set("bbb", "b");
-  hash.set("cccc", "c");
-
-  EXPECT_EQ(3, hash.size());
-  EXPECT_STREQ("a", hash.get("aa"));
-  EXPECT_STREQ("b", hash.get("bbb"));
-  EXPECT_STREQ("c", hash.get("cccc"));
-}
-
-TEST(Hashes, FixedStringHash)
-{
-  // The point of this test is to verify that the key-length parameter
-  // of the template actually limits the length of the keys.
-  typedef APR::Hash<char, const char, 2> H;
-
-  APR::Pool pool;
-  H hash(pool);
-  hash.set("aa&qux", "a");
-  hash.set("bb#foo", "b");
-  hash.set("cc@bar", "c");
-
-  EXPECT_EQ(3, hash.size());
-  EXPECT_STREQ("a", hash.get("aa%foo"));
-  EXPECT_STREQ("b", hash.get("bb*bar"));
-  EXPECT_STREQ("c", hash.get("cc$qux"));
-}
-
-TEST(Hashes, Delete)
-{
-  typedef APR::Hash<char, const char> H;
-
-  APR::Pool pool;
-  H hash(pool);
-  hash.set("aa", "a");
-  hash.set("bbb", "b");
-  hash.set("cccc", "c");
-
-  hash.del("bbb");
-
-  EXPECT_EQ(2, hash.size());
-  EXPECT_STREQ("a", hash.get("aa"));
-  EXPECT_STREQ("c", hash.get("cccc"));
-}
-
-TEST(Hashes, Iterate)
-{
-  typedef APR::Hash<char, const char> H;
-
-  APR::Pool pool;
-  H hash(pool);
-  hash.set("aa", "a");
-  hash.set("bbb", "b");
-  hash.set("cccc", "c");
-
-  struct C : public H::Iteration
-  {
-    H& m_hash;
-    explicit C(H& hashref) : m_hash(hashref) {}
-
-    bool operator()(const H::Key& key, H::value_type value)
-      {
-        EXPECT_STREQ(value, m_hash.get(key));
-        return true;
-      }
-  } callback(hash);
-
-  hash.iterate(callback, pool);
-}
+BOOST_AUTO_TEST_SUITE_END();

Copied: subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_const_arrays.cpp (from r1849322, subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap.cpp)
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_const_arrays.cpp?p2=subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_const_arrays.cpp&p1=subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap.cpp&r1=1849322&r2=1849354&rev=1849354&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap.cpp (original)
+++ subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_const_arrays.cpp Thu Dec 20 01:33:47 2018
@@ -19,313 +19,79 @@
  * ====================================================================
  */
 
+#include <boost/test/unit_test.hpp>
+
 #include <algorithm>
 #include <stdexcept>
 
 #include "../src/aprwrap.hpp"
 
-#include <gmock/gmock.h>
-
-//
-// Pools
-//
-
-TEST(Pools, InitializeGlobalPool)
-{
-  APR::Pool pool;
-  EXPECT_THAT(pool.get(), testing::NotNull());
-  EXPECT_THAT(apr_pool_parent_get(pool.get()), testing::NotNull());
-}
-
-TEST(Pools, CreateSubpool)
-{
-  APR::Pool pool;
-  APR::Pool subpool(&pool);
-  EXPECT_EQ(pool.get(), apr_pool_parent_get(subpool.get()));
-}
-
-TEST(Pools, TypedAllocate)
-{
-  APR::Pool pool;
-  const unsigned char* buffer = pool.alloc<unsigned char>(1);
-  EXPECT_THAT(buffer, testing::NotNull());
-}
+#include "test_aprwrap_array_helpers.hpp"
 
-// N.B.: This test may pass randomly even if zero-filled allocation
-// does not work correctly, since we cannot make assumptions about the
-// values of uninitialized memory.
-TEST(Pools, TypedAllocateZerofill)
-{
-  APR::Pool pool;
-  static const std::size_t size = 32757;
-  const unsigned char* buffer = pool.allocz<unsigned char>(size);
-  ASSERT_THAT(buffer, testing::NotNull());
-  EXPECT_EQ(size, std::count(buffer, buffer + size, 0));
-}
+BOOST_AUTO_TEST_SUITE(aprwrap_const_arrayw);
 
-//
-// Array helper functions
-//
-
-namespace {
-// Create a randomly-ordered array of constant strings.
-apr_array_header_t* fill_array(APR::Pool& pool)
-{
-  apr_array_header_t* a = apr_array_make(pool.get(), 0, sizeof(const char*));
-  APR_ARRAY_PUSH(a, const char*) = "primus";
-  APR_ARRAY_PUSH(a, const char*) = "secundus";
-  APR_ARRAY_PUSH(a, const char*) = "tertius";
-  APR_ARRAY_PUSH(a, const char*) = "quartus";
-  APR_ARRAY_PUSH(a, const char*) = "quintus";
-  APR_ARRAY_PUSH(a, const char*) = "sextus";
-  APR_ARRAY_PUSH(a, const char*) = "septimus";
-  std::random_shuffle(&APR_ARRAY_IDX(a, 0, const char*),
-                      &APR_ARRAY_IDX(a, a->nelts, const char*));
-  return a;
-}
-} // anonymous namespace
-
-//
-// Arrays
-//
-
-TEST(Arrays, CreateArray)
-{
-  typedef APR::Array<unsigned char> Array;
-
-  APR::Pool pool;
-  Array array(pool);
-
-  EXPECT_THAT(array.array(), testing::NotNull());
-  EXPECT_EQ(0, array.size());
-  EXPECT_EQ(sizeof(unsigned char), sizeof(Array::value_type));
-  EXPECT_EQ(sizeof(Array::value_type), array.array()->elt_size);
-}
-
-TEST(Arrays, WrapArray)
-{
-  typedef APR::Array<unsigned char> Array;
-
-  APR::Pool pool;
-  apr_array_header_t* apr_array =
-    apr_array_make(pool.get(), 0, sizeof(Array::value_type));
-  ASSERT_THAT(apr_array, testing::NotNull());
-
-  Array array(apr_array);
-  EXPECT_EQ(apr_array, array.array());
-  EXPECT_EQ(0, array.size());
-}
-
-TEST(Arrays, RewrapTypeMismatch)
-{
-  typedef APR::Array<unsigned char> ByteArray;
-  typedef APR::Array<int> IntArray;
-
-  APR::Pool pool;
-  EXPECT_THROW(ByteArray array(IntArray(pool).array()),
-               std::invalid_argument);
-}
-
-TEST(Arrays, OutOfBounds)
-{
-  typedef APR::Array<unsigned char> Array;
-
-  APR::Pool pool;
-  Array array(pool);
-
-  EXPECT_THROW(array.at(-1), std::out_of_range);
-  EXPECT_THROW(array.at(array.size()), std::out_of_range);
-}
-
-TEST(Arrays, Indexing)
-{
-  typedef APR::Array<const char*> Array;
-
-  APR::Pool pool;
-  Array array(fill_array(pool));
-
-  EXPECT_STREQ(array[0], APR_ARRAY_IDX(array.array(), 0, Array::value_type));
-  EXPECT_STREQ(array[array.size() - 1], APR_ARRAY_IDX(array.array(),
-                                                      array.array()->nelts - 1,
-                                                      Array::value_type));
-}
-
-TEST(Arrays, CheckedIndexing)
-{
-  typedef APR::Array<const char*> Array;
-
-  APR::Pool pool;
-  Array array(fill_array(pool));
-
-  EXPECT_STREQ(array.at(0), APR_ARRAY_IDX(array.array(), 0, Array::value_type));
-  EXPECT_STREQ(array.at(array.size() - 1),
-               APR_ARRAY_IDX(array.array(), array.array()->nelts - 1,
-                             Array::value_type));
-}
-
-TEST(Arrays, Iteration)
-{
-  typedef APR::Array<const char*> Array;
-
-  APR::Pool pool;
-  Array array(fill_array(pool));
-
-  struct Iteration : public Array::Iteration
-  {
-    Iteration(apr_array_header_t* raw_array)
-      : m_index(0), m_raw_array(raw_array)
-      {}
-
-    bool operator()(Array::value_type& value)
-      {
-        EXPECT_STREQ(value, APR_ARRAY_IDX(m_raw_array, m_index,
-                                          Array::value_type));
-        ++m_index;
-        return true;
-      }
-
-  private:
-    Array::size_type m_index;
-    apr_array_header_t* m_raw_array;
-  } callback(array.array());
-
-  array.iterate(callback);
-}
-
-TEST(Arrays, ConstIteration)
-{
-  typedef APR::Array<const char*> Array;
-
-  APR::Pool pool;
-  Array array(fill_array(pool));
-
-  struct Iteration : public Array::ConstIteration
-  {
-    Iteration(const  apr_array_header_t* raw_array)
-      : m_index(0), m_raw_array(raw_array)
-      {}
-
-    bool operator()(const Array::value_type& value)
-      {
-        EXPECT_STREQ(value, APR_ARRAY_IDX(m_raw_array, m_index,
-                                          Array::value_type));
-        ++m_index;
-        return true;
-      }
-
-  private:
-    Array::size_type m_index;
-    const apr_array_header_t* m_raw_array;
-  } callback(array.array());
-
-  array.iterate(callback);
-}
-
-TEST(Arrays, Push)
-{
-  typedef APR::Array<const char*> Array;
-
-  APR::Pool pool;
-  Array array(fill_array(pool));
-
-  const Array::size_type point = array.size();
-  const Array::value_type first = array[0];
-  const Array::value_type last = array[point - 1];
-
-  array.push("octavius");
-  array.push("nonus");
-  array.push("decimus");
-
-  EXPECT_EQ(point + 3, array.size());
-  EXPECT_STREQ(first, array[0]);
-  EXPECT_STREQ(last, array[point - 1]);
-  EXPECT_STREQ("octavius", array[point]);
-  EXPECT_STREQ("decimus", array[array.size() - 1]);
-}
-
-TEST(Arrays, Pop)
-{
-  typedef APR::Array<const char*> Array;
-
-  APR::Pool pool;
-  Array array(fill_array(pool));
-
-  for (Array::size_type i = 0, z = array.size(); i <= z; ++i)
-    {
-      const char** last = (!array.array()->nelts ? NULL
-                           : &APR_ARRAY_IDX(array.array(),
-                                            array.array()->nelts - 1,
-                                            const char*));
-      EXPECT_EQ(last, array.pop());
-    }
-}
-
-//
-// ConstArrays
-//
-
-TEST(ConstArrays, WrapArray)
+BOOST_AUTO_TEST_CASE(wrap_array)
 {
   typedef APR::ConstArray<unsigned char> Array;
 
   APR::Pool pool;
   const apr_array_header_t* apr_array =
     apr_array_make(pool.get(), 0, sizeof(Array::value_type));
-  ASSERT_THAT(apr_array, testing::NotNull());
+  BOOST_TEST_REQUIRE(apr_array != nullptr);
 
   Array array(apr_array);
-  EXPECT_EQ(apr_array, array.array());
-  EXPECT_EQ(0, array.size());
+  BOOST_TEST(array.array() == apr_array);
+  BOOST_TEST(array.size() == 0);
 }
 
-TEST(ConstArrays, RewrapTypeMismatch)
+BOOST_AUTO_TEST_CASE(rewrap_type_mismatch)
 {
   typedef APR::ConstArray<unsigned char> ByteArray;
   typedef APR::Array<int> IntArray;
 
   APR::Pool pool;
-  EXPECT_THROW(ByteArray array(IntArray(pool).array()),
-               std::invalid_argument);
+  BOOST_CHECK_THROW(ByteArray array(IntArray(pool).array()),
+                    std::invalid_argument);
 }
 
-TEST(ConstArrays, OutOfBounds)
+BOOST_AUTO_TEST_CASE(out_of_bounds)
 {
   typedef APR::ConstArray<unsigned char> Array;
 
   APR::Pool pool;
   Array array = Array(APR::Array<Array::value_type>(pool));
 
-  EXPECT_THROW(array.at(-1), std::out_of_range);
-  EXPECT_THROW(array.at(array.size()), std::out_of_range);
+  BOOST_CHECK_THROW(array.at(-1), std::out_of_range);
+  BOOST_CHECK_THROW(array.at(array.size()), std::out_of_range);
 }
 
-TEST(ConstArrays, Indexing)
+BOOST_AUTO_TEST_CASE(indexing)
 {
   typedef APR::ConstArray<const char*> Array;
 
   APR::Pool pool;
   Array array(fill_array(pool));
 
-  EXPECT_STREQ(array[0], APR_ARRAY_IDX(array.array(), 0, Array::value_type));
-  EXPECT_STREQ(array[array.size() - 1], APR_ARRAY_IDX(array.array(),
+  BOOST_TEST(array[0] == APR_ARRAY_IDX(array.array(), 0, Array::value_type));
+  BOOST_TEST(array[array.size() - 1] == APR_ARRAY_IDX(array.array(),
                                                       array.array()->nelts - 1,
                                                       Array::value_type));
 }
 
-TEST(ConstArrays, CheckedIndexing)
+BOOST_AUTO_TEST_CASE(checked_indexing)
 {
   typedef APR::ConstArray<const char*> Array;
 
   APR::Pool pool;
   Array array(fill_array(pool));
 
-  EXPECT_STREQ(array.at(0), APR_ARRAY_IDX(array.array(), 0, Array::value_type));
-  EXPECT_STREQ(array.at(array.size() - 1),
-               APR_ARRAY_IDX(array.array(), array.array()->nelts - 1,
-                             Array::value_type));
+  BOOST_TEST(array.at(0) == APR_ARRAY_IDX(array.array(), 0, Array::value_type));
+  BOOST_TEST(array.at(array.size() - 1) == APR_ARRAY_IDX(array.array(),
+                                                         array.array()->nelts - 1,
+                                                         Array::value_type));
 }
 
-TEST(ConstArrays, Iteration)
+BOOST_AUTO_TEST_CASE(iteration)
 {
   typedef APR::ConstArray<const char*> Array;
 
@@ -340,7 +106,7 @@ TEST(ConstArrays, Iteration)
 
     bool operator()(const Array::value_type& value)
       {
-        EXPECT_STREQ(value, APR_ARRAY_IDX(m_raw_array, m_index,
+        BOOST_TEST(value == APR_ARRAY_IDX(m_raw_array, m_index,
                                           Array::value_type));
         ++m_index;
         return true;
@@ -354,82 +120,4 @@ TEST(ConstArrays, Iteration)
   array.iterate(callback);
 }
 
-//
-// Hash tables
-//
-
-TEST(Hashes, StringHash)
-{
-  typedef APR::Hash<char, const char> H;
-
-  APR::Pool pool;
-  H hash(pool);
-  hash.set("aa", "a");
-  hash.set("bbb", "b");
-  hash.set("cccc", "c");
-
-  EXPECT_EQ(3, hash.size());
-  EXPECT_STREQ("a", hash.get("aa"));
-  EXPECT_STREQ("b", hash.get("bbb"));
-  EXPECT_STREQ("c", hash.get("cccc"));
-}
-
-TEST(Hashes, FixedStringHash)
-{
-  // The point of this test is to verify that the key-length parameter
-  // of the template actually limits the length of the keys.
-  typedef APR::Hash<char, const char, 2> H;
-
-  APR::Pool pool;
-  H hash(pool);
-  hash.set("aa&qux", "a");
-  hash.set("bb#foo", "b");
-  hash.set("cc@bar", "c");
-
-  EXPECT_EQ(3, hash.size());
-  EXPECT_STREQ("a", hash.get("aa%foo"));
-  EXPECT_STREQ("b", hash.get("bb*bar"));
-  EXPECT_STREQ("c", hash.get("cc$qux"));
-}
-
-TEST(Hashes, Delete)
-{
-  typedef APR::Hash<char, const char> H;
-
-  APR::Pool pool;
-  H hash(pool);
-  hash.set("aa", "a");
-  hash.set("bbb", "b");
-  hash.set("cccc", "c");
-
-  hash.del("bbb");
-
-  EXPECT_EQ(2, hash.size());
-  EXPECT_STREQ("a", hash.get("aa"));
-  EXPECT_STREQ("c", hash.get("cccc"));
-}
-
-TEST(Hashes, Iterate)
-{
-  typedef APR::Hash<char, const char> H;
-
-  APR::Pool pool;
-  H hash(pool);
-  hash.set("aa", "a");
-  hash.set("bbb", "b");
-  hash.set("cccc", "c");
-
-  struct C : public H::Iteration
-  {
-    H& m_hash;
-    explicit C(H& hashref) : m_hash(hashref) {}
-
-    bool operator()(const H::Key& key, H::value_type value)
-      {
-        EXPECT_STREQ(value, m_hash.get(key));
-        return true;
-      }
-  } callback(hash);
-
-  hash.iterate(callback, pool);
-}
+BOOST_AUTO_TEST_SUITE_END();

Copied: subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_hashes.cpp (from r1849322, subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap.cpp)
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_hashes.cpp?p2=subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_hashes.cpp&p1=subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap.cpp&r1=1849322&r2=1849354&rev=1849354&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap.cpp (original)
+++ subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_hashes.cpp Thu Dec 20 01:33:47 2018
@@ -19,346 +19,16 @@
  * ====================================================================
  */
 
+#include <boost/test/unit_test.hpp>
+
 #include <algorithm>
 #include <stdexcept>
 
 #include "../src/aprwrap.hpp"
 
-#include <gmock/gmock.h>
-
-//
-// Pools
-//
-
-TEST(Pools, InitializeGlobalPool)
-{
-  APR::Pool pool;
-  EXPECT_THAT(pool.get(), testing::NotNull());
-  EXPECT_THAT(apr_pool_parent_get(pool.get()), testing::NotNull());
-}
-
-TEST(Pools, CreateSubpool)
-{
-  APR::Pool pool;
-  APR::Pool subpool(&pool);
-  EXPECT_EQ(pool.get(), apr_pool_parent_get(subpool.get()));
-}
-
-TEST(Pools, TypedAllocate)
-{
-  APR::Pool pool;
-  const unsigned char* buffer = pool.alloc<unsigned char>(1);
-  EXPECT_THAT(buffer, testing::NotNull());
-}
-
-// N.B.: This test may pass randomly even if zero-filled allocation
-// does not work correctly, since we cannot make assumptions about the
-// values of uninitialized memory.
-TEST(Pools, TypedAllocateZerofill)
-{
-  APR::Pool pool;
-  static const std::size_t size = 32757;
-  const unsigned char* buffer = pool.allocz<unsigned char>(size);
-  ASSERT_THAT(buffer, testing::NotNull());
-  EXPECT_EQ(size, std::count(buffer, buffer + size, 0));
-}
-
-//
-// Array helper functions
-//
-
-namespace {
-// Create a randomly-ordered array of constant strings.
-apr_array_header_t* fill_array(APR::Pool& pool)
-{
-  apr_array_header_t* a = apr_array_make(pool.get(), 0, sizeof(const char*));
-  APR_ARRAY_PUSH(a, const char*) = "primus";
-  APR_ARRAY_PUSH(a, const char*) = "secundus";
-  APR_ARRAY_PUSH(a, const char*) = "tertius";
-  APR_ARRAY_PUSH(a, const char*) = "quartus";
-  APR_ARRAY_PUSH(a, const char*) = "quintus";
-  APR_ARRAY_PUSH(a, const char*) = "sextus";
-  APR_ARRAY_PUSH(a, const char*) = "septimus";
-  std::random_shuffle(&APR_ARRAY_IDX(a, 0, const char*),
-                      &APR_ARRAY_IDX(a, a->nelts, const char*));
-  return a;
-}
-} // anonymous namespace
-
-//
-// Arrays
-//
-
-TEST(Arrays, CreateArray)
-{
-  typedef APR::Array<unsigned char> Array;
-
-  APR::Pool pool;
-  Array array(pool);
-
-  EXPECT_THAT(array.array(), testing::NotNull());
-  EXPECT_EQ(0, array.size());
-  EXPECT_EQ(sizeof(unsigned char), sizeof(Array::value_type));
-  EXPECT_EQ(sizeof(Array::value_type), array.array()->elt_size);
-}
-
-TEST(Arrays, WrapArray)
-{
-  typedef APR::Array<unsigned char> Array;
-
-  APR::Pool pool;
-  apr_array_header_t* apr_array =
-    apr_array_make(pool.get(), 0, sizeof(Array::value_type));
-  ASSERT_THAT(apr_array, testing::NotNull());
-
-  Array array(apr_array);
-  EXPECT_EQ(apr_array, array.array());
-  EXPECT_EQ(0, array.size());
-}
-
-TEST(Arrays, RewrapTypeMismatch)
-{
-  typedef APR::Array<unsigned char> ByteArray;
-  typedef APR::Array<int> IntArray;
-
-  APR::Pool pool;
-  EXPECT_THROW(ByteArray array(IntArray(pool).array()),
-               std::invalid_argument);
-}
-
-TEST(Arrays, OutOfBounds)
-{
-  typedef APR::Array<unsigned char> Array;
-
-  APR::Pool pool;
-  Array array(pool);
-
-  EXPECT_THROW(array.at(-1), std::out_of_range);
-  EXPECT_THROW(array.at(array.size()), std::out_of_range);
-}
-
-TEST(Arrays, Indexing)
-{
-  typedef APR::Array<const char*> Array;
-
-  APR::Pool pool;
-  Array array(fill_array(pool));
-
-  EXPECT_STREQ(array[0], APR_ARRAY_IDX(array.array(), 0, Array::value_type));
-  EXPECT_STREQ(array[array.size() - 1], APR_ARRAY_IDX(array.array(),
-                                                      array.array()->nelts - 1,
-                                                      Array::value_type));
-}
-
-TEST(Arrays, CheckedIndexing)
-{
-  typedef APR::Array<const char*> Array;
-
-  APR::Pool pool;
-  Array array(fill_array(pool));
-
-  EXPECT_STREQ(array.at(0), APR_ARRAY_IDX(array.array(), 0, Array::value_type));
-  EXPECT_STREQ(array.at(array.size() - 1),
-               APR_ARRAY_IDX(array.array(), array.array()->nelts - 1,
-                             Array::value_type));
-}
-
-TEST(Arrays, Iteration)
-{
-  typedef APR::Array<const char*> Array;
-
-  APR::Pool pool;
-  Array array(fill_array(pool));
-
-  struct Iteration : public Array::Iteration
-  {
-    Iteration(apr_array_header_t* raw_array)
-      : m_index(0), m_raw_array(raw_array)
-      {}
-
-    bool operator()(Array::value_type& value)
-      {
-        EXPECT_STREQ(value, APR_ARRAY_IDX(m_raw_array, m_index,
-                                          Array::value_type));
-        ++m_index;
-        return true;
-      }
-
-  private:
-    Array::size_type m_index;
-    apr_array_header_t* m_raw_array;
-  } callback(array.array());
-
-  array.iterate(callback);
-}
-
-TEST(Arrays, ConstIteration)
-{
-  typedef APR::Array<const char*> Array;
-
-  APR::Pool pool;
-  Array array(fill_array(pool));
-
-  struct Iteration : public Array::ConstIteration
-  {
-    Iteration(const  apr_array_header_t* raw_array)
-      : m_index(0), m_raw_array(raw_array)
-      {}
-
-    bool operator()(const Array::value_type& value)
-      {
-        EXPECT_STREQ(value, APR_ARRAY_IDX(m_raw_array, m_index,
-                                          Array::value_type));
-        ++m_index;
-        return true;
-      }
-
-  private:
-    Array::size_type m_index;
-    const apr_array_header_t* m_raw_array;
-  } callback(array.array());
+BOOST_AUTO_TEST_SUITE(aprwrap_hashes);
 
-  array.iterate(callback);
-}
-
-TEST(Arrays, Push)
-{
-  typedef APR::Array<const char*> Array;
-
-  APR::Pool pool;
-  Array array(fill_array(pool));
-
-  const Array::size_type point = array.size();
-  const Array::value_type first = array[0];
-  const Array::value_type last = array[point - 1];
-
-  array.push("octavius");
-  array.push("nonus");
-  array.push("decimus");
-
-  EXPECT_EQ(point + 3, array.size());
-  EXPECT_STREQ(first, array[0]);
-  EXPECT_STREQ(last, array[point - 1]);
-  EXPECT_STREQ("octavius", array[point]);
-  EXPECT_STREQ("decimus", array[array.size() - 1]);
-}
-
-TEST(Arrays, Pop)
-{
-  typedef APR::Array<const char*> Array;
-
-  APR::Pool pool;
-  Array array(fill_array(pool));
-
-  for (Array::size_type i = 0, z = array.size(); i <= z; ++i)
-    {
-      const char** last = (!array.array()->nelts ? NULL
-                           : &APR_ARRAY_IDX(array.array(),
-                                            array.array()->nelts - 1,
-                                            const char*));
-      EXPECT_EQ(last, array.pop());
-    }
-}
-
-//
-// ConstArrays
-//
-
-TEST(ConstArrays, WrapArray)
-{
-  typedef APR::ConstArray<unsigned char> Array;
-
-  APR::Pool pool;
-  const apr_array_header_t* apr_array =
-    apr_array_make(pool.get(), 0, sizeof(Array::value_type));
-  ASSERT_THAT(apr_array, testing::NotNull());
-
-  Array array(apr_array);
-  EXPECT_EQ(apr_array, array.array());
-  EXPECT_EQ(0, array.size());
-}
-
-TEST(ConstArrays, RewrapTypeMismatch)
-{
-  typedef APR::ConstArray<unsigned char> ByteArray;
-  typedef APR::Array<int> IntArray;
-
-  APR::Pool pool;
-  EXPECT_THROW(ByteArray array(IntArray(pool).array()),
-               std::invalid_argument);
-}
-
-TEST(ConstArrays, OutOfBounds)
-{
-  typedef APR::ConstArray<unsigned char> Array;
-
-  APR::Pool pool;
-  Array array = Array(APR::Array<Array::value_type>(pool));
-
-  EXPECT_THROW(array.at(-1), std::out_of_range);
-  EXPECT_THROW(array.at(array.size()), std::out_of_range);
-}
-
-TEST(ConstArrays, Indexing)
-{
-  typedef APR::ConstArray<const char*> Array;
-
-  APR::Pool pool;
-  Array array(fill_array(pool));
-
-  EXPECT_STREQ(array[0], APR_ARRAY_IDX(array.array(), 0, Array::value_type));
-  EXPECT_STREQ(array[array.size() - 1], APR_ARRAY_IDX(array.array(),
-                                                      array.array()->nelts - 1,
-                                                      Array::value_type));
-}
-
-TEST(ConstArrays, CheckedIndexing)
-{
-  typedef APR::ConstArray<const char*> Array;
-
-  APR::Pool pool;
-  Array array(fill_array(pool));
-
-  EXPECT_STREQ(array.at(0), APR_ARRAY_IDX(array.array(), 0, Array::value_type));
-  EXPECT_STREQ(array.at(array.size() - 1),
-               APR_ARRAY_IDX(array.array(), array.array()->nelts - 1,
-                             Array::value_type));
-}
-
-TEST(ConstArrays, Iteration)
-{
-  typedef APR::ConstArray<const char*> Array;
-
-  APR::Pool pool;
-  Array array(fill_array(pool));
-
-  struct Iteration : public Array::Iteration
-  {
-    Iteration(const  apr_array_header_t* raw_array)
-      : m_index(0), m_raw_array(raw_array)
-      {}
-
-    bool operator()(const Array::value_type& value)
-      {
-        EXPECT_STREQ(value, APR_ARRAY_IDX(m_raw_array, m_index,
-                                          Array::value_type));
-        ++m_index;
-        return true;
-      }
-
-  private:
-    Array::size_type m_index;
-    const apr_array_header_t* m_raw_array;
-  } callback(array.array());
-
-  array.iterate(callback);
-}
-
-//
-// Hash tables
-//
-
-TEST(Hashes, StringHash)
+BOOST_AUTO_TEST_CASE(string_hash)
 {
   typedef APR::Hash<char, const char> H;
 
@@ -368,13 +38,13 @@ TEST(Hashes, StringHash)
   hash.set("bbb", "b");
   hash.set("cccc", "c");
 
-  EXPECT_EQ(3, hash.size());
-  EXPECT_STREQ("a", hash.get("aa"));
-  EXPECT_STREQ("b", hash.get("bbb"));
-  EXPECT_STREQ("c", hash.get("cccc"));
+  BOOST_TEST(hash.size() == 3);
+  BOOST_TEST(hash.get("aa") == "a");
+  BOOST_TEST(hash.get("bbb") == "b");
+  BOOST_TEST(hash.get("cccc") == "c");
 }
 
-TEST(Hashes, FixedStringHash)
+BOOST_AUTO_TEST_CASE(fixed_string_hash)
 {
   // The point of this test is to verify that the key-length parameter
   // of the template actually limits the length of the keys.
@@ -386,13 +56,13 @@ TEST(Hashes, FixedStringHash)
   hash.set("bb#foo", "b");
   hash.set("cc@bar", "c");
 
-  EXPECT_EQ(3, hash.size());
-  EXPECT_STREQ("a", hash.get("aa%foo"));
-  EXPECT_STREQ("b", hash.get("bb*bar"));
-  EXPECT_STREQ("c", hash.get("cc$qux"));
+  BOOST_TEST(hash.size() == 3);
+  BOOST_TEST(hash.get("aa%foo") == "a");
+  BOOST_TEST(hash.get("bb*bar") == "b");
+  BOOST_TEST(hash.get("cc$qux") == "c");
 }
 
-TEST(Hashes, Delete)
+BOOST_AUTO_TEST_CASE(delete_element)
 {
   typedef APR::Hash<char, const char> H;
 
@@ -404,12 +74,12 @@ TEST(Hashes, Delete)
 
   hash.del("bbb");
 
-  EXPECT_EQ(2, hash.size());
-  EXPECT_STREQ("a", hash.get("aa"));
-  EXPECT_STREQ("c", hash.get("cccc"));
+  BOOST_TEST(hash.size() == 2);
+  BOOST_TEST(hash.get("aa") == "a");
+  BOOST_TEST(hash.get("cccc") == "c");
 }
 
-TEST(Hashes, Iterate)
+BOOST_AUTO_TEST_CASE(iterate)
 {
   typedef APR::Hash<char, const char> H;
 
@@ -426,10 +96,12 @@ TEST(Hashes, Iterate)
 
     bool operator()(const H::Key& key, H::value_type value)
       {
-        EXPECT_STREQ(value, m_hash.get(key));
+        BOOST_TEST(value == m_hash.get(key));
         return true;
       }
   } callback(hash);
 
   hash.iterate(callback, pool);
 }
+
+BOOST_AUTO_TEST_SUITE_END();

Copied: subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_pools.cpp (from r1849322, subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap.cpp)
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_pools.cpp?p2=subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_pools.cpp&p1=subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap.cpp&r1=1849322&r2=1849354&rev=1849354&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap.cpp (original)
+++ subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_pools.cpp Thu Dec 20 01:33:47 2018
@@ -19,417 +19,48 @@
  * ====================================================================
  */
 
+#include <boost/test/unit_test.hpp>
+
+#include "fixture_initialize_apr.hpp"
+
 #include <algorithm>
 #include <stdexcept>
 
 #include "../src/aprwrap.hpp"
 
-#include <gmock/gmock.h>
-
-//
-// Pools
-//
+BOOST_AUTO_TEST_SUITE(aprwrap_pools);
 
-TEST(Pools, InitializeGlobalPool)
+BOOST_AUTO_TEST_CASE(initialize_global_pool)
 {
   APR::Pool pool;
-  EXPECT_THAT(pool.get(), testing::NotNull());
-  EXPECT_THAT(apr_pool_parent_get(pool.get()), testing::NotNull());
+  BOOST_TEST(pool.get() != nullptr);
+  BOOST_TEST(apr_pool_parent_get(pool.get()) != nullptr);
 }
 
-TEST(Pools, CreateSubpool)
+BOOST_AUTO_TEST_CASE(create_subpool)
 {
   APR::Pool pool;
   APR::Pool subpool(&pool);
-  EXPECT_EQ(pool.get(), apr_pool_parent_get(subpool.get()));
+  BOOST_TEST(pool.get() == apr_pool_parent_get(subpool.get()));
 }
 
-TEST(Pools, TypedAllocate)
+BOOST_AUTO_TEST_CASE(typed_allocate)
 {
   APR::Pool pool;
   const unsigned char* buffer = pool.alloc<unsigned char>(1);
-  EXPECT_THAT(buffer, testing::NotNull());
+  BOOST_TEST(buffer != nullptr);
 }
 
 // N.B.: This test may pass randomly even if zero-filled allocation
 // does not work correctly, since we cannot make assumptions about the
 // values of uninitialized memory.
-TEST(Pools, TypedAllocateZerofill)
+BOOST_AUTO_TEST_CASE(typed_allocate_zerofill)
 {
   APR::Pool pool;
   static const std::size_t size = 32757;
   const unsigned char* buffer = pool.allocz<unsigned char>(size);
-  ASSERT_THAT(buffer, testing::NotNull());
-  EXPECT_EQ(size, std::count(buffer, buffer + size, 0));
-}
-
-//
-// Array helper functions
-//
-
-namespace {
-// Create a randomly-ordered array of constant strings.
-apr_array_header_t* fill_array(APR::Pool& pool)
-{
-  apr_array_header_t* a = apr_array_make(pool.get(), 0, sizeof(const char*));
-  APR_ARRAY_PUSH(a, const char*) = "primus";
-  APR_ARRAY_PUSH(a, const char*) = "secundus";
-  APR_ARRAY_PUSH(a, const char*) = "tertius";
-  APR_ARRAY_PUSH(a, const char*) = "quartus";
-  APR_ARRAY_PUSH(a, const char*) = "quintus";
-  APR_ARRAY_PUSH(a, const char*) = "sextus";
-  APR_ARRAY_PUSH(a, const char*) = "septimus";
-  std::random_shuffle(&APR_ARRAY_IDX(a, 0, const char*),
-                      &APR_ARRAY_IDX(a, a->nelts, const char*));
-  return a;
-}
-} // anonymous namespace
-
-//
-// Arrays
-//
-
-TEST(Arrays, CreateArray)
-{
-  typedef APR::Array<unsigned char> Array;
-
-  APR::Pool pool;
-  Array array(pool);
-
-  EXPECT_THAT(array.array(), testing::NotNull());
-  EXPECT_EQ(0, array.size());
-  EXPECT_EQ(sizeof(unsigned char), sizeof(Array::value_type));
-  EXPECT_EQ(sizeof(Array::value_type), array.array()->elt_size);
-}
-
-TEST(Arrays, WrapArray)
-{
-  typedef APR::Array<unsigned char> Array;
-
-  APR::Pool pool;
-  apr_array_header_t* apr_array =
-    apr_array_make(pool.get(), 0, sizeof(Array::value_type));
-  ASSERT_THAT(apr_array, testing::NotNull());
-
-  Array array(apr_array);
-  EXPECT_EQ(apr_array, array.array());
-  EXPECT_EQ(0, array.size());
-}
-
-TEST(Arrays, RewrapTypeMismatch)
-{
-  typedef APR::Array<unsigned char> ByteArray;
-  typedef APR::Array<int> IntArray;
-
-  APR::Pool pool;
-  EXPECT_THROW(ByteArray array(IntArray(pool).array()),
-               std::invalid_argument);
-}
-
-TEST(Arrays, OutOfBounds)
-{
-  typedef APR::Array<unsigned char> Array;
-
-  APR::Pool pool;
-  Array array(pool);
-
-  EXPECT_THROW(array.at(-1), std::out_of_range);
-  EXPECT_THROW(array.at(array.size()), std::out_of_range);
+  BOOST_TEST_REQUIRE(buffer != nullptr);
+  BOOST_TEST(std::count(buffer, buffer + size, 0) == size);
 }
 
-TEST(Arrays, Indexing)
-{
-  typedef APR::Array<const char*> Array;
-
-  APR::Pool pool;
-  Array array(fill_array(pool));
-
-  EXPECT_STREQ(array[0], APR_ARRAY_IDX(array.array(), 0, Array::value_type));
-  EXPECT_STREQ(array[array.size() - 1], APR_ARRAY_IDX(array.array(),
-                                                      array.array()->nelts - 1,
-                                                      Array::value_type));
-}
-
-TEST(Arrays, CheckedIndexing)
-{
-  typedef APR::Array<const char*> Array;
-
-  APR::Pool pool;
-  Array array(fill_array(pool));
-
-  EXPECT_STREQ(array.at(0), APR_ARRAY_IDX(array.array(), 0, Array::value_type));
-  EXPECT_STREQ(array.at(array.size() - 1),
-               APR_ARRAY_IDX(array.array(), array.array()->nelts - 1,
-                             Array::value_type));
-}
-
-TEST(Arrays, Iteration)
-{
-  typedef APR::Array<const char*> Array;
-
-  APR::Pool pool;
-  Array array(fill_array(pool));
-
-  struct Iteration : public Array::Iteration
-  {
-    Iteration(apr_array_header_t* raw_array)
-      : m_index(0), m_raw_array(raw_array)
-      {}
-
-    bool operator()(Array::value_type& value)
-      {
-        EXPECT_STREQ(value, APR_ARRAY_IDX(m_raw_array, m_index,
-                                          Array::value_type));
-        ++m_index;
-        return true;
-      }
-
-  private:
-    Array::size_type m_index;
-    apr_array_header_t* m_raw_array;
-  } callback(array.array());
-
-  array.iterate(callback);
-}
-
-TEST(Arrays, ConstIteration)
-{
-  typedef APR::Array<const char*> Array;
-
-  APR::Pool pool;
-  Array array(fill_array(pool));
-
-  struct Iteration : public Array::ConstIteration
-  {
-    Iteration(const  apr_array_header_t* raw_array)
-      : m_index(0), m_raw_array(raw_array)
-      {}
-
-    bool operator()(const Array::value_type& value)
-      {
-        EXPECT_STREQ(value, APR_ARRAY_IDX(m_raw_array, m_index,
-                                          Array::value_type));
-        ++m_index;
-        return true;
-      }
-
-  private:
-    Array::size_type m_index;
-    const apr_array_header_t* m_raw_array;
-  } callback(array.array());
-
-  array.iterate(callback);
-}
-
-TEST(Arrays, Push)
-{
-  typedef APR::Array<const char*> Array;
-
-  APR::Pool pool;
-  Array array(fill_array(pool));
-
-  const Array::size_type point = array.size();
-  const Array::value_type first = array[0];
-  const Array::value_type last = array[point - 1];
-
-  array.push("octavius");
-  array.push("nonus");
-  array.push("decimus");
-
-  EXPECT_EQ(point + 3, array.size());
-  EXPECT_STREQ(first, array[0]);
-  EXPECT_STREQ(last, array[point - 1]);
-  EXPECT_STREQ("octavius", array[point]);
-  EXPECT_STREQ("decimus", array[array.size() - 1]);
-}
-
-TEST(Arrays, Pop)
-{
-  typedef APR::Array<const char*> Array;
-
-  APR::Pool pool;
-  Array array(fill_array(pool));
-
-  for (Array::size_type i = 0, z = array.size(); i <= z; ++i)
-    {
-      const char** last = (!array.array()->nelts ? NULL
-                           : &APR_ARRAY_IDX(array.array(),
-                                            array.array()->nelts - 1,
-                                            const char*));
-      EXPECT_EQ(last, array.pop());
-    }
-}
-
-//
-// ConstArrays
-//
-
-TEST(ConstArrays, WrapArray)
-{
-  typedef APR::ConstArray<unsigned char> Array;
-
-  APR::Pool pool;
-  const apr_array_header_t* apr_array =
-    apr_array_make(pool.get(), 0, sizeof(Array::value_type));
-  ASSERT_THAT(apr_array, testing::NotNull());
-
-  Array array(apr_array);
-  EXPECT_EQ(apr_array, array.array());
-  EXPECT_EQ(0, array.size());
-}
-
-TEST(ConstArrays, RewrapTypeMismatch)
-{
-  typedef APR::ConstArray<unsigned char> ByteArray;
-  typedef APR::Array<int> IntArray;
-
-  APR::Pool pool;
-  EXPECT_THROW(ByteArray array(IntArray(pool).array()),
-               std::invalid_argument);
-}
-
-TEST(ConstArrays, OutOfBounds)
-{
-  typedef APR::ConstArray<unsigned char> Array;
-
-  APR::Pool pool;
-  Array array = Array(APR::Array<Array::value_type>(pool));
-
-  EXPECT_THROW(array.at(-1), std::out_of_range);
-  EXPECT_THROW(array.at(array.size()), std::out_of_range);
-}
-
-TEST(ConstArrays, Indexing)
-{
-  typedef APR::ConstArray<const char*> Array;
-
-  APR::Pool pool;
-  Array array(fill_array(pool));
-
-  EXPECT_STREQ(array[0], APR_ARRAY_IDX(array.array(), 0, Array::value_type));
-  EXPECT_STREQ(array[array.size() - 1], APR_ARRAY_IDX(array.array(),
-                                                      array.array()->nelts - 1,
-                                                      Array::value_type));
-}
-
-TEST(ConstArrays, CheckedIndexing)
-{
-  typedef APR::ConstArray<const char*> Array;
-
-  APR::Pool pool;
-  Array array(fill_array(pool));
-
-  EXPECT_STREQ(array.at(0), APR_ARRAY_IDX(array.array(), 0, Array::value_type));
-  EXPECT_STREQ(array.at(array.size() - 1),
-               APR_ARRAY_IDX(array.array(), array.array()->nelts - 1,
-                             Array::value_type));
-}
-
-TEST(ConstArrays, Iteration)
-{
-  typedef APR::ConstArray<const char*> Array;
-
-  APR::Pool pool;
-  Array array(fill_array(pool));
-
-  struct Iteration : public Array::Iteration
-  {
-    Iteration(const  apr_array_header_t* raw_array)
-      : m_index(0), m_raw_array(raw_array)
-      {}
-
-    bool operator()(const Array::value_type& value)
-      {
-        EXPECT_STREQ(value, APR_ARRAY_IDX(m_raw_array, m_index,
-                                          Array::value_type));
-        ++m_index;
-        return true;
-      }
-
-  private:
-    Array::size_type m_index;
-    const apr_array_header_t* m_raw_array;
-  } callback(array.array());
-
-  array.iterate(callback);
-}
-
-//
-// Hash tables
-//
-
-TEST(Hashes, StringHash)
-{
-  typedef APR::Hash<char, const char> H;
-
-  APR::Pool pool;
-  H hash(pool);
-  hash.set("aa", "a");
-  hash.set("bbb", "b");
-  hash.set("cccc", "c");
-
-  EXPECT_EQ(3, hash.size());
-  EXPECT_STREQ("a", hash.get("aa"));
-  EXPECT_STREQ("b", hash.get("bbb"));
-  EXPECT_STREQ("c", hash.get("cccc"));
-}
-
-TEST(Hashes, FixedStringHash)
-{
-  // The point of this test is to verify that the key-length parameter
-  // of the template actually limits the length of the keys.
-  typedef APR::Hash<char, const char, 2> H;
-
-  APR::Pool pool;
-  H hash(pool);
-  hash.set("aa&qux", "a");
-  hash.set("bb#foo", "b");
-  hash.set("cc@bar", "c");
-
-  EXPECT_EQ(3, hash.size());
-  EXPECT_STREQ("a", hash.get("aa%foo"));
-  EXPECT_STREQ("b", hash.get("bb*bar"));
-  EXPECT_STREQ("c", hash.get("cc$qux"));
-}
-
-TEST(Hashes, Delete)
-{
-  typedef APR::Hash<char, const char> H;
-
-  APR::Pool pool;
-  H hash(pool);
-  hash.set("aa", "a");
-  hash.set("bbb", "b");
-  hash.set("cccc", "c");
-
-  hash.del("bbb");
-
-  EXPECT_EQ(2, hash.size());
-  EXPECT_STREQ("a", hash.get("aa"));
-  EXPECT_STREQ("c", hash.get("cccc"));
-}
-
-TEST(Hashes, Iterate)
-{
-  typedef APR::Hash<char, const char> H;
-
-  APR::Pool pool;
-  H hash(pool);
-  hash.set("aa", "a");
-  hash.set("bbb", "b");
-  hash.set("cccc", "c");
-
-  struct C : public H::Iteration
-  {
-    H& m_hash;
-    explicit C(H& hashref) : m_hash(hashref) {}
-
-    bool operator()(const H::Key& key, H::value_type value)
-      {
-        EXPECT_STREQ(value, m_hash.get(key));
-        return true;
-      }
-  } callback(hash);
-
-  hash.iterate(callback, pool);
-}
+BOOST_AUTO_TEST_SUITE_END();

Copied: subversion/trunk/subversion/bindings/cxx/tests/test_exceptions.cpp (from r1849353, subversion/trunk/subversion/bindings/cxx/tests/test_exception.cpp)
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxx/tests/test_exceptions.cpp?p2=subversion/trunk/subversion/bindings/cxx/tests/test_exceptions.cpp&p1=subversion/trunk/subversion/bindings/cxx/tests/test_exception.cpp&r1=1849353&r2=1849354&rev=1849354&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/cxx/tests/test_exception.cpp (original)
+++ subversion/trunk/subversion/bindings/cxx/tests/test_exceptions.cpp Thu Dec 20 01:33:47 2018
@@ -18,6 +18,7 @@
  *    under the License.
  * ====================================================================
  */
+#include <boost/test/unit_test.hpp>
 
 #include <algorithm>
 #include <cstdio>
@@ -28,13 +29,11 @@
 #include "svnxx.hpp"
 #include "../src/private.hpp"
 
-#include <apr.h>
+//#include <apr.h>
 #include "svn_error.h"
 #undef TRUE
 #undef FALSE
 
-#include <gmock/gmock.h>
-
 namespace {
 svn_error_t* make_error_test_error()
 {
@@ -49,7 +48,9 @@ svn_error_t* make_error_test_error()
 }
 } // anonymous namespace
 
-TEST(Exceptions, CatchError)
+BOOST_AUTO_TEST_SUITE(exceptions);
+
+BOOST_AUTO_TEST_CASE(catch_error)
 {
   try
     {
@@ -58,27 +59,27 @@ TEST(Exceptions, CatchError)
   catch (const SVN::Error& err)
     {
       SVN::Error::MessageList ml = err.messages();
-      EXPECT_EQ(3, ml.size());
-      EXPECT_EQ(SVN_ERR_UNSUPPORTED_FEATURE, ml[0].code());
-      EXPECT_EQ(SVN_ERR_BASE, ml[1].code());
-      EXPECT_EQ(SVN_ERR_TEST_FAILED, ml[2].code());
+      BOOST_TEST(ml.size() == 3);
+      BOOST_TEST(ml[0].code() == SVN_ERR_UNSUPPORTED_FEATURE);
+      BOOST_TEST(ml[1].code() == SVN_ERR_BASE);
+      BOOST_TEST(ml[2].code() == SVN_ERR_TEST_FAILED);
 
       SVN::Error::MessageList tml = err.traced_messages();
 #ifdef SVN_DEBUG
-      EXPECT_EQ(8, tml.size());
-      EXPECT_EQ(SVN_ERR_UNSUPPORTED_FEATURE, tml[0].code());
-      EXPECT_EQ(SVN_ERR_UNSUPPORTED_FEATURE, tml[1].code());
-      EXPECT_EQ(SVN_ERR_UNSUPPORTED_FEATURE, tml[2].code());
-      EXPECT_EQ(SVN_ERR_BASE, tml[3].code());
-      EXPECT_EQ(SVN_ERR_BASE, tml[4].code());
-      EXPECT_EQ(SVN_ERR_BASE, tml[5].code());
-      EXPECT_EQ(SVN_ERR_TEST_FAILED, tml[6].code());
-      EXPECT_EQ(SVN_ERR_TEST_FAILED, tml[7].code());
+      BOOST_TEST(tml.size() == 8);
+      BOOST_TEST(tml[0].code() == SVN_ERR_UNSUPPORTED_FEATURE);
+      BOOST_TEST(tml[1].code() == SVN_ERR_UNSUPPORTED_FEATURE);
+      BOOST_TEST(tml[2].code() == SVN_ERR_UNSUPPORTED_FEATURE);
+      BOOST_TEST(tml[3].code() == SVN_ERR_BASE);
+      BOOST_TEST(tml[4].code() == SVN_ERR_BASE);
+      BOOST_TEST(tml[5].code() == SVN_ERR_BASE);
+      BOOST_TEST(tml[6].code() == SVN_ERR_TEST_FAILED);
+      BOOST_TEST(tml[7].code() == SVN_ERR_TEST_FAILED);
 #else  // !SVN_DEBUG
-      EXPECT_EQ(3, tml.size());
-      EXPECT_EQ(SVN_ERR_UNSUPPORTED_FEATURE, tml[0].code());
-      EXPECT_EQ(SVN_ERR_BASE, tml[1].code());
-      EXPECT_EQ(SVN_ERR_TEST_FAILED, tml[2].code());
+      BOOST_TEST(3, tml.size());
+      BOOST_TEST(SVN_ERR_UNSUPPORTED_FEATURE, tml[0].code());
+      BOOST_TEST(SVN_ERR_BASE, tml[1].code());
+      BOOST_TEST(SVN_ERR_TEST_FAILED, tml[2].code());
 #endif // SVN_DEBUG
     }
 }
@@ -98,7 +99,7 @@ svn_error_t* make_cancel_test_error()
 }
 } // anonymous namespace
 
-TEST(Exceptions, CatchCancelled)
+BOOST_AUTO_TEST_CASE(catch_canceled)
 {
   try
     {
@@ -107,27 +108,29 @@ TEST(Exceptions, CatchCancelled)
   catch (const SVN::Cancelled& err)
     {
       SVN::Error::MessageList ml = err.messages();
-      EXPECT_EQ(3, ml.size());
-      EXPECT_EQ(SVN_ERR_BASE, ml[0].code());
-      EXPECT_EQ(SVN_ERR_TEST_FAILED, ml[1].code());
-      EXPECT_EQ(SVN_ERR_CANCELLED, ml[2].code());
+      BOOST_TEST(ml.size() == 3);
+      BOOST_TEST(ml[0].code() == SVN_ERR_BASE);
+      BOOST_TEST(ml[1].code() == SVN_ERR_TEST_FAILED);
+      BOOST_TEST(ml[2].code() == SVN_ERR_CANCELLED);
 
       SVN::Error::MessageList tml = err.traced_messages();
 #ifdef SVN_DEBUG
-      EXPECT_EQ(8, tml.size());
-      EXPECT_EQ(SVN_ERR_BASE, tml[0].code());
-      EXPECT_EQ(SVN_ERR_BASE, tml[1].code());
-      EXPECT_EQ(SVN_ERR_BASE, tml[2].code());
-      EXPECT_EQ(SVN_ERR_TEST_FAILED, tml[3].code());
-      EXPECT_EQ(SVN_ERR_TEST_FAILED, tml[4].code());
-      EXPECT_EQ(SVN_ERR_CANCELLED, tml[5].code());
-      EXPECT_EQ(SVN_ERR_CANCELLED, tml[6].code());
-      EXPECT_EQ(SVN_ERR_CANCELLED, tml[7].code());
+      BOOST_TEST(tml.size() == 8);
+      BOOST_TEST(tml[0].code() == SVN_ERR_BASE);
+      BOOST_TEST(tml[1].code() == SVN_ERR_BASE);
+      BOOST_TEST(tml[2].code() == SVN_ERR_BASE);
+      BOOST_TEST(tml[3].code() == SVN_ERR_TEST_FAILED);
+      BOOST_TEST(tml[4].code() == SVN_ERR_TEST_FAILED);
+      BOOST_TEST(tml[5].code() == SVN_ERR_CANCELLED);
+      BOOST_TEST(tml[6].code() == SVN_ERR_CANCELLED);
+      BOOST_TEST(tml[7].code() == SVN_ERR_CANCELLED);
 #else  // !SVN_DEBUG
-      EXPECT_EQ(3, tml.size());
-      EXPECT_EQ(SVN_ERR_BASE, tml[0].code());
-      EXPECT_EQ(SVN_ERR_TEST_FAILED, tml[1].code());
-      EXPECT_EQ(SVN_ERR_CANCELLED, tml[2].code());
+      BOOST_TEST(tml.size() == 3);
+      BOOST_TEST(tml[0].code() == SVN_ERR_BASE);
+      BOOST_TEST(tml[1].code() == SVN_ERR_TEST_FAILED);
+      BOOST_TEST(tml[2].code() == SVN_ERR_CANCELLED);
 #endif // SVN_DEBUG
     }
 }
+
+BOOST_AUTO_TEST_SUITE_END();



Mime
View raw message