map_test.hpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. ////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2006-2012. Distributed under the Boost
  4. // Software License, Version 1.0. (See accompanying file
  5. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // See http://www.boost.org/libs/interprocess for documentation.
  8. //
  9. ////////////////////////////////////////
  10. #ifndef BOOST_INTERPROCESS_TEST_MAP_TEST_HEADER
  11. #define BOOST_INTERPROCESS_TEST_MAP_TEST_HEADER
  12. #include <boost/interprocess/detail/config_begin.hpp>
  13. #include "check_equal_containers.hpp"
  14. #include <map>
  15. // interprocess
  16. #include <boost/interprocess/containers/pair.hpp>
  17. // interprocess/detail
  18. #include <boost/interprocess/detail/utilities.hpp>
  19. // intrusive/detail
  20. #include <boost/intrusive/detail/minimal_pair_header.hpp>
  21. #include <boost/intrusive/detail/minimal_less_equal_header.hpp>
  22. // std
  23. #include <string>
  24. #include "print_container.hpp"
  25. #include "get_process_id_name.hpp"
  26. template<class T1, class T2, class T3, class T4>
  27. bool operator ==(std::pair<T1, T2> &p1, std::pair<T1, T2> &p2)
  28. {
  29. return p1.first == p2.first && p1.second == p2.second;
  30. }
  31. namespace boost{
  32. namespace interprocess{
  33. namespace test{
  34. template<class ManagedSharedMemory
  35. ,class MyShmMap
  36. ,class MyStdMap
  37. ,class MyShmMultiMap
  38. ,class MyStdMultiMap>
  39. int map_test ()
  40. {
  41. typedef typename MyShmMap::key_type IntType;
  42. typedef boost::interprocess::pair<IntType, IntType> IntPairType;
  43. typedef typename MyStdMap::value_type StdPairType;
  44. const int memsize = 65536;
  45. const char *const shMemName = test::get_process_id_name();
  46. const int max = 100;
  47. try{
  48. //Create shared memory
  49. shared_memory_object::remove(shMemName);
  50. ManagedSharedMemory segment(create_only, shMemName, memsize);
  51. segment.reserve_named_objects(100);
  52. //Shared memory allocator must be always be initialized
  53. //since it has no default constructor
  54. MyShmMap *shmmap =
  55. segment.template construct<MyShmMap>("MyShmMap")
  56. (std::less<IntType>(), segment.get_segment_manager());
  57. MyStdMap *stdmap = new MyStdMap;
  58. MyShmMultiMap *shmmultimap =
  59. segment.template construct<MyShmMultiMap>("MyShmMultiMap")
  60. (std::less<IntType>(), segment.get_segment_manager());
  61. MyStdMultiMap *stdmultimap = new MyStdMultiMap;
  62. //Test construction from a range
  63. {
  64. //This is really nasty, but we have no other simple choice
  65. IntPairType aux_vect[50];
  66. for(int i = 0; i < 50; ++i){
  67. IntType i1(i/2);
  68. IntType i2(i/2);
  69. new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2));
  70. }
  71. typedef typename MyStdMap::value_type StdValueType;
  72. typedef typename MyStdMap::key_type StdKeyType;
  73. typedef typename MyStdMap::mapped_type StdMappedType;
  74. StdValueType aux_vect2[50];
  75. for(int i = 0; i < 50; ++i){
  76. new(&aux_vect2[i])StdValueType(StdKeyType(i/2), StdMappedType(i/2));
  77. }
  78. IntPairType aux_vect3[50];
  79. for(int i = 0; i < 50; ++i){
  80. IntType i1(i/2);
  81. IntType i2(i/2);
  82. new(&aux_vect3[i])IntPairType(boost::move(i1), boost::move(i2));
  83. }
  84. MyShmMap *shmmap2 =
  85. segment.template construct<MyShmMap>("MyShmMap2")
  86. ( ::boost::make_move_iterator(&aux_vect[0])
  87. , ::boost::make_move_iterator(aux_vect + 50)
  88. , std::less<IntType>(), segment.get_segment_manager());
  89. MyStdMap *stdmap2 = new MyStdMap(aux_vect2, aux_vect2 + 50);
  90. MyShmMultiMap *shmmultimap2 =
  91. segment.template construct<MyShmMultiMap>("MyShmMultiMap2")
  92. ( ::boost::make_move_iterator(&aux_vect3[0])
  93. , ::boost::make_move_iterator(aux_vect3 + 50)
  94. , std::less<IntType>(), segment.get_segment_manager());
  95. MyStdMultiMap *stdmultimap2 = new MyStdMultiMap(aux_vect2, aux_vect2 + 50);
  96. if(!CheckEqualContainers(shmmap2, stdmap2)) return 1;
  97. if(!CheckEqualContainers(shmmultimap2, stdmultimap2)) return 1;
  98. //ordered range insertion
  99. //This is really nasty, but we have no other simple choice
  100. for(int i = 0; i < 50; ++i){
  101. IntType i1(i);
  102. IntType i2(i);
  103. new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2));
  104. }
  105. for(int i = 0; i < 50; ++i){
  106. new(&aux_vect2[i])StdValueType(StdKeyType(i), StdMappedType(i));
  107. }
  108. for(int i = 0; i < 50; ++i){
  109. IntType i1(i);
  110. IntType i2(i);
  111. new(&aux_vect3[i])IntPairType(boost::move(i1), boost::move(i2));
  112. }
  113. MyShmMap *shmmap3 =
  114. segment.template construct<MyShmMap>("MyShmMap3")
  115. ( ordered_unique_range
  116. , ::boost::make_move_iterator(&aux_vect[0])
  117. , ::boost::make_move_iterator(aux_vect + 50)
  118. , std::less<IntType>(), segment.get_segment_manager());
  119. MyStdMap *stdmap3 = new MyStdMap(aux_vect2, aux_vect2 + 50);
  120. MyShmMultiMap *shmmultimap3 =
  121. segment.template construct<MyShmMultiMap>("MyShmMultiMap3")
  122. ( ordered_range
  123. , ::boost::make_move_iterator(&aux_vect3[0])
  124. , ::boost::make_move_iterator(aux_vect3 + 50)
  125. , std::less<IntType>(), segment.get_segment_manager());
  126. MyStdMultiMap *stdmultimap3 = new MyStdMultiMap(aux_vect2, aux_vect2 + 50);
  127. if(!CheckEqualContainers(shmmap3, stdmap3)){
  128. std::cout << "Error in construct<MyShmMap>(MyShmMap3)" << std::endl;
  129. return 1;
  130. }
  131. if(!CheckEqualContainers(shmmultimap3, stdmultimap3)){
  132. std::cout << "Error in construct<MyShmMultiMap>(MyShmMultiMap3)" << std::endl;
  133. return 1;
  134. }
  135. segment.destroy_ptr(shmmap2);
  136. segment.destroy_ptr(shmmultimap2);
  137. delete stdmap2;
  138. delete stdmultimap2;
  139. segment.destroy_ptr(shmmap3);
  140. segment.destroy_ptr(shmmultimap3);
  141. delete stdmap3;
  142. delete stdmultimap3;
  143. }
  144. {
  145. //This is really nasty, but we have no other simple choice
  146. IntPairType aux_vect[max];
  147. for(int i = 0; i < max; ++i){
  148. IntType i1(i);
  149. IntType i2(i);
  150. new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2));
  151. }
  152. IntPairType aux_vect3[max];
  153. for(int i = 0; i < max; ++i){
  154. IntType i1(i);
  155. IntType i2(i);
  156. new(&aux_vect3[i])IntPairType(boost::move(i1), boost::move(i2));
  157. }
  158. for(int i = 0; i < max; ++i){
  159. shmmap->insert(boost::move(aux_vect[i]));
  160. stdmap->insert(StdPairType(i, i));
  161. shmmultimap->insert(boost::move(aux_vect3[i]));
  162. stdmultimap->insert(StdPairType(i, i));
  163. }
  164. if(!CheckEqualPairContainers(shmmap, stdmap)) return 1;
  165. if(!CheckEqualPairContainers(shmmultimap, stdmultimap)) return 1;
  166. typename MyShmMap::iterator it;
  167. typename MyShmMap::const_iterator cit = it;
  168. (void)cit;
  169. shmmap->erase(shmmap->begin()++);
  170. stdmap->erase(stdmap->begin()++);
  171. shmmultimap->erase(shmmultimap->begin()++);
  172. stdmultimap->erase(stdmultimap->begin()++);
  173. if(!CheckEqualPairContainers(shmmap, stdmap)) return 1;
  174. if(!CheckEqualPairContainers(shmmultimap, stdmultimap)) return 1;
  175. shmmap->erase(shmmap->begin());
  176. stdmap->erase(stdmap->begin());
  177. shmmultimap->erase(shmmultimap->begin());
  178. stdmultimap->erase(stdmultimap->begin());
  179. if(!CheckEqualPairContainers(shmmap, stdmap)) return 1;
  180. if(!CheckEqualPairContainers(shmmultimap, stdmultimap)) return 1;
  181. //Swapping test
  182. std::less<IntType> lessfunc;
  183. MyShmMap tmpshmemap2 (lessfunc, segment.get_segment_manager());
  184. MyStdMap tmpstdmap2;
  185. MyShmMultiMap tmpshmemultimap2(lessfunc, segment.get_segment_manager());
  186. MyStdMultiMap tmpstdmultimap2;
  187. shmmap->swap(tmpshmemap2);
  188. stdmap->swap(tmpstdmap2);
  189. shmmultimap->swap(tmpshmemultimap2);
  190. stdmultimap->swap(tmpstdmultimap2);
  191. shmmap->swap(tmpshmemap2);
  192. stdmap->swap(tmpstdmap2);
  193. shmmultimap->swap(tmpshmemultimap2);
  194. stdmultimap->swap(tmpstdmultimap2);
  195. if(!CheckEqualPairContainers(shmmap, stdmap)) return 1;
  196. if(!CheckEqualPairContainers(shmmultimap, stdmultimap)) return 1;
  197. }
  198. //Insertion from other container
  199. //Initialize values
  200. {
  201. //This is really nasty, but we have no other simple choice
  202. IntPairType aux_vect[50];
  203. for(int i = 0; i < 50; ++i){
  204. IntType i1(-1);
  205. IntType i2(-1);
  206. new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2));
  207. }
  208. IntPairType aux_vect3[50];
  209. for(int i = 0; i < 50; ++i){
  210. IntType i1(-1);
  211. IntType i2(-1);
  212. new(&aux_vect3[i])IntPairType(boost::move(i1), boost::move(i2));
  213. }
  214. shmmap->insert(::boost::make_move_iterator(&aux_vect[0]), ::boost::make_move_iterator(aux_vect + 50));
  215. shmmultimap->insert(::boost::make_move_iterator(&aux_vect3[0]), ::boost::make_move_iterator(aux_vect3 + 50));
  216. for(std::size_t i = 0; i != 50; ++i){
  217. StdPairType stdpairtype(-1, -1);
  218. stdmap->insert(stdpairtype);
  219. stdmultimap->insert(stdpairtype);
  220. }
  221. if(!CheckEqualPairContainers(shmmap, stdmap)) return 1;
  222. if(!CheckEqualPairContainers(shmmultimap, stdmultimap)) return 1;
  223. for(int i = 0, j = static_cast<int>(shmmap->size()); i < j; ++i){
  224. shmmap->erase(IntType(i));
  225. stdmap->erase(i);
  226. shmmultimap->erase(IntType(i));
  227. stdmultimap->erase(i);
  228. }
  229. if(!CheckEqualPairContainers(shmmap, stdmap)) return 1;
  230. if(!CheckEqualPairContainers(shmmultimap, stdmultimap)) return 1;
  231. }
  232. {
  233. IntPairType aux_vect[50];
  234. for(int i = 0; i < 50; ++i){
  235. IntType i1(-1);
  236. IntType i2(-1);
  237. new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2));
  238. }
  239. IntPairType aux_vect3[50];
  240. for(int i = 0; i < 50; ++i){
  241. IntType i1(-1);
  242. IntType i2(-1);
  243. new(&aux_vect3[i])IntPairType(boost::move(i1), boost::move(i2));
  244. }
  245. IntPairType aux_vect4[50];
  246. for(int i = 0; i < 50; ++i){
  247. IntType i1(-1);
  248. IntType i2(-1);
  249. new(&aux_vect4[i])IntPairType(boost::move(i1), boost::move(i2));
  250. }
  251. IntPairType aux_vect5[50];
  252. for(int i = 0; i < 50; ++i){
  253. IntType i1(-1);
  254. IntType i2(-1);
  255. new(&aux_vect5[i])IntPairType(boost::move(i1), boost::move(i2));
  256. }
  257. shmmap->insert(::boost::make_move_iterator(&aux_vect[0]), ::boost::make_move_iterator(aux_vect + 50));
  258. shmmap->insert(::boost::make_move_iterator(&aux_vect3[0]), ::boost::make_move_iterator(aux_vect3 + 50));
  259. shmmultimap->insert(::boost::make_move_iterator(&aux_vect4[0]), ::boost::make_move_iterator(aux_vect4 + 50));
  260. shmmultimap->insert(::boost::make_move_iterator(&aux_vect5[0]), ::boost::make_move_iterator(aux_vect5 + 50));
  261. for(std::size_t i = 0; i != 50; ++i){
  262. StdPairType stdpairtype(-1, -1);
  263. stdmap->insert(stdpairtype);
  264. stdmultimap->insert(stdpairtype);
  265. stdmap->insert(stdpairtype);
  266. stdmultimap->insert(stdpairtype);
  267. }
  268. if(!CheckEqualPairContainers(shmmap, stdmap)) return 1;
  269. if(!CheckEqualPairContainers(shmmultimap, stdmultimap)) return 1;
  270. shmmap->erase(shmmap->begin()->first);
  271. stdmap->erase(stdmap->begin()->first);
  272. shmmultimap->erase(shmmultimap->begin()->first);
  273. stdmultimap->erase(stdmultimap->begin()->first);
  274. if(!CheckEqualPairContainers(shmmap, stdmap)) return 1;
  275. if(!CheckEqualPairContainers(shmmultimap, stdmultimap)) return 1;
  276. }
  277. {
  278. //This is really nasty, but we have no other simple choice
  279. IntPairType aux_vect[max];
  280. for(int i = 0; i < max; ++i){
  281. IntType i1(i);
  282. IntType i2(i);
  283. new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2));
  284. }
  285. IntPairType aux_vect3[max];
  286. for(int i = 0; i < max; ++i){
  287. IntType i1(i);
  288. IntType i2(i);
  289. new(&aux_vect3[i])IntPairType(boost::move(i1), boost::move(i2));
  290. }
  291. for(int i = 0; i < max; ++i){
  292. shmmap->insert(boost::move(aux_vect[i]));
  293. stdmap->insert(StdPairType(i, i));
  294. shmmultimap->insert(boost::move(aux_vect3[i]));
  295. stdmultimap->insert(StdPairType(i, i));
  296. }
  297. if(!CheckEqualPairContainers(shmmap, stdmap)) return 1;
  298. if(!CheckEqualPairContainers(shmmultimap, stdmultimap)) return 1;
  299. for(int i = 0; i < max; ++i){
  300. IntPairType intpair;
  301. {
  302. IntType i1(i);
  303. IntType i2(i);
  304. new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
  305. }
  306. shmmap->insert(shmmap->begin(), boost::move(intpair));
  307. stdmap->insert(stdmap->begin(), StdPairType(i, i));
  308. //PrintContainers(shmmap, stdmap);
  309. {
  310. IntType i1(i);
  311. IntType i2(i);
  312. new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
  313. }
  314. shmmultimap->insert(shmmultimap->begin(), boost::move(intpair));
  315. stdmultimap->insert(stdmultimap->begin(), StdPairType(i, i));
  316. //PrintContainers(shmmultimap, stdmultimap);
  317. if(!CheckEqualPairContainers(shmmap, stdmap))
  318. return 1;
  319. if(!CheckEqualPairContainers(shmmultimap, stdmultimap))
  320. return 1;
  321. {
  322. IntType i1(i);
  323. IntType i2(i);
  324. new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
  325. }
  326. shmmap->insert(shmmap->end(), boost::move(intpair));
  327. stdmap->insert(stdmap->end(), StdPairType(i, i));
  328. {
  329. IntType i1(i);
  330. IntType i2(i);
  331. new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
  332. }
  333. shmmultimap->insert(shmmultimap->end(), boost::move(intpair));
  334. stdmultimap->insert(stdmultimap->end(), StdPairType(i, i));
  335. if(!CheckEqualPairContainers(shmmap, stdmap))
  336. return 1;
  337. if(!CheckEqualPairContainers(shmmultimap, stdmultimap))
  338. return 1;
  339. {
  340. IntType i1(i);
  341. IntType i2(i);
  342. new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
  343. }
  344. shmmap->insert(shmmap->lower_bound(IntType(i)), boost::move(intpair));
  345. stdmap->insert(stdmap->lower_bound(i), StdPairType(i, i));
  346. //PrintContainers(shmmap, stdmap);
  347. {
  348. IntType i1(i);
  349. IntType i2(i);
  350. new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
  351. }
  352. {
  353. IntType i1(i);
  354. shmmultimap->insert(shmmultimap->lower_bound(boost::move(i1)), boost::move(intpair));
  355. stdmultimap->insert(stdmultimap->lower_bound(i), StdPairType(i, i));
  356. }
  357. //PrintContainers(shmmultimap, stdmultimap);
  358. if(!CheckEqualPairContainers(shmmap, stdmap))
  359. return 1;
  360. if(!CheckEqualPairContainers(shmmultimap, stdmultimap))
  361. return 1;
  362. {
  363. IntType i1(i);
  364. IntType i2(i);
  365. new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
  366. }
  367. {
  368. IntType i1(i);
  369. shmmap->insert(shmmap->upper_bound(boost::move(i1)), boost::move(intpair));
  370. stdmap->insert(stdmap->upper_bound(i), StdPairType(i, i));
  371. }
  372. //PrintContainers(shmmap, stdmap);
  373. {
  374. IntType i1(i);
  375. IntType i2(i);
  376. new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
  377. }
  378. {
  379. IntType i1(i);
  380. shmmultimap->insert(shmmultimap->upper_bound(boost::move(i1)), boost::move(intpair));
  381. stdmultimap->insert(stdmultimap->upper_bound(i), StdPairType(i, i));
  382. }
  383. //PrintContainers(shmmultimap, stdmultimap);
  384. if(!CheckEqualPairContainers(shmmap, stdmap))
  385. return 1;
  386. if(!CheckEqualPairContainers(shmmultimap, stdmultimap))
  387. return 1;
  388. }
  389. //Compare count with std containers
  390. for(int i = 0; i < max; ++i){
  391. if(shmmap->count(IntType(i)) != stdmap->count(i)){
  392. return -1;
  393. }
  394. if(shmmultimap->count(IntType(i)) != stdmultimap->count(i)){
  395. return -1;
  396. }
  397. }
  398. //Now do count exercise
  399. shmmap->erase(shmmap->begin(), shmmap->end());
  400. shmmultimap->erase(shmmultimap->begin(), shmmultimap->end());
  401. shmmap->clear();
  402. shmmultimap->clear();
  403. for(int j = 0; j < 3; ++j)
  404. for(int i = 0; i < 100; ++i){
  405. IntPairType intpair;
  406. {
  407. IntType i1(i), i2(i);
  408. new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
  409. }
  410. shmmap->insert(boost::move(intpair));
  411. {
  412. IntType i1(i), i2(i);
  413. new(&intpair)IntPairType(boost::move(i1), boost::move(i2));
  414. }
  415. shmmultimap->insert(boost::move(intpair));
  416. if(shmmap->count(IntType(i)) != typename MyShmMultiMap::size_type(1))
  417. return 1;
  418. if(shmmultimap->count(IntType(i)) != typename MyShmMultiMap::size_type(j+1))
  419. return 1;
  420. }
  421. }
  422. segment.template destroy<MyShmMap>("MyShmMap");
  423. delete stdmap;
  424. segment.destroy_ptr(shmmultimap);
  425. delete stdmultimap;
  426. segment.shrink_to_fit_indexes();
  427. if(!segment.all_memory_deallocated())
  428. return 1;
  429. }
  430. catch(...){
  431. shared_memory_object::remove(shMemName);
  432. throw;
  433. }
  434. shared_memory_object::remove(shMemName);
  435. return 0;
  436. }
  437. template<class ManagedSharedMemory
  438. ,class MyShmMap
  439. ,class MyStdMap
  440. ,class MyShmMultiMap
  441. ,class MyStdMultiMap>
  442. int map_test_copyable ()
  443. {
  444. typedef typename MyShmMap::key_type IntType;
  445. typedef boost::interprocess::pair<IntType, IntType> IntPairType;
  446. typedef typename MyStdMap::value_type StdPairType;
  447. const int memsize = 65536;
  448. const char *const shMemName = test::get_process_id_name();
  449. const int max = 100;
  450. try{
  451. //Create shared memory
  452. shared_memory_object::remove(shMemName);
  453. ManagedSharedMemory segment(create_only, shMemName, memsize);
  454. segment.reserve_named_objects(100);
  455. //Shared memory allocator must be always be initialized
  456. //since it has no default constructor
  457. MyShmMap *shmmap =
  458. segment.template construct<MyShmMap>("MyShmMap")
  459. (std::less<IntType>(), segment.get_segment_manager());
  460. MyStdMap *stdmap = new MyStdMap;
  461. MyShmMultiMap *shmmultimap =
  462. segment.template construct<MyShmMultiMap>("MyShmMultiMap")
  463. (std::less<IntType>(), segment.get_segment_manager());
  464. MyStdMultiMap *stdmultimap = new MyStdMultiMap;
  465. int i;
  466. for(i = 0; i < max; ++i){
  467. {
  468. IntType i1(i), i2(i);
  469. IntPairType intpair1(boost::move(i1), boost::move(i2));
  470. shmmap->insert(boost::move(intpair1));
  471. stdmap->insert(StdPairType(i, i));
  472. }
  473. {
  474. IntType i1(i), i2(i);
  475. IntPairType intpair2(boost::move(i1), boost::move(i2));
  476. shmmultimap->insert(boost::move(intpair2));
  477. stdmultimap->insert(StdPairType(i, i));
  478. }
  479. }
  480. if(!CheckEqualContainers(shmmap, stdmap)) return 1;
  481. if(!CheckEqualContainers(shmmultimap, stdmultimap)) return 1;
  482. {
  483. //Now, test copy constructor
  484. MyShmMap shmmapcopy(*shmmap);
  485. MyStdMap stdmapcopy(*stdmap);
  486. MyShmMultiMap shmmmapcopy(*shmmultimap);
  487. MyStdMultiMap stdmmapcopy(*stdmultimap);
  488. if(!CheckEqualContainers(&shmmapcopy, &stdmapcopy))
  489. return 1;
  490. if(!CheckEqualContainers(&shmmmapcopy, &stdmmapcopy))
  491. return 1;
  492. //And now assignment
  493. shmmapcopy = *shmmap;
  494. stdmapcopy = *stdmap;
  495. shmmmapcopy = *shmmultimap;
  496. stdmmapcopy = *stdmultimap;
  497. if(!CheckEqualContainers(&shmmapcopy, &stdmapcopy))
  498. return 1;
  499. if(!CheckEqualContainers(&shmmmapcopy, &stdmmapcopy))
  500. return 1;
  501. delete stdmap;
  502. delete stdmultimap;
  503. segment.destroy_ptr(shmmap);
  504. segment.destroy_ptr(shmmultimap);
  505. }
  506. segment.shrink_to_fit_indexes();
  507. if(!segment.all_memory_deallocated())
  508. return 1;
  509. }
  510. catch(...){
  511. shared_memory_object::remove(shMemName);
  512. throw;
  513. }
  514. shared_memory_object::remove(shMemName);
  515. return 0;
  516. }
  517. } //namespace test{
  518. } //namespace interprocess{
  519. } //namespace boost{
  520. #include <boost/interprocess/detail/config_end.hpp>
  521. #endif //#ifndef BOOST_INTERPROCESS_TEST_MAP_TEST_HEADER