From 6b3c72a25caaeb39fcef99d2e19b64cf9d1e11f1 Mon Sep 17 00:00:00 2001 From: Gerry Manoim Date: Thu, 2 Jul 2020 19:42:49 -0400 Subject: [PATCH] ENH: Add wrappers for abseil containers --- include/libpy/library_wrappers/abseil.h | 19 +++++++++++++++++++ tests/library_wrappers/test_abseil.cc | 20 ++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 include/libpy/library_wrappers/abseil.h create mode 100644 tests/library_wrappers/test_abseil.cc diff --git a/include/libpy/library_wrappers/abseil.h b/include/libpy/library_wrappers/abseil.h new file mode 100644 index 00000000..369fbdde --- /dev/null +++ b/include/libpy/library_wrappers/abseil.h @@ -0,0 +1,19 @@ +#pragma once + +#include +#include + +#include "libpy/to_object.h" + +namespace py { +namespace dispatch { + +template +struct to_object> + : public map_to_object> {}; + +template +struct to_object> : public set_to_object> {}; + +} // namespace dispatch +} // namespace py diff --git a/tests/library_wrappers/test_abseil.cc b/tests/library_wrappers/test_abseil.cc new file mode 100644 index 00000000..0f8768b1 --- /dev/null +++ b/tests/library_wrappers/test_abseil.cc @@ -0,0 +1,20 @@ +#include "libpy/library_wrappers/abseil.h" + +#include "test_utils.h" + +namespace test_abseil { + +class abseil_to_object : public with_python_interpreter {}; + +TEST_F(abseil_to_object, btree_map) { + auto map = absl::btree_map(); + py_test::test_map_to_object_impl(map); +} + +TEST_F(abseil_to_object, btree_set) { + auto filler = py_test::examples(); + auto a = absl::btree_set(filler.begin(), filler.end()); + py_test::test_set_to_object_impl(a); +} + +} // namespace test_abseil