diff --git a/test/flat_map_test.cpp b/test/flat_map_test.cpp new file mode 100644 index 0000000..7fb5d97 --- /dev/null +++ b/test/flat_map_test.cpp @@ -0,0 +1,117 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2004-2026. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/interprocess for documentation. +// +////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include +#include +#include "print_container.hpp" +#include "movable_int.hpp" +#include "map_test.hpp" +#include "emplace_test.hpp" + +///////////////////////////////////////////////////////////////// +// +// This example repeats the same operations with std::map and +// shmem_map using the node allocator +// and compares the values of both containers +// +///////////////////////////////////////////////////////////////// + +using namespace boost::interprocess; + +//Customize managed_shared_memory class +typedef basic_managed_shared_memory + , + rbtree_best_fit, + iset_index + > my_managed_shared_memory; + +//Alias allocator type +typedef allocator, my_managed_shared_memory::segment_manager> + shmem_pair_allocator_t; +typedef allocator, my_managed_shared_memory::segment_manager> + shmem_movable_pair_allocator_t; + +typedef allocator, my_managed_shared_memory::segment_manager> + shmem_move_copy_pair_allocator_t; + +//Alias map types +typedef std::map MyStdMap; +typedef std::multimap MyStdMultiMap; + +typedef boost::container::flat_map, shmem_pair_allocator_t> MyShmMap; +typedef boost::container::flat_multimap, shmem_pair_allocator_t> MyShmMultiMap; + +typedef boost::container::flat_map + ,shmem_movable_pair_allocator_t> MyMovableShmMap; +typedef boost::container::flat_multimap + ,shmem_movable_pair_allocator_t> MyMovableShmMultiMap; + +typedef boost::container::flat_map + ,shmem_move_copy_pair_allocator_t> MyMoveCopyShmMap; +typedef boost::container::flat_multimap + ,shmem_move_copy_pair_allocator_t> MyMoveCopyShmMultiMap; + +int main() +{ + using namespace boost::interprocess::test; + + if (0 != map_test()){ + std::cout << "Error in map_test" << std::endl; + return 1; + } + + if (0 != map_test_copyable()){ + std::cout << "Error in map_test" << std::endl; + return 1; + } + +// if (0 != map_test()){ +// return 1; +// } + + if (0 != map_test()){ + std::cout << "Error in map_test" << std::endl; + return 1; + } + + //#if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC_MINOR__ < 3) + const test::EmplaceOptions MapOptions = (test::EmplaceOptions)(test::EMPLACE_HINT_PAIR | test::EMPLACE_ASSOC_PAIR); + + if(!boost::interprocess::test::test_emplace, MapOptions>()) + return 1; + if(!boost::interprocess::test::test_emplace, MapOptions>()) + return 1; + //#endif //!defined(__GNUC__) + return 0; + +} diff --git a/test/flat_tree_test.cpp b/test/flat_set_test.cpp similarity index 59% rename from test/flat_tree_test.cpp rename to test/flat_set_test.cpp index a517da1..37712b8 100644 --- a/test/flat_tree_test.cpp +++ b/test/flat_set_test.cpp @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost +// (C) Copyright Ion Gaztanaga 2004-2026. Distributed under the Boost // Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // @@ -11,14 +11,10 @@ #include #include #include -#include #include -#include #include "print_container.hpp" -#include "dummy_test_allocator.hpp" #include "movable_int.hpp" #include "set_test.hpp" -#include "map_test.hpp" #include "emplace_test.hpp" ///////////////////////////////////////////////////////////////// @@ -44,10 +40,6 @@ typedef allocator shmem_allocator_t; typedef allocator shmem_movable_allocator_t; -typedef allocator, my_managed_shared_memory::segment_manager> - shmem_pair_allocator_t; -typedef allocator, my_managed_shared_memory::segment_manager> - shmem_movable_pair_allocator_t; typedef allocator shmem_move_copy_allocator_t; @@ -55,30 +47,17 @@ typedef allocator shmem_copy_allocator_t; -typedef allocator, my_managed_shared_memory::segment_manager> - shmem_move_copy_pair_allocator_t; - //Alias set types typedef std::set MyStdSet; typedef std::multiset MyStdMultiSet; -typedef std::map MyStdMap; -typedef std::multimap MyStdMultiMap; typedef boost::container::flat_set, shmem_allocator_t> MyShmSet; typedef boost::container::flat_multiset, shmem_allocator_t> MyShmMultiSet; -typedef boost::container::flat_map, shmem_pair_allocator_t> MyShmMap; -typedef boost::container::flat_multimap, shmem_pair_allocator_t> MyShmMultiMap; typedef boost::container::flat_set ,shmem_movable_allocator_t> MyMovableShmSet; typedef boost::container::flat_multiset ,shmem_movable_allocator_t> MyMovableShmMultiSet; -typedef boost::container::flat_map - ,shmem_movable_pair_allocator_t> MyMovableShmMap; -typedef boost::container::flat_multimap - ,shmem_movable_pair_allocator_t> MyMovableShmMultiMap; typedef boost::container::flat_set ,shmem_move_copy_allocator_t> MyMoveCopyShmSet; @@ -90,13 +69,6 @@ typedef boost::container::flat_set ,shmem_copy_allocator_t> MyCopyShmMultiSet; -typedef boost::container::flat_map - ,shmem_move_copy_pair_allocator_t> MyMoveCopyShmMap; -typedef boost::container::flat_multimap - ,shmem_move_copy_pair_allocator_t> MyMoveCopyShmMultiMap; - int main() { using namespace boost::interprocess::test; @@ -146,49 +118,9 @@ int main() return 1; } - if (0 != map_test()){ - std::cout << "Error in map_test" << std::endl; - return 1; - } - - if (0 != map_test_copyable()){ - std::cout << "Error in map_test" << std::endl; - return 1; - } - -// if (0 != map_test()){ -// return 1; -// } - - if (0 != map_test()){ - std::cout << "Error in map_test" << std::endl; - return 1; - } - //#if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC_MINOR__ < 3) const test::EmplaceOptions SetOptions = (test::EmplaceOptions)(test::EMPLACE_HINT | test::EMPLACE_ASSOC); - const test::EmplaceOptions MapOptions = (test::EmplaceOptions)(test::EMPLACE_HINT_PAIR | test::EMPLACE_ASSOC_PAIR); - if(!boost::interprocess::test::test_emplace, MapOptions>()) - return 1; - if(!boost::interprocess::test::test_emplace, MapOptions>()) - return 1; if(!boost::interprocess::test::test_emplace, SetOptions>()) return 1; if(!boost::interprocess::test::test_emplace, SetOptions>()) diff --git a/test/map_test.cpp b/test/map_test.cpp new file mode 100644 index 0000000..7a6ab5c --- /dev/null +++ b/test/map_test.cpp @@ -0,0 +1,116 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/interprocess for documentation. +// +////////////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include +#include +#include +#include "print_container.hpp" +#include "movable_int.hpp" +#include "map_test.hpp" +#include "emplace_test.hpp" + +/////////////////////////////////////////////////////////////////// +// // +// This example repeats the same operations with std::map and // +// shmem_map using the node allocator // +// and compares the values of both containers // +// // +/////////////////////////////////////////////////////////////////// + +using namespace boost::interprocess; + +//Customize managed_shared_memory class +typedef basic_managed_shared_memory + >, + map_index + > my_managed_shared_memory; + +//We will work with narrow characters for shared memory objects +//Alias an integer node allocator type +typedef allocator, my_managed_shared_memory::segment_manager> + shmem_node_pair_allocator_t; +typedef allocator, my_managed_shared_memory::segment_manager> + shmem_movable_node_pair_allocator_t; +typedef allocator, my_managed_shared_memory::segment_manager> + shmem_move_copy_node_pair_allocator_t; + +//Alias standard types +typedef std::map MyStdMap; +typedef std::multimap MyStdMultiMap; + +//Alias non-movable types +typedef boost::container::map, shmem_node_pair_allocator_t> MyShmMap; +typedef boost::container::multimap, shmem_node_pair_allocator_t> MyShmMultiMap; + +//Alias movable types +typedef boost::container::map, + shmem_movable_node_pair_allocator_t> MyMovableShmMap; +typedef boost::container::multimap, + shmem_movable_node_pair_allocator_t> MyMovableShmMultiMap; + +typedef boost::container::map + ,shmem_move_copy_node_pair_allocator_t> MyMoveCopyShmMap; +typedef boost::container::multimap + ,shmem_move_copy_node_pair_allocator_t> MyMoveCopyShmMultiMap; + +int main () +{ + using namespace boost::interprocess::ipcdetail; + + if (0 != test::map_test()){ + return 1; + } + + if(0 != test::map_test_copyable()){ + return 1; + } + +// if (0 != test::map_test()){ +// return 1; +// } + + if (0 != test::map_test()){ + return 1; + } + + const test::EmplaceOptions MapOptions = (test::EmplaceOptions)(test::EMPLACE_HINT_PAIR | test::EMPLACE_ASSOC_PAIR); + if(!boost::interprocess::test::test_emplace, MapOptions>()) + return 1; + if(!boost::interprocess::test::test_emplace, MapOptions>()) + return 1; + + return 0; +} diff --git a/test/tree_test.cpp b/test/set_test.cpp similarity index 62% rename from test/tree_test.cpp rename to test/set_test.cpp index 8670ab4..3b9e6ad 100644 --- a/test/tree_test.cpp +++ b/test/set_test.cpp @@ -10,16 +10,13 @@ #include #include #include -#include #include #include #include #include #include "print_container.hpp" #include "movable_int.hpp" -#include "dummy_test_allocator.hpp" #include "set_test.hpp" -#include "map_test.hpp" #include "emplace_test.hpp" /////////////////////////////////////////////////////////////////// @@ -43,30 +40,20 @@ typedef basic_managed_shared_memory //Alias an integer node allocator type typedef allocator shmem_allocator_t; -typedef allocator, my_managed_shared_memory::segment_manager> - shmem_node_pair_allocator_t; typedef allocator shmem_movable_allocator_t; -typedef allocator, my_managed_shared_memory::segment_manager> - shmem_movable_node_pair_allocator_t; typedef allocator shmem_move_copy_allocator_t; typedef allocator shmem_copy_allocator_t; -typedef allocator, my_managed_shared_memory::segment_manager> - shmem_move_copy_node_pair_allocator_t; //Alias standard types typedef std::set MyStdSet; typedef std::multiset MyStdMultiSet; -typedef std::map MyStdMap; -typedef std::multimap MyStdMultiMap; //Alias non-movable types typedef boost::container::set, shmem_allocator_t> MyShmSet; typedef boost::container::multiset, shmem_allocator_t> MyShmMultiSet; -typedef boost::container::map, shmem_node_pair_allocator_t> MyShmMap; -typedef boost::container::multimap, shmem_node_pair_allocator_t> MyShmMultiMap; //Alias movable types typedef boost::container::set @@ -74,12 +61,6 @@ typedef boost::container::set typedef boost::container::multiset, shmem_movable_allocator_t> MyMovableShmMultiSet; -typedef boost::container::map, - shmem_movable_node_pair_allocator_t> MyMovableShmMap; -typedef boost::container::multimap, - shmem_movable_node_pair_allocator_t> MyMovableShmMultiMap; typedef boost::container::set @@ -95,16 +76,6 @@ typedef boost::container::multiset, shmem_copy_allocator_t> MyCopyShmMultiSet; - -typedef boost::container::map - ,shmem_move_copy_node_pair_allocator_t> MyMoveCopyShmMap; -typedef boost::container::multimap - ,shmem_move_copy_node_pair_allocator_t> MyMoveCopyShmMultiMap; - int main () { using namespace boost::interprocess::ipcdetail; @@ -149,48 +120,11 @@ int main () return 1; } - if (0 != test::map_test()){ - return 1; - } - - if(0 != test::map_test_copyable()){ - return 1; - } - -// if (0 != test::map_test()){ -// return 1; -// } - - if (0 != test::map_test()){ - return 1; - } - const test::EmplaceOptions SetOptions = (test::EmplaceOptions)(test::EMPLACE_HINT | test::EMPLACE_ASSOC); if(!boost::interprocess::test::test_emplace, SetOptions>()) return 1; if(!boost::interprocess::test::test_emplace, SetOptions>()) return 1; - const test::EmplaceOptions MapOptions = (test::EmplaceOptions)(test::EMPLACE_HINT_PAIR | test::EMPLACE_ASSOC_PAIR); - if(!boost::interprocess::test::test_emplace, MapOptions>()) - return 1; - if(!boost::interprocess::test::test_emplace, MapOptions>()) - return 1; return 0; }