subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1849670 - in /subversion/trunk/subversion/bindings/cxx: include/ include/svnxx/ src/ src/aprwrap/ src/private/ tests/
Date Mon, 24 Dec 2018 05:06:35 GMT
Author: brane
Date: Mon Dec 24 05:06:35 2018
New Revision: 1849670

URL: http://svn.apache.org/viewvc?rev=1849670&view=rev
Log:
Implement SVN++ library initialisation and teardown.

[in subversion/bindings/cxx]
* include/svnxx/init.hpp: New.
* include/svnxx.hpp: Include svnxx/init.hpp.

* src/private/init-private.hpp: New.
* src/init.cpp: New. Implementation of class init.

* src/aprwrap/pool.hpp: Don't undefine Subversion's symbols.
* src/aprwrap/impl.cpp
  (Pool::get_root_pool): Just forward to class init.

* tests/fixture_init.hpp: New; test suite fixture for library initialisation.
* tests/test_aprwrap_arrays.cpp,
  tests/test_aprwrap_const_arrays.cpp,
  tests/test_aprwrap_hashes.cpp,
  tests/test_aprwrap_pools.cpp,
  tests/test_exceptions.cpp: Use the new init fixture.
* tests/test_init.cpp: New; tests for library initialisation and teardown.

* tests/svnxx-tests.cpp:
  (initialize_apr_library): Removed. Test suites are now responsible for
   their own initialisation, using the new init fixture.

Added:
    subversion/trunk/subversion/bindings/cxx/include/svnxx/init.hpp   (with props)
    subversion/trunk/subversion/bindings/cxx/src/init.cpp   (with props)
    subversion/trunk/subversion/bindings/cxx/src/private/init-private.hpp   (with props)
    subversion/trunk/subversion/bindings/cxx/tests/fixture_init.hpp   (with props)
    subversion/trunk/subversion/bindings/cxx/tests/test_init.cpp   (with props)
Modified:
    subversion/trunk/subversion/bindings/cxx/include/svnxx.hpp
    subversion/trunk/subversion/bindings/cxx/src/aprwrap/impl.cpp
    subversion/trunk/subversion/bindings/cxx/src/aprwrap/pool.hpp
    subversion/trunk/subversion/bindings/cxx/tests/svnxx-tests.cpp
    subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_arrays.cpp
    subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_const_arrays.cpp
    subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_hashes.cpp
    subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_pools.cpp
    subversion/trunk/subversion/bindings/cxx/tests/test_exceptions.cpp

Modified: subversion/trunk/subversion/bindings/cxx/include/svnxx.hpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxx/include/svnxx.hpp?rev=1849670&r1=1849669&r2=1849670&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/cxx/include/svnxx.hpp (original)
+++ subversion/trunk/subversion/bindings/cxx/include/svnxx.hpp Mon Dec 24 05:06:35 2018
@@ -29,6 +29,7 @@
 #define SVNXX_HPP
 
 // Expose the whole API and alias the default version namespace
+#include "svnxx/init.hpp"
 #include "svnxx/exception.hpp"
 #include "svnxx/tristate.hpp"
 

Added: subversion/trunk/subversion/bindings/cxx/include/svnxx/init.hpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxx/include/svnxx/init.hpp?rev=1849670&view=auto
==============================================================================
--- subversion/trunk/subversion/bindings/cxx/include/svnxx/init.hpp (added)
+++ subversion/trunk/subversion/bindings/cxx/include/svnxx/init.hpp Mon Dec 24 05:06:35 2018
@@ -0,0 +1,63 @@
+/**
+ * @copyright
+ * ====================================================================
+ *    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.
+ * ====================================================================
+ * @endcopyright
+ */
+
+#ifndef __cplusplus
+#error "This is a C++ header file."
+#endif
+
+#ifndef SVNXX_INIT_HPP
+#define SVNXX_INIT_HPP
+
+#include <memory>
+
+namespace apache {
+namespace subversion {
+namespace svnxx {
+
+namespace detail {
+// Forward declaration of the private API context.
+class context;
+} // namespace detail
+
+/**
+ * @brief SVN++ initialization.
+ *
+ * The @c init class takes care of library initialization and
+ * teardown and maintains shared (global) internal state. You must
+ * create an @c init object before you can use the SVN++ API. It is
+ * safe to create create any number of these objects.
+ */
+class init
+{
+public:
+  init();
+
+private:
+  std::shared_ptr<detail::context> context;
+};
+
+} // namespace svnxx
+} // namespace subversion
+} // namespace apache
+
+#endif  // SVNXX_INIT_HPP

Propchange: subversion/trunk/subversion/bindings/cxx/include/svnxx/init.hpp
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: subversion/trunk/subversion/bindings/cxx/src/aprwrap/impl.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxx/src/aprwrap/impl.cpp?rev=1849670&r1=1849669&r2=1849670&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/cxx/src/aprwrap/impl.cpp (original)
+++ subversion/trunk/subversion/bindings/cxx/src/aprwrap/impl.cpp Mon Dec 24 05:06:35 2018
@@ -21,13 +21,11 @@
  * @endcopyright
  */
 
-#include <mutex>
-
-#include "svn_private_config.h"
-
 #include "pool.hpp"
 #include "hash.hpp"
 
+#include "../private/init-private.hpp"
+
 namespace apache {
 namespace subversion {
 namespace svnxx {
@@ -39,18 +37,8 @@ namespace apr {
 
 apr_pool_t* Pool::get_root_pool()
 {
-  static std::once_flag atomic_init_flag;
-  static apr_pool_t* root_pool = nullptr;
-
-  std::call_once(
-      atomic_init_flag,
-      []()
-        {
-          const auto allocator = svn_pool_create_allocator(true);
-          root_pool = svn_pool_create_ex(nullptr, allocator);
-        });
-
-  return root_pool;
+  auto ctx = detail::context::get();
+  return ctx->get_root_pool();
 }
 
 //

Modified: subversion/trunk/subversion/bindings/cxx/src/aprwrap/pool.hpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxx/src/aprwrap/pool.hpp?rev=1849670&r1=1849669&r2=1849670&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/cxx/src/aprwrap/pool.hpp (original)
+++ subversion/trunk/subversion/bindings/cxx/src/aprwrap/pool.hpp Mon Dec 24 05:06:35 2018
@@ -30,8 +30,6 @@
 #include "svnxx/noncopyable.hpp"
 
 #include "svn_pools.h"
-#undef TRUE
-#undef FALSE
 
 namespace apache {
 namespace subversion {

Added: subversion/trunk/subversion/bindings/cxx/src/init.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxx/src/init.cpp?rev=1849670&view=auto
==============================================================================
--- subversion/trunk/subversion/bindings/cxx/src/init.cpp (added)
+++ subversion/trunk/subversion/bindings/cxx/src/init.cpp Mon Dec 24 05:06:35 2018
@@ -0,0 +1,89 @@
+/**
+ * @copyright
+ * ====================================================================
+ *    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.
+ * ====================================================================
+ * @endcopyright
+ */
+
+#include <sstream>
+
+#include "private/init-private.hpp"
+
+#include <apr_general.h>
+#include "svn_pools.h"
+
+namespace apache {
+namespace subversion {
+namespace svnxx {
+
+init::init()
+  : context(detail::context::create())
+{}
+
+namespace detail {
+
+std::mutex context::guard;
+context::weak_ptr context::self;
+
+context::ptr context::create()
+{
+  std::unique_lock<std::mutex> lock(guard);
+  auto ctx = self.lock();
+  if (!ctx)
+    {
+      // Work around the private constructor: since this struct is
+      // defined within a class member, the the private constructor
+      // is accessible and std::make_shared won't complain about it.
+      struct make_shared_hack : public context {};
+      ctx = std::make_shared<make_shared_hack>();
+      self = ctx;
+    }
+  return ctx;
+}
+
+context::context()
+{
+  const auto status = apr_initialize();
+  if (status)
+    {
+      char errbuf[120];
+      std::stringstream message;
+      message << "APR initialization failed: "
+              << apr_strerror(status, errbuf, sizeof(errbuf) - 1);
+      throw std::runtime_error(message.str());
+    }
+
+  const auto allocator = svn_pool_create_allocator(true);
+  root_pool = svn_pool_create_ex(nullptr, allocator);
+
+  // TODO: Check root pool for null.
+  // TODO: Change allocation-failed handler?
+}
+
+context::~context()
+{
+  std::unique_lock<std::mutex> lock(guard);
+  apr_terminate();
+  root_pool = nullptr;
+}
+
+} // namespace detail
+} // namespace svnxx
+} // namespace subversion
+} // namespace apache

Propchange: subversion/trunk/subversion/bindings/cxx/src/init.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: subversion/trunk/subversion/bindings/cxx/src/private/init-private.hpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxx/src/private/init-private.hpp?rev=1849670&view=auto
==============================================================================
--- subversion/trunk/subversion/bindings/cxx/src/private/init-private.hpp (added)
+++ subversion/trunk/subversion/bindings/cxx/src/private/init-private.hpp Mon Dec 24 05:06:35
2018
@@ -0,0 +1,89 @@
+/**
+ * @copyright
+ * ====================================================================
+ *    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.
+ * ====================================================================
+ * @endcopyright
+ */
+
+#ifndef __cplusplus
+#error "This is a C++ header file."
+#endif
+
+#ifndef SVNXX_PRIVATE_INIT_HPP
+#define SVNXX_PRIVATE_INIT_HPP
+
+#include <memory>
+#include <mutex>
+#include <stdexcept>
+
+#include <apr_pools.h>
+
+#include "svnxx/init.hpp"
+#include "svnxx/noncopyable.hpp"
+
+#include "svn_private_config.h"
+
+namespace apache {
+namespace subversion {
+namespace svnxx {
+namespace detail {
+
+class context : noncopyable
+{
+public:
+  using ptr = std::shared_ptr<context>;
+  using weak_ptr = std::weak_ptr<context>;
+
+  ~context();
+
+  static ptr create();
+  static ptr get()
+    {
+      auto ctx = self.lock();
+      if (!ctx)
+        {
+          throw std::logic_error(
+              _("The SVN++ library is not initialized."
+                " Did you forget to create an instance of "
+                " the apache::subversion::svnxx::init class?"));
+        }
+      return ctx;
+    }
+
+  apr_pool_t* get_root_pool() const noexcept
+    {
+      return root_pool;
+    }
+
+private:
+  // Thou shalt not create contexts other than through the factory.
+  context();
+
+  apr_pool_t* root_pool{nullptr};
+
+  static std::mutex guard;
+  static weak_ptr self;
+};
+
+} // namespace detail
+} // namespace svnxx
+} // namespace subversion
+} // namespace apache
+
+#endif // SVNXX_PRIVATE_INIT_HPP

Propchange: subversion/trunk/subversion/bindings/cxx/src/private/init-private.hpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: subversion/trunk/subversion/bindings/cxx/tests/fixture_init.hpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxx/tests/fixture_init.hpp?rev=1849670&view=auto
==============================================================================
--- subversion/trunk/subversion/bindings/cxx/tests/fixture_init.hpp (added)
+++ subversion/trunk/subversion/bindings/cxx/tests/fixture_init.hpp Mon Dec 24 05:06:35 2018
@@ -0,0 +1,38 @@
+/*
+ * ====================================================================
+ *    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_FIXTURE_INIT_HPP
+#define SVNXX_TEST_FIXTURE_INIT_HPP
+
+#include "svnxx/init.hpp"
+
+namespace {
+struct init
+{
+  apache::subversion::svnxx::init fixturizer;
+};
+} // anonymous namespace
+
+#endif  // SVNXX_TEST_FIXTURE_INIT_HPP

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

Modified: 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=1849670&r1=1849669&r2=1849670&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/cxx/tests/svnxx-tests.cpp (original)
+++ subversion/trunk/subversion/bindings/cxx/tests/svnxx-tests.cpp Mon Dec 24 05:06:35 2018
@@ -22,35 +22,6 @@
 #define BOOST_TEST_MODULE svnxx
 #include <boost/test/unit_test.hpp>
 
-#include <iostream>
-#include <stdexcept>
-
-#include <apr_general.h>
-
-
-struct initialize_apr_library
-{
-  initialize_apr_library()
-    {
-      const auto status = apr_initialize();
-      if (status)
-        {
-          char errbuf[512];
-          std::cerr << "APR initialization failed: "
-                    << apr_strerror(status, errbuf, sizeof(errbuf) - 1)
-                    << std::endl;
-          throw std::runtime_error("APR initialization failed");
-        }
-    }
-  ~initialize_apr_library()
-    {
-      apr_terminate();
-    }
-};
-
-BOOST_GLOBAL_FIXTURE(initialize_apr_library);
-
-
 int main (int argc, char* argv[])
 {
   return boost::unit_test::unit_test_main(&init_unit_test, argc, argv);

Modified: subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_arrays.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_arrays.cpp?rev=1849670&r1=1849669&r2=1849670&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_arrays.cpp (original)
+++ subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_arrays.cpp Mon Dec 24 05:06:35
2018
@@ -26,9 +26,12 @@
 
 #include "../src/aprwrap.hpp"
 
+#include "fixture_init.hpp"
+
 #include "test_aprwrap_array_helpers.hpp"
 
-BOOST_AUTO_TEST_SUITE(aprwrap_arrays);
+BOOST_AUTO_TEST_SUITE(aprwrap_arrays,
+                      * boost::unit_test::fixture<init>());
 
 BOOST_AUTO_TEST_CASE(create_array)
 {

Modified: subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_const_arrays.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_const_arrays.cpp?rev=1849670&r1=1849669&r2=1849670&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_const_arrays.cpp (original)
+++ subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_const_arrays.cpp Mon Dec 24
05:06:35 2018
@@ -26,9 +26,12 @@
 
 #include "../src/aprwrap.hpp"
 
+#include "fixture_init.hpp"
+
 #include "test_aprwrap_array_helpers.hpp"
 
-BOOST_AUTO_TEST_SUITE(aprwrap_const_arrayw);
+BOOST_AUTO_TEST_SUITE(aprwrap_const_arrayw,
+                      * boost::unit_test::fixture<init>());
 
 BOOST_AUTO_TEST_CASE(wrap_array)
 {

Modified: subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_hashes.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_hashes.cpp?rev=1849670&r1=1849669&r2=1849670&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_hashes.cpp (original)
+++ subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_hashes.cpp Mon Dec 24 05:06:35
2018
@@ -26,7 +26,10 @@
 
 #include "../src/aprwrap.hpp"
 
-BOOST_AUTO_TEST_SUITE(aprwrap_hashes);
+#include "fixture_init.hpp"
+
+BOOST_AUTO_TEST_SUITE(aprwrap_hashes,
+                      * boost::unit_test::fixture<init>());
 
 BOOST_AUTO_TEST_CASE(string_hash)
 {

Modified: subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_pools.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_pools.cpp?rev=1849670&r1=1849669&r2=1849670&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_pools.cpp (original)
+++ subversion/trunk/subversion/bindings/cxx/tests/test_aprwrap_pools.cpp Mon Dec 24 05:06:35
2018
@@ -26,7 +26,10 @@
 
 #include "../src/aprwrap.hpp"
 
-BOOST_AUTO_TEST_SUITE(aprwrap_pools);
+#include "fixture_init.hpp"
+
+BOOST_AUTO_TEST_SUITE(aprwrap_pools,
+                      * boost::unit_test::fixture<init>());
 
 BOOST_AUTO_TEST_CASE(initialize_global_pool)
 {

Modified: subversion/trunk/subversion/bindings/cxx/tests/test_exceptions.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxx/tests/test_exceptions.cpp?rev=1849670&r1=1849669&r2=1849670&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/cxx/tests/test_exceptions.cpp (original)
+++ subversion/trunk/subversion/bindings/cxx/tests/test_exceptions.cpp Mon Dec 24 05:06:35
2018
@@ -29,10 +29,9 @@
 #include "svnxx.hpp"
 #include "../src/private.hpp"
 
-//#include <apr.h>
 #include "svn_error.h"
-#undef TRUE
-#undef FALSE
+
+#include "fixture_init.hpp"
 
 namespace {
 svn_error_t* make_error_test_error()
@@ -48,7 +47,8 @@ svn_error_t* make_error_test_error()
 }
 } // anonymous namespace
 
-BOOST_AUTO_TEST_SUITE(exceptions);
+BOOST_AUTO_TEST_SUITE(exceptions,
+                      * boost::unit_test::fixture<init>());
 
 BOOST_AUTO_TEST_CASE(catch_error)
 {

Added: subversion/trunk/subversion/bindings/cxx/tests/test_init.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxx/tests/test_init.cpp?rev=1849670&view=auto
==============================================================================
--- subversion/trunk/subversion/bindings/cxx/tests/test_init.cpp (added)
+++ subversion/trunk/subversion/bindings/cxx/tests/test_init.cpp Mon Dec 24 05:06:35 2018
@@ -0,0 +1,64 @@
+/*
+ * ====================================================================
+ *    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.
+ * ====================================================================
+ */
+#include <boost/test/unit_test.hpp>
+
+#include "../src/private/init-private.hpp"
+
+namespace svn = ::apache::subversion::svnxx;
+namespace detail = ::apache::subversion::svnxx::detail;
+
+BOOST_AUTO_TEST_SUITE(init);
+
+BOOST_AUTO_TEST_CASE(context_with_init)
+{
+  svn::init svnxx_initialized;
+  BOOST_TEST(detail::context::get());
+}
+
+BOOST_AUTO_TEST_CASE(context_without_init)
+{
+  BOOST_CHECK_THROW(detail::context::get(), std::logic_error);
+}
+
+BOOST_AUTO_TEST_CASE(init_scope)
+{
+  {
+    svn::init svnxx_initialized;
+    BOOST_TEST(detail::context::get());
+  }
+  BOOST_CHECK_THROW(detail::context::get(), std::logic_error);
+}
+
+BOOST_AUTO_TEST_CASE(multi_init_same_context)
+{
+  svn::init svnxx_initialized_first;
+  const auto ctx = detail::context::get();
+  BOOST_REQUIRE(ctx);
+
+  {
+    svn::init svnxx_initialized_second;
+    BOOST_TEST(ctx == detail::context::get());
+  }
+
+  BOOST_TEST(ctx == detail::context::get());
+}
+
+BOOST_AUTO_TEST_SUITE_END();

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



Mime
View raw message